Beispiel #1
0
 def SaveLoRX(self):
     # Send saved Ant 14 delays as Ant 15 to the SQL database and the ACC (if the data source is not 'Simulation')
     # Note, ONLY Ant 14 delay is changed, and it is ascribed to Ant 15.  No other delay changes are made.
     if self.data_source == 'Data':
         if (Time.now().mjd - self.time.mjd) > 1.0:
             question = "Warning: Data more than a day old. Are you sure you want to save delays to SQL and ACC?"
         else:
             question = "Save delays to SQL and ACC?"
         import cal_header as ch
         
         delays = self.delays[0] - self.delays
         delays = np.append(delays,self.delays[0])
         # Have to change the sign of Ant 14 Y-X delay, hence the minus sign
         xydelays = np.append(self.xydelays,-float(self.dla14.get()))
         # Do not change delays where both delays and xydelays are zero
         # which is taken as a missing antenna
         bad, = np.where(self.delays == 0)
         bad2, = np.where(self.xydelays == 0)
         idx1,idx2 = common_val_idx(bad,bad2)
         delays[bad[idx1]] = 0.0
         # Check that the delays to all antennas except Ant 14 are zero, or give warning if not
         for i in range(13):
             if delays[i] != 0.0:
                 question = "Some Ant1-13 delays are not 0, but will NOT be updated.  Save anyway?"
                 break
             if xydelays[i] != 0.0:
                 question = "Some Ant1-13 delays are not 0, but will NOT be updated.  Save anyway?"
                 break
         
         if askyesno("Write Delays",question):
             # All Y-X delays need a sign flip, hence the minus sign
             ch.dla_update2sql(delays,-xydelays,lorx=True)
             #ch.dla_update2sql(-delays,xydelays)  # 300 MHz design uses flipped signs!
             ch.dla_censql2table()
Beispiel #2
0
    def SaveLoRX(self):
        # Send saved Ant 14 delays as Ant 15 to the SQL database and the ACC (if the data source is not 'Simulation')
        # Note, ONLY Ant 14 delay is changed, and it is ascribed to Ant 15.  No other delay changes are made.
        if self.data_source == 'Data':
            if (Time.now().mjd - self.time.mjd) > 1.0:
                question = "Warning: Data more than a day old. Are you sure you want to save delays to SQL and ACC?"
            else:
                question = "Save delays to SQL and ACC?"
            import cal_header as ch

            delays = self.delays[0] - self.delays
            delays = np.append(delays, self.delays[0])
            # Have to change the sign of Ant 14 Y-X delay, hence the minus sign
            xydelays = np.append(self.xydelays, -float(self.dla14.get()))
            # Do not change delays where both delays and xydelays are zero
            # which is taken as a missing antenna
            bad, = np.where(self.delays == 0)
            bad2, = np.where(self.xydelays == 0)
            idx1, idx2 = common_val_idx(bad, bad2)
            delays[bad[idx1]] = 0.0
            # Check that the delays to all antennas except Ant 14 are zero, or give warning if not
            for i in range(13):
                if delays[i] != 0.0:
                    question = "Some Ant1-13 delays are not 0, but will NOT be updated.  Save anyway?"
                    break
                if xydelays[i] != 0.0:
                    question = "Some Ant1-13 delays are not 0, but will NOT be updated.  Save anyway?"
                    break

            if askyesno("Write Delays", question):
                # All Y-X delays need a sign flip, hence the minus sign
                ch.dla_update2sql(delays, -xydelays, lorx=True)
                #ch.dla_update2sql(-delays,xydelays,lorx=True)  # 300 MHz design uses flipped signs!
                ch.dla_censql2table()
Beispiel #3
0
def xydla(filename, ant_str='ant1-14', apply=False):
    ''' Determine X vs. Y delay based on packet capture with Noise Diode on
    
        filename    Name and path of a PRT (packet capture) file taken with ND-ON,
                      using a fixed band, e.g. band15.fsq.
                      
        Returns xy  14-element list of delays to apply, for use in second argument
                      of cal_header.dla_update2sql()
                      
        Optional argument:
        ant_str     If supplied, is the standard specification of antennas to include.
                       Antennas not included are updated with 0 (i.e. no change)
        apply       If True, calls cal_header.dla_update2sql() and 
                                   cal_header.dla_censql2table()
                      to update X vs. Y delays
    '''
    import matplotlib.pylab as plt
    from util import lobe
    f, ax = plt.subplots(4, 4)
    ants = p.ant_str2list(ant_str)
    ax.shape = (16)
    if type(filename) is dict:
        # Interpret input as an already read dictionary, rather than a filename, and skip
        # the slow process of reading it again.
        out = filename
    else:
        out = p.rd_jspec(filename)
    xy = []
    chrange = np.arange(
        2100, 3900)  # Portion of 4096 sub-channel range to use for the fit
    npts = len(chrange)
    x = np.linspace(
        0, np.pi * npts / 4096.,
        1800)  # This makes phase slope come out in units of delay steps
    for i in range(14):
        if i in ants:
            ax[i].plot(np.angle(out['a'][i, 2, :, 30]),
                       'y.',
                       label='Ant ' + str(i + 1))
            res = np.polyfit(x, np.unwrap(np.angle(out['a'][i, 2, chrange,
                                                            30])), 1)
            ax[i].plot(chrange, lobe(np.polyval(res, x)), 'r.')
            ax[i].set_ylim(-4, 4)
            ax[i].legend(fontsize=9, loc='best', fancybox=True, framealpha=0.5)
        else:
            res = [0., 0.]
        xy.append(res[0])
    if apply:
        import cal_header as ch
        ch.dla_update2sql(np.zeros(14, np.float), np.array(xy))
        ch.dla_censql2table()
    return np.array(xy)
Beispiel #4
0
 def Save(self):
     # Send saved delays to the SQL database and the ACC (if the data source is not 'Simulation')
     if self.data_source == 'Data':
         if (Time.now().mjd - self.time.mjd) > 1.0:
             question = "Warning: Data more than a day old. Are you sure you want to save delays to SQL and ACC?"
         else:
             question = "Save delays to SQL and ACC?"
         import cal_header as ch
         # Calculate delays relative to Ant 1 and tack Ant1-14 delay at end
         delays = self.delays[0] - self.delays
         delays = np.append(delays, self.delays[0])
         # Have to change the sign of Ant 14 Y-X delay, hence the minus sign
         xydelays = np.append(self.xydelays, -float(self.dla14.get()))
         # Do not change delays for a missing antenna
         bad, = np.where(self.missing == 1)
         delays[bad] = 0.0
         if askyesno("Write Delays", question):
             # All Y-X delays need a sign flip, hence the minus sign
             ch.dla_update2sql(delays, -xydelays)
             #ch.dla_update2sql(-delays,xydelays)  # 300 MHz design uses flipped signs!
             ch.dla_censql2table()
Beispiel #5
0
 def Save(self):
     # Send saved delays to the SQL database and the ACC (if the data source is not 'Simulation')
     if self.data_source == 'Data':
         if (Time.now().mjd - self.time.mjd) > 1.0:
             question = "Warning: Data more than a day old. Are you sure you want to save delays to SQL and ACC?"
         else:
             question = "Save delays to SQL and ACC?"
         import cal_header as ch
         # Calculate delays relative to Ant 1 and tack Ant1-14 delay at end
         delays = self.delays[0] - self.delays
         delays = np.append(delays,self.delays[0])
         # Have to change the sign of Ant 14 Y-X delay, hence the minus sign
         xydelays = np.append(self.xydelays,-float(self.dla14.get()))
         # Do not change delays where both delays and xydelays are zero
         # which is taken as a missing antenna
         bad, = np.where(self.delays == 0)
         bad2, = np.where(self.xydelays == 0)
         idx1,idx2 = common_val_idx(bad,bad2)
         delays[bad[idx1]] = 0.0
         if askyesno("Write Delays",question):
             # All Y-X delays need a sign flip, hence the minus sign
             ch.dla_update2sql(delays,-xydelays)
             #ch.dla_update2sql(-delays,xydelays)  # 300 MHz design uses flipped signs!
             ch.dla_censql2table()