Changeset 1375 in lmdz_wrf


Ignore:
Timestamp:
Dec 6, 2016, 6:46:31 PM (8 years ago)
Author:
lfita
Message:

Add:

`addVar': Operation to add a new variable in a file using exisintg dimensions
`setvar_nc': Operation to set values of a variable from values of an other one
`rm_FillValue': Operation to remove the _FillValue from a variable inside a netCDF file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/nc_var.py

    r1360 r1375  
    3434## e.g. # nc_var.py -o compute_opersvarsfiles -S 'lon|lon|-1;lat|lat|-1;time_counter|time_counter|-1@forwrdderiv,1,1,2|/ccc/store/cont003/gen7593/fitaborl/etudes/DynamicoESM/aquaplanet/AR40/19800101000000-19810101000000/histday.nc|t2m' -v 'tasderiv,x-derivative|of|air|temperature,K
    3535## e.g. # nc_var.py -o getvars_tofile -S soils_param_Zobler_textXIOS.nc -f soils_param_colorXIOS.nc -v 'soiltext,soiltexttypes'
     36## e.g. # nc_var.py -o addVar -S 'lon,lat|mask@mask@1|f' -f new_ORCHIDEE_13PFTmap_2010_cmpi6_LUH2v2h.nc -v mask
     37## e.g. # nc_var.py -o setvar_nc -S 'new_ORCHIDEE_13PFTmap_2010_cmpi6_LUH2v2h.nc,maxvegetfrac,veget;0' -f new_ORCHIDEE_13PFTmap_2010_cmpi6_LUH2v2h.nc -v mask
     38## e.g. $ nc_var.py -o VarVal_FillValue -S '0.,eq,std' -f new_lai2D.nc -v LAI
     39## e.g. # nc_var.py -o rm_FillValue -f new_ORCHIDEE_13PFTmap_2010_cmpi6_LUH2v2h.nc -S 0 -v mask
    3640
    3741from optparse import OptionParser
     
    4448import generic_tools as gen
    4549
     50# addVar: Operation to add a new variable in a file using exisintg dimensions
    4651# addvals: Function to add values to a given variable at a given dimension
    4752# CDO_toCF: Function to pass a CDO output file to CF-conventions
     
    104109#   giving Header, Middle, Tail for the name files
    105110# reproject: Function to reproject values to another one
     111# rm_FillValue: Operation to remove the _FillValue from a variable inside a netCDF file
    106112# Partialmap_Entiremap: Function to transform from a partial global map (e.g.: only land points) to an entire one
    107113#   Coincidence of points is done throughout a first guess from fractions of the total domain of search
     
    117123# sellonlatlevbox: Function to select a lotlan box and a given level from a data-set
    118124# selvar: Function to select a series of variables from a netcdf file. Variables with
    119 # setvar_asciivalues: Function to set de values of a variable with an ASCII file (common
     125# setvar_asciivalues: Function to set de values of a variable with an ASCII file (common Fortran-like format)
     126# setvar_nc: Operation to set values of a variable from values of an other one
    120127# sorttimesmat: Function to sort the time values of a given file
    121128# spacemean: Function to retrieve a space mean series from a multidimensional variable of a file
     
    146153# WRF_toCF: Function to pass a WRF original file to CF-conventions
    147154
    148 operations=['addvals', 'CDO_toCF', 'chdimname', 'changevartype', 'checkallvars',     \
    149   'checkAllValues', 'checkNaNs',                                                     \
     155operations=['addVar', 'addvals', 'CDO_toCF', 'chdimname', 'changevartype',           \
     156  'checkallvars', 'checkAllValues', 'checkNaNs',                                     \
    150157  'chgtimestep', 'chvarname', 'cleaning_varsfile', 'compute_deaccum',                \
    151158  'compute_opersvarsfiles',                                                          \
     
    165172  'netcdf_fold_concatenation_HMT', 'reproject', 'Partialmap_Entiremap',              \
    166173  'Partialmap_EntiremapFor', 'Partialmap_EntiremapForExact',                         \
    167   'pinterp', 'remapnn',                                                              \
     174  'pinterp', 'remapnn', 'rm_FillValue',                                              \
    168175  'seasmean', 'sellonlatbox', 'sellonlatlevbox', 'selvar', 'setvar_asciivalues',     \
    169   'sorttimesmat', 'spacemean', 'SpatialWeightedMean', 'statcompare_files',           \
     176  'setvar_nc', 'sorttimesmat', 'spacemean', 'SpatialWeightedMean',                   \
     177  'statcompare_files',                                                               \
    170178  'subbasin', 'submns', 'subyrs', 'TimeInf', 'time_reset',                           \
    171179  'TimeSplitmat', 'timemean', 'valmod', 'valmod_dim','varaddattrk', 'varaddattr',    \
     
    249257    quit(-1)
    250258
    251 if oper == 'addvals':
     259if oper == 'addVar':
     260    ncvar.addVar(opts.values, opts.ncfile, opts.varname)
     261elif oper == 'addvals':
    252262    ncvar.addvals(opts.values, opts.ncfile, opts.varname)
    253263elif oper == 'CDO_toCF':
     
    384394elif oper == 'reproject':
    385395    ncvar.reproject(opts.values, opts.ncfile, opts.varname)
     396elif oper == 'rm_FillValue':
     397    ncvar.rm_FillValue(opts.values, opts.ncfile, opts.varname)
    386398elif oper == 'seasmean':
    387399    ncvar.seasmean(timename, opts.ncfile, opts.varname)
     
    394406elif oper == 'setvar_asciivalues':
    395407    ncvar.setvar_asciivalues(opts.values, opts.ncfile, opts.varname)
     408elif oper == 'setvar_nc':
     409    ncvar.setvar_nc(opts.values, opts.ncfile, opts.varname)
    396410elif oper == 'sorttimesmat':
    397411    ncvar.sorttimesmat(opts.ncfile, opts.varname)
Note: See TracChangeset for help on using the changeset viewer.