Changeset 679 in lmdz_wrf


Ignore:
Timestamp:
Jan 21, 2016, 11:05:39 AM (9 years ago)
Author:
lfita
Message:

Adding point frequency on `draw_lines_time'

Location:
trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/drawing.py

    r678 r679  
    18131813      ncfilens= [filen] ',' separated list of netCDF files
    18141814      values= [dimvname];[valuesaxis];[dimtit];[leglabels];[vtit];[title];[timevals];[locleg];
    1815         [graphk];[collines];[points];[period]
     1815        [graphk];[collines];[points];[pointfreq];[period]
    18161816        [dimvname]: ',' list of names of the variables with he values of the common dimension
    18171817        [valuesaxis]: which axis will be used for the values ('x', or 'y')
     
    18401840        [points]: ',' list of type of points for the lines, None for automatic, single
    18411841          value all the same
     1842        [pointfreq]: frequency of point plotting, 'all' for all time steps
    18421843        [period]: which period to plot
    18431844          '-1': all period
     
    18561857    expectargs = '[dimvname];[valuesaxis];[dimtit];[leglabels];[vtit];[title];'
    18571858    expectargs = expectargs + '[timevals];[locleg];[graphk];[collines];[points];'
    1858     expectargs = expectargs + '[period]'
     1859    expectargs = expectargs + '[pointfreq];[period]'
    18591860    drw.check_arguments(fname,len(expectargs.split(';')),values,';',expectargs)
    18601861
     
    18711872    collines0 = values.split(';')[9]
    18721873    points0 = values.split(';')[10]
    1873     period = values.split(';')[11]
     1874    pointfreq0 = values.split(';')[11]
     1875    period = values.split(';')[12]
    18741876
    18751877    Nfiles = len(ncfiles)
     
    20432045        legvals = None
    20442046
     2047    if pointfreq0 == 'all':
     2048        pointfreq = None
     2049    else:
     2050        pointfreq = int(pointfreq0)
     2051
    20452052    drw.plot_lines_time(dimvalues, varvalues, valuesaxis, dimtit, legvals, vartit,   \
    2046       varunits, timepos, timelabels, title, locleg, graphk, collines, points)
     2053      varunits, timepos, timelabels, title, locleg, graphk, collines, points, pointfreq)
    20472054
    20482055    return
  • trunk/tools/drawing_tools.py

    r678 r679  
    24912491    Nlines = len(valtimes)
    24922492# Canging line kinds every 7 lines (end of standard colors)
    2493     pointkindsauto=['.', 'x', 'o', '*', 'o', '<', '>', '5']
     2493    pointkindsauto=['.', ',', 'x', 'o', '*', '+', '<', '|', '_', '>', '1', '8', 's', \
     2494      'p', 'h', 'D']
    24942495    Npts = len(pointkindsauto)
    24952496    linekinds = []
     
    53395340# Canging line kinds every 7 lines (end of standard colors)
    53405341    linekinds=['.-','x-','o-']
     5342    pointkindsauto=['.', ',', 'x', 'o', '*', '+', '<', '|', '_', '>', '1', '8', 's', \
     5343      'p', 'h', 'D']
    53415344
    53425345    Ntraj = len(vardv)
     
    53955398
    53965399def plot_lines_time(vardv, varvv, vaxis, dtit, linesn0, vtit, vunit, tpos, tlabs,    \
    5397   gtit, gloc, kfig, coll, ptl):
     5400  gtit, gloc, kfig, coll, ptl, ptf):
    53985401    """ Function to plot a collection of lines with a time axis
    53995402      vardv= list of set of dimension values
     
    54175420      ptl= ',' list of type of points for the lines, None for automatic, single
    54185421          value all the same
    5419 
     5422      ptf= frequency of point plotting, 'all' for all time steps
     5423 
    54205424      plot_lines([np.arange(10)], [np.sin(np.arange(10)*np.pi/2.5)], 'y', 'time (s)',      \
    54215425  ['2.5'], 'sin', '-', 'sinus frequency dependency', 'pdf')
    54225426    """
    5423     fname = 'plot_lines'
     5427    fname = 'plot_lines_time'
    54245428
    54255429    if vardv == 'h':
     
    54305434# Canging line kinds every 7 lines (end of standard colors)
    54315435    linekinds = []
     5436    pointkinds = []
     5437    pointkindsauto=['.', ',', 'x', 'o', '*', '+', '<', '|', '_', '>', '1', '8', 's', \
     5438      'p', 'h', 'D']
     5439    Nkpts = len(pointkindsauto)
    54325440    if ptl is None:
    5433         linekindsauto=['.-','x-','o-']
    5434         for ptype in range(4):
    5435             for ip in range(7):
    5436                 linekinds.append(linekindsauto[ptype])
    5437     else:
    5438         linekinds = ptl
     5441        if ptf is None:
     5442            for ptype in range(4):
     5443                for ip in range(Nkpts):
     5444                    linekinds.append(pointkindsauto[ptype] + '-')
     5445        else:
     5446            for ptype in range(4):
     5447                for ip in range(Nkpts):
     5448                    linekinds.append('-')
     5449                    pointkinds.append(pointkindsauto[ptype])
     5450    else:
     5451        if ptf is None:
     5452            for pt in ptl:
     5453                linekinds.append(pt + '-')
     5454        else:
     5455            pointkinds = ptl
     5456            for pt in ptl:
     5457                linekinds.append('-')
    54395458
    54405459    Ntraj = len(vardv)
     
    54585477        for il in range(Ntraj):
    54595478            if coll is None:
    5460                 plt.plot(varvv[il], vardv[il], linekinds[il], label= linesn[il])
     5479                if ptf is None:
     5480                    plt.plot(varvv[il], vardv[il], linekinds[il], label= linesn[il])
     5481                else:
     5482                    plt.plot(varvv[il], vardv[il], linekinds[il])
     5483                    plt.plot(varvv[il][::ptf], vardv[il][::ptf], pointkinds[il],     \
     5484                      label= linesn[il])
    54615485            else:
    5462                 plt.plot(varvv[il], vardv[il], linekinds[il], label= linesn[il],\
    5463                   color=coll[il])
     5486                if ptf is None:
     5487                    plt.plot(varvv[il], vardv[il], linekinds[il], label= linesn[il], \
     5488                      color=coll[il])
     5489                else:
     5490                    plt.plot(varvv[il], vardv[il], linekinds[il], color=coll[il])
     5491                    plt.plot(varvv[il][::ptf], vardv[il][::ptf], pointkinds[il],     \
     5492                      label= linesn[il], color=coll[il])
    54645493
    54655494            minvv = np.min(varvv[il])
     
    54845513        for il in range(Ntraj):
    54855514            if coll is None:
    5486                 plt.plot(vardv[il], varvv[il], linekinds[il], label= linesn[il])
     5515                if ptf is None:
     5516                    plt.plot(vardv[il], varvv[il], linekinds[il], label= linesn[il])
     5517                else:
     5518                    plt.plot(vardv[il], varvv[il], linekinds[il])
     5519                    plt.plot(vardv[il][::ptf], varvv[il][::ptf], pointkinds[il],     \
     5520                      label= linesn[il])
    54875521            else:
    5488                 plt.plot(vardv[il], varvv[il], linekinds[il], label= linesn[il],\
    5489                   color=coll[il])
     5522                if ptf is None:
     5523                    plt.plot(vardv[il], varvv[il], linekinds[il], label= linesn[il], \
     5524                      color=coll[il])
     5525                else:
     5526                    plt.plot(vardv[il], varvv[il], linekinds[il], color=coll[il])
     5527                    plt.plot(vardv[il][::ptf], varvv[il][::ptf], linekinds[il],      \
     5528                      label= linesn[il], color=coll[il])
    54905529
    54915530            minvv = np.min(varvv[il])
Note: See TracChangeset for help on using the changeset viewer.