Changeset 458 for trunk/UTIL


Ignore:
Timestamp:
Dec 8, 2011, 1:12:21 AM (13 years ago)
Author:
aslmd
Message:

UTIL: PYTHON: spaghetti plot is default for 1D plots. handling 1D plot can be quite improved.

Location:
trunk/UTIL/PYTHON
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/UTIL/PYTHON/myscript.py

    r457 r458  
    99
    1010    ### WHAT I PLOT
    11     parser.add_option('-v', '--var',    action='append',dest='var',      type="string",  default=None,  help='variable color-shaded (append)')
     11    parser.add_option('-v', '--var',    action='append',dest='var',      type="string",  default=None,  help='variable color-shaded')
    1212    parser.add_option('-w', '--with',   action='store',dest='var2',      type="string",  default=None,  help='variable contoured')
    1313    parser.add_option('-a', '--anomaly',action='store_true',dest='anomaly',              default=False, help='compute and plot relative anomaly in %')
    1414    parser.add_option('--mult',         action='store',dest='mult',      type="float",   default=1.,    help='a multiplicative factor to plotted field')
    15     parser.add_option('-m', '--min',    action='append',dest='vmin',     type="float",   default=None,  help='bounding minimum value (append)')   
    16     parser.add_option('-M', '--max',    action='append',dest='vmax',     type="float",   default=None,  help='bounding maximum value (append)')
     15    parser.add_option('-m', '--min',    action='append',dest='vmin',     type="float",   default=None,  help='bounding minimum value [min]')   
     16    parser.add_option('-M', '--max',    action='append',dest='vmax',     type="float",   default=None,  help='bounding maximum value [max]')
    1717    parser.add_option('-H', '--hole',   action='store_true',dest='hole',                 default=False, help='holes above max and below min')
    1818    parser.add_option('--nolow',        action='store_true',dest='nolow',                default=False, help='plot only minima and maxima [false]')
     
    2929    parser.add_option('--title',        action='store',dest='zetitle',   type="string",  default="fill",help='customize the whole title')
    3030    parser.add_option('-T', '--tiled',  action='store_true',dest='tile',                 default=False, help='draw a tiled plot (no blank zone)')
    31     parser.add_option('--res',          action='store',dest='res',       type="float",   default=200.,  help='Resolution for png outputs. --save png needed. [200.]')
    32     parser.add_option('--trans',        action='store',dest='trans',     type="float",   default=1.,    help='shaded plots transparency, from 0 (transparent) to 1 (opaque) [1]')
    33     parser.add_option('--area',         action='store',dest='area',       type="string",   default=None,  help='Area on the map to be plot [None]')
     31    parser.add_option('--res',          action='store',dest='res',       type="float",   default=200.,  help='resolution for png outputs. --save png needed. [200.]')
     32    parser.add_option('--trans',        action='store',dest='trans',     type="float",   default=1.,    help='shaded plot transparency, 0 to 1 (=opaque) [1]')
     33    parser.add_option('--area',         action='store',dest='area',       type="string",   default=None,  help='area on the map to be plot [None]')
    3434
    3535    ### SPECIFIC FOR MAPPING [MAPMODE 1]
    3636    parser.add_option('-p', '--proj',   action='store',dest='proj',      type="string",  default=None,  help='projection')
    3737    parser.add_option('-b', '--back',   action='store',dest='back',      type="string",  default=None,  help='background image [None]')
     38    parser.add_option('-W', '--winds',  action='store_true',dest='winds',                default=False, help='wind vectors [False]')
    3839    parser.add_option('-s', '--stride', action='store',dest='ste',       type="int",     default=3,     help='stride vectors [3]')
    39     parser.add_option('-W', '--winds',  action='store_true',dest='winds',                default=False, help='wind vectors [False]')
    4040    parser.add_option('-z', '--zoom',   action='store',dest='zoom',      type="float",   default=None,  help='zoom factor in %')
    4141    parser.add_option('--blat',         action='store',dest='blat',      type="int",     default=None,  help='reference lat (or bounding lat for stere) [computed]')
     
    6464    ### SPECIAL
    6565    parser.add_option('--tsat',         action='store_true',dest='tsat',               default=False,help='convert temperature field T in Tsat-T using pressure')
    66     parser.add_option('--rate',         action='store'     ,dest='rate', type="int",   default=None, help='Output is a movie along Time dimension. --time must not be specified. [None]')
     66    parser.add_option('--rate',         action='store'     ,dest='rate', type="int",   default=None, help='output is a movie along Time dimension [None]')
    6767    parser.add_option('--quality',      action='store_true',dest='quality',            default=False,help='For movie mode: improves movie quality.(slower)')
    6868
  • trunk/UTIL/PYTHON/planetoplot.py

    r457 r458  
    7272    from mymath import deg,max,min,mean,get_tsat,writeascii,fig2data,fig2img
    7373    import matplotlib as mpl
    74     from matplotlib.pyplot import contour,contourf, subplot, figure, rcParams, savefig, colorbar, pcolor, show, plot, clabel, title, close
     74    from matplotlib.pyplot import contour,contourf, subplot, figure, rcParams, savefig, colorbar, pcolor, show, plot, clabel, title, close, legend
    7575    from matplotlib.cm import get_cmap
    7676    import numpy as np
     
    154154          vert = nc.variables["altitude"][:]
    155155      elif typefile in ['meso','mesoapi','geo','mesoideal']:
     156          ### the following lines are kind of dirty... not possible to ask for several lats and lons
    156157          if vlon is not None or vlat is not None:   indices = bidimfind(lon2d,lat2d,vlon,vlat) ; print '********** INDICES: ', indices
    157158          if slon is not None: slon[0][0] = indices[0] ; slon[0][1] = indices[0]
     
    254255    print "********************************************"
    255256    while error is False:
    256        print "********** NPLOT", nplot
    257      
    258        ### General plot settings
     257     
     258       print "********** NPLOT", nplot
    259259       if nplot > numplot: break
    260        if numplot > 1:  subplot(subv,subh,nplot)
    261 
    262        ### Map projection                   
    263        if mapmode == 1:     m = define_proj(proj,wlon,wlat,back=back,blat=blat,blon=blon) ; x, y = m(lon2d, lat2d)
    264        elif mapmode ==0:    m = None ; x = None ; y = None
    265260
    266261       ####################################################################
     
    301296           vecy, error = reducefield( all_windv[index_f], d4=indextime, d3=indexvert, yint=yintegral, alt=vert)
    302297       ####################################################################
     298       ### General plot settings
     299       changesubplot = (numplot > 1) and (len(what_I_plot.shape) != 1)  ## default for 1D plots: superimposed. to be reworked for better flexibility.
     300       if changesubplot: subplot(subv,subh,nplot)
     301       ### Map projection                   
     302       if mapmode == 1:     m = define_proj(proj,wlon,wlat,back=back,blat=blat,blon=blon) ; x, y = m(lon2d, lat2d)
     303       elif mapmode ==0:    m = None ; x = None ; y = None
     304       ####################################################################
    303305
    304306       if not error:
     
    371373                            elif mapmode == 0:     contourf( x, y, what_I_plot_frame, zelevels, cmap = palette, alpha=trans)
    372374                        else:
    373                             if mapmode == 1:       m.pcolor( x, y, what_I_plot_frame, cmap = palette, vmin=zevmin, vmax=zevmax ,alpha=trans)
    374                             elif mapmode == 0:     pcolor( x, y, what_I_plot_frame, cmap = palette, vmin=zevmin, vmax=zevmax ,alpha=trans)
     375                            if mapmode == 1:       m.pcolor( x, y, what_I_plot_frame, cmap = palette, vmin=zevmin, vmax=zevmax, alpha=trans)
     376                            elif mapmode == 0:     pcolor( x, y, what_I_plot_frame, cmap = palette, vmin=zevmin, vmax=zevmax, alpha=trans)
    375377                        if colorb != 'nobar':       
    376378                            if (fileref is not None) and (index_f is numplot-1):   daformat = "%.3f"
     
    432434               ##### 1D field
    433435               elif len(what_I_plot.shape) is 1:
    434                  plot(x,what_I_plot)
     436                 lbl = ""
     437                 if indexlat is not None:  lbl = lbl + " ix" + str(indexlat)
     438                 if indexlon is not None:  lbl = lbl + " iy" + str(indexlon)
     439                 if indexvert is not None: lbl = lbl + " iz" + str(indexvert)
     440                 if indextime is not None: lbl = lbl + " it" + str(indextime)
     441
     442                 if indexvert is not None:    plot(x,what_I_plot,label=lbl)  ## regular plot
     443                 else:                        plot(what_I_plot,x,label=lbl)  ## vertical profile
     444                 legend(loc='best')
    435445                 if save == 'txt':  writeascii(np.transpose(what_I_plot),'profile'+str(nplot)+'.txt')
    436446
Note: See TracChangeset for help on using the changeset viewer.