示例#1
0
 def update_with_gbtstatus(self):
     if self.gbtstat is None:
         self.gbtstat = GBTStatus()
     self.gbtstat.collectKVPairs()
     g = self.gbtstat.kvPairs
     self.update("TELESCOP", "GBT")
     self.update("OBSERVER", g['observer'])
     self.update("PROJID", g['data_dir'])
     self.update("FRONTEND", g['receiver'])
     self.update("NRCVR", 2)  # I think all the GBT receivers have 2...
     if 'inear' in g['rcvr_pol']:
         self.update("FD_POLN", 'LIN')
     else:
         self.update("FD_POLN", 'CIRC')
     freq = float(g['freq'])
     self.update("OBSFREQ", freq)
     self.update("SRC_NAME", g['source'])
     if g['ant_motion'] == 'Tracking' or g['ant_motion'] == 'Guiding':
         self.update("TRK_MODE", 'TRACK')
     elif g['ant_motion'] == 'Stopped':
         self.update("TRK_MODE", 'DRIFT')
     else:
         self.update("TRK_MODE", 'UNKNOWN')
     self.ra = float(g['j2000_major'].split()[0])
     self.ra_str = self.gbtstat.degrees2hms(self.ra)
     self.dec = float(g['j2000_minor'].split()[0])
     self.dec_str = self.gbtstat.degrees2dms(self.dec)
     self.update("RA_STR", self.ra_str)
     self.update("RA", self.ra)
     self.update("DEC_STR", self.dec_str)
     self.update("DEC", self.dec)
     h, m, s = g['lst'].split(":")
     lst = int(
         round(
             astro.hms_to_rad(int(h), int(m), float(s)) * 86400.0 /
             astro.TWOPI))
     self.update("LST", lst)
     self.update("AZ", float(g['az_actual']))
     self.update("ZA", 90.0 - float(g['el_actual']))
     beam_deg = 2.0 * astro.beam_halfwidth(freq, 100.0) / 60.0
     self.update("BMAJ", beam_deg)
     self.update("BMIN", beam_deg)
 def update_with_gbtstatus(self):
     if self.gbtstat is None:
         self.gbtstat = GBTStatus()
     self.gbtstat.collectKVPairs()
     g = self.gbtstat.kvPairs
     self.update("TELESCOP", "GBT")
     self.update("OBSERVER", g['observer'])
     self.update("PROJID", g['data_dir'])
     self.update("FRONTEND", g['receiver'])
     self.update("NRCVR", 2) # I think all the GBT receivers have 2...
     if 'inear' in g['rcvr_pol']:
         self.update("FD_POLN", 'LIN')
     else:
         self.update("FD_POLN", 'CIRC')
     freq = float(g['freq'])
     self.update("OBSFREQ", freq)
     self.update("SRC_NAME", g['source'])
     if g['ant_motion']=='Tracking' or g['ant_motion']=='Guiding':
         self.update("TRK_MODE", 'TRACK')
     elif g['ant_motion']=='Stopped':
         self.update("TRK_MODE", 'DRIFT')
     else:
         self.update("TRK_MODE", 'UNKNOWN')
     self.ra = float(g['j2000_major'].split()[0])
     self.ra_str = self.gbtstat.degrees2hms(self.ra)
     self.dec = float(g['j2000_minor'].split()[0])
     self.dec_str = self.gbtstat.degrees2dms(self.dec)
     self.update("RA_STR", self.ra_str)
     self.update("RA", self.ra)
     self.update("DEC_STR", self.dec_str)
     self.update("DEC", self.dec)
     h, m, s = g['lst'].split(":")
     lst = int(round(astro.hms_to_rad(int(h),int(m),float(s))*86400.0/astro.TWOPI))
     self.update("LST", lst)
     self.update("AZ", float(g['az_actual']))
     self.update("ZA", 90.0-float(g['el_actual']))
     beam_deg = 2.0*astro.beam_halfwidth(freq, 100.0)/60.0
     self.update("BMAJ", beam_deg)
     self.update("BMIN", beam_deg)
class vegas_status:

    def __init__(self):
        self.stat_buf = shm.SharedMemoryHandle(VEGAS_STATUS_KEY)
        self.sem = possem.sem_open(VEGAS_STATUS_SEMID, possem.O_CREAT, 00644, 1)
        self.hdr = None
        self.gbtstat = None
        self.read()
        self.new_databuf_format = True
        if 'BACKEND' in self.keys():
            if 'GUPPI' == self['BACKEND']:
                self.new_databuf_format=False # GUPPI mode

    def __getitem__(self, key):
        return self.hdr[key]

    def keys(self):
        return [k for k, v in self.hdr.items()]

    def values(self):
        return [v for k, v in self.hdr.items()]

    def items(self):
        return self.hdr.items()

    def lock(self):
        return possem.sem_wait(self.sem)

    def unlock(self):
        return possem.sem_post(self.sem)

    def data_buffer_format(self):
        """
        Returns true if the vegas data buffer format is in use and False otherwise
        """
        self.new_databuf_format=True        
        if 'BACKEND' in self.keys():
            if 'GUPPI' == self['BACKEND']:
                self.new_databuf_format=False # GUPPI mode
        return self.new_databuf_format
        
    def read(self):
        self.lock()
        self.hdr = header_from_string(self.stat_buf.read())
        self.unlock()

    def write(self):
        self.lock()
        self.stat_buf.write(repr(self.hdr.ascard)+"END"+" "*77)
        self.unlock()

    def update(self, key, value, comment=None):
        self.hdr.update(key, value, comment)

    def show(self):
        for k, v in self.hdr.items():
            print "'%8s' :"%k, v
        print ""

    def update_with_gbtstatus(self):
        if self.gbtstat is None:
            self.gbtstat = GBTStatus()
        self.gbtstat.collectKVPairs()
        g = self.gbtstat.kvPairs
        self.update("TELESCOP", "GBT")
        self.update("OBSERVER", g['observer'])
        self.update("PROJID", g['data_dir'])
        self.update("FRONTEND", g['receiver'])
        self.update("NRCVR", 2) # I think all the GBT receivers have 2...
        if 'inear' in g['rcvr_pol']:
            self.update("FD_POLN", 'LIN')
        else:
            self.update("FD_POLN", 'CIRC')
        freq = float(g['freq'])
        self.update("OBSFREQ", freq)
        self.update("SRC_NAME", g['source'])
        if g['ant_motion']=='Tracking' or g['ant_motion']=='Guiding':
            self.update("TRK_MODE", 'TRACK')
        elif g['ant_motion']=='Stopped':
            self.update("TRK_MODE", 'DRIFT')
        else:
            self.update("TRK_MODE", 'UNKNOWN')
        self.ra = float(g['j2000_major'].split()[0])
        self.ra_str = self.gbtstat.degrees2hms(self.ra)
        self.dec = float(g['j2000_minor'].split()[0])
        self.dec_str = self.gbtstat.degrees2dms(self.dec)
        self.update("RA_STR", self.ra_str)
        self.update("RA", self.ra)
        self.update("DEC_STR", self.dec_str)
        self.update("DEC", self.dec)
        h, m, s = g['lst'].split(":")
        lst = int(round(astro.hms_to_rad(int(h),int(m),float(s))*86400.0/astro.TWOPI))
        self.update("LST", lst)
        self.update("AZ", float(g['az_actual']))
        self.update("ZA", 90.0-float(g['el_actual']))
        beam_deg = 2.0*astro.beam_halfwidth(freq, 100.0)/60.0
        self.update("BMAJ", beam_deg)
        self.update("BMIN", beam_deg)

    def update_azza(self):
        """
        update_azza():
            Update the AZ and ZA based on the current time with the vegas_status instance.
        """
        (iptr, ang, stat) = s.sla_dafin(self['RA_STR'].replace(':', ' '), 1)
        self.update("RA", ang*15.0*RADTODEG)
        (iptr, ang, stat) = s.sla_dafin(self['DEC_STR'].replace(':', ' '), 1)
        self.update("DEC", ang*RADTODEG)
        MJD = astro.current_MJD()
        az, za = astro.radec_to_azza(self['RA'], self['DEC'], MJD, scope='GBT')
        self.update("AZ", az)
        self.update("ZA", za)
示例#4
0
class vegas_status:
    def __init__(self):
        self.stat_buf = shm.SharedMemoryHandle(VEGAS_STATUS_KEY)
        self.sem = possem.sem_open(VEGAS_STATUS_SEMID, possem.O_CREAT, 00644,
                                   1)
        self.hdr = None
        self.gbtstat = None
        self.read()
        self.new_databuf_format = True
        if 'BACKEND' in self.keys():
            if 'GUPPI' == self['BACKEND']:
                self.new_databuf_format = False  # GUPPI mode

    def __getitem__(self, key):
        return self.hdr[key]

    def keys(self):
        return [k for k, v in self.hdr.items()]

    def values(self):
        return [v for k, v in self.hdr.items()]

    def items(self):
        return self.hdr.items()

    def lock(self):
        return possem.sem_wait(self.sem)

    def unlock(self):
        return possem.sem_post(self.sem)

    def data_buffer_format(self):
        """
        Returns true if the vegas data buffer format is in use and False otherwise
        """
        self.new_databuf_format = True
        if 'BACKEND' in self.keys():
            if 'GUPPI' == self['BACKEND']:
                self.new_databuf_format = False  # GUPPI mode
        return self.new_databuf_format

    def read(self):
        self.lock()
        self.hdr = header_from_string(self.stat_buf.read())
        self.unlock()

    def write(self):
        self.lock()
        self.stat_buf.write(repr(self.hdr.ascard) + "END" + " " * 77)
        self.unlock()

    def update(self, key, value, comment=None):
        self.hdr.update(key, value, comment)

    def show(self):
        for k, v in self.hdr.items():
            print "'%8s' :" % k, v
        print ""

    def update_with_gbtstatus(self):
        if self.gbtstat is None:
            self.gbtstat = GBTStatus()
        self.gbtstat.collectKVPairs()
        g = self.gbtstat.kvPairs
        self.update("TELESCOP", "GBT")
        self.update("OBSERVER", g['observer'])
        self.update("PROJID", g['data_dir'])
        self.update("FRONTEND", g['receiver'])
        self.update("NRCVR", 2)  # I think all the GBT receivers have 2...
        if 'inear' in g['rcvr_pol']:
            self.update("FD_POLN", 'LIN')
        else:
            self.update("FD_POLN", 'CIRC')
        freq = float(g['freq'])
        self.update("OBSFREQ", freq)
        self.update("SRC_NAME", g['source'])
        if g['ant_motion'] == 'Tracking' or g['ant_motion'] == 'Guiding':
            self.update("TRK_MODE", 'TRACK')
        elif g['ant_motion'] == 'Stopped':
            self.update("TRK_MODE", 'DRIFT')
        else:
            self.update("TRK_MODE", 'UNKNOWN')
        self.ra = float(g['j2000_major'].split()[0])
        self.ra_str = self.gbtstat.degrees2hms(self.ra)
        self.dec = float(g['j2000_minor'].split()[0])
        self.dec_str = self.gbtstat.degrees2dms(self.dec)
        self.update("RA_STR", self.ra_str)
        self.update("RA", self.ra)
        self.update("DEC_STR", self.dec_str)
        self.update("DEC", self.dec)
        h, m, s = g['lst'].split(":")
        lst = int(
            round(
                astro.hms_to_rad(int(h), int(m), float(s)) * 86400.0 /
                astro.TWOPI))
        self.update("LST", lst)
        self.update("AZ", float(g['az_actual']))
        self.update("ZA", 90.0 - float(g['el_actual']))
        beam_deg = 2.0 * astro.beam_halfwidth(freq, 100.0) / 60.0
        self.update("BMAJ", beam_deg)
        self.update("BMIN", beam_deg)

    def update_azza(self):
        """
        update_azza():
            Update the AZ and ZA based on the current time with the vegas_status instance.
        """
        (iptr, ang, stat) = s.sla_dafin(self['RA_STR'].replace(':', ' '), 1)
        self.update("RA", ang * 15.0 * RADTODEG)
        (iptr, ang, stat) = s.sla_dafin(self['DEC_STR'].replace(':', ' '), 1)
        self.update("DEC", ang * RADTODEG)
        MJD = astro.current_MJD()
        az, za = astro.radec_to_azza(self['RA'], self['DEC'], MJD, scope='GBT')
        self.update("AZ", az)
        self.update("ZA", za)