Changeset 929 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
Jun 23, 2016, 12:51:47 PM (8 years ago)
Author:
lfita
Message:

'gen' staff and improving 'ivattrs'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/nc_var_tools.py

    r922 r929  
    16081608  fname = 'idims'
    16091609
     1610  if ncfile == 'h':
     1611      print fname + '_____________________________________________________________'
     1612      print idims.__doc__
     1613      quit()
     1614
    16101615  if not os.path.isfile(ncfile):
    16111616    print errormsg
     
    17341739    attribute name, '|',  attribute value, '|', attribute kind ('S', string '!' as spaces; 'I', integer; 'R', real; 'D', double )
    17351740  """
     1741  fname = 'ivattrs'
     1742
     1743  if varn == 'h':
     1744      print fname + '_____________________________________________________________'
     1745      print idims.__doc__
     1746      quit()
    17361747
    17371748  if not os.path.isfile(ncfile):
    17381749    print errormsg
    1739     print '    ivattrs: File "' + ncfile + '" does not exist !!'
    1740     print errormsg
     1750    print '  ' + fname + ": File '" + ncfile + "' does not exist !!"
    17411751    quit(-1)   
    17421752
     
    17441754  ncvars = ncf.variables
    17451755
    1746   if not searchInlist(ncvars, varn):
    1747       print '    ivattrs: File "' + ncfile + '" does not have variable: "' + varn + '" '
     1756  if not gen.searchInlist(ncvars, varn):
     1757      print '  ' + fname + ": File '" + ncfile + "' does not have variable: '" +     \
     1758        varn + "' !!"
    17481759      ncf.close()
    17491760      quit(-1)
     
    17531764  allattrs=''
    17541765  allattrsdic = {}
     1766  iattr = 0
    17551767  for attr in ncattrs:
    17561768      attrv=varval.getncattr(attr)
     
    17751787      else:
    17761788          print errormsg
    1777           print '    ivattrs: Reading attribute "', type(attrv), '" not ready! value:', attrv
     1789          print '  ' + fname + ": Attribute type '", type(attrv), "' value:", attrv, \
     1790            "' not ready !!"
    17781791          ncf.close()
    17791792          quit(-1)
    17801793      print attr, '|',  attrv, '|', attrk
    17811794      allattrsdic[attr]  = [attrv, attrk]
    1782       allattrs=allattrs + ':' + attr + '|' + str(attrv) + '|' + attrk
     1795      if iattr == 0:
     1796          allattrs = attr + '|' + str(attrv) + '|' + attrk
     1797      else:
     1798          allattrs = allattrs + ':' + attr + '|' + str(attrv) + '|' + attrk
     1799
     1800      iattr=iattr + 1
    17831801
    17841802  print '####### ###### ##### #### ### ## #'
Note: See TracChangeset for help on using the changeset viewer.