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


Ignore:
Timestamp:
Mar 23, 2015, 11:30:25 AM (10 years ago)
Author:
lfita
Message:

More correct search for values of the dimensions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/drawing.py

    r380 r381  
    378378        [dimvals/c]: list of [dimname]|[value] telling at which dimension of the
    379379          variable a given value is required (no dimension name, all the length)
    380         [dimx/yvn]: ',' list with the name of the variables with the values of the dimensions
     380        [dimx/yvn]: names of the variables with the values of the dimensions for the plot
    381381        [colorbar]: name of the color bar
    382382        [ckind]: kind of contours
     
    519519    odimyu = objdimy.getncattr('units')
    520520
    521     if len(objdimx.shape) <= 2:
    522 #        odimxv = objdimx[valshad.shape]
    523 #        odimyv = objdimy[valshad.shape]
    524         odimxv = objdimx[:]
    525         odimyv = objdimy[:]
    526 
    527     elif len(objdimx.shape) == 3:
    528 #        dimcut = [0, slice(0,valshad.shape[0]), slice(0,valshad.shape[1])]
    529 #        odimxv = objdimx[tuple(dimcut)]
    530 #        odimyv = objdimy[tuple(dimcut)]
    531         odimxv = objdimx[0,:]
    532         odimyv = objdimy[0,:]
    533     else:
    534         print errormsg
    535         print '  ' + fname + ': shape of dimension variable:', objdimx.shape,        \
    536           ' not ready!!'
    537         quit(-1)
     521# Getting only tat dimensions with coincident names
     522    dimnvx = objdimx.dimensions
     523    cutslice = []
     524    for idimn in objdimx.dimensions:
     525        if idimn == dimxvn:
     526            cutslice.append(slice(0,len(objsf.dimensions(idimn))))
     527        else:
     528            cutslice.append(0)
     529
     530    odimxv = objdimx[tuple(cutslice)]
     531
     532    dimnvy = objdimy.dimensions
     533    cutslice = []
     534    for idimn in objdimy.dimensions:
     535        if idimn == dimyvn:
     536            cutslice.append(slice(0,len(objsf.dimensions(idimn))))
     537        else:
     538            cutslice.append(0)
     539
     540    odimyv = objdimy[tuple(cutslice)]
     541
     542#    if len(objdimx.shape) <= 2:
     543#        odimxv = objdimx[:]
     544#        odimyv = objdimy[:]
     545#    elif len(objdimx.shape) == 3:
     546#        odimxv = objdimx[0,:]
     547#        odimyv = objdimy[0,:]
     548#    else:
     549#        print errormsg
     550#        print '  ' + fname + ': shape of dimension variable:', objdimx.shape,        \
     551#          ' not ready!!'
     552#        quit(-1)
    538553
    539554    if countlabelfmt == 'None':
Note: See TracChangeset for help on using the changeset viewer.