Changeset 1417 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
Jan 18, 2017, 11:52:29 PM (8 years ago)
Author:
lfita
Message:

Adding range' values option for draw_vector'

Location:
trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/drawing.py

    r1402 r1417  
    39073907          [color]: color of the vectors
    39083908            'singlecol'@[colorn]: all the vectors same color ('auto': for 'red')
    3909             'wind'@[colorbar]: color of the vectors according to wind speed sqrt(u^2+v^2) and given [colorbar]
     3909            'wind'@[colorbar]@[sminv],[smaxv]: color of the vectors according to wind speed sqrt(u^2+v^2) and given [colorbar]
    39103910              all vectors the same length
    3911             '3rdvar'@[colorbar]@[varn]@[units]: color of the vectors according to a 3rd variable (to be added at -v) and given [colorbar]
     3911              [smin/axv]: minimum and maximum value for the shading or:
     3912               'Srange': for full range
     3913               'Saroundmean@val': for mean-xtrm,mean+xtrm where xtrm = np.min(mean-min@val,max@val-mean)
     3914               'Saroundminmax@val': for min*val,max*val
     3915               'Saroundpercentile@val': for median-xtrm,median+xtrm where xtrm = np.min(median-percentile_(val),
     3916                 percentile_(100-val)-median)
     3917               'Smean@val': for -xtrm,xtrm where xtrm = np.min(mean-min*@val,max*@val-mean)
     3918               'Smedian@val': for -xtrm,xtrm where xtrm = np.min(median-min@val,max@val-median)
     3919               'Spercentile@val': for -xtrm,xtrm where xtrm = np.min(median-percentile_(val),
     3920                 percentile_(100-val)-median)
     3921 
     3922            '3rdvar'@[colorbar]@[varn]@[units]@[sminv],[smaxv]: color of the vectors according to a 3rd variable (to be added at -v) and given [colorbar]
    39123923              all vectors the same length
    39133924          [length]: length of the wind vectors ('auto', for 9)
     
    40414052    if coln == 'singlecol':
    40424053        colorv = colv
     4054        shading_nx = None
    40434055    elif coln == 'wind':
    40444056        colorv = np.sqrt(uwvals**2 + vwvals**2)
     4057        # Min/Max colorbar
     4058        shadminmax = colorvals.split('@')[2]
     4059        shading_nx = shadminmax.split(',')       
    40454060    elif coln == '3rdvar':
    40464061        if len(varn.split(',')) != 3:
     
    40534068        stdvn, lonvn, unitsvn = drw.var_3desc(ocolvec)
    40544069        colorvals = colorvals + '@' + stdvn + '@' + unitsvn
     4070        # Min/Max colorbar
     4071        shadminmax = colorvals.split('@')[4]
     4072        shading_nx = shadminmax.split(',')       
    40554073    else:
    40564074        print errormsg
     
    40654083
    40664084    drw.plot_vector(lonvals, latvals, uwvals, vwvals, freqv, colorvals, colorv,      \
    4067       lengthv, windname, windunits, mapvalues, gtit, kindfig, figuren)
     4085      lengthv, shading_nx, windname, windunits, mapvalues, gtit, kindfig, figuren)
    40684086
    40694087    of.close()
  • trunk/tools/drawing_tools.py

    r1401 r1417  
    67906790    return
    67916791
    6792 def plot_vector(xvals,yvals,uvals,vvals,vecfreq,vecoln,veccolor,veclength,windn,wuts,\
    6793   mapv,graphtit,kfig,figname):
     6792def plot_vector(xvals, yvals, uvals, vvals, vecfreq, vecoln, veccolor, veclength, vs,\
     6793  windn, wuts, mapv, graphtit, kfig, figname):
    67946794    """ Function to plot vectors
    67956795      xvals= values for the x-axis
     
    68076807        'singlecol': 'auto', for 9
    68086808        'wind' and '3rdvar': 'auto' length as wind speed, otherwise fix length
     6809      vs= minmum and maximum values to plot in shadow or:
     6810        'Srange': for full range
     6811        'Saroundmean@val': for mean-xtrm,mean+xtrm where xtrm = np.min(mean-min@val,max@val-mean)
     6812        'Saroundminmax@val': for min*val,max*val
     6813        'Saroundpercentile@val': for median-xtrm,median+xtrm where xtrm = np.min(median-percentile_(val),
     6814          percentile_(100-val)-median)
     6815        'Smean@val': for -xtrm,xtrm where xtrm = np.min(mean-min*@val,max*@val-mean)
     6816        'Smedian@val': for -xtrm,xtrm where xtrm = np.min(median-min@val,max@val-median)
     6817        'Spercentile@val': for -xtrm,xtrm where xtrm = np.min(median-percentile_(val),
     6818           percentile_(100-val)-median)
    68096819      windn= name of the wind variable in the graph
    68106820      wuts= units of the wind variable in the graph
     
    68556865    elif VecN == 'wind' or VecN == '3rdvar':
    68566866        vcolor = vecoln.split('@')[1]
     6867        # Changing limits of the colors
     6868        vsend = graphic_range(vs,veccolor)
    68576869
    68586870    plt.rc('text', usetex=True)
     
    69136925
    69146926        plt.quiver(xvals[::yfreq,::xfreq], yvals[::yfreq,::xfreq],                   \
    6915           uvals[::yfreq,::xfreq], vvals[::yfreq,::xfreq],
    6916           veccolor[::yfreq,::xfreq], cmap=plt.get_cmap(vcolor), pivot='middle')
     6927          uvals[::yfreq,::xfreq], vvals[::yfreq,::xfreq],                            \
     6928          veccolor[::yfreq,::xfreq], cmap=plt.get_cmap(vcolor), pivot='middle',      \
     6929          vmin=vsend[0], vmax=vsend[1])
    69176930        cbar = plt.colorbar()
    69186931
Note: See TracChangeset for help on using the changeset viewer.