- Timestamp:
- Jun 17, 2016, 11:11:52 AM (8 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/generic_tools.py
r843 r850 2975 2975 return 2976 2976 2977 def singleline_printing_class(classobj): 2978 """ Function to print all the values of a given class in a single line to be parseavel 2979 output as: 'singleline_printing_class[attrval]';'[attrval]';'... 2980 [attrval] = @'[attribute]'@:'[value]('!' for spaces) 2981 """ 2982 fname='singleline_printing_class' 2983 2984 valscls = vars(classobj) 2985 sline=fname + ' ' 2986 2987 for attrcls in valscls: 2988 sline = sline + '@' + attrcls + '@:' + str(valscls[attrcls]).replace(' ','!') + ";" 2989 2990 print sline 2991 return 2992 2977 2993 def cycl_incr(cyclval,cycle,ninc): 2978 2994 """ Function to increment a cyclic value [cyclval] with a cycle [cycle] a given number [ninc] of times -
trunk/tools/nc_var_tools.py
r848 r850 15252 15252 modchar = ModelChar(model,ncfile) 15253 15253 gen.printing_class(modchar) 15254 gen.singleline_printing_class(modchar) 15254 15255 15255 15256 return 15256 15257 15257 15258 #quit() 15258 15259 """operation to make:15260 addfattr, add a attributes to a variable from another file: addfattr -S [file]:[var]15261 addfdim, add a new dimension from another file: addfdim -S [file]:[dimension]15262 addfgattr, add global attribute from another file: addfgattr -S [file]15263 addfvar, add a new variable from another file: addfvar -S [file]:[variable]15264 addgattr, add a new global attribute: addatr -S [attrname]|[attrvalue]15265 addgattrk, add a new global attribute: addatr -S [attrname]|[attrvalue]|[kind(S (!, white spaces),I,R,D)]15266 addref, add a new variable with dimension and attributes from an already existing 'variable ref' in the file: addref -S [variable ref]:[attr name]@[value]:[[attr2]@[value2], ...]:[value/file with values] mname, modify name -S newname15267 addvals, Function to add values to a given variable at a given dimension: addvals -S [dimension]:[position]:[Nvals]:[addval],15268 *[position]: position within the dimension at which the variable wants to be increased15269 'first': first position of the dimension15270 'middle': middle position of the dimension15271 'last': last position of the dimension15272 'num': before given value15273 *[addval]: value to give to the added values15274 'val': a given value15275 'missing': as a missing value15276 addvattr, add a new attribute to any given variable: addvattr -S [attrname]|[attrvalue]15277 addvattrk, add a new attribute to any given variable: addvattr15278 k -S [attrname]|[attrvalue]|[kind(S (!, white spaces),I,R,D)]15279 checkNaNs, checks for NaN values over all variables in a file15280 checkAllValues, check for variables with along all their dimensions with the same value in a file15281 flipdim, flips the value following one dimension: flipdim -S Ndim15282 infgattrs, give the values of all the global attributes of the file: infgattrs15283 infsinggattrs, give the value of a single global attribute of the file: infsinggattrs -S [attribute name]15284 infsingvattrs, give the value of a single attribute of the variable: infsingvattrs -S [attribute name]15285 inftime, give all the information of the variable time: inftime15286 infvars, give the names of all the variables of the file: infvars15287 infvattrs, give the values of all the attributes of a variable: infvattrs15288 mdname, modify dimension name: mdname -S olddname:newdname15289 means, computes the spatial mean of the variable: means15290 meanseas, compute the seasonal mean of a variable: meanseas -S [timename]15291 meant, computes the temporal mean of the variable: meant -S [power](power of the polynomial fit)15292 mname, modify name: mname -S newname15293 out, output values: out -S inidim1,[inidim2,...]:enddim1,[enddim2,...]15294 rgattr, read a global attribute: rgattr -S [attrname]15295 rvattr, read a variable attribute: rvattr -S [attrname]15296 rmgattr, remove a global attribute: rmgattr -S [attrname]15297 rmvariable, remove a variable: rmvariable15298 rmvattr, remove an attribute to any given variable: rmvattr -S [attrname]15299 subsetmns, retrieve a subset of values based on months: subsetmns -S [MM1]:[...:[MMn]] or [MMi]-[MMe] for a period (output as 'subsetmns.nc')15300 subsetyrs, retrieve a subset of values based on years: subsetyrs -S [YYYY1]:[...:[YYYYn]] or [YYYYi]-[YYYYe] for a period (output as 'subsetyrs.nc')15301 timescheck, checks time-steps of a given file: timescheck -S [FirstDate]:[LastDate][freq]:[[auxmonth]]15302 [FirstDate] = first date within file (in [YYYY][MM][DD][HH][MI][SS] format)15303 [LastDate] = last date within file (in [YYYY][MM][DD][HH][MI][SS] format)15304 [freq] = frequency of the data within the file (in time units) or 'month' (monthly values)15305 [auxmonth] = in case of 'month'15306 midmon: dates are given according to the mid time value of the month15307 real: dates are given increassing a month from the previous date15308 timesort, sort a variable time: timesort15309 timestepchg, changes a time-step value from a file, using a given time-step from another one: timestepchg -S [origtime_step]:[newfile]:[newtime_step]15310 valmod, modifiy values of variable -S [modification]:15311 sumc,[constant]: add [constant] to variables values15312 subc,[constant]: substract [constant] to variables values15313 mulc,[constant]: multipy by [constant] to variables values15314 divc,[constant]: divide by [constant] to variables values15315 lowthres,[threshold],[newvalue]: modify all values below [threshold] to [newvalue]15316 upthres,[threshold],[newvalue]: modify all values above [threshold] to [newvalue]15317 valmod_dim(values, ncfile, varn)15318 15319 vartimeshidft, temporaly shift a number of time-steps a given variable inside a netCDF file: vartimeshift -S [nsteps]:[[FillValue]]15320 varmask, mask a variable using a mask: varmask -S [maskfilename]:[maskvar]:[dimsmask]:[timename]. It is assumed that mask[...,dimM,dimJ,dimK]15321 and var[...,dimM,dimJ,dimK] share the last dimensions15322 15323 'addfattr': fattradd(opts.varname, opts.values, opts.ncfile)15324 'addfdim': fdimadd(opts.values, opts.ncfile)15325 'addfgattr': fgaddattr(opts.values, opts.ncfile)15326 'addfvar': fvaradd(opts.values, opts.ncfile)15327 'addgattr': gaddattr(opts.values, opts.ncfile)15328 'addgattrk': gaddattrk(opts.values, opts.ncfile)15329 'addref': varaddref(opts.values, opts.ncfile, opts.varname)15330 'addvattr': varaddattr(opts.values, opts.ncfile, opts.varname)15331 'addvattrk': varaddattrk(opts.values, opts.ncfile, opts.varname)15332 'DataSetSection': datasetsection(opts.values,opts.ncfile)15333 'dimflip': flipdim(opts.values,opts.ncfile,opts.varname)15334 'infgattrs': igattr(opts.ncfile)15335 'infsinggattrs': isgattrs(opts.values, opts.ncfile)15336 'infsingvattrs': isvattrs(opts.values, opts.ncfile, opts.varname)15337 'inftime': timeinf(opts.ncfile, opts.varname)15338 'infvars': ivars(opts.ncfile)15339 'infvattrs': ivattr(opts.ncfile, opts.varname)15340 'mdname': chdimname(opts.values, opts.ncfile, opts.varname)15341 'means': spacemean(opts.ncfile, opts.varname)15342 'meanseas': spacemean(opst.values, opts.ncfile, opts.varname)15343 'meant': timemean(opts.values, opts.ncfile, opts.varname)15344 'mname': chvarname(opts.values, opts.ncfile, opts.varname)15345 'out': varout(opts.values, opts.ncfile, opts.varname)15346 'rgattr': grattr(opts.values, opts.ncfile)15347 'rvattr': vrattr(opts.values, opts.ncfile, opts.varname)15348 'rmgattr': grmattr(opts.values, opts.ncfile)15349 'rmvariable': varrm(opts.ncfile, opts.varname)15350 'rmvattr': varrmattr(opts.values, opts.ncfile, opts.varname)15351 'subsetmns': submns(opts.values, opts.ncfile, opts.varname)15352 'subsetyrs': subyrs(opts.values, opts.ncfile, opts.varname)15353 'timescheck': check_times_file(opts.values, opts.ncfile, opts.varname)15354 'timesort': sorttimesmat(opts.ncfile, opts.varname)15355 'timestepchg': chgtimestep(opts.values, opts.ncfile, opts.varname)15356 'valsadd': addvals(opts.values, opts.ncfile, opts.varname)15357 'valmod': valmod(opts.values, opts.ncfile, opts.varname)15358 'varmask': maskvar(opts.values, opts.ncfile, opts.varname)15359 'vartimeshift': timeshiftvar(opts.values, opts.ncfile, opts.varname)15360 """
Note: See TracChangeset
for help on using the changeset viewer.