Changeset 1589 in lmdz_wrf for trunk


Ignore:
Timestamp:
Jul 3, 2017, 6:02:47 PM (8 years ago)
Author:
lfita
Message:

Adding new functionality of grid-reshape in `draw_2D_shad_time'

Location:
trunk/tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/documentation/plotting/2Dshad_time.html

    r1403 r1589  
    1313    <DIV CLASS="valimg">
    1414      Plotting a 2D field with shading where one of the acis has temporal values
    15       <IMG WIDTH="100%" SRC="figs/hurs_Blues_auto_time.png"></IMG>
     15      <TABLE>
     16        <TR><TD>y-values following data</TD><TD>y-values fixed-pixel size</TD></TR>
     17        <TR><TD><IMG WIDTH="100%" SRC="figs/ta_valley_data-grid.png"></IMG></TD><TD><IMG WIDTH="100%" SRC="figs/ta_valley_fixpixel-grid.png"></IMG></TD></TR>
     18      </TABLE>
    1619    </DIV>
    1720    <DIV CLASS="valhelp">
    1821    draw_2D_shad_time(ncfile, values, varn)<BR>
    1922    &nbsp;&nbsp;ncfile= file to use<BR>
    20     &nbsp;&nbsp;values=[vnamefs]~[dimvals]~[dimxvn]~[dimyvn]~[dimvfmt]~[colorbarvals]~[sminv],[smaxv]~[figt]~<BR>
     23    &nbsp;&nbsp;values=[vnamefs]~[dimvals]~[dimxvn]~[dimyvn]~[dimvfmt]~[colorbarvals]~[sminv],[smaxv]~[gridkind]~[figt]~<BR>
    2124    &nbsp;&nbsp;[kindfig]~[reverse]~[timevals]~[close]<BR>
    2225    &nbsp;&nbsp;&nbsp;&nbsp;[vnamefs]: Name in the figure of the variable to be shaded<BR>
     
    4649    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'Spercentile@val': for -xtrm,xtrm where xtrm = np.min(median-percentile_(val),<BR>
    4750    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;percentile_(100-val)-median)<BR>
     51    &nbsp;&nbsp;&nbsp;&nbsp;[gridkind]= [gridxk],[gridyk] kind of grid along x and y axis<BR>
     52    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'data': size pixel along the given axis change according to the values along the axis<BR>
     53    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'fixpixel': size pixel along the given axis does not change <BR>
    4854    &nbsp;&nbsp;&nbsp;&nbsp;[figt]: title of the figure ('|' for spaces)<BR>
    4955    &nbsp;&nbsp;&nbsp;&nbsp;[kindfig]: kind of figure<BR>
    50     &nbsp;&nbsp;&nbsp;&nbsp;[reverse]: Transformation of the values<BR>
     56    &nbsp;&nbsp;&nbsp;&nbsp;[reverse]: '|' list of transformations to apply on the values<BR>
    5157    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* 'transpose': reverse the axes (x-->y, y-->x)<BR>
    5258    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;* 'flip'@[x/y]: flip the axis x or y<BR>
     
    6773    </DIV>
    6874    <DIV CLASS="valins">
    69       $ python ${pyHOME}/drawing.py -o draw_2D_shad_time -f wrfout_d01_2001-11-11_00:00:00 -S 'hurs~west_east|-1,south_north|27,Time|-1~XLONG~WRFtime~auto~Blues,auto,auto~Srange,Srange~tas|evolution|at|south_north=27~png~None~WRFtime|hours!since!1949-12-01|exct,1,h|$%d^{%H}$|date!($[DD]^{[HH]}$)~True' -v Q2
     75      * Data-relative y-axis <BR>
     76      &nbsp;&nbsp;python ${pyHOME}/drawing.py -o draw_2D_shad_time -f ERAI_pl201507_130.nc -S 'ta~lon|52,lat|30,time|76@100~lev~time~auto~rainbow,auto,vertical~200.,310.~data,data~ta|in|valley|from|ERA-Interim~png~transpose~time|hours!since!2015-07-01!00:00:00|exct,12,h|$%d^{%H}$|date!($[DD]^{[HH]}$)~True' -v t<BR>
     77      * Fixel pixel size y-axis <BR>
     78      &nbsp;&nbsp;python ${pyHOME}/drawing.py -o draw_2D_shad_time -f ERAI_pl201507_130.nc -S 'ta~lon|52,lat|30,time|76@100~lev~time~auto~rainbow,auto,vertical~200.,310.~data,fixpixel~ta|in|valley|from|ERA-Interim~png~transpose~time|hours!since!2015-07-01!00:00:00|exct,12,h|$%d^{%H}$|date!($[DD]^{[HH]}$)~True' -v t<BR>
    7079    </DIV>
    7180  </BODY>
  • trunk/tools/drawing.py

    r1578 r1589  
    2121## e.g. # drawing.py -o draw_2D_shad -f wrfout_d01_2001-11-11_00:00:00 -S 'tas:west_east|-1,south_north|-1,Time|2:XLONG:XLAT:auto:rainbow,auto,auto:Srange,Srange:tas|at|2001-11-11|02|UTC:png:None:cyl,l:True' -v T2
    2222## e.g. # drawing.py -o draw_2D_shad_time -f wrfout_d01_2001-11-11_00:00:00 -S 'hurs~west_east|-1,south_north|27,Time|-1~XLONG~WRFtime~auto~Blues,auto,auto~Srange,Srange~tas|evolution|at|south_north=27~png~None~WRFtime|hours!since!1949-12-01|exct,1,h|$%d^{%H}$|date!($[DD]^{[HH]}$)~True' -v Q2
     23## e.g. #drawing.py -o draw_2D_shad_time -f ERAI_pl201507_130.nc -S 'ta~lon|52,lat|30,time|76@100~lev~time~auto~rainbow,auto,vertical~200.,310.~data,data~ta|in|valley|from|ERA-Interim~png~transpose~time|hours!since!2015-07-01!00:00:00|exct,12,h|$%d^{%H}$|date!($[DD]^{[HH]}$)~True' -v t
     24## e.g. #drawing.py -o draw_2D_shad_time -f ERAI_pl201507_130.nc -S 'ta~lon|52,lat|30,time|76@100~lev~time~auto~rainbow,auto,vertical~200.,310.~data,fixpixel~ta|in|valley|from|ERA-Interim~png~transpose~time|hours!since!2015-07-01!00:00:00|exct,12,h|$%d^{%H}$|date!($[DD]^{[HH]}$)~True' -v t
    2325## e.g. # drawing.py -o draw_2D_shad_cont -f wrfout_d01_2001-11-11_00:00:00 -S 'huss,tas:west_east|-1,south_north|-1,Time|2:Time|2:XLONG:XLAT:auto:Blues,auto,auto:fixc,r:%3g:Srange,Srange:260,300,9:huss|&|tas|at|2001-11-11|02|UTC:png:None:cyl,c:True' -v Q2,T2
    2426## e.g. # drawing.py -o draw_2D_shad_cont_time -f wrfout_d01_2001-11-11_00:00:00 -S 'hfls,tas;west_east|-1,south_north|27,Time|-1;south_north|27;XLONG;WRFtime;auto;BuPu,auto,auto;fixc,y;%3g;Srange,Srange;260,300,9;huss|&|tas|evolution|at|south_north=27;png;None;WRFtime|hours!since!1949-12-01|exct,1,h|$%d^{%H}$|date!($[DD]^{[HH]}$);True' -v LH,T2
     
    306308    draw_2D_shad_time(ncfile, values, varn)
    307309      ncfile= file to use
    308       values=[vnamefs]~[dimvals]~[dimxvn]~[dimyvn]~[dimvfmt]~[colorbarvals]~[sminv],[smaxv]~[figt]~
     310      values=[vnamefs]~[dimvals]~[dimxvn]~[dimyvn]~[dimvfmt]~[colorbarvals]~[sminv],[smaxv]~[gridkind]~[figt]~
    309311       [kindfig]~[reverse]~[timevals]~[close]
    310312        [vnamefs]: Name in the figure of the variable to be shaded
     
    339341          'Spercentile@val': for -xtrm,xtrm where xtrm = np.min(median-percentile_(val),
    340342             percentile_(100-val)-median)
     343        [gridkind]= [gridxk],[gridyk] kind of grid along x and y axis
     344          'data': size pixel along the given axis change according to the values along the axis
     345          'fixpixel': size pixel along the given axis does not change
    341346        [figt]: title of the figure ('|' for spaces)
    342347        [kindfig]: kind of figure
    343         [reverse]: Transformation of the values
     348        [reverse]: '|' list of transformations to apply to the values
    344349          * 'transpose': reverse the axes (x-->y, y-->x)
    345350          * 'flip'@[x/y]: flip the axis x or y
     
    369374
    370375    farguments = '[vnamefs]~[dimvals]~[dimxvn]~[dimyvn]~[dimvfmt]~[colorbarvals]~' + \
    371       '[sminv],[smaxv]~[figt]~[kindfig]~[reverse]~[timevals]~[close]'
     376      '[sminv],[smaxv]~[gridkind]~[figt]~[kindfig]~[reverse]~[timevals]~[close]'
    372377    drw.check_arguments(fname,values,farguments,'~')
    373378
     
    379384    colorbarvals = values.split('~')[5]
    380385    shadminmax = values.split('~')[6]
    381     figtitle = values.split('~')[7].replace('|',' ')
    382     figkind = values.split('~')[8]
    383     revals = values.split('~')[9]
    384     timevals = values.split('~')[10]
    385     close = gen.Str_Bool(values.split('~')[11])
     386    gridkind = values.split('~')[7]
     387    figtitle = values.split('~')[8].replace('|',' ')
     388    figkind = values.split('~')[9]
     389    revals = values.split('~')[10]
     390    timevals = values.split('~')[11]
     391    close = gen.Str_Bool(values.split('~')[12])
    386392
    387393    ncfiles = ncfile
     
    495501
    496502    if vdimxn == timename:
    497         odimxv = odxv
    498         odimxu = timelabel
     503        odimtv = odxv
     504        odimtu = timelabel
    499505        timeaxis = 'x'
    500         odimyv = odyv
    501         odimyu = objdimy.getncattr('units')
    502         timepos, timelabels = drw.CFtimes_plot(odxv, timeunit, timekind, timefmt)
     506        odimvv = odyv
     507        odimvu = objdimy.getncattr('units')
    503508    elif vdimyn == timename:
    504         odimyv = odyv
    505         odimyu = timelabel
     509        odimtv = odyv
     510        odimtu = timelabel
    506511        timeaxis = 'y'
    507         odimxv = odxv
    508         odimxu = objdimx.getncattr('units')
    509         timepos, timelabels = drw.CFtimes_plot(odyv, timeunit, timekind, timefmt)
     512        odimvv = odxv
     513        odimvu = objdimx.getncattr('units')
    510514    else:
    511515        print errormsg
    512516        print '  ' + fname + ": time variable '" + timename + "' not found!!"
    513517        quit(-1)
     518    timepos, timelabels = drw.CFtimes_plot(odimtv, timeunit, timekind, timefmt)
    514519
    515520    shading_nx = []
     
    531536    vaxis = [xstyl, xaxf, Nxax, xaxor]
    532537
     538    # kind of grid-pixels
     539    [gridxk, gridyk] = gridkind.split(',')
     540
    533541    if revals == 'None':
    534542        revals = None
    535543
    536     drw.plot_2D_shadow_time(valshad, vnamesfig, odxv, odyv, odimxu, odimyu,          \
    537       dimnamesv, vaxis, colormapv, shading_nx, varunits, figtitle, figkind, revals,  \
    538       timeaxis, timepos, timelabels, close)
     544    drw.plot_2D_shadow_time(valshad, vnamesfig, odimvv, odimtv, odimvu, dimnamesv,   \
     545      vaxis, colormapv, shading_nx, varunits, gridxk, gridyk, figtitle, figkind,     \
     546      revals, timeaxis, timepos, timelabels, close)
    539547
    540548    return
  • trunk/tools/drawing_tools.py

    r1588 r1589  
    44694469      vtit= title of the figure
    44704470      kfig= kind of figure (jpg, pdf, png)
    4471       reva=
     4471      reva= '|' for transformations to apply
    44724472        * 'transpose': reverse the axes (x-->y, y-->x)
    44734473        * 'flip'@[x/y]: flip the axis x or y
Note: See TracChangeset for help on using the changeset viewer.