Ignore:
Timestamp:
Jul 5, 2011, 4:18:57 PM (13 years ago)
Author:
aslmd
Message:

MESOSCALE: python graphics. autoscale + bug fixes.

Location:
trunk/MESOSCALE/PLOT/PYTHON
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MESOSCALE/PLOT/PYTHON/mylib/myplot.py

    r197 r199  
    4444    from timestuff import sol2ls
    4545    nc  = Dataset(namefile)
    46     if 'Times' in nc.variables:
     46    if 'Times' in nc.variables and 'vert' not in nc.variables:
    4747        zetime = nc.variables['Times'][0]
    4848        zetimestart = getattr(nc, 'START_DATE')
  • trunk/MESOSCALE/PLOT/PYTHON/scripts/winds.py

    r197 r199  
    1818           colorb=None,\
    1919           winds=True,\
    20            addchar=None,
    21            interv=[0,1]):
     20           addchar=None,\
     21           interv=[0,1],\
     22           vmin=None,\
     23           vmax=None):
    2224
    2325    ####################################################################################################################
     
    2830    from netCDF4 import Dataset
    2931    from myplot import getcoord2d,define_proj,makeplotpng,simplinterv,vectorfield,ptitle,latinterv,getproj,wrfinterv,dumpbdy
    30     from mymath import deg
    31     from matplotlib.pyplot import contourf, subplot, figure, rcParams, savefig, colorbar
     32    from mymath import deg,max,min,mean
     33    from matplotlib.pyplot import contourf, subplot, figure, rcParams, savefig, colorbar, pcolor
    3234    from matplotlib.cm import get_cmap
    3335    import numpy as np
     
    109111            elif dimension == 3:   field = nc.variables[var][:,:,:]
    110112            elif dimension == 4:   field = nc.variables[var][:,nvert,:,:] 
    111 
     113        dev = np.std(field)*2.5
     114        if vmin is None:  zevmin = mean(field) - dev
     115        else:             zevmin = vmin
     116        if vmax is None:  zevmax = mean(field) + dev
     117        else:             zevmax = vmax
     118        print "bounds ", zevmin, zevmax
     119 
    112120    ###########################
    113121    ### Get length of time axis
     
    208216               if dimension == 2:                what_I_plot = field[:,:]
    209217               elif dimension == 3:              what_I_plot = field[i,:,:]
    210            contourf( x, y, what_I_plot, 30, cmap = get_cmap(name=colorb) )
    211            if colorb:     colorbar(fraction=0.05,pad=0.1)
     218           #contourf( x, y, what_I_plot, 30, cmap = get_cmap(name=colorb), vmin=zevmin, vmax=zevmax )
     219           pcolor( x, y, what_I_plot, cmap = get_cmap(name=colorb), vmin=zevmin, vmax=zevmax )
     220           if colorb:     colorbar(fraction=0.05,pad=0.1,format='%.1e')
    212221
    213222       ### Vector plot
     
    281290    parser.add_option('-c', action='store', dest='colorb',      type="string",  default=None,  help='change colormap (and draw a colorbar)')
    282291    parser.add_option('-x', action='store_false', dest='winds',                 default=True,  help='flag: no wind vectors')
     292    parser.add_option('-m', action='store', dest='vmin',        type="float",   default=None,  help='bounding minimum value for color plot')   
     293    parser.add_option('-M', action='store', dest='vmax',        type="float",   default=None,  help='bounding maximum value for color plot')
    283294    (opt,args) = parser.parse_args()
    284295    if opt.namefile is None:
     
    315326    name = winds (zefile,int(zelevel),\
    316327           proj=opt.proj,back=opt.back,target=opt.target,stride=opt.stride,var=opt.var,numplot=opt.numplot,colorb=opt.colorb,winds=opt.winds,\
    317            addchar=lschar,interv=[zehour,zehourin])
     328           addchar=lschar,interv=[zehour,zehourin],vmin=opt.vmin,vmax=opt.vmax)
    318329
    319330    #########################################################
Note: See TracChangeset for help on using the changeset viewer.