Changeset 655 in lmdz_wrf for trunk


Ignore:
Timestamp:
Oct 15, 2015, 11:01:51 AM (9 years ago)
Author:
lfita
Message:

Adding legend on `draw_topo_geogrid_boxes'
Fixing typo on legend position in all figures

Location:
trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/drawing.py

    r651 r655  
    1313## e.g. # drawing.py -o draw_2D_shad_line -f 'mean_dtcon-pluc-pres_lat.nc,mean_dtcon-pluc-pres_lat.nc' -S 'dtcon,prc:bottom_top|-1,south_north|-1:latmean:presmean:seismic,k:-5.,5.:monthly|dtcon|&|prc:pdf:flip@y:None:True' -v 'dtconmean,prcmean'
    1414## e.g. # drawing.py -f 'geo_em.d02.nc' -o draw_topo_geogrid -S '0.,3000.:None:FF_3dom d02:png:cyl,i'
    15 ## e.g. # drawing.py -o draw_topo_geogrid_boxes -S '0.,3000.:None:FF domains:pdf:lcc,i:d01,d02,d03' -f geo_em.d01.nc,geo_em.d02.nc,geo_em.d03.nc
     15## e.g. # drawing.py -o draw_topo_geogrid_boxes -S '0.,3000.:None:FF domains:pdf:lcc,i:d01,d02,d03:0' -f geo_em.d01.nc,geo_em.d02.nc,geo_em.d03.nc
    1616## e.g. # drawing.py -o draw_trajectories -f 'WRF/control/trajectory.dat@-1@/home/lluis/etudes/domains/WL_HyMeX_HighRes_C/geo_em.d03.nc#XLONG_M#XLAT_M,WRF_LMDZ/wlmdza/trajectory.dat@-1@/home/lluis/etudes/domains/WL_HyMeX_C/geo_em.d01.nc#XLONG_M#XLAT_M,WRF_LMDZ/wlmdzb/trajectory.dat@-1@/home/lluis/etudes/domains/WL_HyMeX_C/geo_em.d01.nc#XLONG_M#XLAT_M,WRF_LMDZ/wlmdzb_ii/trajectory.dat@-1@/home/lluis/etudes/domains/WL_HyMeX_C/geo_em.d01.nc#XLONG_M#XLAT_M' -S '$WRF_{CRM}$,$LMDZ_{AR4.0}$,$LMDZ_{NPv3.1}$,$LMDZ_{NPv3.1b}$|None|medicane trajectories|pdf|cyl,i' -v obs/trajectory.dat,satellite,-1
    1717## e.g. # drawing.py -o draw_vals_trajectories -f WRF_LMDZ/wlmdza/tevolboxtraj_T2.nc,WRF_LMDZ/wlmdzb/tevolboxtraj_T2.nc,WRF/control/tevolboxtraj_T2.nc -S 'mean:-1:$WRF_{CRM}$,$LMDZ_{AR4.0}$,$LMDZ_{NPv3.1}$@4:tas:time|($[DD]^[HH]$):exct,6,h:$%d^{%H}$:trajectory|following|mean:pdf' -v T2
     
    14121412    draw_topo_geogrid_boxes(ncfile, values)
    14131413      ncfiles= ',' list of geo_em.d[nn].nc files to use (fisrt as topographyc reference)
    1414       values= [minTopo],[maxTopo]:[lonlatL]:[title]:[graphic_kind]:[mapvalues]:[labels]
     1414      values= [minTopo],[maxTopo]:[lonlatL]:[title]:[graphic_kind]:[mapvalues]:[labels]:[legloc]
    14151415        [min/max]Topo: minimum and maximum values of topography to draw
    14161416        lonlatL: limits of longitudes and latitudes [lonmin, latmin, lonmax, latmax] or None
     
    14281428            * 'h', high
    14291429            * 'f', full
     1430        legloc= location of the legend (0, autmoatic)
     1431          1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right',
     1432          5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center',
     1433          9: 'upper center', 10: 'center'
    14301434        labels= labels to write in the graph
    14311435    """
     
    14601464    mapvalues = values.split(':')[4]
    14611465    labels = values.split(':')[5]
     1466    legloc = int(values.split(':')[6])
    14621467
    14631468    ncfile = ncfiles.split(',')[0]
     
    15091514
    15101515    drw.plot_topo_geogrid_boxes(topography, Xboxlines, Yboxlines, boxlabels,         \
    1511       objlon0, objlat0, mintopo, maxtopo, lonlatL, grtit, kindfig, mapvalues, True)
     1516      objlon0, objlat0, mintopo, maxtopo, lonlatL, grtit, kindfig, mapvalues, legloc,\
     1517      True)
    15121518
    15131519    objdomf.close()
     
    16951701        [vartit]: name of the variable in the graph
    16961702        [title]: title of the plot ('|' for spaces)
    1697         [locleg]: location of the legend (-1, autmoatic)
     1703        [locleg]: location of the legend (0, autmoatic)
    16981704          1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right',
    16991705          5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center',
     
    18241830                'l': milisecond
    18251831           [tfmt]; desired format
    1826         [locleg]: location of the legend (-1, autmoatic)
     1832        [locleg]: location of the legend (0, autmoatic)
    18271833          1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right',
    18281834          5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center',
     
    18931899    if points0.find(',') != -1:
    18941900        points = points0.split(',')
     1901        for ip in range(len(points)):
     1902            points[ip] = points[ip] + '-'
    18951903    elif points0 == 'None':
    18961904        points = None
     
    18981906        points = []
    18991907        for ip in range(Nfiles):
    1900             points.append(points0)
     1908            points.append(points0+'-')
    19011909
    19021910# Getting values
     
    20292037    timepos, timelabels = drw.CFtimes_plot(tvals, timeunit, timekind, timefmt)
    20302038
    2031     if leglabels.find(',') != -1:
    2032       drw.plot_lines_time(dimvalues, varvalues, valuesaxis, dimtit,                  \
    2033         leglabels.split(','), vartit, varunits, timepos, timelabels, title, locleg,  \
    2034         graphk, collines, points)
    2035     else:
    2036       drw.plot_lines_time(dimvalues, varvalues, valuesaxis, dimtit,                  \
    2037         None, vartit, varunits, timepos, timelabels, title, locleg, graphk, collines)
     2039    if leglabels != 'None':
     2040        legvals = leglabels.split(',')
     2041    else:
     2042        legvals = None
     2043
     2044    drw.plot_lines_time(dimvalues, varvalues, valuesaxis, dimtit, legvals, vartit,   \
     2045      varunits, timepos, timelabels, title, locleg, graphk, collines, points)
     2046
    20382047    return
    20392048
     
    24422451      [timefmt]: format of the time labels
    24432452      [title]: title of the graphic ('|' for spaces)
    2444       [locleg]: location of the legend (-1, autmoatic)
     2453      [locleg]: location of the legend (0, automatic)
    24452454        1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right',
    24462455        5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center',
     
    27062715      [Tint]: [Tbeg]@[Tend] or None, interval of time to plot or -1 for all the times
    27072716      [labels]: ',' separated list of labels for the legend
    2708       [locleg]: location of the legend (-1, autmoatic)
     2717      [locleg]: location of the legend (0, automatic)
    27092718        1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right',
    27102719        5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center',
  • trunk/tools/drawing_tools.py

    r652 r655  
    9595    dateD = np.zeros((3), dtype=int)
    9696    timeT = np.zeros((3), dtype=int)
     97
     98    print 'Lluis:',StringDT
     99#    quit()
    97100
    98101    dateD[0] = int(StringDT[0:4])
     
    19011904        Srefdate = txtunits[Ntxtunits - 2]
    19021905
     1906    print 'Lluis Srefdate:',Srefdate, 'txtunits:',txtunits,'units:',units
    19031907    if not trefT == -1:
    19041908#        print '  ' + fname + ': refdate with time!'
     
    24522456
    24532457def plot_TimeSeries(valtimes, vunits, tunits, hfileout, vtit, ttit, tkind, tformat,  \
    2454   tit, linesn, lloc, kfig):
     2458  tit, linesn, lloc, kfig,coll,ptl):
    24552459    """ Function to draw time-series
    24562460      valtimes= list of arrays to plot [vals1[1values, 1times], [...,valsM[Mvals,Mtimes]])
     
    24692473      tit= title of the graph
    24702474      linesn= list of values fot the legend
    2471       lloc= location of the legend (-1, autmoatic)
     2475      lloc= location of the legend (0, autmoatic)
    24722476        1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right',
    24732477        5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center',
    24742478        9: 'upper center', 10: 'center'
    24752479      kfig= type of figure: jpg, png, pds, ps
     2480      coll= ',' list of colors for the lines, None for automatic, single
     2481          value all the same
     2482      ptl= ',' list of type of points for the lines, None for automatic, single
     2483          value all the same
    24762484    """
    24772485    fname = 'plot_TimeSeries'
     
    24822490        quit()
    24832491
    2484 
     2492    Nlines = len(linesn)
    24852493# Canging line kinds every 7 lines (end of standard colors)
    2486     linekinds=['.-','x-','o-']
    2487 
    2488     Nlines = len(valtimes)
     2494    linekinds = []
     2495    if ptl is None:
     2496        linekindsauto=['.-','x-','o-']
     2497        for ptype in range(4):
     2498            for ip in range(7):
     2499                linekinds.append(linekindsauto[ptype])
     2500    else:
     2501        if len(ptl) > 1:
     2502            linekinds = ptl
     2503        else:
     2504            for il in range(Nlines):
     2505                linekinds.append(ptl+'-')
    24892506
    24902507    Nvalues = []
     
    25222539            if vmin < ymin: ymin = vmin
    25232540            if vmax > ymax: ymax = vmax
     2541        print il,'Lluis: ymin;',ymin,'ymax;',ymax
    25242542
    25252543    dx = np.max(Ntimes)
     
    25432561        if vtit == 'ps':
    25442562            array[0,:] = np.where(array[0,:] < 98000., None, array[0,:])
    2545         plt.plot(array[1,:],array[0,:], linekinds[N7lines], label= linesn[il])
    2546         if il == 6: N7lines = N7lines + 1
     2563
     2564        if coll is None:
     2565            plt.plot(array[1,:],array[0,:], linekinds[il], label= linesn[il])
     2566        else:
     2567            plt.plot(array[1,:],array[0,:], linekinds[il], label= linesn[il],   \
     2568              color=coll[il])
    25472569
    25482570    timevals = np.arange(xmin,xmax)*1.
    25492571
     2572    print 'Lluis tunits:',tunits
    25502573    tpos, tlabels = CFtimes_plot(timevals, tunits, tkind, tformat)
    25512574
     
    33093332
    33103333def plot_topo_geogrid_boxes(varv, boxesX, boxesY, boxlabels, olon, olat, mint, maxt, \
    3311   lonlatLims, gtit, kfig, mapv, closeif):
     3334  lonlatLims, gtit, kfig, mapv, gloc, closeif):
    33123335    """ plotting geo_em.d[nn].nc topography from WPS files
    33133336    plot_topo_geogrid(domf, mint, maxt, gtit, kfig, mapv)
     
    33313354          * 'h', high
    33323355          * 'f', full
     3356      gloc= location of the legend (0, autmoatic)
     3357        1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right',
     3358        5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center',
     3359        9: 'upper center', 10: 'center'
    33333360      closeif= Boolean value if the figure has to be closed
    33343361    """
     
    34543481
    34553482    plt.title(graphtit)
    3456     plt.legend(loc=0)
     3483    plt.legend(loc=gloc)
    34573484   
    34583485    output_kind(kfig, figname, closeif)
     
    51955222      vunit= units of the vaxis
    51965223      gtit= main title
    5197       gloc= location of the legend (-1, autmoatic)
     5224      gloc= location of the legend (0, autmoatic)
    51985225        1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right',
    51995226        5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center',
     
    52805307      tlabs= labels of the time ticks
    52815308      gtit= main title
    5282       gloc= location of the legend (-1, autmoatic)
     5309      gloc= location of the legend (0, autmoatic)
    52835310        1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right',
    52845311        5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center',
Note: See TracChangeset for help on using the changeset viewer.