示例#1
0
 def savefig(self):
     labels = plt.get_figlabels()
     _, ext = self.plotmode.split('-')
     for label in plt.get_figlabels():
         fn = os.path.join(self.outdir,'{}.{}'.format(label,ext))
         fig = plt.figure(label)
         fig.set_tight_layout(True)
         plt.savefig(fn)
         print("created {}".format(fn))
示例#2
0
def sat_xy_corr(out0, out1, band=0, ant_str='ant1-13', doplot=True):
    ''' Analyze a pair of parallel and cross polarization calibration packet captures
        on a Geosat in K-band (bands 33, 34, 35, 36, 37) and
        return the X vs. Y delay phase corrections on all antennas 1-14.
        
        Required keyword:
           prtlist   a list of 2 PRT filenames, the first being the 
                       parallel-feed scan, and the second being the
                       crossed-feed scan.
           band      the band index (0-4) corresponding to the above 5 bands
        Optional keyword:
           doplot    True => plot the final result, False => no plot
    '''
    import pcapture2 as p
    from util import bl2ord, ant_str2list
        
    if doplot: import matplotlib.pylab as plt

    antlist = ant_str2list(ant_str)
    nant = len(antlist)
#    out0 = p.rd_jspec(prtlist[0])  # Parallel scan
#    out1 = p.rd_jspec(prtlist[1])  # Perpendicular scan
    # Integrate over (10) repeated records for the desired band
    ph0 = np.angle(np.sum(out0['x'][:,:,:,10*band:10*(band+1)],3))
    ph1 = np.angle(np.sum(out1['x'][:,:,:,10*band:10*(band+1)],3))
    # Determine secular change in phase at the two times, relative to ant 1
    for i in antlist:
        if i == antlist[0]:
            dp = np.zeros_like(ph0[0,0])
        else:
            dp = lobe(ph1[bl2ord[antlist[0],i],0] - ph0[bl2ord[antlist[0],i],0])
        ph0[bl2ord[i,13],2:] = lobe(ph1[bl2ord[i,13],2:]-dp)     # Insert crossed-feed phases from ph1 into ph0, corrected for secular change

    ph0 = ph0[bl2ord[antlist,13]]          # Now restrict to only baselines with ant 14
    fstart = (band+32)*0.325 + 1.1 - 0.025
    fghz = np.linspace(fstart,fstart+0.400,4096)
    nf = len(fghz)
    dph = np.zeros((nant+1,nf),np.float)
    # Determine xi_rot
    xi2 = ph0[:,2] - ph0[:,0] + ph0[:,3] - ph0[:,1]  # This is 2 * xi, measured separately on each of 13 antennas
    xi_rot = lobe(np.unwrap(np.angle(np.sum(np.exp(1j*xi2),0)))/2.)   # Very clever average does not suffer from wrapping issues
    #xi_rot = np.zeros_like(xi_rot) + np.pi/2.    # *********** Zero out xi_rot for now ****************
    # Form differential delay phase from channels, and average them
    # dph14 = XY - XX - xi_rot and YY - YX + xi_rot
    dph14 = np.concatenate((lobe(ph0[:,2] - ph0[:,0] - xi_rot),lobe(ph0[:,1] - ph0[:,3] + xi_rot)))  # 26 values for Ant 14
    dph[nant] = np.angle(np.sum(np.exp(1j*dph14),0))  # Very clever average does not suffer from wrapping issues
    # dphi = XX - YX + xi_rot and XY - YY - xi_rot 
    dphi = np.array((lobe(ph0[:,0] - ph0[:,3] + xi_rot),lobe(ph0[:,2] - ph0[:,1] - xi_rot)))  # 2 values for Ant 14
    dph[:nant] = np.angle(np.sum(np.exp(1j*dphi),0))
    
    if doplot:
        figlabel = 'XY_Phase_'+str(band+33)
        if figlabel in plt.get_figlabels():
            f = plt.figure(figlabel)
            ax = f.get_axes()
        else:
            f, ax = plt.subplots(4, 4, num=figlabel)
            ax.shape = (16,)
        for i in range(nant): 
            ax[antlist[i]].plot(fghz,dphi[0,i],',')
            ax[antlist[i]].plot(fghz,dphi[1,i],',')
            ax[antlist[i]].plot(fghz,dph[i],'k,')
            ax[antlist[i]].set_title('Ant '+str(antlist[i]+1),fontsize=9)
        for i in range(2*nant):
            ax[13].plot(fghz,dph14[i],',')
            ax[13].set_title('Ant 14',fontsize=9)
        ax[13].plot(fghz,dph[nant],'k,')
        for i in range(14): ax[i].set_ylim(-4,4)
        f.suptitle('Multicolor: Measurements, Black: Final Results')
        ax[14].plot(fghz,xi_rot)
        for i in range(nant):
            ax[15].plot(fghz,xi2[i],',')
#    np.savez('/common/tmp/Feed_rotation/' + npzlist[0].split('/')[-1][:14] + '_delay_phase.npz', fghz=fghz, dph=dph, xi_rot=xi_rot)
    time = Time.now().lv
    xy_phase = {'antlist':antlist, 'timestamp':time, 'fghz':fghz, 'xyphase':dph, 'xi_rot':xi_rot, 'dphi':dphi, 'dph14':dph14}
    return xy_phase