def start_acc_scan(self, duration_tot_req): """Start recording ACC""" self.scanresult['rec'].append('acc') self.scanresult['acc'] = data_io.ScanRecInfo() self.scanresult['acc'].set_stnid(self.get_stnid()) # Also duration of ACC sweep since each sb is 1 second. dur1acc = modeparms.TotNrOfsb # Duration of one ACC interv2accs = 7 # time between end of 1 ACC and start of next one acc_cadence = dur1acc + interv2accs # =519s between start of 2 ACC (nraccs, timrest) = divmod(duration_tot_req, acc_cadence) if timrest > dur1acc: nraccs += 1 duration_tot = nraccs * acc_cadence - interv2accs if duration_tot != duration_tot_req: print("""Note: will use total duration {}s to fit with ACC cadence.""".format(duration_tot)) # Make sure swlevel=<2 self._lcu_interface.set_swlevel(2) # Set CalServ.conf to dump ACCs: self._lcu_interface.acc_mode(enable=True) # Boot to swlevel 3 so the calserver service starts self._lcu_interface.set_swlevel(3) # Possibly make mock acc statistics: if self.mockrun: self._lcu_interface.mockstatistics('acc', 1.0, duration_tot) return duration_tot
def record_obsprog(stationdriver, scan): """At starttime execute the observation program specified by the obsfun method pointer and run with arguments specified by obsargs dict. """ scan_flat = dict(scan) del scan_flat['beam'] for k in scan['beam'].keys(): scan_flat[k] = scan['beam'][k] freqbndobj = modeparms.FreqSetup(scan['beam']['freqspec']) scan_flat['freqbndobj'] = freqbndobj prg = ObsPrograms(stationdriver) obsfun, obsargs_sig = prg.getprogram(scan['obsprog']) scan_flat['bfdsesdumpdir'] = stationdriver.bf_data_dir # Map only args required by obsargs = {k: scan_flat[k] for k in obsargs_sig} # Setup Calibration tables on LCU: CALTABLESRC = 'default' # FIXME put this in args ## (Only BST uses calibration tables) # Choose between 'default' or 'local' stationdriver.set_caltable(CALTABLESRC) # Prepare for obs program. try: stationdriver.goto_observingstate() except RuntimeError as e: raise RuntimeError(e) # Run the observation program: obsinfolist = obsfun(**obsargs) # Stop program beam stationdriver.stop_beam() scan_id = None scanpath_scdat = None scanresult = {} if obsinfolist is not None: datatype = 'sop:' + scan['obsprog'] scanrec = dataIO.ScanRecInfo() scanrec.set_stnid(stationdriver.get_stnid()) scanrec.set_scanrecparms(datatype, freqbndobj.arg, scan['duration_tot'], scan['beam']['pointing']) beamstarted = datetime.datetime.strptime(obsinfolist[0].filenametime, "%Y%m%d_%H%M%S") scan_id = stationdriver.get_scanid(beamstarted) scanpath_scdat = os.path.join(stationdriver.scanpath, scan_id) # Add caltables used caltabinfos = stationdriver.get_caltableinfos(freqbndobj.rcumodes) # Add obsinfos to scanrecs for obsinfo in obsinfolist: obsinfo.caltabinfos = caltabinfos scanrec.add_obs(obsinfo) # Move data to archive stationdriver.movefromlcu(stationdriver.get_lcuDumpDir() + "/*.dat", scanpath_scdat) scanrec.path = scanpath_scdat scanresult[datatype] = scanrec scanresult['scan_id'] = scan_id scanresult['scanpath_scdat'] = scanpath_scdat return scanresult
def start_bfs_scan(self, starttime, freqsetup, duration_tot): """Start recording BFS data""" caltabinfos = self.get_caltableinfos(freqsetup.rcumodes) rspctl_cmds = [] # BFS doesn't use rspctl cmds ldatinfo_bfs = data_io.LDatInfo('bfs', self.get_stnid(), self.rcusetup_cmds, self.beamctl_cmds, rspctl_cmds, caltabinfos) scanpath_bfdat = os.path.join(self.bf_data_dir, self.scan_id) lanesalloc = modeparms.getlanes(freqsetup.subbands_spw, freqsetup.bits, freqsetup.nrlanes) self.lanes = tuple(lanesalloc.keys()) if self._lcu_interface.stnid == 'UK902': # FIXME self.lanes = (0, 1) # UK902 only has 2 lanes # Select only ports for lanes to be used laneports = tuple(self.get_laneports()[i] for i in self.lanes) datafiles, logfiles = \ self.dru_interface._rec_bf_proxy(laneports, duration_tot, scanpath_bfdat, starttime=starttime, compress=False, band=freqsetup.rcubands[0], stnid=self.get_stnid()) bfsdatapaths = [] bfslogpaths = [] for lane in self.lanes: datafileguess = datafiles.pop() dumplogname = logfiles.pop() if not datafileguess: _outdumpdir, _outarg, datafileguess, dumplogname = \ bfbackend.bfsfilepaths(lane, starttime, modeparms.band2rcumode(freqsetup.rcubands[0]), scanpath_bfdat, self.bf_port0, self.get_stnid()) bfsdatapaths.append(datafileguess) bfslogpaths.append(dumplogname) # Duration of BFS not determinable via LCU commands so add this by hand ldatinfo_bfs.duration_scan = duration_tot # Set scanrecinfo self.scanresult['rec'].append('bfs') self.scanresult['bfs'] = data_io.ScanRecInfo() self.scanresult['bfs'].set_stnid(self.get_stnid()) # No integration for BFS self.scanresult['bfs'].set_scanrecparms('bfs', freqsetup.arg, duration_tot, ldatinfo_bfs.pointing, integration=None) return ldatinfo_bfs, bfsdatapaths, bfslogpaths
def start_bsx_scan(self, bsxtype, freqsetup, duration, integration=1.0): """\ Start BSX scanrec """ rcusetup_cmds = self.rcusetup_cmds beamctl_cmds = self.beamctl_cmds duration_tot = duration ldatinfos = [] # Record statistic for duration_tot seconds if bsxtype == 'bst' or bsxtype == 'sst': caltabinfos = self.get_caltableinfos(freqsetup.rcumodes) rspctl_cmds = self._lcu_interface.run_rspctl_statistics( bsxtype, integration, duration_tot) ldatinfos.append( data_io.LDatInfo(bsxtype, self.get_stnid(), rcusetup_cmds, beamctl_cmds, rspctl_cmds, caltabinfos=caltabinfos, septonconf=self.septonconf)) elif bsxtype == 'xst': nrsubbands = freqsetup.nrsubbands() duration_frq = None # FIXME set to desired value if duration_frq is None: if nrsubbands > 1: duration_frq = integration else: duration_frq = duration_tot # TODO Consider that specified duration is not the same as # actual duration. Each step in frequency sweep take about 6s # for 1s int. (rep, _rst) = divmod(duration_tot, duration_frq * nrsubbands) rep = int(rep) if rep == 0: warnings.warn( "Total duration too short for 1 full repetition." "Will increase total duration to get 1 full rep.") duration_tot = duration_frq * nrsubbands rep = 1 # Repeat rep times (freq sweep) for _itr in range(rep): # Start freq sweep for sb_rcumode in freqsetup.subbands_spw: if ':' in sb_rcumode: sblo, sbhi = sb_rcumode.split(':') subbands = range(int(sblo), int(sbhi) + 1) else: subbands = [int(sb) for sb in sb_rcumode.split(',')] for subband in subbands: # Record data rspctl_cmds = \ self._lcu_interface.run_rspctl_statistics( bsxtype, integration, duration_frq, subband) ldatinfos.append( data_io.LDatInfo('xst', self.get_stnid(), rcusetup_cmds, beamctl_cmds, rspctl_cmds, septonconf=self.septonconf)) # Set scanrecinfo self.scanresult['rec'].append('bsx') self.scanresult['bsx'] = data_io.ScanRecInfo() self.scanresult['bsx'].set_stnid(self.get_stnid()) self.scanresult['bsx'].set_scanrecparms(ldatinfos[0].ldat_type, freqsetup.arg, ldatinfos[0].duration_scan, ldatinfos[0].pointing, ldatinfos[0].integration) return ldatinfos