Changeset 396 in lmdz_wrf for trunk/tools/drawing.py


Ignore:
Timestamp:
Apr 8, 2015, 4:01:25 PM (10 years ago)
Author:
lfita
Message:

Fixing 'slice_variable' for that dimensions which are not given a value to slice

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/drawing.py

    r383 r396  
    519519    odimyu = objdimy.getncattr('units')
    520520
    521 # Getting only tat dimensions with coincident names
     521# Getting only that dimensions with coincident names
    522522    dimnvx = objdimx.dimensions
    523523    cutslice = []
     
    580580
    581581    if mapvalue == 'None': mapvalue = None
    582 
    583     print '  ' + fname + ': Lluis shapes valshad:',valshad.shape,'valcont:',valcont.shape
    584582
    585583    drw.plot_2D_shadow_contour(valshad, valcont, vnamesfig, odimxv, odimyv, odimxu,  \
     
    764762    if vdimxn == timename:
    765763        timevals = objsf.variables[vdimxn][:]
     764        timedims = objsf.variables[vdimxn].dimensions
    766765        dimt = 'x'
    767766        ovalaxis = objsf.variables[vdimyn]
     
    769768    elif vdimyn == timename:
    770769        timevals = objsf.variables[vdimyn][:]
     770        timedims = objsf.variables[vdimyn].dimensions
    771771        dimt = 'y'
    772772        ovalaxis = objsf.variables[vdimxn]
     
    779779    timepos, timelabels = drw.CFtimes_plot(timevals, timeunit, timekind, timefmt)
    780780
    781     if len(ovalaxis.shape) <= 2:
    782         ovalaxisv = ovalaxis[:]
    783 
    784     elif len(ovalaxis.shape) == 3:
    785         ovalaxisv = ovalaxis[0,:]
    786     else:
    787         print errormsg
    788         print '  ' + fname + ': shape of dimension variable:', ovalaxis.shape,       \
    789           ' not ready!!'
    790         quit(-1)
     781# Getting only that dimensions with coincident names
     782    dimnvx = ovalaxis.dimensions
     783
     784    cutslice = []
     785    for idimn in dimsshad:
     786        found = False
     787        for dimsn in dimnvx:
     788            if idimn == dimsn:
     789                cutslice.append(slice(0,len(objsf.dimensions[idimn])))
     790                found = True
     791        if not found: cutslice.append(0)
     792
     793    ovalaxisv = ovalaxis[tuple(cutslice)]
     794
     795##    if len(ovalaxis.shape) <= 2:
     796##        ovalaxisv = ovalaxis[:]
     797
     798##    elif len(ovalaxis.shape) == 3:
     799##        ovalaxisv = ovalaxis[0,:]
     800##    else:
     801##        print errormsg
     802##        print '  ' + fname + ': shape of dimension variable:', ovalaxis.shape,       \
     803##          ' not ready!!'
     804##        quit(-1)
    791805
    792806    if countlabelfmt == 'None':
     
    19221936    dimxv = dimtvalues[0:dimtsqx]
    19231937    dimyv = dimtvalues[0:dimt:dimtsqx]
    1924 
    1925     print 'Lluis lens: dimxv, dimyv:',len(dimxv), len(dimyv)
    19261938
    19271939    dimn = ['time','time']
Note: See TracChangeset for help on using the changeset viewer.