5 from pandas.plotting 
import register_matplotlib_converters
 
    6 register_matplotlib_converters()
 
    9 import matplotlib.axes 
as maxes
 
   10 import matplotlib.cm 
as cm
 
   11 import matplotlib.colors 
as colors
 
   12 from matplotlib.colors 
import BoundaryNorm
 
   13 import matplotlib.pyplot 
as plt
 
   14 from matplotlib.ticker 
import MaxNLocator
 
   15 from mpl_toolkits.basemap 
import Basemap
 
   16 from mpl_toolkits.axes_grid1 
import make_axes_locatable
 
   18 import plot_utils 
as pu
 
   19 import var_utils 
as vu
 
   22 _logger = logging.getLogger(__name__)
 
   24 cmGray     = plt.cm.get_cmap(
"gist_gray")
 
   25 cmRainbow  = plt.cm.get_cmap(
"gist_rainbow")
 
   26 cmSpectral = plt.cm.get_cmap(
"nipy_spectral")
 
   27 cmHeat     = plt.cm.get_cmap(
"gist_heat")
 
   28 cmOcean    = plt.cm.get_cmap(
"ocean")
 
   29 cmNCAR     = plt.cm.get_cmap(
"gist_ncar")
 
   31 WhiteBlack1 = 
cmGray(np.linspace(1.0,0.0,17)) 
 
   32 BlackRed    = 
cmHeat(np.linspace(0.0,0.5,10)) 
 
   36 GreenBlueCyan = 
cmNCAR(np.linspace(0.05,0.2,20)) 
 
   38 MVW = 
cmNCAR(np.linspace(0.8,0.98,21)) 
 
   39 WhiteBlack2 = 
cmGray(np.linspace(0.9,0.0,31)) 
 
   43 btcolors = np.concatenate((WhiteBlack1, BlackRed, ROYG, GreenBlueCyan, MVW, WhiteBlack2))
 
   45 btCMap = colors.ListedColormap(btcolors)
 
   52 distriZooms[
'default'] = {
 
   59 distriZooms[
'abi'] = {
 
   66 distriZooms[
'ahi'] = {
 
   75                ObsType,VarName,var_unit,out_name,nstation,levbin, \
 
   76                dmin=None,dmax=None,dotsize=6,color="rainbow"):
 
   97     cLon = distriZooms[
'default'][
'cLon']
 
   98     minLon = distriZooms[
'default'][
'minLon']
 
   99     maxLon = distriZooms[
'default'][
'maxLon']
 
  100     minLat = distriZooms[
'default'][
'minLat']
 
  101     maxLat = distriZooms[
'default'][
'maxLat']
 
  103     for key, val 
in distriZooms.items():
 
  106             minLon = val[
'minLon']
 
  107             maxLon = val[
'maxLon']
 
  108             minLat = val[
'minLat']
 
  109             maxLat = val[
'maxLat']
 
  111     parallels=np.arange(-90,90,30)      
 
  114         fig,ax=plt.subplots(figsize=(5,5))
 
  115         m=Basemap(projection=
'nsper',     
 
  120         m.drawparallels(parallels, linewidth=0.2, dashes=[1,3])
 
  121         meridians=np.arange(-180,180,30)    
 
  122         m.drawmeridians(meridians, linewidth=0.2, dashes=[1,3])
 
  124         fig,ax=plt.subplots(figsize=(8,8))
 
  125         m=Basemap(projection=
'cyl',     
 
  126             llcrnrlon=minLon, llcrnrlat=minLat, 
 
  127             urcrnrlon=maxLon, urcrnrlat=maxLat, 
 
  130         m.drawparallels(parallels, linewidth=0.2, dashes=[1,3],
 
  131             labels=[
True,
True,
True,
True])   
 
  132         meridians=np.arange(-180,180,60)    
 
  133         m.drawmeridians(meridians, linewidth=0.2, dashes=[1,3],
 
  134             labels=[
True,
True,
True,
True])
 
  136     m.drawcoastlines(linewidth=0.2,zorder=10)  
 
  143         plt.text(0.5, 1.25, 
'%s   %s %s nlocs:%s' \
 
  144             %(ObsType,VarName,var_unit,len(values[~np.isnan(values)])),    \
 
  145             horizontalalignment=
'center', \
 
  146             fontsize=12, transform = ax.transAxes)
 
  148         if ObsType[:6] == 
'gnssro':
 
  149             plt.text(0.5, 1.25, 
'%s   %s %s nlocs:%s nprofile:%s' \
 
  150                 %(ObsType,VarName,var_unit,len(values[~np.isnan(values)]),nstation),    \
 
  151                 horizontalalignment=
'center', \
 
  152                 fontsize=12, transform = ax.transAxes)
 
  153         elif ObsType == 
'aircraft':
 
  154             plt.text(0.5, 1.25, 
'%s   %s %s nlocs:%s nflight:%s' \
 
  155                 %(ObsType,VarName,var_unit,len(values[~np.isnan(values)]),nstation),    \
 
  156                 horizontalalignment=
'center', \
 
  157                 fontsize=12, transform = ax.transAxes)
 
  159             plt.text(0.5, 1.25, 
'%s   %s %s nlocs:%s nstation:%s' \
 
  160                 %(ObsType,VarName,var_unit,len(values[~np.isnan(values)]),nstation),    \
 
  161                 horizontalalignment=
'center', \
 
  162                 fontsize=12, transform = ax.transAxes)
 
  166         if (
"abi" in ObsType 
or "ahi" in ObsType):
 
  168             if dmin 
is None: dmin = 183
 
  169             if dmax 
is None: dmax = 303
 
  171             cm = plt.cm.get_cmap(
"gist_ncar")
 
  172             if dmin 
is None: dmin = 190
 
  173             if dmax 
is None: dmax = 270
 
  175         cm = plt.cm.get_cmap(color)
 
  177     finite = np.isfinite(values)
 
  178     if (((
"abi" in ObsType 
or "ahi" in ObsType)
 
  179          and finite.sum() > 4e4)
 
  180         or "model" in ObsType):
 
  188         lonsPlot = lons[finite]
 
  189         lonsPlot[lonsPlot > 180.0] -= 360.0 
 
  190         latsPlot = lats[finite]
 
  191         valuesPlot = values[finite]
 
  192         lonSort = np.argsort(lonsPlot)
 
  194         sc = m.pcolor(lonsPlot[lonSort], latsPlot[lonSort], valuesPlot[lonSort],
 
  195                       cmap = cm, vmin = dmin, vmax = dmax,
 
  196                       latlon = 
True, tri = 
True)
 
  199         sc = m.scatter(lons[finite], lats[finite], c=values[finite],
 
  201                        s = dotsize, cmap = cm, vmin = dmin, vmax = dmax,
 
  202                        marker = 
'.', linewidth = 0,
 
  207     divider = make_axes_locatable(ax)
 
  208     cax = divider.append_axes(
"top",
 
  211     plt.colorbar(sc,cax=cax,ax=ax,orientation=
'horizontal')
 
  212     cax.xaxis.set_ticks_position(
'top')  
 
  214     plt.savefig(
'distri_%s_%s_%s.png'%(VarName,out_name,levbin),dpi=200,bbox_inches=
'tight')
 
  221   minLon = -180., maxLon = 180.,
 
  222   minLat = -90., maxLat = 90.,
 
  224   projection = 'default',
 
  225   dmin = None, dmax = None,
 
  236     fig,ax=plt.subplots(figsize=(5,5))
 
  237     if projection == 
'default':
 
  241     m=Basemap(projection=proj,
 
  246     parallels=np.arange(-90, 90, 30)
 
  247     m.drawparallels(parallels, linewidth=0.2, dashes=[1,3], zorder = 3)
 
  248     meridians=np.arange(-180, 180, 30)
 
  249     m.drawmeridians(meridians, linewidth=0.2, dashes=[1,3], zorder = 3)
 
  251     fig,ax=plt.subplots(figsize=(8,8))
 
  252     if projection == 
'default':
 
  256     m=Basemap(projection=proj,
 
  257               llcrnrlon=minLon, llcrnrlat=minLat, 
 
  258               urcrnrlon=maxLon, urcrnrlat=maxLat, 
 
  261     parallels = np.arange(minLat, maxLat, (maxLat - minLat) / 6.)
 
  262     m.drawparallels(parallels, linewidth=0.2, dashes=[1,3],
 
  263                     labels=[
True,
True,
True,
True], zorder = 3)
 
  264     meridians = np.arange(minLon, maxLon, (maxLon - minLon) / 6.)
 
  265     m.drawmeridians(meridians, linewidth=0.2, dashes=[1,3],
 
  266                     labels=[
True,
True,
True,
True], zorder = 3)
 
  268   m.drawcoastlines(linewidth=0.2, zorder=2)  
 
  276   assert (cbarType 
is None or cbarType 
in [
'Log', 
'SymLog']), \
 
  277     'scatterMapFields: invalid cbarType: '+cbarType
 
  279   for name, field 
in fields.items():
 
  280     finite = np.isfinite(field)
 
  282        vmin = field[finite].min()
 
  286        vmax = field[finite].max()
 
  291       sc = m.scatter(lons[name][finite], lats[name][finite], c=c.get(name, field[finite]),
 
  293                      s = sizes.get(name, 1),
 
  294                      cmap = cmap, vmin = vmin, vmax = vmax,
 
  295                      marker = markers.get(name, 
'.'), linewidth = 0,
 
  298     elif cbarType == 
'Log':
 
  299       if vmin <= logVLim: vmin = logVLim
 
  300       field_ = field[finite]
 
  301       field_[field_ < vmin] = vmin
 
  302       sc = m.scatter(lons[name][finite], lats[name][finite], c=c.get(name, field_),
 
  304                      s = sizes.get(name, 1),
 
  306                      marker = markers.get(name, 
'.'), linewidth = 0,
 
  307                      norm=colors.LogNorm(vmin=vmin, vmax=vmax),
 
  310     elif cbarType == 
'SymLog':
 
  311       sc = m.scatter(lons[name][finite], lats[name][finite], c=c.get(name, field[finite]),
 
  313                      s = sizes.get(name, 1),
 
  315                      marker = markers.get(name, 
'.'), linewidth = 0,
 
  316                      norm=colors.SymLogNorm(vmin=vmin, vmax=vmax,
 
  317                                             linthresh=1.e-4*vmax, linscale=1.0, base=10),
 
  321   divider = make_axes_locatable(ax)
 
  322   cax = divider.append_axes(
"top",
 
  325   plt.colorbar(sc, cax=cax, ax=ax, orientation=
'horizontal')
 
  326   cax.xaxis.set_ticks_position(
'top')  
 
  328   plt.savefig(filename, dpi=200, bbox_inches=
'tight')
 
  339     zgrid = np.loadtxt(
"/glade/work/jban/pandac/fix_input/graphics/zgrid_v55.txt")
 
  341     fig, ax1 = plt.subplots()
 
  343     xarray = range(len(xlabeltime))
 
  344     valuemin = np.amin(Stats)
 
  345     valuemax = np.amax(Stats)
 
  349     if (valuemin > 0 
or valuemax < 0):
 
  351         plt.contourf(xarray,ylevels,Stats,40,vmin=valuemin, vmax=valuemax,cmap=color)
 
  355         if ( -valuemin < epsilon 
and valuemax < epsilon ):
 
  359         elif ( -valuemin < epsilon 
and valuemax > epsilon ):
 
  362         elif ( -valuemin > epsilon 
and valuemax < epsilon ):
 
  368         norm = matplotlib.colors.DivergingNorm(vmin=valuemin, vcenter=0, vmax=valuemax)
 
  369         plt.contourf(xarray,ylevels,Stats,40,vmin=valuemin, vmax=valuemax,norm=norm,cmap=cmap)
 
  370     xarray = range(len(xlabeltime))
 
  371     major_ticks = np.arange(0, 56, 5)
 
  372     ax1.set_yticks(major_ticks)
 
  374     ax1.set_ylabel(
'Vertical level',fontsize=15)
 
  377     ax2.set_yticks(major_ticks-1)
 
  378     ax2.set_yticklabels((zgrid[::5]).astype(int))
 
  380     ax2.set_ylabel(
'Height (m)',fontsize=13)
 
  382     FCDay = 
''.join(VarName.split(
"_")[1:][:-3])
 
  383     if (FCDay == 
'day0.0'):
 
  384         ax1.set_xlabel(
'Analysis Time',fontsize=15)
 
  385         ax1.set_xticks(xarray[::4])
 
  386         ax1.set_xticklabels(xlabeltime[::4],rotation=90)
 
  387     elif (FCDay == 
'day0.25'):
 
  388         ax1.set_xlabel( 
'6h Forecast',fontsize=15)
 
  389         ax1.set_xticks(xarray[::4])
 
  390         ax1.set_xticklabels(xlabeltime[::4],rotation=90)
 
  392         ax1.set_xlabel( 
'Lead Time',fontsize=15)
 
  394     plt.colorbar(extend=
'both',orientation=
"horizontal",pad=0.2)
 
  396     region = 
''.join(VarName.split(
"_")[2:][:-2])
 
  397     var    = 
''.join(VarName.split(
"_")[3:][:-1])
 
  398     stats  = 
''.join(VarName.split(
"_")[4:])
 
  399     plt.title(stats+
'  variable:'+vu.varDictModel[var][1]+
'('+ vu.varDictModel[var][0]+
')  '+region, fontsize = 12)
 
  400     plt.savefig(VarName+
'_TS_2d.png',dpi=200,bbox_inches=
'tight')
 
  403 maxLegendEntries = 12
 
  411                title="", dataLabel="y", \
 
  412                sciticks=False, logscale= False, signdef=False, \
 
  413                indepLabel="x", invert_ind_axis=False, \
 
  414                ny=1, nx=1, nplots=1, iplot=0, \
 
  415                linesValsMinCI=None, linesValsMaxCI=None, \
 
  416                dmin=np.NaN, dmax=np.NaN, \
 
  417                lineAttribOffset=0, \
 
  419                interiorLabels=True):
 
  447     ax = fig.add_subplot(ny, nx, iplot+1)
 
  450     ax.set_title(title,fontsize=5)
 
  453     plotVals = np.asarray([])
 
  455     for iline, lineVals 
in enumerate(linesVals):
 
  456         if np.all(np.isnan(lineVals)):
 
  459                 _logger.warning(
"skipping all-NaN data")
 
  460                 _logger.warning(title+
"; "+indepLabel+
"; "+linesLabel[iline])
 
  461             nanWarnSer=nanWarnSer+1
 
  463         if len(lineVals)!=len(xVals):
 
  466                 _logger.warning(
"skipping data where len(x)!=len(y)")
 
  467                 _logger.warning(title+
"; "+indepLabel+
"; "+linesLabel[iline])
 
  468             lenWarnSer=lenWarnSer+1
 
  472         pColor = pu.plotColor(len(linesVals),iline+lineAttribOffset)
 
  474         ax.plot(xVals, lineVals, \
 
  476                 label=linesLabel[iline], \
 
  477                 ls=pu.plotLineStyle(len(linesVals),iline+lineAttribOffset), \
 
  480         plotVals = np.append(plotVals, lineVals)
 
  483         if linesValsMinCI 
is not None and \
 
  484            linesValsMaxCI 
is not None:
 
  488                 significant = np.empty(len(lineVals))
 
  489                 significant[:] = np.NaN
 
  491                 significant = np.multiply(linesValsMinCI[iline], linesValsMaxCI[iline])
 
  492             significant = np.array([x 
if np.isfinite(x) 
else -1.0 
for x 
in significant])
 
  494             lineArr = np.array(lineVals)
 
  495             xArr = np.array(xVals)
 
  496             negsiginds = np.array([i 
for i,x 
in enumerate(significant)
 
  497                                    if (x > 0.0 
and lineArr[i] < 0.0)],dtype=int)
 
  498             if len(negsiginds) > 0:
 
  499                 ax.plot(xArr[negsiginds], lineArr[negsiginds], \
 
  505             possiginds = np.array([i 
for i,x 
in enumerate(significant)
 
  506                                    if (x > 0.0 
and lineArr[i] > 0.0)],dtype=int)
 
  507             if len(possiginds) > 0:
 
  508                 ax.plot(xArr[possiginds], lineArr[possiginds], \
 
  514             ax.plot(xVals, linesValsMinCI[iline], \
 
  519             ax.plot(xVals, linesValsMaxCI[iline], \
 
  524             ax.fill_between(xVals, linesValsMinCI[iline], linesValsMaxCI[iline], \
 
  527                             linewidth=0.0, alpha = 0.1)
 
  528             ax.fill_between(xVals, linesValsMinCI[iline], linesValsMaxCI[iline], \
 
  529                             where=significant > 0.0, \
 
  532                             linewidth=0.2, alpha = 0.3)
 
  535         ax.tick_params(axis=
'x',labelbottom=
False)
 
  536         ax.tick_params(axis=
'y',labelleft=
False)
 
  541         ax.plot([xVals[0], xVals[-1]], [0., 0.], ls=
"--", c=
".3", \
 
  542             linewidth=0.7,markersize=0)
 
  545     mindval, maxdval = pu.get_clean_ax_limits(dmin,dmax,plotVals,signdef)
 
  548     ax.xaxis.set_tick_params(labelsize=3)
 
  549     ax.yaxis.set_tick_params(labelsize=3)
 
  551     isLogScale = logscale
 
  553         nonzero = np.logical_and(np.greater(np.abs(plotVals), 0.), np.isfinite(plotVals))
 
  554         if nonzero.sum() > 0:
 
  555             vmin = np.nanmin(np.abs(plotVals[nonzero]))
 
  556             vmax = np.nanmax(np.abs(plotVals[nonzero]))
 
  559                 if vmax / vmin > 10.0:
 
  564                 ax.set_yscale(
'symlog')
 
  568         if isLogScale 
and np.isfinite(maxdval) 
and maxdval > 0.:
 
  569             ax.set_ylim(
None, maxdval)
 
  570             if np.abs(vmin) > 0.:
 
  571                 ax.set_ylim(vmin, 
None)
 
  575             ax.ticklabel_format(style=
'sci', axis=
'y', scilimits=(0,0))
 
  576         if (np.isfinite(mindval) 
and 
  577             np.isfinite(maxdval)):
 
  578             ax.set_ylim(mindval,maxdval)
 
  579             if maxdval-mindval < 1.0 
or \
 
  580                maxdval-mindval > 100.0:
 
  581                 ax.tick_params(axis=
'y',rotation=-35)
 
  582         ax.yaxis.get_offset_text().set_fontsize(3)
 
  585     ix = int(iplot)%int(nx)
 
  586     iy = int(iplot)/int(nx)
 
  587     if not interiorLabels \
 
  588        and (iy < ny-2 
or ( iy == ny-2 
and (int(nplots)%int(nx)==0 
or ix <= (int(nplots)%int(nx) - 1)) )):
 
  589         ax.tick_params(axis=
'x',labelbottom=
False)
 
  590     if interiorLabels 
or ix == 0:
 
  591         ax.set_xlabel(indepLabel,fontsize=4)
 
  592     if interiorLabels 
or iy == ny-1:
 
  593         ax.set_ylabel(dataLabel,fontsize=4)
 
  596     if nLines <= maxLegendEntries:
 
  599             lh = ax.legend(loc=
'best',fontsize=3,frameon=
True,\
 
  600                            framealpha=0.4,ncol=1)
 
  601             lh.get_frame().set_linewidth(0.0)
 
  602         elif ix==nx-1 
or iplot==nplots-1:
 
  604             ax.legend(loc=
'upper left',fontsize=3,frameon=
False, \
 
  605                       bbox_to_anchor=(1.02, 1), borderaxespad=0)
 
  620                 title="", dataLabel="x", \
 
  621                 sciticks=False, logscale=False, signdef=False, \
 
  622                 indepLabel="y", invert_ind_axis=False, \
 
  623                 ny=1, nx=1, nplots=1, iplot=0, \
 
  624                 linesValsMinCI=None, linesValsMaxCI=None, \
 
  625                 dmin=np.NaN, dmax=np.NaN, \
 
  626                 lineAttribOffset=0, \
 
  628                 interiorLabels=True):
 
  656     ax = fig.add_subplot(ny, nx, iplot+1)
 
  659     ax.set_title(title,fontsize=5)
 
  662     plotVals = np.asarray([])
 
  664     for iline, lineVals 
in enumerate(linesVals):
 
  665         if np.all(np.isnan(lineVals)):
 
  668                 _logger.warning(
"skipping all-NaN data")
 
  669                 _logger.warning(title+
"; "+dataLabel+
"; "+linesLabel[iline])
 
  670             nanWarnProf=nanWarnProf+1
 
  672         if len(lineVals)!=len(yVals):
 
  675                 _logger.warning(
"skipping data where len(x)!=len(y)")
 
  676                 _logger.warning(title+
"; "+dataLabel+
"; "+linesLabel[iline])
 
  677             lenWarnProf=lenWarnProf+1
 
  681         pColor = pu.plotColor(len(linesVals),iline+lineAttribOffset)
 
  683         ax.plot(lineVals, yVals, \
 
  685                 label=linesLabel[iline], \
 
  686                 ls=pu.plotLineStyle(len(linesVals),iline+lineAttribOffset), \
 
  689         plotVals = np.append(plotVals,lineVals)
 
  692         if linesValsMinCI 
is not None and \
 
  693            linesValsMaxCI 
is not None:
 
  697                 significant = np.empty(len(lineVals))
 
  698                 significant[:] = np.NaN
 
  700                 significant = np.multiply(linesValsMinCI[iline], linesValsMaxCI[iline])
 
  701             significant = np.array([x 
if np.isfinite(x) 
else -1.0 
for x 
in significant])
 
  703             lineArr = np.array(lineVals)
 
  704             yArr = np.array(yVals)
 
  705             negsiginds = np.array([i 
for i,x 
in enumerate(significant)
 
  706                                    if (x > 0.0 
and lineArr[i] < 0.0)],dtype=int)
 
  707             if len(negsiginds) > 0:
 
  708                 ax.plot(lineArr[negsiginds], yArr[negsiginds], \
 
  714             possiginds = np.array([i 
for i,x 
in enumerate(significant)
 
  715                                    if (x > 0.0 
and lineArr[i] > 0.0)],dtype=int)
 
  716             if len(possiginds) > 0:
 
  717                 ax.plot(lineArr[possiginds], yArr[possiginds], \
 
  723             ax.plot(linesValsMinCI[iline], yVals, \
 
  728             ax.plot(linesValsMaxCI[iline], yVals, \
 
  733             ax.fill_betweenx(yVals, linesValsMinCI[iline], linesValsMaxCI[iline], \
 
  736                             linewidth=0.0, alpha = 0.1)
 
  737             ax.fill_betweenx(yVals, linesValsMinCI[iline], linesValsMaxCI[iline], \
 
  738                             where=significant > 0.0, \
 
  741                             linewidth=0.2, alpha = 0.3)
 
  744         ax.tick_params(axis=
'x',labelbottom=
False)
 
  745         ax.tick_params(axis=
'y',labelleft=
False)
 
  750         ax.plot([0., 0.], [yVals[0], yVals[-1]], ls=
"--", c=
".3", \
 
  751             linewidth=0.7,markersize=0)
 
  754     mindval, maxdval = pu.get_clean_ax_limits(dmin,dmax,plotVals,signdef)
 
  757     ax.xaxis.set_tick_params(labelsize=3)
 
  758     ax.yaxis.set_tick_params(labelsize=3)
 
  760     isLogScale = logscale
 
  762         nonzero = np.logical_and(np.greater(np.abs(plotVals), 0.), np.isfinite(plotVals))
 
  763         if nonzero.sum() > 0:
 
  764             vmin = np.nanmin(np.abs(plotVals[nonzero]))
 
  765             vmax = np.nanmax(np.abs(plotVals[nonzero]))
 
  768                 if vmax / vmin > 10.0:
 
  773                 ax.set_xscale(
'symlog')
 
  777         if isLogScale 
and np.isfinite(maxdval) 
and maxdval > 0.:
 
  778             ax.set_xlim(
None, maxdval)
 
  779             if np.abs(mindval) > 0.:
 
  780                 ax.set_xlim(mindval, 
None)
 
  784             ax.ticklabel_format(style=
'sci', axis=
'x', scilimits=(0,0))
 
  785         if (np.isfinite(mindval) 
and 
  786             np.isfinite(maxdval)):
 
  787             ax.set_xlim(mindval,maxdval)
 
  788             if maxdval-mindval < 1.0 
or \
 
  789                maxdval-mindval > 100.0:
 
  790                 ax.tick_params(axis=
'x',rotation=-35)
 
  791         ax.xaxis.get_offset_text().set_fontsize(3)
 
  795     ix = int(iplot)%int(nx)
 
  796     iy = int(iplot)/int(nx)
 
  797     if not interiorLabels \
 
  798        and (iy < ny-2 
or ( iy == ny-2 
and (int(nplots)%int(nx)==0 
or ix <= (int(nplots)%int(nx) - 1)) )):
 
  799         ax.tick_params(axis=
'x',labelbottom=
False)
 
  800     if interiorLabels 
or ix == 0:
 
  801         ax.set_xlabel(dataLabel,fontsize=4)
 
  802     if interiorLabels 
or iy == ny-1:
 
  803         ax.set_ylabel(indepLabel,fontsize=4)
 
  806     if nLines <= maxLegendEntries:
 
  809             lh = ax.legend(loc=
'best',fontsize=3,frameon=
True,\
 
  810                            framealpha=0.4,ncol=1)
 
  811             lh.get_frame().set_linewidth(0.0)
 
  812         elif ix==nx-1 
or iplot==nplots-1:
 
  814             ax.legend(loc=
'upper left',fontsize=3,frameon=
False, \
 
  815                       bbox_to_anchor=(1.02, 1), borderaxespad=0)
 
  829                    xsDates, linesVals, \
 
  831                    title="", dataLabel="", \
 
  832                    sciticks=False, logscale = False, signdef=False, \
 
  833                    ny=1, nx=1, nplots=1, iplot=0, \
 
  834                    linesValsMinCI=None, linesValsMaxCI=None, \
 
  835                    dmin=np.NaN, dmax=np.NaN, \
 
  836                    lineAttribOffset=0, \
 
  838                    interiorLabels=True):
 
  865     ax = fig.add_subplot(ny, nx, iplot+1)
 
  868     ax.set_title(title,fontsize=5)
 
  871     plotVals = np.asarray([])
 
  874     for iline, lineVals 
in enumerate(linesVals):
 
  875         if np.all(np.isnan(lineVals)):
 
  878                 _logger.warning(
"skipping all-NaN data")
 
  879                 _logger.warning(title+
"; "+dataLabel+
"; "+linesLabel[iline])
 
  880             nanWarnTS=nanWarnTS+1
 
  884         if isinstance(xsDates[0],(list,np.ndarray)):
 
  885             xVals = pu.TDeltas2Seconds(xsDates[min([iline,len(xsDates)-1])])
 
  887             xVals = pu.TDeltas2Seconds(xsDates)
 
  889         if len(lineVals)!=len(xVals):
 
  892                 _logger.warning(
"skipping data where len(x)!=len(y)")
 
  893                 _logger.warning(title+
"; "+dataLabel+
"; "+linesLabel[iline])
 
  894             lenWarnTS=lenWarnTS+1
 
  901             minX = min([xVals[0], minX])
 
  902             maxX = max([xVals[-1], maxX])
 
  906         pColor = pu.plotColor(len(linesVals),iline+lineAttribOffset)
 
  908         ax.plot(xVals, lineVals, \
 
  909                 label=linesLabel[iline], \
 
  911                 ls=pu.plotLineStyle(len(linesVals),iline+lineAttribOffset), \
 
  914         plotVals = np.append(plotVals, lineVals)
 
  917         if linesValsMinCI 
is not None and \
 
  918            linesValsMaxCI 
is not None:
 
  922                 significant = np.empty(len(lineVals))
 
  923                 significant[:] = np.NaN
 
  925                 significant = np.multiply(linesValsMinCI[iline], linesValsMaxCI[iline])
 
  926             significant = np.array([x 
if np.isfinite(x) 
else -1.0 
for x 
in significant])
 
  928             lineArr = np.array(lineVals)
 
  929             xArr = np.array(xVals)
 
  930             negsiginds = np.array([i 
for i,x 
in enumerate(significant)
 
  931                                    if (x > 0.0 
and lineArr[i] < 0.0)],dtype=int)
 
  932             if len(negsiginds) > 0:
 
  933                 ax.plot(xArr[negsiginds], lineArr[negsiginds], \
 
  939             possiginds = np.array([i 
for i,x 
in enumerate(significant)
 
  940                                    if (x > 0.0 
and lineArr[i] > 0.0)],dtype=int)
 
  941             if len(possiginds) > 0:
 
  942                 ax.plot(xArr[possiginds], lineArr[possiginds], \
 
  948             ax.plot(xVals, linesValsMinCI[iline], \
 
  953             ax.plot(xVals, linesValsMaxCI[iline], \
 
  958             ax.fill_between(xVals, linesValsMinCI[iline], linesValsMaxCI[iline], \
 
  961                             linewidth=0.0, alpha = 0.1)
 
  962             ax.fill_between(xVals, linesValsMinCI[iline], linesValsMaxCI[iline], \
 
  963                             where=significant > 0.0, \
 
  966                             linewidth=0.2, alpha = 0.3)
 
  969         ax.tick_params(axis=
'x',labelbottom=
False)
 
  970         ax.tick_params(axis=
'y',labelleft=
False)
 
  974     mindval, maxdval = pu.get_clean_ax_limits(dmin,dmax,plotVals,signdef)
 
  978         ax.plot([minX, maxX], [0., 0.], ls=
"--", c=
".3", \
 
  979             linewidth=0.7,markersize=0)
 
  982     if isinstance(xsDates[0],(list,np.ndarray)):
 
  983         pu.format_x_for_dates(ax, xsDates[0])
 
  985         pu.format_x_for_dates(ax, xsDates)
 
  987     ax.xaxis.set_tick_params(labelsize=3)
 
  988     ax.yaxis.set_tick_params(labelsize=3)
 
  989     isLogScale = logscale
 
  991         nonzero = np.logical_and(np.greater(np.abs(plotVals), 0.), np.isfinite(plotVals))
 
  992         if nonzero.sum() > 0:
 
  993             vmin = np.nanmin(np.abs(plotVals[nonzero]))
 
  994             vmax = np.nanmax(np.abs(plotVals[nonzero]))
 
  997                 if vmax / vmin > 10.0:
 
 1002                 ax.set_yscale(
'symlog')
 
 1006         if isLogScale 
and np.isfinite(maxdval) 
and maxdval > 0.:
 
 1007             ax.set_ylim(
None, maxdval)
 
 1008             if np.abs(vmin) > 0.:
 
 1009                 ax.set_ylim(vmin, 
None)
 
 1013             ax.ticklabel_format(style=
'sci', axis=
'y', scilimits=(0,0))
 
 1014         if (np.isfinite(mindval) 
and 
 1015             np.isfinite(maxdval)):
 
 1016             ax.set_ylim(mindval,maxdval)
 
 1017             if maxdval-mindval < 1.0 
or \
 
 1018                maxdval-mindval > 100.0:
 
 1019                 ax.tick_params(axis=
'y',rotation=-35)
 
 1020         ax.yaxis.get_offset_text().set_fontsize(3)
 
 1025     ix = int(iplot)%int(nx)
 
 1026     iy = int(iplot)/int(nx)
 
 1027     if not interiorLabels \
 
 1028        and (iy < ny-2 
or ( iy == ny-2 
and (int(nplots)%int(nx)==0 
or ix <= (int(nplots)%int(nx) - 1)) )):
 
 1029         ax.tick_params(axis=
'x',labelbottom=
False)
 
 1030     if interiorLabels 
or ix == 0:
 
 1031         ax.set_ylabel(dataLabel,fontsize=4)
 
 1034     if nLines <= maxLegendEntries:
 
 1037             nlcol = np.int(np.ceil(np.sqrt(nLines)))
 
 1038             lh = ax.legend(loc=
'best',fontsize=3,frameon=
True,\
 
 1039                            framealpha=0.4,ncol=nlcol)
 
 1040             lh.get_frame().set_linewidth(0.0)
 
 1041         elif ix==nx-1 
or iplot==nplots-1:
 
 1043             ax.legend(loc=
'upper left',fontsize=3,frameon=
False, \
 
 1044                       bbox_to_anchor=(1.02, 1), borderaxespad=0)
 
 1052                      xDates, yVals, contourVals, \
 
 1053                      title="", clabel="", \
 
 1054                      sciticks=False, logscale=False, signdef=False, \
 
 1055                      dataLabel="y", invert_ind_axis=False, \
 
 1056                      ny=1, nx=1, nplots=1, iplot=0, \
 
 1057                      dmin=np.NaN, dmax=np.NaN,
 
 1058                      interiorLabels=True):
 
 1080     ax = fig.add_subplot(ny, nx, iplot+1)
 
 1082     if (np.isnan(contourVals)).all():
 
 1083         ax.tick_params(axis=
'x',labelbottom=
False)
 
 1084         ax.tick_params(axis=
'y',labelleft=
False)
 
 1087     xVals = pu.TDeltas2Seconds(xDates)
 
 1090     mindval, maxdval = pu.get_clean_ax_limits(dmin,dmax,contourVals,signdef)
 
 1096         cint = contourVals.astype(int)
 
 1097         isInt = np.all((contourVals - cint) == 0)
 
 1099           minscid = np.nanmax(np.array([1., dmin]))
 
 1101           minscid = maxdval*1.e-5
 
 1102         lognorm = colors.LogNorm(vmin=minscid, vmax=maxdval)
 
 1104         cmapName = 
'seismic' 
 1108         lognorm = colors.SymLogNorm(vmin=mindval, vmax=maxdval,
 
 1109                     linthresh=1.e-3*maxdval, linscale=1.3, base=10)
 
 1117     cmap = plt.get_cmap(cmapName)
 
 1118     cmap.set_bad(color = 
'k', alpha = 1.0)
 
 1122         levels = MaxNLocator(nbins=nlevs).tick_values(mindval,maxdval)
 
 1123         norm = BoundaryNorm(levels, ncolors=cmap.N, clip=
True)
 
 1125     cp = ax.pcolormesh(xVals_pcolor, yVals_pcolor, contourVals, cmap=cmap, norm=norm)
 
 1128     ax.set_title(title,fontsize=5)
 
 1131     pu.format_x_for_dates(ax, xDates)
 
 1132     ax.xaxis.set_tick_params(labelsize=3)
 
 1133     ax.yaxis.set_tick_params(labelsize=3)
 
 1136     ix = int(iplot)%int(nx)
 
 1137     iy = int(iplot)/int(nx)
 
 1138     if not interiorLabels \
 
 1139        and (iy < ny-2 
or ( iy == ny-2 
and (int(nplots)%int(nx)==0 
or ix <= (int(nplots)%int(nx) - 1)) )):
 
 1140         ax.tick_params(axis=
'x',labelbottom=
False)
 
 1141     if interiorLabels 
or ix == 0:
 
 1142         ax.set_ylabel(dataLabel,fontsize=4)
 
 1143     if interiorLabels 
or ix == nx-1:
 
 1145         m = plt.cm.ScalarMappable(cmap=cmap)
 
 1146         m.set_array(contourVals)
 
 1148         if (np.isfinite(mindval) 
and 
 1149             np.isfinite(maxdval) 
and 
 1151             m.set_clim(mindval,maxdval)
 
 1152         cb = plt.colorbar(m, ax=ax)
 
 1154         if sciticks 
and not logscale:
 
 1155             cb.ax.ticklabel_format(style=
'sci', axis=
'y', scilimits=(0,0))
 
 1156         cb.ax.yaxis.get_offset_text().set_fontsize(3)
 
 1158         cb.ax.tick_params(labelsize=3)
 
 1159         cb.set_label(clabel,fontsize=5)
 
 1174     xs_diff = xs[1] - xs[0]
 
 1177     xs_extend = [xs[0]-xs_diff]
 
 1179     for x 
in xs: xs_extend.append(x)
 
 1181     xs_extend.append(xs_extend[-1]+(xs[-1]-xs[-2]))
 
 1183     xs_pcolormesh_midpoints = []
 
 1184     for ii, x 
in enumerate(xs_extend[:-1]):
 
 1185         xs_pcolormesh_midpoints.append(x+0.5*(xs_extend[ii+1] - xs_extend[ii]))
 
 1187     ys_diff = ys[1] - ys[0]
 
 1190     ys_extend = [ys[0]-ys_diff]
 
 1192     for y 
in ys: ys_extend.append(y)
 
 1194     ys_extend.append(ys_extend[-1]+(ys[-1]-ys[-2]))
 
 1196     ys_pcolormesh_midpoints = []
 
 1197     for ii, y 
in enumerate(ys_extend[:-1]):
 
 1198         ys_pcolormesh_midpoints.append(y+0.5*(ys_extend[ii+1] - ys_extend[ii]))
 
 1200     return xs_pcolormesh_midpoints, ys_pcolormesh_midpoints
 
 1211              ny=1, nx=1, nplots=1, iplot=0,
 
 1214              interiorLabels=True):
 
 1232     ax = fig.add_subplot(ny, nx, iplot+1)
 
 1235     ax.set_title(title,fontsize=5)
 
 1240     for ihist, countVals 
in enumerate(countsVals):
 
 1241         if np.all(np.isnan(countVals)):
 
 1244                 _logger.warning(
"skipping all-NaN data")
 
 1245                 _logger.warning(title+
"; "+indepLabel+
"; "+countsLabel[ihist])
 
 1246             nanWarnPDF=nanWarnPDF+1
 
 1248         if len(countVals)!=len(xVals):
 
 1251                 _logger.warning(
"skipping data where len(x)!=len(y)")
 
 1252                 _logger.warning(title+
"; "+indepLabel+
"; "+countsLabel[ihist])
 
 1253             lenWarnPDF=lenWarnPDF+1
 
 1259         dx = xVals[1] - xVals[0]
 
 1261         ax.plot(xVals, np.divide(countVals,np.sum(countVals)*dx),
 
 1262                 color=pu.plotColor(len(countsVals),ihist+lineAttribOffset),
 
 1263                 label=countsLabel[ihist],
 
 1264                 ls=pu.plotLineStyle(len(countsVals),ihist+lineAttribOffset),
 
 1267         plotVals.append(countVals)
 
 1271         ax.tick_params(axis=
'x',labelbottom=
False)
 
 1272         ax.tick_params(axis=
'y',labelleft=
False)
 
 1276     from scipy.stats 
import norm
 
 1277     ax.plot(xVals, norm.pdf(xVals),
 
 1285     ax.xaxis.set_tick_params(labelsize=3)
 
 1286     ax.yaxis.set_tick_params(labelsize=3)
 
 1288     ax.set_ylim(bottom=1.e-6)
 
 1291     ix = int(iplot)%int(nx)
 
 1292     iy = int(iplot)/int(nx)
 
 1293     if not interiorLabels \
 
 1294        and (iy < ny-2 
or ( iy == ny-2 
and (int(nplots)%int(nx)==0 
or ix <= (int(nplots)%int(nx) - 1)) )):
 
 1295         ax.tick_params(axis=
'x',labelbottom=
False)
 
 1296     if interiorLabels 
or ix == 0:
 
 1297         ax.set_xlabel(indepLabel,fontsize=4)
 
 1298         ax.set_ylabel(
'PDF',fontsize=4)
 
 1303         lh = ax.legend(loc=
'best',fontsize=3,frameon=
True,\
 
 1304                        framealpha=0.4,ncol=1)
 
 1305         lh.get_frame().set_linewidth(0.0)
 
 1306     elif ix==nx-1 
or iplot==nplots-1:
 
 1308         ax.legend(loc=
'upper left',fontsize=3,frameon=
False, \
 
 1309                   bbox_to_anchor=(1.02, 1), borderaxespad=0)
 
 1325                title="", dataLabel="y", \
 
 1327                ny=1, nx=1, nplots=1, iplot=0,
 
 1330                interiorLabels=True):
 
 1352     ax = fig.add_subplot(ny, nx, iplot+1)
 
 1353     ix = int(iplot)%int(nx)
 
 1354     iy = int(iplot)/int(nx)
 
 1357     ax.set_title(title,fontsize=5)
 
 1362     linesLabel = [
'RMS',
'STD',
'Mean']
 
 1363     for iline, lineVals 
in enumerate([rmsVals,stdVals,meanVals]):
 
 1364         if np.all(np.isnan(lineVals)):
 
 1367                 _logger.warning(
"skipping all-NaN data")
 
 1368                 _logger.warning(title+
"; "+indepLabel+
"; "+linesLabel[iline])
 
 1369             nanWarnRamp=nanWarnRamp+1
 
 1371         if len(lineVals)!=len(xVals):
 
 1374                 _logger.warning(
"skipping data where len(x)!=len(y)")
 
 1375                 _logger.warning(title+
"; "+indepLabel+
"; "+linesLabel[iline])
 
 1376             lenWarnRamp=lenWarnRamp+1
 
 1380         pColor = pu.plotColor(4,iline+lineAttribOffset)
 
 1382         ax.plot(xVals, lineVals,
 
 1384                 label=linesLabel[iline],
 
 1385                 ls=pu.plotLineStyle(4,iline+lineAttribOffset),
 
 1388         plotVals.append(lineVals)
 
 1391         ax.tick_params(axis=
'x',labelbottom=
False)
 
 1392         ax.tick_params(axis=
'y',labelleft=
False)
 
 1396     ind0 = np.argmax(countVals)
 
 1399     for ii, std 
in enumerate(stdVals):
 
 1400         if np.isfinite(std): indexMaxX4Std = ii
 
 1401     indexMaxX = indexMaxX4Std
 
 1403     for ii, count 
in enumerate(countVals):
 
 1404         if count > maxCount: maxCount = count
 
 1405         if count < 0.002*maxCount:
 
 1408     if indexMaxX > indexMaxX4Std:
 
 1409         ind1 = np.argmax(stdVals[0:indexMaxX4Std])
 
 1411         ind1 = np.argmax(stdVals[0:indexMaxX])
 
 1413     weights = [0.2]*(ind1-ind0+1)
 
 1415     p = np.polyfit(xVals[ind0:ind1+1],stdVals[ind0:ind1+1],1,
 
 1419     ERR0 = X0 * p[0] + p[1]
 
 1423     ERR1 = stdVals[ind1]
 
 1424     X1 = (ERR1 - p[1]) / p[0]
 
 1429             'X':  [round(X0,2),  round(X1,2)],
 
 1430             'ERR': [round(ERR0,2), round(ERR1,2)],
 
 1433             'X0': [round(X0,2)],
 
 1434             'X1': [round(X1,2)],
 
 1435             'ERR0': [round(ERR0,2)],
 
 1436             'ERR1': [round(ERR1,2)],
 
 1440     fitX  = np.asarray([0.0]  + ERRfitDict[
'bu'][
'X']  + [xVals[indexMaxX4Std]])
 
 1441     fitERR = np.asarray([ERR0] + ERRfitDict[
'bu'][
'ERR'] + [ERR1])
 
 1443     plotVals.append(fitERR)
 
 1445     pColor = pu.plotColor(4,1+lineAttribOffset)
 
 1447     ax.plot(fitX, fitERR,
 
 1457     ax.xaxis.set_tick_params(labelsize=3)
 
 1458     ax.yaxis.set_tick_params(labelsize=3)
 
 1461     mindval, maxdval = pu.get_clean_ax_limits(plotVals=plotVals)
 
 1462     if (np.isfinite(mindval) 
and 
 1463         np.isfinite(maxdval)):
 
 1464         ax.set_ylim(mindval,maxdval)
 
 1467     if not interiorLabels \
 
 1468        and (iy < ny-2 
or ( iy == ny-2 
and (int(nplots)%int(nx)==0 
or ix <= (int(nplots)%int(nx) - 1)) )):
 
 1469         ax.tick_params(axis=
'x',labelbottom=
False)
 
 1470     if interiorLabels 
or ix == 0:
 
 1471         ax.set_xlabel(indepLabel,fontsize=4)
 
 1472     if interiorLabels 
or iy == ny-1:
 
 1473         ax.set_ylabel(dataLabel,fontsize=4)
 
 1478         lh = ax.legend(loc=
'best',fontsize=3,frameon=
True,\
 
 1479                        framealpha=0.4,ncol=1)
 
 1480         lh.get_frame().set_linewidth(0.0)
 
 1481     elif ix==nx-1 
or iplot==nplots-1:
 
 1483         ax.legend(loc=
'upper left',fontsize=3,frameon=
False, \
 
 1484                   bbox_to_anchor=(1.02, 1), borderaxespad=0)
 
 1491     if interiorLabels 
or ix == nx:
 
 1492         ax2.set_ylabel(
'Count',fontsize=4,color=color)
 
 1493     ax2.plot(xVals[:indexMaxX4Std], countVals[:indexMaxX4Std],
 
 1498     ax2.tick_params(axis=
'y', labelcolor=color)
 
 1499     ax2.yaxis.set_tick_params(labelsize=3)
 
 1501     ax2.set_ylim(bottom=100.)
 
def plotfitRampComposite(fig, xVals, countVals, meanVals, rmsVals, stdVals, title="", dataLabel="y", indepLabel="x", ny=1, nx=1, nplots=1, iplot=0, lineAttribOffset=1, legend_inside=True, interiorLabels=True)
 
def plotTimeserial2D(Stats, xlabeltime, ylevels, VarName)
 
def transformXY_for_pcolor(xs, ys)
 
def plotTimeSeries(fig, xsDates, linesVals, linesLabel, title="", dataLabel="", sciticks=False, logscale=False, signdef=False, ny=1, nx=1, nplots=1, iplot=0, linesValsMinCI=None, linesValsMaxCI=None, dmin=np.NaN, dmax=np.NaN, lineAttribOffset=0, legend_inside=True, interiorLabels=True)
 
def plotSeries(fig, linesVals, xVals, linesLabel, title="", dataLabel="y", sciticks=False, logscale=False, signdef=False, indepLabel="x", invert_ind_axis=False, ny=1, nx=1, nplots=1, iplot=0, linesValsMinCI=None, linesValsMaxCI=None, dmin=np.NaN, dmax=np.NaN, lineAttribOffset=0, legend_inside=True, interiorLabels=True)
 
def scatterMapFields(lons, lats, fields, filename, minLon=-180., maxLon=180., minLat=-90., maxLat=90., cLon=None, projection='default', dmin=None, dmax=None, markers={}, sizes={}, cmap='gist_ncar', cbarType=None, c={}, logVLim=1.e-12)
 
def plotPDF(fig, countsVals, xVals, countsLabel, title="", indepLabel="x", ny=1, nx=1, nplots=1, iplot=0, lineAttribOffset=1, legend_inside=True, interiorLabels=True)
 
def plotTimeSeries2D(fig, xDates, yVals, contourVals, title="", clabel="", sciticks=False, logscale=False, signdef=False, dataLabel="y", invert_ind_axis=False, ny=1, nx=1, nplots=1, iplot=0, dmin=np.NaN, dmax=np.NaN, interiorLabels=True)
 
def plotDistri(lats, lons, values, ObsType, VarName, var_unit, out_name, nstation, levbin, dmin=None, dmax=None, dotsize=6, color="rainbow")
 
def plotProfile(fig, linesVals, yVals, linesLabel, title="", dataLabel="x", sciticks=False, logscale=False, signdef=False, indepLabel="y", invert_ind_axis=False, ny=1, nx=1, nplots=1, iplot=0, linesValsMinCI=None, linesValsMaxCI=None, dmin=np.NaN, dmax=np.NaN, lineAttribOffset=0, legend_inside=True, interiorLabels=True)