Exemple #1
0
 def getnewparams(self):
     """ This will take all of the terms in the entries and update the param
         dictionary in the Plot Class object. If no Plot Class exists then 
         the fucntion will become a pass through."""        
     if self.PC is None:
         return
     paramtemp = {}
     for field in INIOPTIONS:
         if field == 'reinterp':
             paramtemp[field] = self.options[field]['var'].get()
         else:
             varval = [i.get() for i in self.options[field]['entries']]
            
             if field=='paramheight':
                 paramtemp[field] = [[varval[2*i],float(varval[2*i+1])] for i in np.arange(0,len(varval)/2) ]
             elif field=='paramlim':
                 paramtemp[field] = [[float(varval[2*i]),float(varval[2*i+1])] for i in np.arange(0,len(varval)/2) ]
             elif field=='timebounds':
                 splist = [i.split(' ') for i in varval ]
                 timelist = [splist[0][0],splist[0][1],splist[1][0],splist[1][1]]
                 paramtemp[field] = str2posix(timelist)
             elif len(varval)>1:
                 paramtemp[field]=[float(i) for i in varval]
             else:
                 paramtemp[field]=float(varval[0])
     self.PC.params=paramtemp  
def PlotTECdiff(gpsloc,timelist,satnum,sublist,pname='mahdiff.png',tectype = 'TEC'):
    """ This will plot the differences between two gps sites. The code filters
        first by satilite number. The TEC is interpolated over the time period
        and then subtracted.
        Inputs
        gpsloc - The directory holding the ionofiles.
        timelist - A list of strings holding the time the data will be interpolated over
            [date1,time1,date2,time1]
            
        satnum - The satilite number as an int or float.
        sublist - This is the name of the recievers that will have their values compared
        pname - Name of the plot
        tectype - Either vTEC or TEC, determines which type will be compared."""
        
    # Figure out location or receivers
    flist1 = glob.glob(os.path.join(gpsloc,'*.iono'))
    
    fnames = np.array([os.path.splitext(os.path.split(i)[1])[0].lower().split('-')[0] for i in flist1])
    
    [f0,f1] = [np.argwhere(i.lower()==fnames)[0][0] for i in sublist]
    
    # read in the receivers and filter out by sat number
    mah0str = flist1[f0]
    mah1str = flist1[f1]
    
    mah0 = GeoData(readIonofiles,(mah0str,))
    mah1 = GeoData(readIonofiles,(mah1str,))
    
    sat230 = mah0.data['satnum']==satnum
    sat231 = mah1.data['satnum']==satnum

    timemah0 = mah0.times[sat230]
    timemah1 = mah1.times[sat231]

    TEC0 = mah0.data[tectype][sat230]
    TEC1 = mah1.data[tectype][sat231]
    
    # Interpolation
    xends = str2posix(timelist)
    xint = np.linspace(xends[0],xends[1],180)
    mah0int = np.interp(xint,timemah0[:,0],TEC0)
    mah1int = np.interp(xint,timemah1[:,0],TEC1)
    
    mahdif = mah0int-mah1int
    
    #plotting
    dts = map(datetime.datetime.utcfromtimestamp, xint)
    fig, axmat = plt.subplots(1,1,dpi=300)
    
    lines = axmat.plot(dts,mahdif)
    axmat.set_title(sublist[0]+' - '+sublist[1] +' '+ timelist[0])
    dtfmt = DateFormatter('%H:%M:%S')
    axmat.xaxis.set_major_locator(HourLocator())
    axmat.xaxis.set_major_formatter(dtfmt)
    axmat.xaxis.set_minor_locator(MinuteLocator(interval=15))

    axmat.set_xlabel('Time UT')
    axmat.set_ylabel(tectype)
    plt.savefig(pname)