Changeset 871 for trunk/UTIL


Ignore:
Timestamp:
Feb 1, 2013, 6:10:25 AM (12 years ago)
Author:
aslmd
Message:

UTIL PYTHON. Corrected a bug in getdimfromvar so that it works quite in all the cases now.

Location:
trunk/UTIL/PYTHON
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/UTIL/PYTHON/myplot.py

    r865 r871  
    732732def getdimfromvar (nc):
    733733    varinfile = nc.variables.keys()
    734     dim = nc.variables[varinfile[-1]].shape ## usually the last variable is 4D or 3D
    735     return dim
     734    sav = [0.]
     735    for var in varinfile:
     736        dim = nc.variables[var].shape ## usually the last variable is 4D or 3D
     737        if len(dim) > len(sav): sav=dim
     738    return sav
    736739
    737740## FROM COOKBOOK http://www.scipy.org/Cookbook/SignalSmooth
     
    814817    elif 'u' in varinfile:  [uchar,vchar] = ['u','v']   #; print "this is GCM file"
    815818    elif 'vitu' in varinfile:  [uchar,vchar] = ['vitu','vitv']   #; print "this is GCM v5 file"
     819    elif 'ucomp' in varinfile:  [uchar,vchar] = ['ucomp','vcomp']
    816820    ### you can add choices here !
    817821    else:                   [uchar,vchar] = ['not found','not found']
     
    11181122             "TSK":          "RdBu_r",\
    11191123             "QH2O":         "PuBu",\
     1124             "PSFC":         "RdYlBu_r",\
    11201125             "USTM":         "YlOrRd",\
    11211126             "WIND":         "YlOrRd",\
     
    12351240        "Southern_Hemisphere":   [[-90., 60.],[-180., 180.]],\
    12361241        "Northern_Hemisphere":   [[-60., 90.],[-180., 180.]],\
     1242        "Tharsis_alt":           [[-30., 60.],[ 190., 350.]],\
    12371243        "Tharsis":               [[-30., 60.],[-170.,- 10.]],\
    12381244        "Whole_No_High":         [[-60., 60.],[-180., 180.]],\
     
    12491255        "Xanadu":                [[-40., 20.],[  40., 120.]],\
    12501256        "Hyperboreae":           [[ 80., 87.],[- 70.,- 10.]],\
     1257        "VM_alt":                [[-15.,  0.],[ 270., 300.]],\
    12511258              }
    12521259    if area not in list:   area = "Whole"
  • trunk/UTIL/PYTHON/planetoplot.py

    r866 r871  
    228228          ### --> add a line here if your reference is not present
    229229          else:
    230               print "No altitude found. Try to build a simple axis." ; dadim = getdimfromvar(nc)
     230              dadim = getdimfromvar(nc) ; print "No altitude found. Try to build a simple axis.",dadim
    231231              if   len(dadim) == 4:  print "-- 4D field. Assume z is dim 2." ; vert = np.arange(dadim[-3])
    232232              elif len(dadim) == 3:  print "-- 3D field. Assume z is dim 1." ; vert = [0.]
Note: See TracChangeset for help on using the changeset viewer.