Example #1
0
 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
Example #2
0
    def stop_acc_scan(self, duration_tot, freqsetup):
        self._lcu_interface.set_swlevel(2)
        self._lcu_interface.acc_mode(enable=False)
        self._lcu_interface.set_swlevel(3)

        # Create obsinfo each ACC file
        _, acc_files = self._lcu_interface.getdatalist()
        for acc_file in acc_files:
            obsid, _ = acc_file.split('_acc_')
            rspctl_cmds = []  # ACC doesn't have any rspctl cmds
            ldatinfo_acc = data_io.LDatInfo('acc', self.get_stnid(),
                                            self.last_rcusetup_cmds,
                                            self.last_beamctl_cmds,
                                            rspctl_cmds)
            ldatinfo_acc.filenametime = obsid
            self.scanresult['acc'].add_obs(ldatinfo_acc)

        # Set scanrecinfo
        pointing = ldatinfo_acc.pointing
        acc_integration = 1.0
        self.scanresult['acc'].set_scanrecparms('acc', freqsetup.arg,
                                                duration_tot, pointing,
                                                acc_integration)
        self.scanresult['acc'].set_scanpath(self.scanpath_scdat)
        scanrecpath = self.scanresult['acc'].get_scanrecpath()

        # Transfer data from LCU to DAU
        if os.path.exists(scanrecpath):
            print("Dest directory exists already (will put data here)")
        else:
            print("Creating directory " + scanrecpath + " for ACC "
                  + str(duration_tot) + " s band=" + str(freqsetup.rcumodes[0]))
            os.makedirs(scanrecpath)

        # Move ACC dumps to storage
        accsrcfiles = self._lcu_interface.ACCsrcDir + "/*.dat"
        self.movefromlcu(accsrcfiles, scanrecpath)
Example #3
0
    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
Example #4
0
    def do_bfs_OW(self, freqbndobj, duration, pointing, bfdsesdumpdir,
                  starttime):
        """Record BeamFormed Streams (BFS) with particular beamlet allocation.
        """

        band = freqbndobj.rcubands[0]
        ###
        bits = 8  # 8
        attenuation = None
        # Subbands allocation
        if band == '10_90' or band == '30_90':
            # LBA
            lanes = (0, 1)  # (0,1)
            beamlets = '0:243'  # '0:243'
            subbands = '164:407'  # '164:407'
        elif band == '110_190':
            # HBAlo
            lanes = (0, 1, 2, 3)  # Normally (0,1,2,3) for all 4 lanes.
            beamlets = '0:487'
            subbands = '12:499'
        elif band == '210_250':
            # HBAhi
            lanes = (0, 1)
            beamlets = '0:243'
            subbands = '12:255'
        else:
            raise ValueError(
                "Wrong band: "
                "should be 10_90 (LBA), 110_190 (HBAlo) or 210_250 (HBAhi).")

        # Wait until it is time to start
        starttime_req = starttime
        warmuptime = 14
        pause = 0  # Sufficient?
        beaminittime = 13
        #self.stationdriver._waittoboot(rectime, pause)
        margin = datetime.timedelta(seconds=(warmuptime + pause +
                                             beaminittime))
        starttime = waituntil(starttime_req, margin)
        rectime = starttime

        # Necessary since fork creates multiple instances of myobs and each one
        # will call it's __del__ on completion and __del__ shutdown...
        shutdown = self.stationdriver.halt_observingstate_when_finished
        self.stationdriver.halt_observingstate_when_finished = False
        self.stationdriver.exit_check = False

        dir_bmctl = ilisa.monitorcontrol.directions.normalizebeamctldir(
            pointing)

        # BEGIN Dummy or hot beam start: (takes about 14sec)
        print("Running warmup beam... @ {}".format(datetime.datetime.utcnow()))
        # Setting bits is necessary:
        self.stationdriver._rcusetup(bits, attenuation)
        self.stationdriver._run_beamctl(beamlets, subbands, band, dir_bmctl)
        self.stationdriver.stop_beam()
        # END Dummy or hot start

        print("Pause {}s after boot.".format(pause))
        time.sleep(pause)

        # Real beam start:
        print("Beam started @ UT {}".format(datetime.datetime.utcnow()))
        rcu_setup_cmds = self.stationdriver._rcusetup(bits, attenuation)
        beamctl_cmds = self.stationdriver._run_beamctl(beamlets, subbands,
                                                       band, dir_bmctl)
        rspctl_cmds = []
        beamstart = datetime.datetime.utcnow()
        timeleft = rectime - beamstart
        if timeleft.total_seconds() < 0.:
            rectime = beamstart
        print("(Beam started) Time left before recording: {}".format(
            timeleft.total_seconds()))
        bfsnametime = starttime.strftime("%Y%m%d_%H%M%S")
        obsinfo = dataIO.LDatInfo('bfs', self.stationdriver.get_stnid(),
                                  rcu_setup_cmds, beamctl_cmds, rspctl_cmds)
        obsinfo.filenametime = bfsnametime

        REC = True
        if REC == True:
            port0 = self.stationdriver.bf_port0
            stnid = self.stationdriver.get_stnid()
            compress = True
            datafiles, _logfiles = bfbackend.rec_bf_streams(
                rectime, duration, lanes, band, bfdsesdumpdir, port0, stnid,
                compress)
            bfsdatapaths = []
            for lane in lanes:
                datafileguess = datafiles.pop()
                if not datafileguess:
                    _outdumpdir, _outarg, datafileguess, _dumplogname = \
                        bfbackend.bfsfilepaths(lane, rectime,
                                               modeparms.band2rcumode(band),
                                               bfdsesdumpdir, port0, stnid)
                bfsdatapaths.append(datafileguess)
        else:
            print("Not recording")
            time.sleep(duration)
        sys.stdout.flush()
        self.stationdriver.stop_beam()
        self.stationdriver.halt_observingstate_when_finished = shutdown
        return [obsinfo]