def static_param(self, horizon=20): """ Args: horizon: """ if self._static_calculated: idx = self.data.target_tables.query( 'solarSystem != "Unspecified" and isQuery == False and ' 'RA == 0').SB_UID.unique() self.obs_param.ix[idx] = self.schedblocks.ix[idx].apply( lambda r: DsaTool.observable( r['RA'], r['DEC'], self._ALMA_ephem, r['RA'], r['minAR'], r['maxAR'], r['array'], r['SB_UID'], horizon=horizon), axis=1 ) else: self.obs_param = self.schedblocks.apply( lambda r: DsaTool.observable( r['RA'], r['DEC'], self._ALMA_ephem, r['RA'], r['minAR'], r['maxAR'], r['array'], r['SB_UID'], horizon=horizon), axis=1 ) ind1 = pd.np.around(self.schedblocks.repfreq, decimals=1) ind2 = self.schedblocks.apply( lambda x: str( int(x['maxPWVC'] / 0.05) * 0.05 + (0.05 if (x['maxPWVC'] % 0.05) > 0.02 else 0.)) if x['maxPWVC'] < 8 else '7.95', axis=1) self.schedblocks['transmission_ot'] = self.pwvdata.lookup( ind1, ind2) self.schedblocks['tau_ot'] = self.tau.lookup(ind1, ind2) self.schedblocks['tsky_ot'] = self.tsky.lookup(ind1, ind2) self.schedblocks['airmass_ot'] = self.schedblocks.apply( lambda x: calc_airmass(x['DEC'], transit=True), axis=1) self.schedblocks['tsys_ot'] = ( self.schedblocks.apply( lambda x: calc_tsys(x['band'], x['tsky_ot'], x['tau_ot'], x['airmass_ot']), axis=1)) self.obs_param.rise.fillna(0, inplace=True) self.obs_param['rise datetime'] = self.obs_param.apply( lambda x: dt.datetime.strptime( '2015-01-01 ' + str(int(x['rise'])) + ':' + str(int(60*(x['rise'] - int(x['rise'])))), '%Y-%m-%d %H:%M'), axis=1) self._static_calculated = True
def write_ephem_coords(self): """ TODO: deal with multiple targets, which RA to take? TODO: make this table unique... by instance """ self.schedblocks['ephem'] = 'N/A' ephem_sb = pd.merge( self.schedblocks, self.data.target_tables.query( 'solarSystem != "Unspecified" and isQuery == False and ' 'RA == 0'), on='SB_UID').drop_duplicates(['SB_UID', 'ephemeris']).set_index( 'SB_UID', drop=False) results = ephem_sb.apply( lambda x: wtool.calc_ephem_coords( x['solarSystem'], x['ephemeris'], x['SB_UID'], alma=self._ALMA_ephem), axis=1) for r in results.iteritems(): self.schedblocks.ix[r[0], 'RA'] = r[1][0] self.schedblocks.ix[r[0], 'DEC'] = r[1][1] self.schedblocks.ix[r[0], 'ephem'] = r[1][2]
def _add_imaging_param(self): self._schedblocks_temp['assumedconf_ar_ot'] = ( self._schedblocks_temp.minAR_ot / 0.9) * \ self._schedblocks_temp.repfreq / 100. self._schedblocks_temp['OT_BestConf'] = self._schedblocks_temp.apply( lambda x: self._ares.array[ DsaTool.find_array(x['assumedconf_ar_ot'], self._listconf)] if x['array'] == "TWELVE-M" else "N/A", axis=1) ar = self._schedblocks_temp.apply(lambda x: self._get_ar_lim(x), axis=1) # noinspection PyUnresolvedReferences self.schedblocks = pd.concat( [self._schedblocks_temp, ar], axis=1).set_index( 'SB_UID', drop=False)