Changeset 639 in lmdz_wrf for trunk


Ignore:
Timestamp:
Sep 19, 2015, 11:50:23 AM (9 years ago)
Author:
lfita
Message:

Adding axes also cutting if a range on the dimensions is provided in 'plot_2D_shadow_time'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/drawing.py

    r638 r639  
    321321
    322322    if len(objdimx.shape) <= 2:
    323         odimxv = objdimx[:]
    324         odimyv = objdimy[:]
     323        odimxv0 = objdimx[:]
     324        odimyv0 = objdimy[:]
    325325
    326326    elif len(objdimx.shape) == 3:
    327         odimxv = objdimx[0,:]
    328         odimyv = objdimy[0,:]
     327        odimxv0 = objdimx[0,:]
     328        odimyv0 = objdimy[0,:]
    329329    else:
    330330        print errormsg
     
    339339    timelabel = timevals.split('|')[4].replace('!',' ')
    340340
     341# Dimensional values
     342    dimscut = {}
     343    for dv in dimvals:
     344        print dv
     345        dvn = dv.split('|')[0]
     346        dvv = dv.split('|')[1]
     347        if dvv.find('@') != -1:
     348            dimscut[dvn] = slice(int(dvv.split('@')[0]),int(dvv.split('@')[1]))
     349        else:
     350            if dvv == -1:
     351                dnL = len(objsf.dimensions[dvn])
     352                dimscut[dvn] = slice(0,dnL)
     353            else:
     354                dimscut[dvn] = slice(dvv,dvv)
     355
     356    if not dr.searchInlist(dimscut.keys(), vdimxn):
     357        dnL = len(objsf.dimensions[vdimxn])
     358        dimscut[vdimxn] = slice(0,dnL)
     359    if not dr.searchInlist(dimscut.keys(), vdimyn):
     360        dnL = len(objsf.dimensions[vdimyn])
     361        dimscut[vdimyn] = slice(0,dnL)
     362
    341363    if vdimxn == timename:
    342         odimxv = objsf.variables[vdimxn][:]
     364#        odimxv = objsf.variables[vdimxn][:]
     365        odimxv = objsf.variables[vdimxn][tuple(dimscut[vdimxn])]
    343366        odimxu = timelabel
    344367        timeaxis = 'x'
    345         odimyv = objsf.variables[vdimyn]
     368        odimyv = objsf.variables[vdimyn][tuple(dimscut[vdimyn])]
    346369        odimyu = odimyv.getncattr('units')
    347370        timepos, timelabels = drw.CFtimes_plot(odimxv, timeunit, timekind, timefmt)
    348371    elif vdimyn == timename:
    349         odimyv = objsf.variables[vdimyn][:]
     372        odimyv = objsf.variables[vdimyn][tuple(dimscut[vdimyn])]
    350373        odimyu = timelabel
    351374        timeaxis = 'y'
    352         odimxv = objsf.variables[vdimxn]
     375        odimxv = objsf.variables[vdimxn][tuple(dimscut[vdimxn])]
    353376        odimxu = odimxv.getncattr('units')
    354377        timepos, timelabels = drw.CFtimes_plot(odimyv, timeunit, timekind, timefmt)
Note: See TracChangeset for help on using the changeset viewer.