Esempio n. 1
0
def plotFgpJson(myScan,rad,bmnum=7,params=['velocity','power','width'], \
              scales=[],channel='a',coords='gate',colors='lasse',yrng=-1,gsct=False,lowGray=False, \
              filtered=False, tFreqBands=[], figure=None,xtick_size=9,
              ytick_size=9,xticks=None,axvlines=None,plotTerminator=False,
              tfreq = None, noise=None, rTime = None,radN = None):
    """create an rti plot for a secified radar and time period

  **Args**:
  	* **myScan** (Beam): Set of beam information for specific radar
    * **rad** (str): the 3 letter radar code, e.g. 'bks'
    * **[bmnum] (int)**: The beam to plot.  default: 7
    * **[params]** (list): a list of the fit parameters to plot, allowable values are: ['velocity', 'power', 'width', 'elevation', 'phi0'].  default: ['velocity', 'power', 'width']
    * **[scales]** (list): a list of the min/max values for the color scale for each param.  If omitted, default scales will be used.  If present, the list should be n x 2 where n is the number of elements in the params list.  Use an empty list for default range, e.g. [[-250,300],[],[]].  default: [[-200,200],[0,30],[0,150]]
    * **[channel]** (char): the channel you wish to plot, e.g. 'a', 'b', 'c', ...  default: 'a'
    * **[coords]** (str): the coordinates to use for the y axis.  The allowable values are 'gate', 'rng', 'geo', 'mag' default: 'gate'
    * **[colors]** (str): a string indicating what color bar to use, valid inputs are ['lasse','aj'].  default: 'lasse'
    * **[yrng]** (list or -1): a list indicating the min and max values for the y axis in the chosen coordinate system, or a -1 indicating to plot everything.  default: -1.
    * **[gsct]** (boolean): a flag indicating whether to plot ground scatter as gray. default: False (ground scatter plotted normally)
    * **[lowGray]** (boolean): a flag indicating whether to plot low velocity scatter as gray. default: False (low velocity scatter plotted normally)
    * **[filtered]** (boolean): a flag indicating whether to boxcar filter the data.  default = False (no filter)
    * **[tFreqBands]** (list): a list of the min/max values for the transmitter frequencies in kHz.  If omitted, the default band will be used.  If more than one band is specified, retfig will cause only the last one to be returned.  default: [[8000,20000]]
    * **[figure]** (matplotlib.figure) figure object to plot on.  If None, a figure object will be created for you.
    * **[xtick_size]** (int): fontsize of xtick labels
    * **[ytick_size]** (int): fontsize of ytick labels
    * **[xticks]** (list): datetime.datetime objects indicating the location of xticks
    * **[axvlines]** (list): datetime.datetime objects indicating the location vertical lines marking the plot
    * **[plotTerminator]** (boolean): Overlay the day/night terminator.
    * **[tfreq]** (int): the beams freqency for the title 
    * **[noise]** (float): the beams noise for the title
    * **[rTime]** (datetime): the beam time for the title
    * **[radN]** (str): Name of radar site for the title
  **Returns**:
    * Plotted figure

  **Example**:
    ::
    
      import datetime as dt
      import matplotlib.pyplot as plot
      plotFgpJson(myScan,'ade',params='velocity',gsct=True,
			scales=[-1000,1000],bmnum = 12,	figure = plot['figure'],
			tfreq = myBeam.prm.tfreq,noise = myBeam.prm.noisesearch,
			rTime=myBeam.time,radN = 'Adak East')

    
  Written by AJ 20121002
  Modified by Matt W. 20130715
  Modified by Nathaniel F. 20131031 (added plotTerminator)
  Modified by Michelle S. 20160324 (updated to create a real time plot and beam vs gate plot)
  """

    #check the inputs
    assert (isinstance(rad, str)
            and len(rad) == 3), 'error, rad must be a string 3 chars long'
    assert(coords == 'gate' or coords == 'rng' or coords == 'geo' or coords == 'mag'),\
    "error, coords must be one of 'gate','rng','geo','mag"
    assert (isinstance(bmnum, int)), 'error, beam must be integer'
    assert (0 < len(params) <
            6), 'error, must input between 1 and 5 params in LIST form'
    for i in range(0, len(params)):
        assert(params[i] == 'velocity' or params[i] == 'power' or params[i] == 'width' or \
        params[i] == 'elevation' or params[i] == 'phi0'), \
        "error, allowable params are 'velocity','power','width','elevation','phi0'"
    assert(scales == [] or len(scales)==len(params)), \
    'error, if present, scales must have same number of elements as params'
    assert(yrng == -1 or (isinstance(yrng,list) and yrng[0] <= yrng[1])), \
    'error, yrng must equal -1 or be a list with the 2nd element larger than the first'
    assert (colors == 'lasse' or colors
            == 'aj'), "error, valid inputs for color are 'lasse' and 'aj'"

    #assign any default color scales
    tscales = []
    for i in range(0, len(params)):
        if (scales == [] or scales[i] == []):
            if (params[i] == 'velocity'): tscales.append([-200, 200])
            elif (params[i] == 'power'): tscales.append([0, 30])
            elif (params[i] == 'width'): tscales.append([0, 150])
            elif (params[i] == 'elevation'): tscales.append([0, 50])
            elif (params[i] == 'phi0'): tscales.append([-numpy.pi, numpy.pi])
        else: tscales.append(scales[i])
    scales = tscales

    #assign default frequency band
    tbands = []
    if tFreqBands == []: tbands.append([8000, 20000])
    else:
        for band in tFreqBands:
            #make sure that starting frequncy is less than the ending frequency for each band
            assert (band[0] < band[1]
                    ), "Starting frequency must be less than ending frequency!"
            tbands.append(band)

    if not myScan:
        logging.debug(
            'error, no data available for the requested time/radar/filetype combination'
        )
        return None

    #initialize empty lists
    vel,pow,wid,elev,phi0,beam,freq,cpid,nave,nsky,nsch,slist,mode,rsep,nrang,frang,gsflg = \
          [],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]
    for i in range(len(tbands)):
        beam.append([])
        cpid.append([])
        nave.append([])
        nsky.append([])
        rsep.append([])
        nrang.append([])
        frang.append([])
        nsch.append([])
        freq.append([])
        slist.append([])
        mode.append([])
        vel.append([])
        pow.append([])
        wid.append([])
        elev.append([])
        phi0.append([])
        gsflg.append([])

        #read the parameters of interest

        for myBeam in myScan:
            beam[i].append(myBeam.bmnum)
            cpid[i].append(myBeam.cp)
            nave[i].append(myBeam.prm.nave)
            nsky[i].append(myBeam.prm.noisesky)
            rsep[i].append(myBeam.prm.rsep)
            nrang[i].append(myBeam.prm.nrang)
            frang[i].append(myBeam.prm.frang)
            nsch[i].append(myBeam.prm.noisesearch)
            if myBeam.prm.tfreq is None:
                myBeam.prm.tfreq = 0
            freq[i].append(myBeam.prm.tfreq / 1e3)
            slist[i].append(myBeam.fit.slist)
            mode[i].append(myBeam.prm.ifmode)
            if ('velocity' in params): vel[i].append(myBeam.fit.v)
            if ('power' in params): pow[i].append(myBeam.fit.p_l)
            if ('width' in params): wid[i].append(myBeam.fit.w_l)
            if ('elevation' in params): elev[i].append(myBeam.fit.elv)
            if ('phi0' in params): phi0[i].append(myBeam.fit.phi0)
            gsflg[i].append(myBeam.fit.gflg)

    for fplot in range(len(tbands)):
        #Check to ensure that data exists for the requested frequency band else
        #continue on to the next range of frequencies
        if not freq[fplot]:
            logging.debug('error, no data in frequency range ' +
                          str(tbands[fplot][0]) + ' kHz to ' +
                          str(tbands[fplot][1]) + ' kHz')
            rtiFig = None  #Need this line in case no data is plotted
            continue

        #get/create a figure
        rtiFig = figure

        #plot each of the parameter panels
        for p in range(len(params)):
            if (params[p] == 'velocity'): pArr = vel[fplot]
            elif (params[p] == 'power'): pArr = pow[fplot]
            elif (params[p] == 'width'): pArr = wid[fplot]
            elif (params[p] == 'elevation'): pArr = elev[fplot]
            elif (params[p] == 'phi0'): pArr = phi0[fplot]
            #draw the axis
            ax = drawAxes(rtiFig,beam[fplot],rad,cpid[fplot],bmnum,nrang[fplot],frang[fplot],rsep[fplot],p==len(params)-1,yrng=yrng,coords=coords,\
                          xtick_size=xtick_size,ytick_size=ytick_size,xticks=xticks,axvlines=axvlines)

            if (pArr == []): continue

            rmax = max(nrang[fplot])
            data = numpy.zeros((len(beam[fplot]), rmax)) - 150000
            if gsct: gsdata = numpy.zeros((len(beam[fplot]), rmax)) - 150000
            x = numpy.zeros(len(beam[fplot]))
            tcnt = 0
            dt_list = []
            for i in range(len(beam[fplot])):
                x[tcnt] = beam[fplot][i]
                dt_list.append(beam[fplot][i])
                if (pArr[i] == []): continue

                if slist[fplot][i] != None:
                    for j in range(len(slist[fplot][i])):
                        if (not gsct or gsflg[fplot][i][j] == 0):
                            data[tcnt][slist[fplot][i][j]] = pArr[i][j]
                        elif gsct and gsflg[fplot][i][j] == 1:
                            data[tcnt][slist[fplot][i][j]] = -100000.

                tcnt += 1
            tmpdata = numpy.ma.masked_where(data <= -150000, data)
            if (coords == 'gate'): y = numpy.linspace(0, rmax, rmax + 1)
            elif (coords == 'rng'):
                y = numpy.linspace(frang[fplot][0], rmax * rsep[fplot][0],
                                   rmax + 1)
            else:
                y = myFov.latFull[bmnum]
            X, Y = numpy.meshgrid(x[:tcnt], y)
            cmap, norm, bounds = genCmap(params[p],
                                         scales[p],
                                         colors=colors,
                                         lowGray=lowGray)
            cmap.set_bad('w', 1.0)
            pcoll = ax.pcolormesh(tmpdata[:][:].T,
                                  lw=0.01,
                                  edgecolors='w',
                                  alpha=1,
                                  cmap=cmap,
                                  norm=norm)
            cb = rtiFig.colorbar(pcoll,
                                 orientation='vertical',
                                 shrink=.65,
                                 fraction=.1)
            l = []
            #define the colorbar labels
            for i in range(0, len(bounds)):
                if (params[p] == 'phi0'):
                    ln = 4
                    if (bounds[i] == 0): ln = 3
                    elif (bounds[i] < 0): ln = 5
                    l.append(str(bounds[i])[:ln])
                    continue
                if ((i == 0 and params[p] == 'velocity')
                        or i == len(bounds) - 1):
                    l.append(' ')
                    continue
                l.append(str(int(bounds[i])))
            cb.ax.set_yticklabels(l)

            #set colorbar ticklabel size
            for t in cb.ax.get_yticklabels():
                t.set_fontsize(9)

            #set colorbar label
            if (params[p] == 'velocity'):
                cb.set_label('Velocity [m/s]', size=10)
            if (params[p] == 'grid'): cb.set_label('Velocity [m/s]', size=10)
            if (params[p] == 'power'): cb.set_label('Power [dB]', size=10)
            if (params[p] == 'width'): cb.set_label('Spec Wid [m/s]', size=10)
            if (params[p] == 'elevation'): cb.set_label('Elev [deg]', size=10)
            if (params[p] == 'phi0'): cb.set_label('Phi0 [rad]', size=10)
        xmin = 0.1
        xmax = 0.96
        if noise is None:
            noise = 0
        rtiFig.text(xmin, .95, radN, ha='left', weight=400)
        rtiFig.text((xmin + xmax) / 2.,
                    .95,
                    str(rTime) + '; Beam: ' + str(bmnum) + '; Freq: ' +
                    str(tfreq) + '; Noise: ' + "{0:.2f}".format(noise),
                    weight=100,
                    ha='center')
        return rtiFig
Esempio n. 2
0
def plotFan(myScan,rad,params='velocity',filtered=False ,\
        scales=[],channel='a',coords='geo',\
        colors='lasse',gsct=False,fovs=None,edgeColors='face',\
        lowGray=False,fill=True,velscl=1000.,legend=True,overlayPoes=False,\
        poesparam='ted',poesMin=-3.,poesMax=0.5, maxbeams = 16, maxgates = 75, \
        poesLabel=r"Total Log Energy Flux [ergs cm$^{-2}$ s$^{-1}$]",overlayBnd=False, \
  tFreqBands=[],myFigs=None,bmnum = None,drawEdge = False,continentBorder = '0.75',\
  tfreq = None, noise = None,nave = 0, inttime = 0,rTime = None, radN = None,merGrid = True,\
  merColor = '0.75',waterColor = '#cce5ff',continentColor = 'w',\
  backgColor='w',gridColor='k',filepath = None,\
  site = None,dist = None,myMap = None):
    """A function to make a geographical fan plot
    
    **Args**:
    	* **myScan** (list): a list size of the radar beam number containing beam information
        * **rad** (list): a list of 3 letter radar codes, e.g. ['bks'], e.g. ['bks','wal','gbr']
        * **[param]** (str): the parameter to be plotted, valid inputs are 'velocity', 'power', 'width', 'elevation', 'phi0'.  default = 'velocity'
        * **[filtered]** (boolean): a flag indicating whether the data should be boxcar filtered.  default = False
        * **[scale]** (list): the min and max values of the color scale, i.e. [min,max].  If this is set to [], then default values will be used
        * **[channel] (char)**: the channel for which to plot data.  default = 'a'
        * **[coords]** (str): the coordinate system to use, valid inputs are 'geo', 'mag'.  default = 'geo'
        * **[colors]** (str): the color map to use, valid inputs are 'lasse', 'aj'.  default = 'lasse'
        * **[gsct]** (boolean): a flag indicating whether to plot ground scatter as gray.  default = False
        * **[fovs]**  (boolean): a flag indicating whether to overplot the radar fields of view.  default = True
        * **[edgeColors]** (str): edge colors of the polygons, default = 'face'
        * **[lowGray]** (boolean): a flag indicating whether to plot low velocities in gray.  default = False
        * **[fill]** (boolean): a flag indicating whether to plot filled or point RB cells.  default = True
        * **[velscl]** (float): the velocity to use as baseline for velocity vector length, only applicable if fill = 0.  default = 1000
        * **[legend]** (boolean): a flag indicating whether to plot the legend, only applicable if fill = 0.  default = True
        * **[overlayPoes]** (boolean): a flag indicating whether to overlay poes data.  default = False
        * **[poesparam]** (str): the poes parameter to plot.  default = 'ted'.  available params can be found in :class:`gme.sat.poes.poesRec`
        * **[poesMin]** (float): the min value for the poes data color scale.  default = -3.
        * **[poesMax]**  (float): the max value for the poes data color scale.  default = 0.5
        * **[maxbeams]** (int): maximum number of beams for a radar
        * **[maxgates]** (int): maximum number of gates for a radar
        * **[poesLabel]** (str): the label for the poes color bar.  default = r"Total Log Energy Flux [ergs cm$^{-2}$ s$^{-1}$]"
        * **[overlayBnd]** (boolean): a flag indicating whether to plot an auroral boundary determined from fitting poes data.  default = False
        * **[tFreqBands]** (list): upper and lower bounds of frequency in kHz to be used.  Must be unset (or set to []) or have a pair for each radar, and for any band set to [] the default will be used.  default = [[8000,20000]], [[8000,20000],[8000,20000]], etc.
        * **[myFigs]** (figure): Array of figures, one for each parameter
        * **[bmnum]** (int): number of beam that you are currently at 
        * **[drawEdge]** (boolean): a flag indicating if the edges of contents are drawn
        * **[continentBorder]** (int): Color of the content border
        * **[tfreq]** (int): The beam numbers param tfreq for title information
        * **[noise]** (float): The beam numbers param noisesearch for title information
        * **[nave]** (int): The number of averages for the displayed beam
        * **[inttime]** (int): The integeration time in seconds for the displayed beam
        * **[rTime]** (datetime): The beam number time for title information
        * **[radN]** (str): Name of the radar like 'Adak East' for title information
        * **[merGrid]** (boolean): Indicates if the map has a grid
        * **[merColor]** (int): Color of the grid if it is drawn
        * **[waterColor]** (str): Color string of the ocean water
        * **[continentColor]** (char): Color char of the content
        * **[backgColor]** (char): Color char of the background color
        * **[gridColor]** (char): Color char of the background grid
        * **[filepath]** (str): file path from current location to picture location
        * ****** Pre -Caluculated information to reduce runtime ****** *
        * **[site]** (site): site information of the radar
        * **[dist]** (geoLoc): location information the width divided by 50
        * **[myMap]** (myMap): Map object with latitude and longitude information
        
    **Returns**:
        * Array of matplotlib figures

    **Example**:
        ::
        
            import datetime as dt
            import matplotlib.pyplot as plot
            plotFan(myScan,['ade'],	fovs = fovs,
            params=['velocity','power','width'],gsct=True, 
			maxbeams = 16,maxgates=75,scales=[[-1000,1000],[0,30],[0,500]],
			drawEdge = False,myFigs = 3*[plot.figure()],bmnum = 1,
			site = site,tfreq = tfreq,noise = myBeam.prm.noisesearch,
			rTime=myBeam.time,radN = 'Adak East',dist = dist,
			merGrid = True, merColor = '0.75', continentBorder = '0.75',
			waterColor = '#cce5ff', continentColor = '0.75',backgColor = 'w',
			gridColor = 'k', filepath =filepath,myMap = myMap)

    Written by AJ 20121004
    Modified by Matt W. 20130717
    Modified by Michelle S. 20160324 (updated to run in real time data)
    """

    #check the inputs
    assert (isinstance(
        rad, list)), "error, rad must be a list, eg ['bks'] or ['bks','fhe']"
    for r in rad:
        assert (isinstance(r, str) and len(r)
                == 3), 'error, elements of rad list must be 3 letter strings'
    assert (coords == 'geo'
            or coords == 'mag'), "error, coords must be one of 'geo' or 'mag'"
    assert (colors == 'lasse' or colors
            == 'aj'), "error, valid inputs for color are 'lasse' and 'aj'"

    #check freq band and set to default if needed
    assert (
        tFreqBands == [] or len(tFreqBands) == len(rad)
    ), 'error, if present, tFreqBands must have same number of elements as rad'
    for i in range(len(myFigs)):
        time.sleep(01)
        param = params[i]
        scale = scales[i]
        myFig = myFigs[i]
        myFig.clf(keep_observers=True)
        tbands = []
        for i in range(len(rad)):
            if tFreqBands == [] or tFreqBands[i] == []:
                tbands.append([8000, 20000])
            else:
                tbands.append(tFreqBands[i])

        for i in range(len(tbands)):
            assert (tbands[i][1] > tbands[i][0]
                    ), 'error, frequency upper bound must be > lower bound'

        if (scale == []):
            if (param == 'velocity'): scale = [-200, 200]
            elif (param == 'power'): scale = [0, 30]
            elif (param == 'width'): scale = [0, 150]
            elif (param == 'elevation'): scale = [0, 50]
            elif (param == 'phi0'): scale = [-numpy.pi, numpy.pi]

        fbase = datetime.datetime.utcnow().strftime("%Y%m%d")

        cmap, norm, bounds = genCmap(param,
                                     scale,
                                     colors=colors,
                                     lowGray=lowGray)

        myBands = []
        for i in range(len(rad)):
            myBands.append(tbands[i])

        try:
            myMap.drawcoastlines(linewidth=0.5, color=continentBorder)
            myMap.drawmapboundary(fill_color=waterColor)
            myMap.fillcontinents(color=continentColor, lake_color=waterColor)
            myMap.drawcountries()
        except:
            myMap.drawcountries()

        cols = []
        ft = 'None'
        pcoll = None
        drawEdge = False
        gridColor = 'k'
        backgColor = 'w'
        waterColor = '#cce5ff'
        continentBorder = '0.75'
        continentColor = 'w'
        merColor = '0.75'
        cTime = datetime.datetime.utcnow()
        if param == 'power':
            gsct = False
        else:
            gsct = True


        overlayFov(myMap, codes=rad, dateTime=cTime,\
                                             fovObj=fovs[0])
        intensities, pcoll = overlayFan(myScan,myMap,myFig,param,coords,\
         gsct=gsct,site=site,fov=fovs[0], fill=fill,velscl=velscl,\
         dist=dist,cmap=cmap,norm=norm,scale = scale,maxbeams=maxbeams,
         maxgates = maxgates)

        #if no data has been found pcoll will not have been set, and the following code will object
        if pcoll:
            cbar = myFig.colorbar(pcoll,
                                  orientation='vertical',
                                  shrink=.65,
                                  fraction=.1,
                                  drawedges=drawEdge,
                                  norm=norm)
            l = []
            #define the colorbar labels
            for i in range(0, len(bounds)):
                if (param == 'phi0'):
                    ln = 4
                    if (bounds[i] == 0): ln = 3
                    elif (bounds[i] < 0): ln = 5
                    l.append(str(bounds[i])[:ln])
                    continue
                l.append(str(int(bounds[i])))
            cbar.ax.set_yticklabels(l)
            cbar.ax.tick_params(axis='y', direction='out')
            #set colorbar ticklabel size
            for ti in cbar.ax.get_yticklabels():
                ti.set_fontsize(12)
            if (param == 'velocity'):
                cbar.set_label('Velocity [m/s]', size=14)
                cbar.extend = 'max'

            if (param == 'grid'): cbar.set_label('Velocity [m/s]', size=14)
            if (param == 'power'): cbar.set_label('Power [dB]', size=14)
            if (param == 'width'): cbar.set_label('Spec Wid [m/s]', size=14)
            if (param == 'elevation'): cbar.set_label('Elev [deg]', size=14)
            if (param == 'phi0'): cbar.set_label('Phi0 [rad]', size=14)

        if (overlayPoes):
            pcols = gme.sat.poes.overlayPoesTed(myMap,
                                                myFig.gca(),
                                                cTime,
                                                param=poesparam,
                                                scMin=poesMin,
                                                scMax=poesMax)
            if (pcols != None):
                cols.append(pcols)
                pTicks = numpy.linspace(poesMin, poesMax, 8)
                cbar = myFig.colorbar(pcols,
                                      ticks=pTicks,
                                      orientation='vertical',
                                      shrink=0.65,
                                      fraction=.1,
                                      norm=matplotlib.colors.Normalize(
                                          vmin=scale[0], vmax=scale[1]))
                cbar.ax.set_yticklabels(pTicks)
                cbar.set_label(poesLabel, size=14)
                cbar.ax.tick_params(axis='y', direction='out')
                #set colorbar ticklabel size
                for ti in cbar.ax.get_yticklabels():
                    ti.set_fontsize(12)
        if (overlayBnd):
            gme.sat.poes.overlayPoesBnd(myMap, myFig.gca(), cTime)

        if noise is None:
            noise = 0

        plt.title(radN + '; Time: ' + str(rTime), loc='center')
        plt.xlabel('Beam: '+str(bmnum)+'; Freq: '+str(tfreq)+'; Noise: '+"{0:.2f}".format(noise)+\
         '; Avg: '+str(nave)+'; Int. Time: '+str(inttime))
        myFig.savefig("%sgeo_%s" % (filepath, param), bbox_inches='tight')
    return myFigs
Esempio n. 3
0
def plotRti(myBeamList,rad,bmnum=7, params=['velocity','power','width'],\
 scales=[], channel='a',coords='gate',colors='lasse',yrng=-1,\
 gsct=False,lowGray=False, filtered=False,tFreqBands=[],\
 figure=None,xtick_size=9,ytick_size=9,myFov = None,\
 xticks=None,axvlines=None,rTime = None,title=None):
    """create an rti plot for a secified radar and time period

  **Args**:
  	* **myBeamList** List of beam information
    * **rad** (str): the 3 letter radar code, e.g. 'bks'
    * **[bmnum] (int)**: The beam to plot.  default: 7
    * **[params]** (list): a list of the fit parameters to plot, allowable values are: ['velocity', 'power', 'width', 'elevation', 'phi0'].  default: ['velocity', 'power', 'width']
    * **[scales]** (list): a list of the min/max values for the color scale for each param.  If omitted, default scales will be used.  If present, the list should be n x 2 where n is the number of elements in the params list.  Use an empty list for default range, e.g. [[-250,300],[],[]].  default: [[-200,200],[0,30],[0,150]]
    * **[channel]** (char): the channel you wish to plot, e.g. 'a', 'b', 'c', ...  default: 'a'
    * **[coords]** (str): the coordinates to use for the y axis.  The allowable values are 'gate', 'rng', 'geo', 'mag' default: 'gate'
    * **[colors]** (str): a string indicating what color bar to use, valid inputs are ['lasse','aj'].  default: 'lasse'
    * **[yrng]** (list or -1): a list indicating the min and max values for the y axis in the chosen coordinate system, or a -1 indicating to plot everything.  default: -1.
    * **[gsct]** (boolean): a flag indicating whether to plot ground scatter as gray. default: False (ground scatter plotted normally)
    * **[lowGray]** (boolean): a flag indicating whether to plot low velocity scatter as gray. default: False (low velocity scatter plotted normally)
    * **[filtered]** (boolean): a flag indicating whether to boxcar filter the data.  default = False (no filter)
    * **[tFreqBands]** (list): a list of the min/max values for the transmitter frequencies in kHz.  If omitted, the default band will be used.  If more than one band is specified, retfig will cause only the last one to be returned.  default: [[8000,20000]]
    * **[figure]** (matplotlib.figure) figure object to plot on.  If None, a figure object will be created for you.
    * **[xtick_size]**: (int) fontsize of xtick labels
    * **[ytick_size]**: (int) fontsize of ytick labels
    * **[myFov]**: field of view parameters
    * **[xticks]**: (list) datetime.datetime objects indicating the location of xticks
    * **[axvlines]**: (list) datetime.datetime objects indicating the location vertical lines marking the plot
    * **[rTime]**: (datetime) current datetime to go on the title of the graph
    * **[title]**: (str) title string for figure
  **Returns**:
    * Return figure

  **Example**:
    ::
    
      import datetime as dt
      import matplotlib.pyplot as plot
      plotRti(myBeamList,'ade',params=['velocity','power','width'],
			scales=[[-1000,1000],[0,30],[0,500]],gsct=True,
			bmnum = 8,figure = plot.figure(),rTime = timeNow,
			title = 'Adak East',myFov = fovs)

    
  Written by AJ 20121002
  Modified by Matt W. 20130715
  Modified by Nathaniel F. 20131031 (added plotTerminator)
  Modified by Michelle S. 20160324 (updated for real time data plotting)
  """

    #check the inputs
    assert (isinstance(rad, str)
            and len(rad) == 3), 'error, rad must be a string 3 chars long'
    assert(coords == 'gate' or coords == 'rng' or coords == 'geo' or coords == 'mag'),\
    "error, coords must be one of 'gate','rng','geo','mag"
    assert (isinstance(bmnum, int)), 'error, beam must be integer'
    assert (0 < len(params) <
            6), 'error, must input between 1 and 5 params in LIST form'
    for i in range(0, len(params)):
        assert(params[i] == 'velocity' or params[i] == 'power' or params[i] == 'width' or \
        params[i] == 'elevation' or params[i] == 'phi0'), \
        "error, allowable params are 'velocity','power','width','elevation','phi0'"
    assert(scales == [] or len(scales)==len(params)), \
    'error, if present, scales must have same number of elements as params'
    assert(yrng == -1 or (isinstance(yrng,list) and yrng[0] <= yrng[1])), \
    'error, yrng must equal -1 or be a list with the 2nd element larger than the first'
    assert (colors == 'lasse' or colors
            == 'aj'), "error, valid inputs for color are 'lasse' and 'aj'"

    #assign any default color scales
    tscales = []
    for i in range(0, len(params)):
        if (scales == [] or scales[i] == []):
            if (params[i] == 'velocity'): tscales.append([-200, 200])
            elif (params[i] == 'power'): tscales.append([0, 30])
            elif (params[i] == 'width'): tscales.append([0, 150])
            elif (params[i] == 'elevation'): tscales.append([0, 50])
            elif (params[i] == 'phi0'): tscales.append([-numpy.pi, numpy.pi])
        else: tscales.append(scales[i])
    scales = tscales

    #assign default frequency band
    tbands = []
    if tFreqBands == []: tbands.append([8000, 20000])
    else:
        for band in tFreqBands:
            #make sure that starting frequncy is less than the ending frequency for each band
            assert (band[0] < band[1]
                    ), "Starting frequency must be less than ending frequency!"
            tbands.append(band)

    if not myBeamList:
        logging.debug(
            'error, no data available for the requested time/radar/filetype combination'
        )
        return None

    #initialize empty lists
    vel,pow,wid,elev,phi0,times,freq,cpid,nave,nsky,nsch,slist,mode,rsep,nrang,frang,gsflg = \
          [],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]
    for i in range(len(tbands)):
        times.append([])
        cpid.append([])
        nave.append([])
        nsky.append([])
        rsep.append([])
        nrang.append([])
        frang.append([])
        nsch.append([])
        freq.append([])
        slist.append([])
        mode.append([])
        vel.append([])
        pow.append([])
        wid.append([])
        elev.append([])
        phi0.append([])
        gsflg.append([])
    timeThen = datetime.datetime.utcnow() - datetime.timedelta(days=1)
    #read the parameters of interest
    for myBeam in myBeamList:
        if myBeam.time > timeThen:
            ids = myBeam.stid
            times[i].append(myBeam.time)
            cpid[i].append(myBeam.cp)
            nave[i].append(myBeam.prm.nave)
            nsky[i].append(myBeam.prm.noisesky)
            rsep[i].append(myBeam.prm.rsep)
            nrang[i].append(myBeam.prm.nrang)
            frang[i].append(myBeam.prm.frang)
            nsch[i].append(myBeam.prm.noisesearch)
            freq[i].append(myBeam.prm.tfreq / 1e3)
            slist[i].append(myBeam.fit.slist)
            mode[i].append(myBeam.prm.ifmode)
            if ('velocity' in params): vel[i].append(myBeam.fit.v)
            if ('power' in params): pow[i].append(myBeam.fit.p_l)
            if ('width' in params): wid[i].append(myBeam.fit.w_l)
            if ('elevation' in params): elev[i].append(myBeam.fit.elv)
            if ('phi0' in params): phi0[i].append(myBeam.fit.phi0)
            gsflg[i].append(myBeam.fit.gflg)

    for fplot in range(len(tbands)):

        #get/create a figure
        rtiFig = figure
        #give the plot a title
        rtiTitle(rtiFig, rTime, title, rad, bmnum)
        #plot the noise bar
        plotNoise(rtiFig, times[fplot], nsky[fplot], nsch[fplot])
        #plot the frequency bar
        plotFreq(rtiFig, times[fplot], freq[fplot], nave[fplot])
        #plot the cpid bar
        plotCpid(rtiFig, times[fplot], cpid[fplot], mode[fplot])

        #plot each of the parameter panels
        figtop = .77
        figheight = .72 / len(params)
        for p in range(len(params)):
            if (params[p] == 'velocity'): pArr = vel[fplot]
            elif (params[p] == 'power'): pArr = pow[fplot]
            elif (params[p] == 'width'): pArr = wid[fplot]
            elif (params[p] == 'elevation'): pArr = elev[fplot]
            elif (params[p] == 'phi0'): pArr = phi0[fplot]
            time.sleep(0.1)
            pos = [
                .1, figtop - figheight * (p + 1) + .02, .76, figheight - .02
            ]

            #draw the axis
            ax = drawAxes(rtiFig,times[fplot],rad,cpid[fplot],bmnum,nrang[fplot],frang[fplot],rsep[fplot],ids,p==len(params)-1,yrng=yrng,coords=coords,\
                          pos=pos,xtick_size=xtick_size,ytick_size=ytick_size,xticks=xticks,axvlines=axvlines, myFov=myFov)

            if (pArr == []): continue

            rmax = max(nrang[fplot])
            data = numpy.zeros((len(times[fplot]) * 2, rmax)) - 150000

            if gsct:
                gsdata = numpy.empty((len(times[fplot]) * 2, rmax))
            x = numpy.empty(len(times[fplot]) * 2)
            tcnt = 0

            dt_list = []
            for i in range(len(times[fplot])):
                x[tcnt] = date2num(times[fplot][i])
                dt_list.append(times[fplot][i])

                if (i < len(times[fplot]) - 1):
                    if (date2num(times[fplot][i + 1]) - x[tcnt] > 4. / 1440.):
                        tcnt += 1
                        x[tcnt] = x[tcnt - 1] + 1. / 1440.
                        dt_list.append(num2date(x[tcnt]))
                tcnt += 1

                if (pArr[i] == []): continue

                if slist[fplot][i] != None:
                    for j in range(len(slist[fplot][i])):
                        if (not gsct or gsflg[fplot][i][j]
                                == 0) or params[p] == 'power':
                            data[tcnt][int(slist[fplot][i][j])] = pArr[i][j]
                        elif gsct and gsflg[fplot][i][j] == 1:
                            data[tcnt][int(slist[fplot][i][j])] = -100000.
            tmpdata = numpy.ma.masked_where(data <= -150000, data)

            if (coords != 'gate' and coords != 'rng'):
                if myFov is None:
                    site = RadarPos(ids)
                    myFov = radFov.fov(site=site,
                                       ngates=rmax,
                                       nbeams=site.maxbeam,
                                       rsep=rsep[fplot][0],
                                       coords=coords)
                myLat = myFov.latCenter[bmnum]
                myLon = myFov.lonCenter[bmnum]

            if (coords == 'gate'): y = numpy.linspace(0, rmax, rmax + 1)
            elif (coords == 'rng'):
                y = numpy.linspace(frang[fplot][0], rmax * rsep[fplot][0],
                                   rmax + 1)
            else:
                y = myFov.latFull[bmnum]

            X, Y = numpy.meshgrid(x[:tcnt], y)

            cmap, norm, bounds = plotUtils.genCmap(params[p],
                                                   scales[p],
                                                   colors=colors,
                                                   lowGray=lowGray)
            cmap.set_bad('w', 1.0)
            pcoll = ax.pcolormesh(X,
                                  Y,
                                  tmpdata[:tcnt][:].T,
                                  lw=0.01,
                                  edgecolors='None',
                                  alpha=1,
                                  cmap=cmap,
                                  norm=norm)
            try:
                cb = plotUtils.drawCB(
                    rtiFig,
                    pcoll,
                    cmap,
                    norm,
                    map=0,
                    pos=[pos[0] + pos[2] + .02, pos[1], 0.02, pos[3]])
            except:
                cb = rtiFig.colorbar(pcoll,
                                     orientation='vertical',
                                     shrink=.65,
                                     fraction=.1)
            l = []
            #define the colorbar labels
            for i in range(0, len(bounds)):
                l.append(str(int(bounds[i])))
            cb.ax.set_yticklabels(l)

            #set colorbar ticklabel size
            for t in cb.ax.get_yticklabels():
                t.set_fontsize(9)

            #set colorbar label
            if (params[p] == 'velocity'):
                cb.set_label('Velocity [m/s]', size=10)
            if (params[p] == 'grid'): cb.set_label('Velocity [m/s]', size=10)
            if (params[p] == 'power'): cb.set_label('Power [dB]', size=10)
            if (params[p] == 'width'): cb.set_label('Spec Wid [m/s]', size=10)
            if (params[p] == 'elevation'): cb.set_label('Elev [deg]', size=10)
            if (params[p] == 'phi0'): cb.set_label('Phi0 [rad]', size=10)
        #end of plotting for loop
        return rtiFig
Esempio n. 4
0
def plotFgpJson(myScan,rad,bmnum=7,params=['velocity','power','width'], \
              scales=[],channel='a',coords='gate',colors='lasse',yrng=-1,gsct=False,lowGray=False, \
              filtered=False, tFreqBands=[], figure=None,xtick_size=9,
              ytick_size=9,xticks=None,axvlines=None,plotTerminator=False,
              tfreq = None, noise=None, rTime = None,radN = None):
  """create an rti plot for a secified radar and time period

  **Args**:
  	* **myScan** (Beam): Set of beam information for specific radar
    * **rad** (str): the 3 letter radar code, e.g. 'bks'
    * **[bmnum] (int)**: The beam to plot.  default: 7
    * **[params]** (list): a list of the fit parameters to plot, allowable values are: ['velocity', 'power', 'width', 'elevation', 'phi0'].  default: ['velocity', 'power', 'width']
    * **[scales]** (list): a list of the min/max values for the color scale for each param.  If omitted, default scales will be used.  If present, the list should be n x 2 where n is the number of elements in the params list.  Use an empty list for default range, e.g. [[-250,300],[],[]].  default: [[-200,200],[0,30],[0,150]]
    * **[channel]** (char): the channel you wish to plot, e.g. 'a', 'b', 'c', ...  default: 'a'
    * **[coords]** (str): the coordinates to use for the y axis.  The allowable values are 'gate', 'rng', 'geo', 'mag' default: 'gate'
    * **[colors]** (str): a string indicating what color bar to use, valid inputs are ['lasse','aj'].  default: 'lasse'
    * **[yrng]** (list or -1): a list indicating the min and max values for the y axis in the chosen coordinate system, or a -1 indicating to plot everything.  default: -1.
    * **[gsct]** (boolean): a flag indicating whether to plot ground scatter as gray. default: False (ground scatter plotted normally)
    * **[lowGray]** (boolean): a flag indicating whether to plot low velocity scatter as gray. default: False (low velocity scatter plotted normally)
    * **[filtered]** (boolean): a flag indicating whether to boxcar filter the data.  default = False (no filter)
    * **[tFreqBands]** (list): a list of the min/max values for the transmitter frequencies in kHz.  If omitted, the default band will be used.  If more than one band is specified, retfig will cause only the last one to be returned.  default: [[8000,20000]]
    * **[figure]** (matplotlib.figure) figure object to plot on.  If None, a figure object will be created for you.
    * **[xtick_size]** (int): fontsize of xtick labels
    * **[ytick_size]** (int): fontsize of ytick labels
    * **[xticks]** (list): datetime.datetime objects indicating the location of xticks
    * **[axvlines]** (list): datetime.datetime objects indicating the location vertical lines marking the plot
    * **[plotTerminator]** (boolean): Overlay the day/night terminator.
    * **[tfreq]** (int): the beams freqency for the title 
    * **[noise]** (float): the beams noise for the title
    * **[rTime]** (datetime): the beam time for the title
    * **[radN]** (str): Name of radar site for the title
  **Returns**:
    * Plotted figure

  **Example**:
    ::
    
      import datetime as dt
      import matplotlib.pyplot as plot
      plotFgpJson(myScan,'ade',params='velocity',gsct=True,
			scales=[-1000,1000],bmnum = 12,	figure = plot['figure'],
			tfreq = myBeam.prm.tfreq,noise = myBeam.prm.noisesearch,
			rTime=myBeam.time,radN = 'Adak East')

    
  Written by AJ 20121002
  Modified by Matt W. 20130715
  Modified by Nathaniel F. 20131031 (added plotTerminator)
  Modified by Michelle S. 20160324 (updated to create a real time plot and beam vs gate plot)
  """
    

  #check the inputs
  assert(isinstance(rad,str) and len(rad) == 3),'error, rad must be a string 3 chars long'
  assert(coords == 'gate' or coords == 'rng' or coords == 'geo' or coords == 'mag'),\
  "error, coords must be one of 'gate','rng','geo','mag"
  assert(isinstance(bmnum,int)),'error, beam must be integer'
  assert(0 < len(params) < 6),'error, must input between 1 and 5 params in LIST form'
  for i in range(0,len(params)):
    assert(params[i] == 'velocity' or params[i] == 'power' or params[i] == 'width' or \
    params[i] == 'elevation' or params[i] == 'phi0'), \
    "error, allowable params are 'velocity','power','width','elevation','phi0'"
  assert(scales == [] or len(scales)==len(params)), \
  'error, if present, scales must have same number of elements as params'
  assert(yrng == -1 or (isinstance(yrng,list) and yrng[0] <= yrng[1])), \
  'error, yrng must equal -1 or be a list with the 2nd element larger than the first'
  assert(colors == 'lasse' or colors == 'aj'),"error, valid inputs for color are 'lasse' and 'aj'"

  #assign any default color scales
  tscales = []
  for i in range(0,len(params)):
    if(scales == [] or scales[i] == []):
      if(params[i] == 'velocity'): tscales.append([-200,200])
      elif(params[i] == 'power'): tscales.append([0,30])
      elif(params[i] == 'width'): tscales.append([0,150])
      elif(params[i] == 'elevation'): tscales.append([0,50])
      elif(params[i] == 'phi0'): tscales.append([-numpy.pi,numpy.pi])
    else: tscales.append(scales[i])
  scales = tscales

  #assign default frequency band
  tbands = []
  if tFreqBands == []: tbands.append([8000,20000])
  else: 
    for band in tFreqBands: 
      #make sure that starting frequncy is less than the ending frequency for each band
      assert(band[0] < band[1]),"Starting frequency must be less than ending frequency!"
      tbands.append(band)


  if not myScan:
    logging.debug('error, no data available for the requested time/radar/filetype combination')
    return None

  #initialize empty lists
  vel,pow,wid,elev,phi0,beam,freq,cpid,nave,nsky,nsch,slist,mode,rsep,nrang,frang,gsflg = \
        [],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]
  for i in range(len(tbands)):
    beam.append([])
    cpid.append([])
    nave.append([])
    nsky.append([])
    rsep.append([])
    nrang.append([])
    frang.append([])
    nsch.append([])
    freq.append([])
    slist.append([])
    mode.append([])
    vel.append([])
    pow.append([])
    wid.append([])
    elev.append([])
    phi0.append([])
    gsflg.append([])
  
  #read the parameters of interest

    for myBeam in myScan:
	  beam[i].append(myBeam.bmnum)
	  cpid[i].append(myBeam.cp)
	  nave[i].append(myBeam.prm.nave)
	  nsky[i].append(myBeam.prm.noisesky)
	  rsep[i].append(myBeam.prm.rsep)
	  nrang[i].append(myBeam.prm.nrang)
	  frang[i].append(myBeam.prm.frang)
	  nsch[i].append(myBeam.prm.noisesearch)
	  if myBeam.prm.tfreq is None:
	  	  myBeam.prm.tfreq = 0
	  freq[i].append(myBeam.prm.tfreq/1e3)
	  slist[i].append(myBeam.fit.slist)
	  mode[i].append(myBeam.prm.ifmode)
	  if('velocity' in params): vel[i].append(myBeam.fit.v)
	  if('power' in params): pow[i].append(myBeam.fit.p_l)
	  if('width' in params): wid[i].append(myBeam.fit.w_l)
	  if('elevation' in params): elev[i].append(myBeam.fit.elv)
	  if('phi0' in params): phi0[i].append(myBeam.fit.phi0)
	  gsflg[i].append(myBeam.fit.gflg)


  for fplot in range(len(tbands)):
    #Check to ensure that data exists for the requested frequency band else
    #continue on to the next range of frequencies
    if not freq[fplot]:
      logging.debug('error, no data in frequency range '+str(tbands[fplot][0])+' kHz to '+str(tbands[fplot][1])+' kHz')
      rtiFig=None	#Need this line in case no data is plotted
      continue

    #get/create a figure
    rtiFig = figure
  
    
    #plot each of the parameter panels
    for p in range(len(params)):
      if(params[p] == 'velocity'): pArr = vel[fplot]
      elif(params[p] == 'power'): pArr = pow[fplot]
      elif(params[p] == 'width'): pArr = wid[fplot]
      elif(params[p] == 'elevation'): pArr = elev[fplot]
      elif(params[p] == 'phi0'): pArr = phi0[fplot]
      #draw the axis
      ax = drawAxes(rtiFig,beam[fplot],rad,cpid[fplot],bmnum,nrang[fplot],frang[fplot],rsep[fplot],p==len(params)-1,yrng=yrng,coords=coords,\
                    xtick_size=xtick_size,ytick_size=ytick_size,xticks=xticks,axvlines=axvlines)
  
      if(pArr == []): continue
      
      rmax = max(nrang[fplot])
      data=numpy.zeros((len(beam[fplot]),rmax))-150000
      if gsct: gsdata=numpy.zeros((len(beam[fplot]),rmax))-150000
      x=numpy.zeros(len(beam[fplot]))
      tcnt = 0
      dt_list   = []
      for i in range(len(beam[fplot])):
        x[tcnt]=beam[fplot][i]
        dt_list.append(beam[fplot][i])
        if(pArr[i] == []): continue
        
        if slist[fplot][i] != None:
          for j in range(len(slist[fplot][i])):
          	  if(not gsct or gsflg[fplot][i][j] == 0):
          	  	  data[tcnt][slist[fplot][i][j]] = pArr[i][j]
          	  elif gsct and gsflg[fplot][i][j] == 1:
          	  	  data[tcnt][slist[fplot][i][j]] = -100000.
        
        tcnt += 1
      tmpdata = numpy.ma.masked_where(data <= -150000, data)
      if(coords == 'gate'): y = numpy.linspace(0,rmax,rmax+1)
      elif(coords == 'rng'): y = numpy.linspace(frang[fplot][0],rmax*rsep[fplot][0],rmax+1)
      else: y = myFov.latFull[bmnum] 
      X, Y = numpy.meshgrid(x[:tcnt], y)
      cmap,norm,bounds = genCmap(params[p],scales[p],colors=colors,lowGray=lowGray)
      cmap.set_bad('w',1.0)
      pcoll = ax.pcolormesh(tmpdata[:][:].T, lw=0.01,edgecolors='w',alpha=1,cmap=cmap,norm=norm)
      cb = rtiFig.colorbar(pcoll,orientation='vertical',shrink=.65,fraction=.1)
      l = []
      #define the colorbar labels
      for i in range(0,len(bounds)):
        if(params[p] == 'phi0'):
          ln = 4
          if(bounds[i] == 0): ln = 3
          elif(bounds[i] < 0): ln = 5
          l.append(str(bounds[i])[:ln])
          continue
        if((i == 0 and params[p] == 'velocity') or i == len(bounds)-1):
          l.append(' ')
          continue
        l.append(str(int(bounds[i])))
      cb.ax.set_yticklabels(l)
        
      #set colorbar ticklabel size
      for t in cb.ax.get_yticklabels():
        t.set_fontsize(9)
      
      #set colorbar label
      if(params[p] == 'velocity'): cb.set_label('Velocity [m/s]',size=10)
      if(params[p] == 'grid'): cb.set_label('Velocity [m/s]',size=10)
      if(params[p] == 'power'): cb.set_label('Power [dB]',size=10)
      if(params[p] == 'width'): cb.set_label('Spec Wid [m/s]',size=10)
      if(params[p] == 'elevation'): cb.set_label('Elev [deg]',size=10)
      if(params[p] == 'phi0'): cb.set_label('Phi0 [rad]',size=10)
    xmin = 0.1
    xmax = 0.96
    if noise is None:
    	noise =0
    rtiFig.text(xmin,.95,radN,ha='left',weight=400)
    rtiFig.text((xmin+xmax)/2.,.95,str(rTime)+'; Beam: '+str(bmnum)+'; Freq: '+str(tfreq)+'; Noise: '+"{0:.2f}".format(noise),weight=100,ha='center')
    return rtiFig
Esempio n. 5
0
def plotRti(myBeamList,rad,bmnum=7, params=['velocity','power','width'],\
	scales=[], channel='a',coords='gate',colors='lasse',yrng=-1,\
	gsct=False,lowGray=False, filtered=False,tFreqBands=[],\
	figure=None,xtick_size=9,ytick_size=9,myFov = None,\
	xticks=None,axvlines=None,rTime = None,title=None):
  """create an rti plot for a secified radar and time period

  **Args**:
  	* **myBeamList** List of beam information
    * **rad** (str): the 3 letter radar code, e.g. 'bks'
    * **[bmnum] (int)**: The beam to plot.  default: 7
    * **[params]** (list): a list of the fit parameters to plot, allowable values are: ['velocity', 'power', 'width', 'elevation', 'phi0'].  default: ['velocity', 'power', 'width']
    * **[scales]** (list): a list of the min/max values for the color scale for each param.  If omitted, default scales will be used.  If present, the list should be n x 2 where n is the number of elements in the params list.  Use an empty list for default range, e.g. [[-250,300],[],[]].  default: [[-200,200],[0,30],[0,150]]
    * **[channel]** (char): the channel you wish to plot, e.g. 'a', 'b', 'c', ...  default: 'a'
    * **[coords]** (str): the coordinates to use for the y axis.  The allowable values are 'gate', 'rng', 'geo', 'mag' default: 'gate'
    * **[colors]** (str): a string indicating what color bar to use, valid inputs are ['lasse','aj'].  default: 'lasse'
    * **[yrng]** (list or -1): a list indicating the min and max values for the y axis in the chosen coordinate system, or a -1 indicating to plot everything.  default: -1.
    * **[gsct]** (boolean): a flag indicating whether to plot ground scatter as gray. default: False (ground scatter plotted normally)
    * **[lowGray]** (boolean): a flag indicating whether to plot low velocity scatter as gray. default: False (low velocity scatter plotted normally)
    * **[filtered]** (boolean): a flag indicating whether to boxcar filter the data.  default = False (no filter)
    * **[tFreqBands]** (list): a list of the min/max values for the transmitter frequencies in kHz.  If omitted, the default band will be used.  If more than one band is specified, retfig will cause only the last one to be returned.  default: [[8000,20000]]
    * **[figure]** (matplotlib.figure) figure object to plot on.  If None, a figure object will be created for you.
    * **[xtick_size]**: (int) fontsize of xtick labels
    * **[ytick_size]**: (int) fontsize of ytick labels
    * **[myFov]**: field of view parameters
    * **[xticks]**: (list) datetime.datetime objects indicating the location of xticks
    * **[axvlines]**: (list) datetime.datetime objects indicating the location vertical lines marking the plot
    * **[rTime]**: (datetime) current datetime to go on the title of the graph
    * **[title]**: (str) title string for figure
  **Returns**:
    * Return figure

  **Example**:
    ::
    
      import datetime as dt
      import matplotlib.pyplot as plot
      plotRti(myBeamList,'ade',params=['velocity','power','width'],
			scales=[[-1000,1000],[0,30],[0,500]],gsct=True,
			bmnum = 8,figure = plot.figure(),rTime = timeNow,
			title = 'Adak East',myFov = fovs)

    
  Written by AJ 20121002
  Modified by Matt W. 20130715
  Modified by Nathaniel F. 20131031 (added plotTerminator)
  Modified by Michelle S. 20160324 (updated for real time data plotting)
  """
    
  
  #check the inputs
  assert(isinstance(rad,str) and len(rad) == 3),'error, rad must be a string 3 chars long'
  assert(coords == 'gate' or coords == 'rng' or coords == 'geo' or coords == 'mag'),\
  "error, coords must be one of 'gate','rng','geo','mag"
  assert(isinstance(bmnum,int)),'error, beam must be integer'
  assert(0 < len(params) < 6),'error, must input between 1 and 5 params in LIST form'
  for i in range(0,len(params)):
    assert(params[i] == 'velocity' or params[i] == 'power' or params[i] == 'width' or \
    params[i] == 'elevation' or params[i] == 'phi0'), \
    "error, allowable params are 'velocity','power','width','elevation','phi0'"
  assert(scales == [] or len(scales)==len(params)), \
  'error, if present, scales must have same number of elements as params'
  assert(yrng == -1 or (isinstance(yrng,list) and yrng[0] <= yrng[1])), \
  'error, yrng must equal -1 or be a list with the 2nd element larger than the first'
  assert(colors == 'lasse' or colors == 'aj'),"error, valid inputs for color are 'lasse' and 'aj'"

  #assign any default color scales
  tscales = []
  for i in range(0,len(params)):
    if(scales == [] or scales[i] == []):
      if(params[i] == 'velocity'): tscales.append([-200,200])
      elif(params[i] == 'power'): tscales.append([0,30])
      elif(params[i] == 'width'): tscales.append([0,150])
      elif(params[i] == 'elevation'): tscales.append([0,50])
      elif(params[i] == 'phi0'): tscales.append([-numpy.pi,numpy.pi])
    else: tscales.append(scales[i])
  scales = tscales

  #assign default frequency band
  tbands = []
  if tFreqBands == []: tbands.append([8000,20000])
  else: 
    for band in tFreqBands: 
      #make sure that starting frequncy is less than the ending frequency for each band
      assert(band[0] < band[1]),"Starting frequency must be less than ending frequency!"
      tbands.append(band)


  if not myBeamList:
    logging.debug('error, no data available for the requested time/radar/filetype combination')
    return None

  #initialize empty lists
  vel,pow,wid,elev,phi0,times,freq,cpid,nave,nsky,nsch,slist,mode,rsep,nrang,frang,gsflg = \
        [],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]
  for i in range(len(tbands)):
    times.append([])
    cpid.append([])
    nave.append([])
    nsky.append([])
    rsep.append([])
    nrang.append([])
    frang.append([])
    nsch.append([])
    freq.append([])
    slist.append([])
    mode.append([])
    vel.append([])
    pow.append([])
    wid.append([])
    elev.append([])
    phi0.append([])
    gsflg.append([])
  timeThen = datetime.datetime.utcnow() - datetime.timedelta(days=1)
  #read the parameters of interest
  for myBeam in myBeamList:
    if myBeam.time > timeThen:
      ids = myBeam.stid
      times[i].append(myBeam.time)
      cpid[i].append(myBeam.cp)
      nave[i].append(myBeam.prm.nave)
      nsky[i].append(myBeam.prm.noisesky)
      rsep[i].append(myBeam.prm.rsep)
      nrang[i].append(myBeam.prm.nrang)
      frang[i].append(myBeam.prm.frang)
      nsch[i].append(myBeam.prm.noisesearch)
      freq[i].append(myBeam.prm.tfreq/1e3)
      slist[i].append(myBeam.fit.slist)
      mode[i].append(myBeam.prm.ifmode)
      if('velocity' in params): vel[i].append(myBeam.fit.v)
      if('power' in params): pow[i].append(myBeam.fit.p_l)
      if('width' in params): wid[i].append(myBeam.fit.w_l)
      if('elevation' in params): elev[i].append(myBeam.fit.elv)
      if('phi0' in params): phi0[i].append(myBeam.fit.phi0)
      gsflg[i].append(myBeam.fit.gflg)


  for fplot in range(len(tbands)):

    #get/create a figure
    rtiFig = figure
    #give the plot a title
    rtiTitle(rtiFig,rTime,title,rad,bmnum)
    #plot the noise bar
    plotNoise(rtiFig,times[fplot],nsky[fplot],nsch[fplot])
    #plot the frequency bar
    plotFreq(rtiFig,times[fplot],freq[fplot],nave[fplot])
    #plot the cpid bar
    plotCpid(rtiFig,times[fplot],cpid[fplot],mode[fplot])
    
    #plot each of the parameter panels
    figtop = .77
    figheight = .72/len(params)
    for p in range(len(params)):
      if(params[p] == 'velocity'): pArr = vel[fplot]
      elif(params[p] == 'power'): pArr = pow[fplot]
      elif(params[p] == 'width'): pArr = wid[fplot]
      elif(params[p] == 'elevation'): pArr = elev[fplot]
      elif(params[p] == 'phi0'): pArr = phi0[fplot]
      time.sleep(0.1)
      pos = [.1,figtop-figheight*(p+1)+.02,.76,figheight-.02]
      
      #draw the axis
      ax = drawAxes(rtiFig,times[fplot],rad,cpid[fplot],bmnum,nrang[fplot],frang[fplot],rsep[fplot],ids,p==len(params)-1,yrng=yrng,coords=coords,\
                    pos=pos,xtick_size=xtick_size,ytick_size=ytick_size,xticks=xticks,axvlines=axvlines, myFov=myFov)
  
      
      if(pArr == []): continue
      
      rmax = max(nrang[fplot])
      data=numpy.zeros((len(times[fplot])*2,rmax))-150000
      
      if gsct: 
      	  gsdata=numpy.empty((len(times[fplot])*2,rmax))
      x=numpy.empty(len(times[fplot])*2)
      tcnt = 0

      dt_list   = []
      for i in range(len(times[fplot])):
        x[tcnt]=date2num(times[fplot][i])
        dt_list.append(times[fplot][i])

        if(i < len(times[fplot])-1):
          if(date2num(times[fplot][i+1])-x[tcnt] > 4./1440.):
            tcnt += 1
            x[tcnt] = x[tcnt-1]+1./1440.
            dt_list.append(num2date(x[tcnt]))
        tcnt += 1
            
        if(pArr[i] == []): continue
        
        if slist[fplot][i] != None :
          for j in range(len(slist[fplot][i])):
            if (not gsct or gsflg[fplot][i][j] == 0) or params[p] == 'power':
              data[tcnt][int(slist[fplot][i][j])] = pArr[i][j]
            elif gsct and gsflg[fplot][i][j] == 1:
              data[tcnt][int(slist[fplot][i][j])] = -100000.
      tmpdata = numpy.ma.masked_where(data <= -150000, data)

      if (coords != 'gate' and coords != 'rng'):
        if myFov is None:
          site    = RadarPos(ids)
          myFov   = radFov.fov(site=site,ngates=rmax,nbeams=site.maxbeam,rsep=rsep[fplot][0],coords=coords)
        myLat   = myFov.latCenter[bmnum]
        myLon   = myFov.lonCenter[bmnum]

      if(coords == 'gate'): y = numpy.linspace(0,rmax,rmax+1)
      elif(coords == 'rng'): y = numpy.linspace(frang[fplot][0],rmax*rsep[fplot][0],rmax+1)
      else: y = myFov.latFull[bmnum]
        
      X, Y = numpy.meshgrid(x[:tcnt], y)
     
      cmap,norm,bounds = plotUtils.genCmap(params[p],scales[p],colors=colors,lowGray=lowGray)
      cmap.set_bad('w',1.0)
      pcoll = ax.pcolormesh(X, Y, tmpdata[:tcnt][:].T, lw=0.01,edgecolors='None',alpha=1,cmap=cmap,norm=norm)
      try:
      	  cb = plotUtils.drawCB(rtiFig,pcoll,cmap,norm,map=0,pos=[pos[0]+pos[2]+.02, pos[1], 0.02, pos[3]])
      except:
      	  cb = rtiFig.colorbar(pcoll,orientation='vertical',shrink=.65,fraction=.1)
      l = []
      #define the colorbar labels
      for i in range(0,len(bounds)):
        l.append(str(int(bounds[i])))
      cb.ax.set_yticklabels(l)
        
      #set colorbar ticklabel size
      for t in cb.ax.get_yticklabels():
        t.set_fontsize(9)

      #set colorbar label
      if(params[p] == 'velocity'): cb.set_label('Velocity [m/s]',size=10)
      if(params[p] == 'grid'): cb.set_label('Velocity [m/s]',size=10)
      if(params[p] == 'power'): cb.set_label('Power [dB]',size=10)
      if(params[p] == 'width'): cb.set_label('Spec Wid [m/s]',size=10)
      if(params[p] == 'elevation'): cb.set_label('Elev [deg]',size=10)
      if(params[p] == 'phi0'): cb.set_label('Phi0 [rad]',size=10)
    #end of plotting for loop
    return rtiFig