- Timestamp:
- Apr 3, 2018, 8:04:03 PM (7 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var.py
r1879 r1881 20 20 ## e.g. # nc_var.py -o nc_var.py -o CFmorzization -S 'X|west_east|XLONG,Y|south_north|XLAT,T|Time|WRFtime,Z|bottom_top|ZNU:GlobalAttr1995.inf:proj1995.inf' -f ~/PY/wrfout_d01_1995-01-01_00\:00\:00 -v QFX@instantaneous@None 21 21 ## e.g.# nc_var.py -o CFmorzization -S 'X|west_east|XLONG,Y|south_north|XLAT,T|Time|WRFtime,Z|bottom_top|ZNU:GlobalAttr1995.inf:proj1995.inf' -f ~/PY/wrfout_d01_1995-01-01_00\:00\:00 -v 'RAINC@time:!accumulation@WRFtime_bnds|h|3' 22 ## e.g # nc_var.py -o dimrm -S removevar -f wrfout_d01_1995-01-01_00:00:00 -v west_east 22 23 23 24 ## e.g. ccrc468-17 # ./nc_var.py -v time -f 123/CCRC_NARCliM_Sydney_All_1990-1999_pr10max.nc -o out -S 1:-1 … … 110 111 # grmattr: Removing a global attribute 111 112 # idims: Give all the dimensions names of a file 113 # ifile: Function to provide some information from a given file 112 114 # igattrs: Give all the global attributes of a file 113 115 # increaseDimvar: Function to increase with 1 dimension an existing variable within a netcdf file. Values of … … 191 193 'get_namelist_vars', 'get_Variables', \ 192 194 'getvalues_lonlat', 'getvars_tofile', 'grattr', \ 193 'grmattr', 'idims', 'i gattrs', 'increaseDimvar', 'isgattrs',\195 'grmattr', 'idims', 'ifile', 'igattrs', 'increaseDimvar', 'isgattrs', \ 194 196 'isvattrs', 'ivars', 'ivattrs', 'LMDZ_toCF', 'lonlat_polygon', 'maskvar', \ 195 197 'merge_files', 'model_characteristics', \ … … 379 381 elif oper == 'idims': 380 382 ncvar.idims(opts.ncfile) 383 elif oper == 'ifile': 384 ncvar.ifile(opts.ncfile) 381 385 elif oper == 'igattrs': 382 386 ncvar.igattrs(opts.ncfile) -
trunk/tools/nc_var_tools.py
r1880 r1881 89 89 # grmattr: Removing a global attribute 90 90 # idims: Give all the dimensions names of a file 91 # ifile: Function to provide some information from a given file 91 92 # igattrs: Give all the global attributes of a file 92 93 # increaseDimvar: Function to increase with 1 dimension an existing variable within a netcdf file. Values of the variable will be repeated along the new dimension … … 24027 24028 return 24028 24029 24030 def ifile(ncfile): 24031 """ Function to provide some information from a given file 24032 ncfile= NetCDFFile from which provide the information 24033 """ 24034 fname = 'ifile' 24035 24036 onc = NetCDFFile(ncfile,'r') 24037 24038 # dimensions 24039 dimns = list(onc.dimensions) 24040 dimns.sort() 24041 for dimn in dimns: 24042 odn = onc.dimensions[dimn] 24043 if odn.isunlimited(): Ld = 'unlimited_' + str(len(odn)) 24044 else: Ld = len(odn) 24045 print ' dim: @' + dimn + '@length= ', Ld 24046 24047 # variables 24048 varns = list(onc.variables.keys()) 24049 varns.sort() 24050 for varn in varns: 24051 ovn = onc.variables[varn] 24052 vardims = ':'.join(list(ovn.dimensions)) 24053 varshapel = [] 24054 for idim in ovn.shape: varshapel.append(str(idim)) 24055 varshape = ':'.join(varshapel) 24056 print ' var: @' + varn + '@ dims= ' + vardims + ' shape= ' + varshape + ' type: ', ovn.dtype 24057 24058 onc.close 24059 24060 return 24061 24062 24029 24063 #quit()
Note: See TracChangeset
for help on using the changeset viewer.