Changeset 1134 in lmdz_wrf


Ignore:
Timestamp:
Oct 4, 2016, 11:17:35 AM (8 years ago)
Author:
lfita
Message:

Making use and introducing in `draw_2D_shad':

`format_axes': Function to provide the format for the ticks of the axes in a figure
`graphic_range': Function to provide the ranges of a figure following different options

Fixing automatic generation of list of available color maps in `check_colorBar'

Location:
trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/drawing.py

    r1133 r1134  
    5656    draw_2D_shad(ncfile, values, varn)
    5757      ncfile= file to use
    58       values=[vnamefs]:[dimvals]:[dimxvn]:[dimyvn]:[colorbarvals]:[sminv],[smaxv]:[figt]:
     58      values=[vnamefs]:[dimvals]:[dimxvn]:[dimyvn]:[dimxyfmt]:[colorbarvals]:[sminv],[smaxv]:[figt]:
    5959       [kindfig]:[reverse]:[mapv]:[close]
    6060        [vnamefs]: Name in the figure of the variable to be shaded
     
    6262          variable a given value is required (-1, all the length)
    6363        [dimx/yvn]: name of the variables with the values of the final dimensions (x,y)
     64        [dimxyfmt]=[dxf],[Ndx],[dyf],[Ndy]: format of the values at each axis
     65          [dxs]: style of x-axis ('auto' for 'pretty')
     66            'Nfix', values computed at even 'Ndx'
     67            'Vfix', values computed at even 'Ndx' increments
     68            'pretty', values computed following aprox. 'Ndx' at 'pretty' intervals (2.,2.5,4,5,10)
     69          [dxf]: format of the labels at the x-axis
     70          [Ndx]: Number of ticks at the x-axis
     71          [ordx]: angle of orientation of ticks at the x-axis ('auto' for horizontal)
     72          [dys]: style of y-axis ('auto' for 'pretty')
     73          [dyf]: format of the labels at the y-axis
     74          [Ndy]: Number of ticks at the y-axis
     75          [ordy]: angle of orientation of ticks at the y-axis ('auto' for horizontal)
    6476        [colorbarvals]=[colbarn],[fmtcolorbar],[orientation]
    6577          [colorbarn]: name of the color bar
     
    103115        quit()
    104116
    105     expectargs = '[vnamefs]:[dimvals]:[dimxvn]:[dimyvn]:[colbarvals]:' +             \
     117    expectargs = '[vnamefs]:[dimvals]:[dimxvn]:[dimyvn]:[dimxyf]:[colbarvals]:' +    \
    106118      '[sminv],[smaxv]:[figt]:[kindfig]:[reverse]:[mapv]:[close]'
    107119 
     
    112124    vdimxn = values.split(':')[2]
    113125    vdimyn = values.split(':')[3]
    114     colorbarvals = values.split(':')[4]
    115     shadminmax = values.split(':')[5]
    116     figtitle = values.split(':')[6].replace('|',' ')
    117     figkind = values.split(':')[7]
    118     revals = values.split(':')[8]
    119     mapvalue = values.split(':')[9]
    120     close = gen.Str_Bool(values.split(':')[10])
     126    dimxyf = values.split(':')[4]
     127    colorbarvals = values.split(':')[5]
     128    shadminmax = values.split(':')[6]
     129    figtitle = values.split(':')[7].replace('|',' ')
     130    figkind = values.split(':')[8]
     131    revals = values.split(':')[9]
     132    mapvalue = values.split(':')[10]
     133    close = gen.Str_Bool(values.split(':')[11])
    121134
    122135    ncfiles = ncfile
     
    193206      objdimy.dimensions, dimvals.replace(':','|').split(','))
    194207
    195 
    196 #    if len(objdimx.shape) <= 2:
    197 ##        odimxv = objdimx[valshad.shape]
    198 ##        odimyv = objdimy[valshad.shape]
    199 #        odimxv = objdimx[:]
    200 #        odimyv = objdimy[:]
    201 
    202 #    elif len(objdimx.shape) == 3:
    203 ##        dimcut = [0, slice(0,valshad.shape[0]), slice(0,valshad.shape[1])]
    204 ##        odimxv = objdimx[tuple(dimcut)]
    205 ##        odimyv = objdimy[tuple(dimcut)]
    206 #        odimxv = objdimx[0,:]
    207 #        odimyv = objdimy[0,:]
    208 #    else:
    209 #        print errormsg
    210 #        print '  ' + fname + ': shape of dimension variable:', objdimx.shape,        \
    211 #          ' not ready!!'
    212 #        quit(-1)
    213 
    214208    shading_nx = []
    215209    if shadminmax.split(',')[0][0:1] != 'S':
     
    225219    if mapvalue == 'None': mapvalue = None
    226220
    227     colbarn = colorbarvals.split(',')[0]
    228     fmtcolbar0 = colorbarvals.split(',')[1]
    229     colbaror0 = colorbarvals.split(',')[2]
    230 
    231     if fmtcolbar0 == 'auto':
    232         fmtcolbar = '%6g'
    233     else:
    234         fmtcolbar = fmtcolbar0
    235     if colbaror0 == 'auto':
    236         colbaror = 'vertical'
    237     else:
    238         colbaror = colbaror0
     221    colbarn, fmtcolbar, colbaror = drw.colorbar_vals(colorbarvals,',')
     222
     223    xstyl, xaxf, Nxax, xaxor, ystyl, yaxf, Nyax, yaxor = drw.format_axes(dimxyf,',')
     224    xaxis = [xstyl, xaxf, Nxax, xaxor]
     225    yaxis = [ystyl, yaxf, Nyax, yaxor]
    239226
    240227    if revals == 'None':
    241228        revals = None
    242229
    243     drw.plot_2D_shadow(valshad, vnamesfig, odimxv, odimyv, odimxu, odimyu, dimnamesv,\
    244       colbarn, fmtcolbar, colbaror, shading_nx, varunits, figtitle, figkind, revals, \
    245       mapvalue, close)
     230    drw.plot_2D_shadow(valshad, vnamesfig, odimxv, odimyv, odimxu, odimyu, xaxis,    \
     231      yaxis, dimnamesv, colbarn, fmtcolbar, colbaror, shading_nx, varunits, figtitle,\
     232      figkind, revals, mapvalue, close)
    246233
    247234    return
  • trunk/tools/drawing_tools.py

    r1132 r1134  
    2828
    2929####### Funtions
     30# check_colorBar: Check if the given colorbar exists in matplotlib
     31# colorbar_vals: Function to provide the colorbar values for a figure
     32# format_axes: Function to provide the format for the ticks of the axes in a figure
     33# graphic_range: Function to provide the ranges of a figure following different options
    3034# searchInlist:
    3135# datetimeStr_datetime:
     
    4044# file_nlines:
    4145# variables_values:
    42 # check_colorBar:
    4346# units_lunits:
    4447# ASCII_LaTeX:
     
    16931696#quit()
    16941697
     1698
     1699
    16951700#######    #######    #######    #######    #######    #######    #######    #######    #######    #######
    16961701
     
    17001705    fname = 'check_colorBar'
    17011706
     1707# FROM: http://matplotlib.org/1.2.1/examples/pylab_examples/show_colormaps.html
     1708# Get a list of the colormaps in matplotlib.  Ignore the ones that end with
     1709# '_r' because these are simply reversed versions of ones that don't end
     1710# with '_r'
     1711    maps = sorted(m for m in plt.cm.datad if not m.endswith("_r"))
     1712    nmaps = len(maps) + 1
     1713
    17021714# Possible color bars
    1703     colorbars = ['binary', 'Blues', 'BuGn', 'BuPu', 'gist_yarg', 'GnBu', 'Greens',   \
    1704       'Greys', 'Oranges', 'OrRd', 'PuBu', 'PuBuGn', 'PuRd', 'Purples', 'RdPu',       \
    1705       'Reds', 'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd', 'afmhot', 'autumn', 'bone',      \
    1706       'cool', 'copper', 'gist_gray', 'gist_heat', 'gray', 'hot', 'pink', 'spring',   \
    1707       'summer', 'winter', 'BrBG', 'bwr', 'coolwarm', 'PiYG', 'PRGn', 'PuOr', 'RdBu', \
    1708       'RdGy', 'RdYlBu', 'RdYlGn', 'seismic', 'Accent', 'Dark2', 'hsv', 'Paired',     \
    1709       'Pastel1', 'Pastel2', 'Set1', 'Set2', 'Set3', 'spectral', 'gist_earth',        \
    1710       'gist_ncar', 'gist_rainbow', 'gist_stern', 'jet', 'brg', 'CMRmap', 'cubehelix',\
    1711       'gnuplot', 'gnuplot2', 'ocean', 'rainbow', 'terrain', 'flag', 'prism']
    1712 
    1713     if not searchInlist(colorbars,cbarn):
     1715#    colorbars = ['binary', 'Blues', 'BuGn', 'BuPu', 'gist_yarg', 'GnBu', 'Greens',   \
     1716#      'Greys', 'Oranges', 'OrRd', 'PuBu', 'PuBuGn', 'PuRd', 'Purples', 'RdPu',       \
     1717#      'Reds', 'YlGn', 'YlGnBu', 'YlOrBr', 'YlOrRd', 'afmhot', 'autumn', 'bone',      \
     1718#      'cool', 'copper', 'gist_gray', 'gist_heat', 'gray', 'hot', 'pink', 'spring',   \
     1719#      'summer', 'winter', 'BrBG', 'bwr', 'coolwarm', 'PiYG', 'PRGn', 'PuOr', 'RdBu', \
     1720#      'RdGy', 'RdYlBu', 'RdYlGn', 'seismic', 'Accent', 'Dark2', 'hsv', 'Paired',     \
     1721#      'Pastel1', 'Pastel2', 'Set1', 'Set2', 'Set3', 'spectral', 'gist_earth',        \
     1722#      'gist_ncar', 'gist_rainbow', 'gist_stern', 'jet', 'brg', 'CMRmap', 'cubehelix',\
     1723#      'gnuplot', 'gnuplot2', 'ocean', 'rainbow', 'terrain', 'flag', 'prism']
     1724
     1725    if not searchInlist(maps,cbarn):
    17141726        print warnmsg
    17151727        print '  ' + fname + ' color bar: "' + cbarn + '" does not exist !!'
    1716         print '  a standard one will be use instead !!'
     1728        print "  the standard 'rainbow' will be use instead !!"
     1729        print '    colorbars availables with this version:', maps
    17171730
    17181731    return
     1732
     1733def colorbar_vals(colorbarvs,splitchar):
     1734    """ Function to provide the colorbar values for a figure
     1735      colorbarvs= [splitchar] separated list of different colorbar values
     1736        [cbn]: name of the color bar to use
     1737        [fmtcb]: format of the tick labels in the colorbar ('C'-like) ('auto' for '%6g')
     1738        [cbor]: orientation of the color bar ('vertical'/'horizontal') ('auto' for vertical)
     1739    """
     1740    fname = 'colorbar_vals'
     1741
     1742    colbarn = colorbarvs.split(splitchar)[0]
     1743    fmtcolbar0 = colorbarvs.split(splitchar)[1]
     1744    colbaror0 = colorbarvs.split(splitchar)[2]
     1745
     1746    if fmtcolbar0 == 'auto':
     1747        fmtcolbar = '%6g'
     1748    else:
     1749        fmtcolbar = fmtcolbar0
     1750    if colbaror0 == 'auto':
     1751        colbaror = 'vertical'
     1752    else:
     1753        colbaror = colbaror0
     1754
     1755    # check colorbar existence
     1756    check_colorBar(colbarn)
     1757
     1758    return colbarn, fmtcolbar, colbaror
    17191759
    17201760def units_lunits(u):
     
    26522692    return boolv
    26532693
    2654 ####### ###### ##### #### ### ## #
     2694def graphic_range(vrng,varsV):
     2695    """ Function to provide the ranges of a figure following different options
     2696      vrng: list of two values: maximum and minimum for the range of the figure
     2697        'Srange': for full range
     2698        'Saroundmean@val': for mean-xtrm,mean+xtrm where xtrm = np.min(mean-min@val,max@val-mean)
     2699        'Saroundminmax@val': for min*val,max*val
     2700        'Saroundpercentile@val': for median-xtrm,median+xtrm where xtrm = np.min(median-percentile_(val),
     2701          percentile_(100-val)-median)
     2702        'Smean@val': for -xtrm,xtrm where xtrm = np.min(mean-min*@val,max*@val-mean)
     2703        'Smedian@val': for -xtrm,xtrm where xtrm = np.min(median-min@val,max@val-median)
     2704        'Spercentile@val': for -xtrm,xtrm where xtrm = np.min(median-percentile_(val),
     2705           percentile_(100-val)-median)
     2706    """
     2707    fname = 'graphic_range'
     2708
     2709    rangegrph = np.zeros((2), dtype=np.float)
     2710# Changing limits of the colors
     2711    if type(vrng[0]) != type(np.float(1.)) and type(vrng[0]) != type(np.float64(1.)):
     2712        if vrng[0] == 'Srange':
     2713            rangegrph[0] = np.min(varsV)
     2714            rangegrph[1] = np.max(varsV)
     2715        elif vrng[0][0:11] == 'Saroundmean':
     2716            meanv = np.mean(varsV)
     2717            permean = np.float(vrng[0].split('@')[1])
     2718            minv = np.min(varsV)*permean
     2719            maxv = np.max(varsV)*permean
     2720            minextrm = np.min([np.abs(meanv-minv), np.abs(maxv-meanv)])
     2721            rangegrph[0] = meanv-minextrm
     2722            rangegrph[1] = meanv+minextrm
     2723        elif vrng[0][0:13] == 'Saroundminmax':
     2724            permean = np.float(vrng[0].split('@')[1])
     2725            minv = np.min(varsV)*permean
     2726            maxv = np.max(varsV)*permean
     2727            rangegrph[0] = minv
     2728            rangegrph[1] = maxv
     2729        elif vrng[0][0:17] == 'Saroundpercentile':
     2730            medianv = np.median(varsV)
     2731            valper = np.float(vrng[0].split('@')[1])
     2732            minv = np.percentile(varsV, valper)
     2733            maxv = np.percentile(varsV, 100.-valper)
     2734            minextrm = np.min([np.abs(medianv-minv), np.abs(maxv-medianv)])
     2735            rangegrph[0] = medianv-minextrm
     2736            rangegrph[1] = medianv+minextrm
     2737        elif vrng[0][0:5] == 'Smean':
     2738            meanv = np.mean(varsV)
     2739            permean = np.float(vrng[0].split('@')[1])
     2740            minv = np.min(varsV)*permean
     2741            maxv = np.max(varsV)*permean
     2742            minextrm = np.min([np.abs(meanv-minv), np.abs(maxv-meanv)])
     2743            rangegrph[0] = -minextrm
     2744            rangegrph[1] = minextrm
     2745        elif vrng[0][0:7] == 'Smedian':
     2746            medianv = np.median(varsV)
     2747            permedian = np.float(vrng[0].split('@')[1])
     2748            minv = np.min(varsV)*permedian
     2749            maxv = np.max(varsV)*permedian
     2750            minextrm = np.min([np.abs(medianv-minv), np.abs(maxv-medianv)])
     2751            rangegrph[0] = -minextrm
     2752            rangegrph[1] = minextrm
     2753        elif vrng[0][0:11] == 'Spercentile':
     2754            medianv = np.median(varsV)
     2755            valper = np.float(vrng[0].split('@')[1])
     2756            minv = np.percentile(varsV, valper)
     2757            maxv = np.percentile(varsV, 100.-valper)
     2758            minextrm = np.min([np.abs(medianv-minv), np.abs(maxv-medianv)])
     2759            rangegrph[0] = -minextrm
     2760            rangegrph[1] = minextrm
     2761        else:
     2762            print errormsg
     2763            print '  ' + fname + ": range '" + vrng[0] + "' not ready!!!"
     2764            quit(-1)
     2765        print '    ' + fname + ': modified shadow min,max:',rangegrph
     2766    else:
     2767        rangegrph[0] = vrng[0]
     2768        rangegrph[1] = vrng[1]
     2769
     2770    return rangegrph
     2771
     2772def format_axes(axesS,char):
     2773    """ Function to provide the format for the ticks of the axes in a figure
     2774      axesS= [char] separated list of ('auto' for all 'auto' values)
     2775        xs: style of x-axis ('auto' for 'pretty')
     2776          'Nfix', values computed at even 'Ndx'
     2777          'Vfix', values computed at even 'Ndx' increments
     2778          'pretty', values computed following aprox. 'Ndx' at 'pretty' intervals (2.,2.5,4,5,10)
     2779        xf: format of the ticks labels at the x-axis ('auto' for '5g')
     2780        Nx: number of ticks labels at the x-axis ('auto' for 5)
     2781        orx: angle of orientation of ticks at the x-axis ('auto' for horizontal)
     2782        ys: style of y-axis ('auto' for 'pretty')
     2783        yf: format of the ticks labels at the y-axis ('auto' for '5g')
     2784        Ny: number of ticks labels at the y-axis ('auto' for 5)
     2785        ory: angle of orientation of ticks at the y-axis ('auto' for horizontal)
     2786    >>> format_axes('auto',',')
     2787    ('pretty', '5g', 5, 0.0, 'pretty', '5g', 5, 0.0)
     2788    >>> format_axes('pretty,auto,7,auto,Vfix,.0f,30,45.',',')
     2789    ('pretty', '5g', 7, 0.0, 'Vfix', '.0f', 30, 45.0)
     2790    """
     2791    fname = 'format_axes'
     2792
     2793    if axesS == 'auto':
     2794        xs = 'pretty'
     2795        xf = '5g'
     2796        Nx = 5
     2797        orx = 0.
     2798        ys = 'pretty'
     2799        yf = '5g'
     2800        Ny = 5
     2801        ory = 0.
     2802    else:
     2803        Sv = axesS.split(char)
     2804
     2805        if Sv[0] == 'auto': xs = 'pretty'
     2806        else: xs = Sv[0]
     2807        if Sv[1] == 'auto': xf = '5g'
     2808        else: xf = Sv[1]
     2809        if Sv[2] == 'auto': Nx = 5
     2810        else:
     2811          if Sv[0] == 'pretty' or Sv[0] == 'Nfix': Nx = int(Sv[2])
     2812          else: Nx = np.float(Sv[2])
     2813        if Sv[3] == 'auto': orx = 0.
     2814        else: orx = np.float(Sv[3])
     2815        if Sv[4] == 'auto': ys = 'pretty'
     2816        else: ys = Sv[4]
     2817        if Sv[5] == 'auto': yf = '5g'
     2818        else: yf = Sv[5]
     2819        if Sv[6] == 'auto': Ny = 5
     2820        else:
     2821          if Sv[4] == 'pretty' or Sv[4] == 'Nfix': Ny = int(Sv[6])
     2822          else: Ny = np.float(Sv[6])
     2823        if Sv[7] == 'auto': ory = 0.
     2824        else: ory = np.float(Sv[7])
     2825
     2826    return xs, xf, Nx, orx, ys, yf, Ny, ory
     2827
     2828####### ###### ##### #### ### ## # END of GENERIC functions
    26552829
    26562830def plot_TimeSeries(valtimes, vunits, tunits, hfileout, vtit, ttit, tkind, tformat,  \
     
    37893963    return
    37903964
    3791 def plot_2D_shadow(varsv,vnames,dimxv,dimyv,dimxu,dimyu,dimn,          \
    3792   colorbar,cbarfmt,cbaror,vs,uts,vtit,kfig,reva,mapv,ifclose):
     3965def plot_2D_shadow(varsv, vnames, dimxv, dimyv, dimxu, dimyu, xaxv, yaxv, dimn,      \
     3966  colorbar, cbarfmt, cbaror, vs, uts, vtit, kfig, reva, mapv, ifclose):
    37933967    """ Adding labels and other staff to the graph
    37943968      varsv= 2D values to plot with shading
     
    37963970      dim[x/y]v = values at the axes of x and y
    37973971      dim[x/y]u = units at the axes of x and y
     3972      xaxv= list with the x-axis paramteres [style, format, number and orientation]
     3973      yaxv= list with the y-axis paramteres [style, format, number and orientation]
    37983974      dimn= dimension names to plot
    37993975      colorbar= name of the color bar to use
     
    38484024        quit(-1)
    38494025
     4026    # Axis ticks
    38504027    # Usually axis > x must be the lon, thus...
    38514028    dimxv0 = dimxv.copy()
    38524029    dimyv0 = dimyv.copy()
    38534030
    3854     dimxt0 = np.array(pretty_int(dimxv.min(),dimxv.max(),5))
    3855     dimyt0 = np.array(pretty_int(dimyv.min(),dimyv.max(),5))
     4031    dxn = dimxv.min()
     4032    dxx = dimxv.max()
     4033    dyn = dimyv.min()
     4034    dyx = dimyv.max()
     4035
     4036    if xaxv[0] == 'pretty':
     4037        dimxt0 = np.array(pretty_int(dxn,dxx,xaxv[2]))
     4038    elif xaxv[0] == 'Nfix':
     4039        dimxt0 = np.arange(dxn,dxx,(dxx-dxn)/(1.*xaxv[2]))
     4040    elif xaxv[0] == 'Vfix':
     4041        dimxt0 = np.arange(0,dxx,xaxv[2])
     4042    if yaxv[0] == 'pretty':
     4043        dimyt0 = np.array(pretty_int(dyn,dyx,yaxv[2]))
     4044    elif yaxv[0] == 'Nfix':
     4045        dimyt0 = np.arange(dyn,dyx,(dyx-dyn)/(1.*yaxv[2]))
     4046    elif yaxv[0] == 'Vfix':
     4047        dimyt0 = np.arange(0,dyx,yaxv[2])
     4048
    38564049    dimxl0 = []
    3857     for i in range(len(dimxt0)): dimxl0.append('{:.1f}'.format(dimxt0[i]))
     4050    for i in range(len(dimxt0)): dimxl0.append('{:{style}}'.format(dimxt0[i], style=xaxv[1]))
    38584051    dimyl0 = []
    3859     for i in range(len(dimyt0)): dimyl0.append('{:.1f}'.format(dimyt0[i]))
     4052    for i in range(len(dimyt0)): dimyl0.append('{:{style}}'.format(dimyt0[i], style=yaxv[1]))
    38604053
    38614054    dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimxu) + ')'
     
    39624155        y = (dimyv-np.min(dimyv))/(np.max(dimyv) - np.min(dimyv))
    39634156
    3964     vsend = np.zeros((2), dtype=np.float)
    39654157# Changing limits of the colors
    3966     if type(vs[0]) != type(np.float(1.)) and type(vs[0]) != type(np.float64(1.)):
    3967         if vs[0] == 'Srange':
    3968             vsend[0] = np.min(varsv)
    3969             vsend[1] = np.max(varsv)
    3970         elif vs[0][0:11] == 'Saroundmean':
    3971             meanv = np.mean(varsv)
    3972             permean = np.float(vs[0].split('@')[1])
    3973             minv = np.min(varsv)*permean
    3974             maxv = np.max(varsv)*permean
    3975             minextrm = np.min([np.abs(meanv-minv), np.abs(maxv-meanv)])
    3976             vsend[0] = meanv-minextrm
    3977             vsend[1] = meanv+minextrm
    3978         elif vs[0][0:13] == 'Saroundminmax':
    3979             permean = np.float(vs[0].split('@')[1])
    3980             minv = np.min(varsv)*permean
    3981             maxv = np.max(varsv)*permean
    3982             vsend[0] = minv
    3983             vsend[1] = maxv
    3984         elif vs[0][0:17] == 'Saroundpercentile':
    3985             medianv = np.median(varsv)
    3986             valper = np.float(vs[0].split('@')[1])
    3987             minv = np.percentile(varsv, valper)
    3988             maxv = np.percentile(varsv, 100.-valper)
    3989             minextrm = np.min([np.abs(medianv-minv), np.abs(maxv-medianv)])
    3990             vsend[0] = medianv-minextrm
    3991             vsend[1] = medianv+minextrm
    3992         elif vs[0][0:5] == 'Smean':
    3993             meanv = np.mean(varsv)
    3994             permean = np.float(vs[0].split('@')[1])
    3995             minv = np.min(varsv)*permean
    3996             maxv = np.max(varsv)*permean
    3997             minextrm = np.min([np.abs(meanv-minv), np.abs(maxv-meanv)])
    3998             vsend[0] = -minextrm
    3999             vsend[1] = minextrm
    4000         elif vs[0][0:7] == 'Smedian':
    4001             medianv = np.median(varsv)
    4002             permedian = np.float(vs[0].split('@')[1])
    4003             minv = np.min(varsv)*permedian
    4004             maxv = np.max(varsv)*permedian
    4005             minextrm = np.min([np.abs(medianv-minv), np.abs(maxv-medianv)])
    4006             vsend[0] = -minextrm
    4007             vsend[1] = minextrm
    4008         elif vs[0][0:11] == 'Spercentile':
    4009             medianv = np.median(varsv)
    4010             valper = np.float(vs[0].split('@')[1])
    4011             minv = np.percentile(varsv, valper)
    4012             maxv = np.percentile(varsv, 100.-valper)
    4013             minextrm = np.min([np.abs(medianv-minv), np.abs(maxv-medianv)])
    4014             vsend[0] = -minextrm
    4015             vsend[1] = minextrm
    4016         else:
    4017             print errormsg
    4018             print '  ' + fname + ": range '" + vs[0] + "' not ready!!!"
    4019             quit(-1)
    4020         print '    ' + fname + ': modified shadow min,max:',vsend
    4021     else:
    4022         vsend[0] = vs[0]
    4023 
    4024     if type(vs[0]) != type(np.float(1.)):
    4025         if vs[1] == 'range':
    4026             vsend[1] = np.max(varsv)
    4027     else:
    4028         vsend[1] = vs[1]
     4158    vsend = graphic_range(vs,varsv)
    40294159
    40304160    plt.rc('text', usetex=True)
     
    40424172        cbar = plt.colorbar(format=cbarfmt,orientation=cbaror)
    40434173   
    4044 
    40454174    if not mapv is None:
    40464175        if colorbar == 'gist_gray':
     
    40494178            m.drawcoastlines()
    40504179
    4051         meridians = pretty_int(nlon,xlon,5)
     4180        meridians = pretty_int(nlon,xlon,Ndimx)
    40524181        m.drawmeridians(meridians,labels=[True,False,False,True])
    4053         parallels = pretty_int(nlat,xlat,5)
     4182        parallels = pretty_int(nlat,xlat,Ndimy)
    40544183        m.drawparallels(parallels,labels=[False,True,True,False])
    40554184
     
    40754204#        plt.xticks(txpos, txlabels)
    40764205#        plt.yticks(typos, tylabels)
    4077         plt.xticks(dimxt, dimxl)
    4078         plt.yticks(dimyt, dimyl)
     4206        plt.xticks(dimxt, dimxl, rotation=xaxv[3])
     4207        plt.yticks(dimyt, dimyl, rotation=yaxv[3])
    40794208
    40804209# units labels
Note: See TracChangeset for help on using the changeset viewer.