Exemple #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'])
     if (g['receiver'] == 'Rcvr26_40'):
         freq = float(g['if_rest_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)
Exemple #2
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'])
     if (g['receiver']=='Rcvr26_40'):
         freq = float(g['if_rest_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)
Exemple #3
0
class vegas_status:
    def __init__(self, instance_id=0):
        self.stat_buf = shm.SharedMemoryHandle(
            vegas_status.ipckey(instance_id))
        self.sem = possem.sem_open(vegas_status.semname(instance_id),
                                   possem.O_CREAT, 00644, 1)
        self.hdr = None
        self.gbtstat = None
        self.read()

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

    @staticmethod
    def ipckey(instance_id):
        databuf_key = os.getenv("VEGAS_STATUS_KEY")
        if databuf_key:
            key = int(databuf_key, 0)
        else:
            key = vegas_ipckey((instance_id & 0x3f) | 0x40)
        return key

    @staticmethod
    def semname(instance_id):
        semid = os.getenv('VEGAS_STATUS_SEMNAME')
        if semid == None:
            semid = os.getenv('VEGAS_KEYFILE')
            if semid == None:
                semid = os.getenv('HOME')
                if semid == None:
                    semid = os.getenv('/tmp')
            semid = '/' + semid[1:].replace('/', '_')
            semid += '_vegas_status_%d' % instance_id
        return semid

    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 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)
Exemple #4
0
class guppi_status:

    def __init__(self, instance_id=0):
        self.stat_buf = shm.SharedMemoryHandle(guppi_status.ipckey(instance_id))
        self.sem = possem.sem_open(guppi_status.semname(instance_id), possem.O_CREAT, 00644, 1)
        self.hdr = None
        self.gbtstat = None
        self.read()

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

    @staticmethod
    def ipckey(instance_id):
        databuf_key = os.getenv("GUPPI_STATUS_KEY")
        if databuf_key:
            key = int(databuf_key, 0)
        else:
            key = guppi_ipckey((instance_id&0x3f)|0x40)
        return key

    @staticmethod
    def semname(instance_id):
        semid = os.getenv('GUPPI_STATUS_SEMNAME')
        if semid == None:
            semid = os.getenv('GUPPI_KEYFILE')
            if semid == None:
                semid = os.getenv('HOME')
                if semid == None:
                    semid = os.getenv('/tmp')
            semid = '/' + semid[1:].replace('/', '_')
            semid += '_guppi_status_%d' % instance_id
        return semid

    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 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 guppi_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)
class vegas_status:

    def __init__(self, status_key = None, status_semid = None):

        # Get user dependend IPC key.  TBF: multiple instances
        instance_id = 0
        self.status_key = status_key if status_key is not None \
            else hashpipe_key.hashpipe_status_key(instance_id)
        self.status_semid = status_semid if status_semid is not None \
            else hashpipe_key.hashpipe_status_semname(instance_id)
        print "status key: %x " % self.status_key
        print "status semid: %s" % self.status_semid

        self.stat_buf = shm.SharedMemoryHandle(self.status_key)
        self.sem = possem.sem_open(self.status_semid, possem.O_CREAT, 00644, 1)
        print "vegas_status.sem" , self.sem

        self.hdr = None
        self.gbtstat = None
        self.read()

    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 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.stat_buf.write(self.hdr.tostring()) # pyfits 3.1
        self.unlock()

    def update(self, key, value, comment=None):
        #self.hdr.update(key, value, comment)
        self.hdr[key] = (value, comment) # for pyfits 3.1.2

    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)
class vegas_status:
    def __init__(self, status_key=None, status_semid=None):

        # Get user dependend IPC key.  TBF: multiple instances
        instance_id = 0
        self.status_key = status_key if status_key is not None \
            else hashpipe_key.hashpipe_status_key(instance_id)
        self.status_semid = status_semid if status_semid is not None \
            else hashpipe_key.hashpipe_status_semname(instance_id)
        print "status key: %x " % self.status_key
        print "status semid: %s" % self.status_semid

        self.stat_buf = shm.SharedMemoryHandle(self.status_key)
        self.sem = possem.sem_open(self.status_semid, possem.O_CREAT, 00644, 1)
        print "vegas_status.sem", self.sem

        self.hdr = None
        self.gbtstat = None
        self.read()

    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 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.stat_buf.write(self.hdr.tostring())  # pyfits 3.1
        self.unlock()

    def update(self, key, value, comment=None):
        #self.hdr.update(key, value, comment)
        self.hdr[key] = (value, comment)  # for pyfits 3.1.2

    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)