Changeset 518 for trunk


Ignore:
Timestamp:
Feb 8, 2012, 10:38:45 AM (13 years ago)
Author:
aslmd
Message:

UTIL/PYTHON: added the possibility to use -c onebar for multiplots as one would easily guess why

Location:
trunk/UTIL/PYTHON
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/UTIL/PYTHON/README.PP

    r511 r518  
    118118***********************************************************************************
    119119pp.py -f wrfout_d01_9999-09-09_09:00:00 -v W,tpot --lat 60 --time 15 -i 4 -l 30,130,100 --div 50
     120***********************************************************************************
     121
     122***********************************************************************************
     123EXAMPLE : Plotting surface temperature maps from TES
     124***********************************************************************************
     125pp.py -f TES/TES.MappedClimatology.nadir.MY25.nc -v Tsurf_day -p npstere --blat 60 --trans 0.5 -b vishires --time 50
     126***********************************************************************************
     127pp.py -f /d5/emlmd/TES/TES.MappedClimatology.nadir.MY25.nc,/d5/emlmd/TES/TES.MappedClimatology.nadir.MY26.nc   -p npstere -v Tsurf_day --time 90,105 --time 105,120 --time 120,135 --time 135,150 --blat 70 --div 30 -m 190 -M 270 -b vishires --trans 0.7
     128***********************************************************************************
     129pp.py -f /d5/emlmd/TES/TES.MappedClimatology.nadir.MY25.nc,/d5/emlmd/TES/TES.MappedClimatology.nadir.MY26.nc -p npstere -v Tsurf_day --time 110,130 --blat 70 --div 30 -m 190 -M 270 -b vishires --trans 0.7 -c onebar --title "Surface temperature (K)"
    120130***********************************************************************************
    121131
  • trunk/UTIL/PYTHON/myplot.py

    r516 r518  
    770770
    771771                    }
     772    if "TSURF" in whichvar: whichvar = "TSURF"
    772773    if whichvar not in fmtvar:
    773774        whichvar = "def"
     
    816817#spectral BrBG RdBu_r
    817818    #print "predefined colorbars"
     819    if "TSURF" in whichone: whichone = "TSURF"
    818820    if whichone not in whichcolorb:
    819821        whichone = "def"
  • trunk/UTIL/PYTHON/myscript.py

    r516 r518  
    2323
    2424    ### VERTICAL INTERPOLATION
    25     parser.add_option('-l', '--level',  action='store',dest='lvl',       type="string",  default="0",   help='level / start,stop,step (-i 2: p,mb)(-i 3,4: z,km) [0]')
     25    parser.add_option('-l', '--level',  action='store',dest='lvl',       type="string",  default="0",   help='level / start,stop,step (-i 2: p,Pa)(-i 3,4: z,km) [0]')
    2626    parser.add_option('-i', '--interp', action='store',dest='itp',       type="int",     default=None,  help='interpolation (2: p, 3: z-amr, 4:z-als)')
    2727    parser.add_option('--intas',        action='store',dest='intas',     type="string",  default=None,  help='specify "mcs" or "tes" for gcm P interpolation grid')
     
    2929
    3030    ### GENERIC GRAPHICS SETTINGS
    31     parser.add_option('-c', '--color',  action='store',dest='clb',       type="string",  default="def", help='change colormap (nobar: no colorbar)')
     31    parser.add_option('-c', '--color',  action='store',dest='clb',       type="string",  default="def", help='change colormap (also: nobar,onebar)')
    3232    parser.add_option('--div',          action='store',dest='ndiv',      type="int",     default=10,    help='number of divisions in colorbar [10]')
    3333    parser.add_option('--title',        action='store',dest='zetitle',   type="string",  default="fill",help='customize the whole title')
  • trunk/UTIL/PYTHON/planetoplot.py

    r516 r518  
    7676    from mymath import deg,max,min,mean,get_tsat,writeascii,fig2data,fig2img
    7777    import matplotlib as mpl
    78     from matplotlib.pyplot import contour,contourf, subplot, figure, rcParams, savefig, colorbar, pcolor, show, plot, clabel, title, close, legend, xlabel, axis, ylabel
     78    from matplotlib.pyplot import contour,contourf, subplot, figure, rcParams, savefig, colorbar, pcolor, show, plot, clabel, title, close, legend, xlabel, axis, ylabel, subplots_adjust, axes
    7979    from matplotlib.cm import get_cmap
    8080    #from mpl_toolkits.basemap import cm
     
    372372       ### General plot settings
    373373       changesubplot = (numplot > 1) and (len(what_I_plot.shape) != 1)  ## default for 1D plots: superimposed. to be reworked for better flexibility.
    374        if changesubplot: subplot(subv,subh,nplot)
     374       if changesubplot: subplot(subv,subh,nplot) #; subplots_adjust(wspace=0,hspace=0)
    375375       ####################################################################
    376376       if error:
     
    391391               else:                                                   zevmin, zevmax = calculate_bounds(what_I_plot,vmin=vmin,vmax=vmax)
    392392               if (fileref is not None) and (index_f == numplot-1):    colorb = "RdBu_r"
    393                if colorb in ["def","nobar"]:                           palette = get_cmap(name=defcolorb(fvar.upper()))
     393               if colorb in ["def","nobar","onebar"]:                  palette = get_cmap(name=defcolorb(fvar.upper()))
    394394               else:                                                   palette = get_cmap(name=colorb)
    395395               #palette = cm.GMT_split
     
    469469                            elif mapmode == 0:     pcolor( x, y, what_I_plot_frame, cmap = palette, vmin=zevmin, vmax=zevmax, alpha=trans)
    470470
    471                         if colorb != 'nobar':       
     471                        if colorb not in ['nobar','onebar']:       
    472472                            if (fileref is not None) and (index_f == numplot-1):   daformat = "%.3f"
    473473                            elif mult != 1:                                        daformat = "%.1f"
     
    477477                            zecb = colorbar( fraction=0.05,pad=0.03,format=daformat,orientation=zeorientation,\
    478478                                      ticks=np.linspace(zevmin,zevmax,num=min([ticks/2+1,21])),extend='neither',spacing='proportional' )
    479                             if zeorientation == "horizontal":
    480                                 zecb.ax.set_xlabel(zetitle)
    481                                 zetitle=""
     479                            if zeorientation == "horizontal" and zetitle != "fill": zecb.ax.set_xlabel(zetitle) ; zetitle=""
    482480                        if winds:
    483481                            if typefile in ['mesoapi','meso']:
     
    578576#       if indexvert is not None:     plottitle = plottitle + " vert: " + str(min(vert[indexvert])) +" "+ str(max(vert[indexvert]))
    579577#       if indextime is not None:     plottitle = plottitle + " time: " + str(min(time[indextime])) +" "+ str(max(time[indextime]))
    580        title( plottitle )
     578       if colorb != "onebar": title( plottitle )
    581579       if nplot >= numplot: error = True
    582580       nplot += 1
    583581
    584  
    585 
    586 
    587 
    588 
     582    if colorb == "onebar":
     583        cax = axes([0.1, 0.2, 0.8, 0.03]) # a ameliorer
     584        zecb = colorbar(cax=cax, orientation="horizontal", format=fmtvar(fvar.upper()),\
     585                 ticks=np.linspace(zevmin,zevmax,num=min([ticks/2+1,21])),extend='neither',spacing='proportional')
     586        if zetitle != "fill": zecb.ax.set_xlabel(zetitle) ; zetitle=""
    589587
    590588     
Note: See TracChangeset for help on using the changeset viewer.