Changeset 952 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
Jun 25, 2016, 12:54:40 PM (8 years ago)
Author:
lfita
Message:

Adding `rangevals:', to plot values axis with a given range ('auto' for use the actual extreme)

Location:
trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/drawing.py

    r948 r952  
    17801780    draw_lines_time(ncfilens, values, varname):
    17811781      ncfilens= [filen] ',' separated list of netCDF files
    1782       values= [dimvname];[valuesaxis];[dimtit];[leglabels];[vtit];[title];[timevals];[locleg];
    1783         [graphk];[collines];[points];[linewidths];[pointsizes];[pointfreq];[period]
     1782      values= [dimvname];[valuesaxis];[dimtit];[leglabels];[vtit];[title];[rangevals];[timevals];
     1783        [legvals];[graphk];[collines];[points];[linewidths];[pointsizes];[pointfreq];[period]
    17841784        [dimvname]: ',' list of names of the variables with he values of the common dimension
    17851785        [valuesaxis]: which axis will be used for the values ('x', or 'y')
     
    17881788        [vartit]: name of the variable in the graph
    17891789        [title]: title of the plot ('|' for spaces)
     1790        [rangevals]: Range of the axis with the values ('None' for 'auto','auto')
     1791          [vmin],[vmax]: minimum and maximum values where [vmNN] can also be:
     1792            'auto': the computed minimumm or maximum of the values 
    17901793        [timevals]: [timen]|[units]|[kind]|[tfmt] time labels characteristics
    17911794           [timen]; name of the time variable
     
    18311834
    18321835    expectargs = '[dimvname];[valuesaxis];[dimtit];[leglabels];[vtit];[title];'
    1833     expectargs = expectargs + '[timevals];[locleg];[graphk];[lines];[collines];[points];'
    1834     expectargs = expectargs + '[linewidths];[pointsizes];[pointfreq];[period]'
     1836    expectargs = expectargs + '[rangevals];[timevals];[legvals];[graphk];[lines];'
     1837    expectargs = expectargs + '[collines];[points];[linewidths];[pointsizes];'
     1838    expectargs - expectargs + '[pointfreq];[period]'
    18351839    drw.check_arguments(fname,values,expectargs,';')
    18361840
     
    18421846    vartit = values.split(';')[4]
    18431847    title = values.split(';')[5].replace('|',' ')
    1844     timevals = values.split(';')[6]
    1845     legvalues = values.split(';')[7]
    1846     graphk = values.split(';')[8]
    1847     lines0 = values.split(';')[9]
    1848     collines0 = values.split(';')[10]
    1849     points0 = values.split(';')[11]
    1850     linewidths0 = values.split(';')[12]
    1851     pointsizes0 = values.split(';')[13]
    1852     pointfreq0 = values.split(';')[14]
    1853     period = values.split(';')[15]
     1848    rangevals = values.split(';')[6]
     1849    timevals = values.split(';')[7]
     1850    legvalues = values.split(';')[8]
     1851    graphk = values.split(';')[9]
     1852    lines0 = values.split(';')[10]
     1853    collines0 = values.split(';')[11]
     1854    points0 = values.split(';')[12]
     1855    linewidths0 = values.split(';')[13]
     1856    pointsizes0 = values.split(';')[14]
     1857    pointfreq0 = values.split(';')[15]
     1858    period = values.split(';')[16]
    18541859
    18551860    Nfiles = len(ncfiles)
     
    19281933    timekind = timevals.split('|')[2]
    19291934    timefmt = timevals.split('|')[3]
     1935
     1936    if rangevals = 'None':
     1937        valmin = 'auto'
     1938        valmax = 'auto'
     1939    else:
     1940        valmin = rangevals.split(',')[0]
     1941        valmax = rangevals.split(',')[0]
     1942        if valmin != 'auto': valmin = np.float(valmin)
     1943        if valmax != 'auto': valmax = np.float(valmax)
    19301944
    19311945    locleg = int(legvalues.split('|')[0])
     
    21012115
    21022116    drw.plot_lines_time(dimvalues, varvalues, valuesaxis, dimtit, legvals, vartit,   \
    2103       varunits, timepos, timelabels, title, locleg, legfontsize, graphk, lines,      \
    2104       collines, points, linewidths, pointsizes, pointfreq)
     2117      varunits, timepos, timelabels, title, locleg, legfontsize, graphk, valmin,     \
     2118      valmax, lines, collines, points, linewidths, pointsizes, pointfreq)
    21052119
    21062120    return
  • trunk/tools/drawing_tools.py

    r951 r952  
    57315731
    57325732def plot_lines_time(vardv, varvv, vaxis, dtit, linesn0, vtit, vunit, tpos, tlabs,    \
    5733   gtit, gloc, gsize, kfig, lsl, coll, ptl, lwidth, psize, ptf):
     5733  gtit, vmin, vmax, gloc, gsize, kfig, lsl, coll, ptl, lwidth, psize, ptf):
    57345734    """ Function to plot a collection of lines with a time axis
    57355735      vardv= list of set of dimension values
     
    57435743      tlabs= labels of the time ticks
    57445744      gtit= main title
     5745      vmin= minimum value for the axis-value 'auto' for use the extreme
     5746      vmax= maximum value for the axis-value 'auto' for use the extreme
    57455747      gloc= location of the legend (0, autmoatic)
    57465748        1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right',
     
    58175819#        plt.xlim(np.min(varTvv),np.max(varTvv))
    58185820#        plt.ylim(np.min(varTdv),np.max(varTdv))
    5819         plt.xlim(xtrmvv[0],xtrmvv[1])
     5821
     5822        if vmin == 'auto':
     5823            xmin = xtrmvv[0]
     5824        else:
     5825            xmin = vmin
     5826        if vmax == 'auto':
     5827            xmax = xtrmvv[1]
     5828        else:
     5829            xmax = vmax
     5830
     5831        plt.xlim(xmin,xmax)
    58205832        plt.ylim(xtrmdv[0],xtrmdv[1])
    58215833
     
    58525864        plt.ylabel(vtit + ' (' + vunit + ')')
    58535865
     5866        if vmin == 'auto':
     5867            ymin = xtrmvv[0]
     5868        else:
     5869            ymin = vmin
     5870        if vmax == 'auto':
     5871            ymax = xtrmvv[1]
     5872        else:
     5873            ymax = vmax
     5874
    58545875        plt.xlim(xtrmdv[0],xtrmdv[1])
    5855         plt.ylim(xtrmvv[0],xtrmvv[1])
     5876        plt.ylim(ymin,ymax)
    58565877
    58575878#        plt.xlim(np.min(varTdv),np.max(varTdv))
Note: See TracChangeset for help on using the changeset viewer.