Changeset 668 in lmdz_wrf


Ignore:
Timestamp:
Jan 15, 2016, 11:19:46 AM (9 years ago)
Author:
lfita
Message:

Adding new variables to `draw_points_lonlat'

Location:
trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/drawing.py

    r665 r668  
    2525## e.g. # drawing.py -o draw_points -S 'tslist.dat,#,3,2,1:SuperStorm|sfc|stations:cyl,i:labelled,8,black:auto:None:0:png:stations_loc' -f $HOME'/etudes/domains/WRFdynamicoSENS_SuperStorm/geo_em_west_east_B25-E180-I1_south_north_B160-E262-I1.nc,XLONG_M,XLAT_M,HGT_M,Time|0,height,0.,1500.,terrain,m'
    2626## e.g. # drawing.py -o draw_ptZvals -f geo_v2_2012102123_RR1.nc -S 'pracc:lon,lat:o:80:2,42,7,47,:values!of!values:Blues:cyl,l:pdf' -v pr
    27 ## e.g. # drawing.py -f carteveg5km.nc -o draw_points_lonlat -S 'longitude:latitude:pdf:points!veget|type:green:.:None:0:legend'
     27## e.g. # drawing.py -f carteveg5km.nc -o draw_points_lonlat -S 'longitude:latitude:pdf:points!veget|type:green:.:0.5:None:0:legend'
    2828
    2929main = 'drawing.py'
     
    24402440    """ Function to plot a series of lon/lat points
    24412441     filen= name of the file
    2442      values= [lonvarname]:[latvarname]:[gkind]:[gtit]:[ptcolor]:[pttype]:[labels]:[locleg]:[figureK]
     2442     values= [lonvarname]:[latvarname]:[gkind]:[gtit]:[ptcolor]:[pttype]:[ptsize]:[labels]:[locleg]:[figureK]
    24432443       [lonvarname]: name of the variable longitude
    24442444       [latvarname]: name of the variable latitude
     
    24472447       [ptcolor]: color of the points ('auto', for "red")
    24482448       [pttype]: type of point
     2449       [ptsize]: size of point
    24492450       [labels]: ',' list of labels to use
    24502451       [locleg]: location of the legend (0, automatic)
     
    24642465
    24652466    expectargs = '[lonvarname]:[latvarname]:[gkind]:[gtit]:[ptcolor]:[pttype]:' +    \
    2466       '[labels]:[locleg]:[figureK]'
     2467      '[ptsize]:[labels]:[locleg]:[figureK]'
    24672468 
    24682469    drw.check_arguments(fname,len(expectargs.split(':')),values,':',                 \
     
    24752476    pointcolor = values.split(':')[4]
    24762477    pointtype = values.split(':')[5]
    2477     labelsv = values.split(':')[6]
    2478     loclegend = values.split(':')[7]
    2479     figureK = values.split(':')[8]
     2478    pointsize = np.float(values.split(':')[6])
     2479    labelsv = values.split(':')[7]
     2480    loclegend = values.split(':')[8]
     2481    figureK = values.split(':')[9]
    24802482
    24812483    fname = 'points_lonlat'
     
    24832485    onc = NetCDFFile(filen, 'r')
    24842486    if not onc.variables.has_key(lonname):
    2485         print errmsg
     2487        print errormsg
    24862488        print fname + ": file '" + filen + "' does not have longitudes '" + lonname +\
    24872489          "' !!"
    24882490        quit(-1)
    24892491    if not onc.variables.has_key(lonname):
    2490         print errmsg
     2492        print errormsg
    24912493        print fname + ": file '" + filen + "' does not have longitudes '" + lonname +\
    24922494          "' !!"
     
    24962498    olat = onc.variables[latname]
    24972499
     2500    Ndimlon = len(olon.shape)
     2501    if Ndimlon == 1:
     2502        lonvals = olon[:]
     2503        latvals = olat[:]
     2504    elif Ndimlon == 2:
     2505        lonvals = olon[:].flatten()
     2506        latvals = olat[:].flatten()
     2507    elif Ndimlon == 3:
     2508        lonvals = olon[1,:,:].flatten()
     2509        latvals = olat[1,:,:].flatten()
     2510# Playing for Anna
     2511#        lonvals = olon[:].flatten()
     2512#        latvals = olat[:].flatten()
     2513    elif Ndimlon == 4:
     2514        lonvals = olon[1,0,:,:].flatten()
     2515        latvals = olat[1,0,:,:].flatten()
     2516    else:
     2517        print errormsg
     2518        print '  ' + fname + ': longitude size:',len(olon),' not ready!!'
     2519        quit(-1)
     2520
    24982521    if labelsv == 'None':
    24992522        labels = None
     
    25012524        labels = labelsv.split(',')
    25022525
    2503     drw.plot_list_points(olon[:], olat[:], gtit, figureK, pointcolor, pointtype,     \
    2504       labels, loclegend, kindfigure, fname)
     2526    drw.plot_list_points(lonvals, latvals, lonname, latname, gtit, figureK, pointcolor, pointtype,    \
     2527      pointsize, labels, loclegend, kindfigure, fname)
    25052528
    25062529    onc.close()
  • trunk/tools/drawing_tools.py

    r665 r668  
    27632763    return
    27642764
    2765 def plot_list_points(xval, yval, vtit, figk, color, ptk, labels, lloc, kfig, figname):
     2765def plot_list_points(xval, yval, varxn, varyn, vtit, figk, color, ptk, pts, labels, lloc, kfig, figname):
    27662766    """ plotting points
    27672767      [x/yval]: x,y values to plot
     2768      var[x/y]n: names of the x,y variables
    27682769      vtit= title of the graph ('|' for spaces)
    27692770      figK= kind of figure
     
    27722773      color= color for the points/labels ('auto', for "red")
    27732774      ptk= kind of point
     2775      pts= point size
    27742776      labels= list of labels for the points (None, no labels)
    27752777      lloc = localisation of the legend
     
    27922794        for iv in range(len(xval)):
    27932795#            print iv,xval[iv],yval[iv],labels[iv],ptkinds[N7pts]
    2794             plt.plot(xval[iv],yval[iv], ptk,label=labels[iv])
     2796            plt.plot(xval[iv],yval[iv], ptk, markersize=pts, label=labels[iv])
    27952797
    27962798        if figk[0:8] == 'labelled':
     
    28042806
    28052807    else:
    2806         plt.plot(xval, yval, ptk, color=ptcol)
     2808        plt.plot(xval, yval, ptk, markersize=pts, color=ptcol)
     2809
     2810    plt.xlabel(varxn)
     2811    plt.ylabel(varyn)
    28072812
    28082813    graphtit = vtit.replace('_','\_').replace('&','\&')
Note: See TracChangeset for help on using the changeset viewer.