Changeset 1082 for trunk/UTIL


Ignore:
Timestamp:
Oct 28, 2013, 5:28:40 PM (11 years ago)
Author:
aslmd
Message:

planetoplot: a more explicit output for the inspect mode.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UTIL/PYTHON/planetoplot_v2/ppclass.py

    r1069 r1082  
    5050    print "**** INSPECT FILE",filename
    5151    test = netCDF4.Dataset(filename)
     52    #for obj in test.dimensions.values(): print obj
    5253    print "**** VARIABLES: ",test.variables.keys()
    53     for dim in test.dimensions.keys():
    54         output = "**** DIMENSION: "+str(dim)+" "+str(len(test.dimensions[dim]))
    55         try: output = output + " ----> "+str(test.variables[dim][0])+"  "+str(test.variables[dim][-1])
    56         except: pass
    57         print output ; output = ""
     54    findinlist(test,glob_listx,"**** FOUND X-AXIS ---> ")
     55    findinlist(test,glob_listy,"**** FOUND Y-AXIS ---> ")
     56    findinlist(test,glob_listz,"**** FOUND Z-AXIS ---> ")
     57    findinlist(test,glob_listt,"**** FOUND T-AXIS ---> ")
     58    print "**** ( according to settings in "+whereset+zefile+" )"
     59# -- function defined for the above function inspect
     60def findinlist(netcdfobj,extlist,message):
     61    found = False
     62    for c in extlist:
     63      if c in netcdfobj.variables.keys():
     64        found = True
     65        output = message+str(c)
     66        if c in netcdfobj.dimensions.keys():
     67          output = output+" ---- has "+str(len(netcdfobj.dimensions[c]))+" values"
     68          try: output = output + " ---- from "+str(netcdfobj.variables[c][0])+" to "+str(netcdfobj.variables[c][-1])
     69          except: pass
     70        print output ; output = ""
     71    if not found:
     72      print message+"not found. will simply use index."       
    5873
    5974# request a given attribute (and test if it is here)
Note: See TracChangeset for help on using the changeset viewer.