source: lmdz_wrf/trunk/tools/nc_var.py @ 1241

Last change on this file since 1241 was 1237, checked in by lfita, 9 years ago

Introducing `compute_opersvarsfiles' into documentation

  • Property svn:executable set to *
File size: 25.8 KB
RevLine 
[192]1#!/usr/bin/python
[1217]2# Python to manage netCDF files.
3# From L. Fita work in different places: CCRC (Australia), LMD (France)
[1219]4# More information at: http://www.xn--llusfb-5va.cat/python/PyNCplot
[1217]5#
6# pyNCplot and its component nc_var.py comes with ABSOLUTELY NO WARRANTY.
7# This work is licendes under a Creative Commons
8#   Attribution-ShareAlike 4.0 International License (http://creativecommons.org/licenses/by-sa/4.0)
9#
10
[418]11## e.g. ccrc468-17 # ./nc_var.py -v time -f 123/CCRC_NARCliM_Sydney_All_1990-1999_pr10max.nc -o out -S 1:-1
12## e.g. ccrc468-17 # ./nc_var.py -v prac -f xyz/CCRC_NARCliM_Sydney_DAM_1990-1999_prac.nc -o mname -S pluja
13## e.g. ccrc468-17 # ./nc_var.py -v lluis -f CCRC_NARCliM_Sydney_MOM_1990-1999_prac.nc -o addref -S 'prac:standard_name@lluis_variable:long_name@test variable lluis:units@m s-1:0.'
14## e.g. ccrc468-17 # ./nc_var.py -v lluis66 -f ~/UNSW-CCRC-WRF/tools/python/CCRC_NARCliM_Sydney_MOM_1990-1999_prac.nc -o addattr -S 'comment|Lluis Fita-123456'
15## e.g. ccrc468-17 # ./nc_var.py -v lluis66 -f ~/UNSW-CCRC-WRF/tools/python/CCRC_NARCliM_Sydney_MOM_1990-1999_prac.nc -o rmvattr -S 'comment'
16## e.g. acuna # ./nc_var.py -f /d4/lflmd/etudes/WRF_LMDZ/WaquaL/WRF/control/wrfout/wrfout_d01_1979-12-01_00:00:00 -o checkallvars -S 'DateStrLen,Time,soil_layers_stag,bottom_top_stag,bottom_top,west_east_stag,west_east,south_north,south_north_stag:-3,1,2,2,2,-2,-2,-2,-2'
17## e.g. foudre # nc_var.py -f ~/etudes/WRF_LMDZ/tests/wrf_input/AR40.0/wrfout_d01_1979-01-01_00\:00\:00 -o checkallvars -S 'bottom_top_plus1,num_orchidee_soil_levels,lmdz_ksoil_types,DIM0009,DateStrLen,Time,soil_layers_stag,bottom_top_stag,bottom_top,west_east_stag,west_east,south_north,south_north_stag:2,0,0,1,-3,1,2,2,2,-2,-2,-2,-2'
18## e.g. # nc_var.py -o field_stats -f ~/etudes/domains/Polynesie/geo_em.d03.nc -S full -v HGT_M
19## e.g. # nc_var.py -o filter_2dim -S '80,y,x,lon,lat' -f 'tahiti_5m_ll.grd' -v 'z'
20## e.g. # nc_var.py -o selvar -f /home/lluis/PY/met_em.d01.1979-01-01_00:00:00.nc -S 'west_east@XLONG_M,south_north@XLAT_M,num_metgrid_levels@int,Time@Times' -v TT,UU,VV,SKINTEMP
[706]21## e.g. # nc_var.py -o 'Partialmap_Entiremap' -f carteveg5km.nc -S 'longitude,latitude,std,5000.,Goode,Goode_5km.nc' -v vegetation_map
[845]22## e.g. # nc_var.py -o subbasin -f routing.nc -S Caceres,-57.75,-16.25,left
23## e.g. # nc_var.py -o computevar_model -f ~/PY/wrfout_d01_2001-11-11_00:00:00 -S hurs
[847]24## e.g. # nc_var.py -o model_characteristics -f ~/PY/wrfout_d01_2001-11-11_00:00:00 -S WRF
[1005]25## e.g. # nc_var.py -o WRF_toCF -f ~/PY/wrfout_d01_2001-11-11_00:00:00 -S XLONG:XLAT:19491201000000:minutes
[1008]26## e.g. # nc_var.py -o cleaning_varsfile -f ~/PY/wrfout_d01_2001-11-11_00:00:00 -S T2,XLONG,XLAT,Times
[1090]27## e.g. # nc_var.py -o LMDZ_toCF -f LMDZ/AR40/vas_histins_1-1.nc -S 'minutes!since!1949-12-01!00:00:00'
28## e.g. # nc_var.py -o CDO_toCF -f LMDZ/AR40/hfss_reproj-histins.nc
[1050]29## e.g. # nc_var.py -o pinterp -f wrfout_d01_2001-11-11_00\:00\:00 -S 100000.:97500.:95000.:92500.:90000.:85000.:80000.:75000.:70000.:65000.:60000.:55000.:50000.:45000.:40000.:35000.:30000.:25000.:20000.:15000.:10000.:5000.:2500.:1000.:500.:250.,1,0 -v WRFt,WRFrh
[1053]30## e.g. # nc_var.py -o pinterp -f /media/ExtDiskC_ext4/DATA/etudes/WRF_LMDZ/WaquaL_highres/short_copies/LMDZ/AR40/histins_19790101000000-19790304000000_short.nc -S 100000.:97500.:95000.:92500.:90000.:85000.:80000.:75000.:70000.:65000.:60000.:55000.:50000.:45000.:40000.:35000.:30000.:25000.:20000.:15000.:10000.:5000.:2500.:1000.:500.:250.,1,0 -v temp,ovap
[1179]31## e.g. # nc_var.py -o reproject -f analysis/LMDZ/AR40/hurs_histins.nc -S 'lon,lat,analysis/WRF/current/hurs_wrfout.nc,lon,lat,npp,time@time' -v hurs
[1181]32## e.g. # nc_var.py -o field_stats_dim -f /home/lluis/PY/wrfout_d01_2001-11-11_00:00:00 -S 'full,None,None,west_east,XLONG,False' -v 'T2'
[1233]33## e.g. # nc_var.py -o compute_opersvarsfiles -S 'west_east|XLONG|-1;south_north|XLAT|-1;Time|Times|3@add|wrfout_d01_2001-11-11_00:00:00|T2%west_east|XLONG|-1;south_north|XLAT|-1;Time|Times|3@subc,273.15|wrfout_d01_2001-11-11_00:00:00|None' -v 'tempC,air!temperature,C'
[1237]34## 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
[192]35
[1237]36
[192]37from optparse import OptionParser
38import numpy as np
39from netCDF4 import Dataset as NetCDFFile
40import os
41import re
42import nc_var_tools as ncvar
[759]43# Using 'generic_tools.py'
[748]44import generic_tools as gen
[192]45
[1215]46# addvals: Function to add values to a given variable at a given dimension
47# CDO_toCF: Function to pass a CDO output file to CF-conventions
48# chdimname: Changing the name of the dimension
49# changevartype: Function to change the type of a variable (when possible)
50# checkallvars: Function to check all variables of a file
51# checkAllValues: Function to check for variables with along all their dimensions with the same value in a file
52# checkNaNs: Function to check for NaN values over all variables in a file
53# chgtimestep: Function to change the values of a given time-step of a variable inside a netCDF for values from a nother file
54# chvarname: Changing the name of the variable
55# cleaning_varsfile: Function to keep a list of varibales from a file
56# compute_deaccum: Function to compute deaccum: deaccumulation of a variable (VAR[t+1]-VAR[t])
57# compute_opersvarsfiles: Function to compute opersvarfiles: operation of variables from different files
58# compute_opervaralltime: Function to compute opervaralltime: operation of variable successible allover the time-steps
59# compute_opervartimes: Function to compute opervartimes: operation of variable for a given sub-set of time-steps
60# compute_tevolboxtraj: Function to compute tevolboxtraj: temporal evolution at a given point along a box following a trajectory
61# computevar_model: Function to provide the way to compute a CF-variable providing its name
62# DatesFiles: Function to find different time values on a series of WRF files in a folder
63# DataSetSection: Function to get a section (values along a dimension) of a given data-set
64# DataSetSection_multidims: Function to get a section (values along multiple dimensions) of a given data-set
65# DataSetSection_multivars: Function to get a section (values along multiple variables) of a given data-set
66# dimToUnlimited: Operation to create an unlimited dimension from an existing one
67# dimVar_creation: Function to add a 1D variable with the size of a given dimension in a file
68# fattradd: Adding attributes from a reference file
69# fdimadd: Adding dimension from another reference file
70# fgaddattr: Adding global attributes from a reference file
71# field_stats: Function to retrieve statistics from a field
72# field_stats_dim: Function to retrieve statistics from a field along dimensions
73# file_creation: Operation to create a file with one variable with a given set of dimensions
74# file_oper_alongdims: Function to operate a file along different dimensions of a variable
75# filter_2dim: Function to filter along 2 dimensions (moving grid-box means of a given size) values of the netCDF file
76# flipdim: flips the value following one dimension
77# fvaradd: Adding variable (and all its attributes and dimensions) from a reference file to a file
78# gaddattrk: Add a global attribute to a netCDF caring about the type. Removes previous attribute if it exist
79# gaddattr: Add a global attribute to a netCDF. Removes previous attribute if it exist
80# get_attribute: Function to get an attribute from a netCDF file
81# get_namelist_vars: Function to get namelist-like  values ([varname] = [value])
82# get_Variables: Function to get a list of variables from an existing file
83# getvalues_lonlat: Function to retrieve the values from the closest grid point to a set of longitude, latitude values
84# grattr: Function to read a global atribute
85# grmattr: Removing a global attribute
86# idims: Give all the dimensions names of a file
87# igattrs: Give all the global attributes of a file
88# increaseDimvar: Function to increase with 1 dimension an existing variable within a netcdf file. Values of
89#   the variable will be repeated along the new dimension
90# isgattrs: Give a single global attribute of a file and its type
91# isvattrs: Give a single attribute of a variable
92# ivars: Give all the variable names of a file
93# ivattrs: Give all the attributes of a variable and its type
94# LMDZ_toCF: Function to pass a LMDZ original file to CF-conventions
95# maskvar: Function to mask a variable using a mask. It is assumed that mask[...,dimM,dimJ,dimK] and
96# model_characteristics: Function to provide major characterisitcs of a given model output
97# ncreplace: Function to replace something from a netCDF file
98# ncstepdiff: Function to compute differencies between time-steps (deacumulate) a netCDF file
99# netcdf_concatenation: Function to concatenate netCDF files for a given set of variables
100# netcdf_fold_concatenation: Function to concatenate netCDF files in a given folder for a given set of variables
101# netcdf_fold_concatenation_HMT: Function to concatenate netCDF files in a given folder for a given set of variables
102#   giving Header, Middle, Tail for the name files
103# reproject: Function to reproject values to another one
104# Partialmap_Entiremap: Function to transform from a partial global map (e.g.: only land points) to an entire one
105#   Coincidence of points is done throughout a first guess from fractions of the total domain of search
106# Partialmap_EntiremapFor: Function to transform from a partial global map (e.g.: only land points) to an entire one
107#   using Fortran code Coincidence of points is done throughout a first guess from fractions of the total domain of search
108# Partialmap_EntiremapForExact: Function to transform from a partial global map (e.g.: only land points) to an entire
109#   one using Fortran code with exact location Coincidence of points is done throughout a first guess from fractions of
110#   the total domain of search
111# pinterp: Function to vertically interpolate using subroutines from the p_interp.F90 NCAR program
112# remapnn: Function to remap to the nearest neightbor a variable using projection from another file
113# seasmean: Function to compute the seasonal mean of a variable
114# sellonlatbox: Function to select a lotlan box from a data-set
115# sellonlatlevbox: Function to select a lotlan box and a given level from a data-set
116# selvar: Function to select a series of variables from a netcdf file. Variables with
117# setvar_asciivalues: Function to set de values of a variable with an ASCII file (common
118# sorttimesmat: Function to sort the time values of a given file
119# spacemean: Function to retrieve a space mean series from a multidimensional variable of a file
120# SpatialWeightedMean: Function to compute the spatial mean using weights from a netCDF file
121# statcompare_files: Python script to statistically compare two different files
122# subbasin: Function to retrieve the subbasin (all the sub-flows untila a given lon,lat)
123# submns: Function to retrieve a series of months from a file
124# subyrs: Function to retrieve a series of years from a file
125# TimeInf: Function to print all the information from the variable time
126# time_reset: Function to re-set the time axis of a file
127# TimeSplitmat: Function to transform a file with CFtimes to a matrix [Nyear,Nmonth,Nday,Nhour,Nminute,Nsecond]
128# timemean: Function to retrieve a time mean series from a multidimensional variable of a file
129# valmod: Function to modify the value of a variable
130# valmod_dim: Function to modify the value of a variable at a given dimension and value
131# varaddattrk: Add an attribute to a variable caring about the type
132# varaddattr: Add an attribute to a variable. Removes previous attribute if it exists
133# varaddref: Function to add a variable in an existing file copying characteristics from an existing one
134# var_creation: Operation to create a new variable in a file with a given set of dimensions
135# varout: Function when we want to output variable values
136# varrmattr: Removing an attribute from a variable
137# varrm: Removing a variable from a file
138# VarVal_FillValue: Function to transform a given value from a given variable to _FillValue in a netCDF file
139# vrattr: Function to remove an atribute from a variable
140# WRF_d0Nref: Function for the generation of an extra WRF domain from a given one
141# WRF_CFlonlat_creation: Function to add a CF-convention longitude/latitude variables in a WRF file
142# WRF_CFtime_creation: Function to add a CF-convention time unit in a WRF file
143# WRF_CFxtime_creation: Function to add a CF-convention time unit in a WRF file using variable 'XTIME'
144# WRF_toCF: Function to pass a WRF original file to CF-conventions
145
[1062]146operations=['addvals', 'CDO_toCF', 'chdimname', 'changevartype', 'checkallvars',     \
[408]147  'checkAllValues', 'checkNaNs',                                                     \
[1008]148  'chgtimestep', 'chvarname', 'cleaning_varsfile', 'compute_deaccum',                \
149  'compute_opersvarsfiles',                                                          \
[192]150  'compute_opervaralltime', 'compute_opervartimes', 'compute_tevolboxtraj',          \
[845]151  'computevar_model', 'DatesFiles',                                                  \
[576]152  'DataSetSection', 'DataSetSection_multidims', 'DataSetSection_multivars',          \
153  'dimToUnlimited', 'dimVar_creation',                                               \
154  'fattradd',                                                                        \
[1181]155  'fdimadd', 'fgaddattr', 'field_stats', 'field_stats_dim', 'file_creation',         \
156  'file_oper_alongdims', 'filter_2dim',                                              \
[656]157  'flipdim', 'fvaradd', 'gaddattrk', 'gaddattr', 'get_attribute',                    \
[965]158  'get_namelist_vars', 'get_Variables',                                              \
[632]159  'getvalues_lonlat', 'grattr',                                                      \
[1173]160  'grmattr', 'idims', 'igattrs', 'increaseDimvar', 'isgattrs',                       \
161  'isvattrs', 'ivars', 'ivattrs', 'LMDZ_toCF', 'maskvar', 'model_characteristics',   \
[311]162  'ncreplace', 'ncstepdiff', 'netcdf_concatenation', 'netcdf_fold_concatenation',    \
[1173]163  'netcdf_fold_concatenation_HMT', 'reproject', 'Partialmap_Entiremap',              \
[905]164  'Partialmap_EntiremapFor', 'Partialmap_EntiremapForExact',                         \
[900]165  'pinterp', 'remapnn',                                                              \
[418]166  'seasmean', 'sellonlatbox', 'sellonlatlevbox', 'selvar', 'setvar_asciivalues',     \
[815]167  'sorttimesmat', 'spacemean', 'SpatialWeightedMean', 'statcompare_files',           \
[1092]168  'subbasin', 'submns', 'subyrs', 'TimeInf', 'time_reset',                           \
[533]169  'TimeSplitmat', 'timemean', 'valmod', 'valmod_dim','varaddattrk', 'varaddattr',    \
170  'varaddref',                                                                       \
[666]171  'var_creation', 'varout', 'varoutold', 'varrmattr', 'varrm', 'VarVal_FillValue',   \
172  'vrattr', 'WRF_d0Nref',                                                            \
[192]173  'WRF_CFlonlat_creation', 'WRF_CFtime_creation', 'WRF_CFxtime_creation',            \
[1005]174  'list_operations', 'WRF_toCF']
[192]175
176### Options
177##string_operation="operation to make: " + '\n' + " out, output values -S inidim1,[inidim2,...]:enddim1,[enddim2,...]"
178string_operation="""operation to make:
179  addgattr, add a new global attribute: addatr -S [attrname]|[attrvalue]
180  addvattr, add a new attribute to any given variable: addatr -S [attrname]|[attrvalue]
181  addref, add a new variable with dimension and attributes from an already existing 'variable ref' in the file and -S [variable ref]:[attr name]@[value]:[[attr2]@[value2], ...]:[value/file with values]  mname, modify name -S newname
182  checkallvalrs: Function to check all variables of a file: -S [dimn1],[[dimn2],...,[dimnN]]:[dim1],[[dim2],...,[dimN]]
183  mname, modify name -S newname
184  out, output values -S inidim1,[inidim2,...]:enddim1,[enddim2,...]
185  valmod, modifiy values of variable -S [modification]:
186     sumc,[constant]: add [constant] to variables values
187     subc,[constant]: substract [constant] to variables values
188     mulc,[constant]: multipy by [constant] to variables values
189     divc,[constant]: divide by [constant] to variables values
190  rmgattr, remove a global attribute: rmgattr -S [attrname]
191  rmvattr, remove an attribute to any given variable: rmvattr -S [attrname]
192"""
193
194#print string_operation
195
[748]196operationnames = "'" + gen.numVector_String(operations, "', '") + "'"
[192]197
198parser = OptionParser()
[820]199parser.add_option("-f", "--netCDF_file", dest="ncfile", help="file to use", 
200  metavar="FILE")
[192]201parser.add_option("-o", "--operation", type='choice', dest="operation", 
202  choices=operations, help="operation to make: " + operationnames, metavar="OPER")
[820]203parser.add_option("-S", "--valueS", dest="values", 
204  help="values to use according to the operation (when applicable); '-h' specific help of the operation", metavar="VALUES")
[192]205parser.add_option("-v", "--variable", dest="varname",
[820]206  help="variable to use (when applicable)", metavar="VAR")
[192]207
208(opts, args) = parser.parse_args()
209
210#if opts.help:
211#  parser.print_help()
212#  print string_operation
213#  sys.exit()
214
215#######    #######
216## MAIN
217    #######
218
219# Operations which file name is not a real file
[508]220NotCheckingFile = ['DatesFiles', 'file_creation', 'list_operations',                 \
[905]221  'model_characteristics', 'netcdf_concatenation', 'netcdf_fold_concatenation',      \
222  'netcdf_fold_concatenation_HMT']
[192]223
224####### ###### ##### #### ### ## #
225errormsg='ERROR -- error -- ERROR -- error'
226
227varn=opts.varname
228oper=opts.operation
229
230if opts.ncfile is not None and not os.path.isfile(opts.ncfile) and                   \
[748]231  not gen.searchInlist(NotCheckingFile,oper):
[192]232    print errormsg
233    print '  File ' + opts.ncfile + ' does not exist !!'
234    quit(-1)
235
236if oper == 'addvals':
237    ncvar.addvals(opts.values, opts.ncfile, opts.varname)
[1062]238elif oper == 'CDO_toCF':
239    ncvar.CDO_toCF(opts.ncfile)
[192]240elif oper == 'chdimname':
[870]241    ncvar.chdimname(opts.values, opts.ncfile)
[408]242elif oper == 'changevartype':
243    ncvar.changevartype(opts.values, opts.ncfile, opts.varname)
[192]244elif oper == 'checkallvars':
245    ncvar.checkallvars(opts.values, opts.ncfile)
246elif oper == 'checkAllValues':
247    ncvar.checkAllValues(opts.values, opts.ncfile)
248elif oper == 'checkNaNs':
249    ncvar.checkNaNs(opts.values, opts.ncfile)
250elif oper == 'chgtimestep':
251    ncvar.chgtimestep(opts.values, opts.ncfile, opts.varname)
252elif oper == 'chvarname':
253    ncvar.chvarname(opts.values, opts.ncfile, opts.varname)
[1008]254elif oper == 'cleaning_varsfile':
255    ncvar.cleaning_varsfile(opts.values, opts.ncfile)
[192]256elif oper == 'compute_deaccum':
257    ncvar.compute_deaccum(opts.values, opts.ncfile, opts.varname)
258elif oper == 'compute_opersvarsfiles':
259    ncvar.compute_opersvarsfiles(opts.values, opts.varname)
260elif oper == 'compute_opervaralltime':
261    ncvar.compute_opervaralltime(opts.values, opts.ncfile, opts.varname)
262elif oper == 'compute_opervartimes':
263    ncvar.compute_opervartimes(opts.values, opts.ncfile, opts.varname)
264elif oper == 'compute_tevolboxtraj':
265    ncvar.compute_tevolboxtraj(opts.values, opts.ncfile, opts.varname)
[845]266elif oper == 'computevar_model':
267    ncvar.computevar_model(opts.values, opts.ncfile)
[192]268elif oper == 'DataSetSection':
269    ncvar.DataSetSection(opts.values, opts.ncfile)
270elif oper == 'DataSetSection_multidims':
[674]271    ncvar.DataSetSection_multidims(opts.values, opts.ncfile, opts.varname)
[576]272elif oper == 'DataSetSection_multivars':
273    ncvar.DataSetSection_multivars(opts.values, opts.ncfile, opts.varname)
[507]274elif oper == 'DatesFiles':
275    ncvar.DatesFiles(opts.values, opts.ncfile, opts.varname)
[397]276elif oper == 'dimToUnlimited':
277    ncvar.dimToUnlimited(opts.values, opts.ncfile)
[192]278elif oper == 'dimVar_creation':
279    ncvar.dimVar_creation(opts.values, opts.ncfile)
280elif oper == 'fattradd':
281    ncvar.fattradd(var, opts.values, opts.ncfile)
282elif oper == 'fdimadd':
283    ncvar.fdimadd(opts.values, opts.ncfile)
284elif oper == 'fgaddattr':
285    ncvar.fgaddattr(opts.values, opts.ncfile)
[386]286elif oper == 'file_creation':
287    ncvar.file_creation(opts.values, opts.ncfile, opts.varname)
[192]288elif oper == 'file_oper_alongdims':
289    ncvar.file_oper_alongdims(opts.values, opts.ncfile, opts.varname)
290elif oper == 'field_stats':
291    ncvar.field_stats(opts.values, opts.ncfile, opts.varname)
[1181]292elif oper == 'field_stats_dim':
293    ncvar.field_stats_dim(opts.values, opts.ncfile, opts.varname)
[192]294elif oper == 'filter_2dim':
295    ncvar.filter_2dim(opts.values, opts.ncfile, opts.varname)
296elif oper == 'flipdim':
297    ncvar.flipdim(opts.values, opts.ncfile, opts.varname)
298elif oper == 'fvaradd':
299    ncvar.fvaradd(opts.values, opts.ncfile)
300elif oper == 'gaddattrk':
301    ncvar.gaddattrk(opts.values, opts.ncfile)
302elif oper == 'gaddattr':
303    ncvar.gaddattr(opts.values, opts.ncfile)
[656]304elif oper == 'get_attribute':
305    ncvar.get_attribute(opts.values, opts.ncfile, opts.varname)
[192]306elif oper == 'get_namelist_vars':
[778]307    ncvar.get_namelist_vars(opts.values, opts.ncfile)
[965]308elif oper == 'get_Variables':
[967]309    ncvar.get_Variables(opts.values, opts.ncfile, opts.varname)
[632]310elif oper == 'getvalues_lonlat':
311    ncvar.getvalues_lonlat(opts.values, opts.ncfile)
[192]312elif oper == 'grattr':
313    ncvar.grattr(opts.values, opts.ncfile)
314elif oper == 'grmattr':
315    ncvar.grmattr(opts.values, opts.ncfile)
[870]316elif oper == 'idims':
317    ncvar.idims(opts.ncfile)
[192]318elif oper == 'igattrs':
319    ncvar.igattrs(opts.ncfile)
[404]320elif oper == 'increaseDimvar':
321    ncvar.increaseDimvar(opts.values, opts.ncfile, opts.varname)
[192]322elif oper == 'isgattrs':
323    ncvar.isgattrs(opts.values, opts.ncfile)
324elif oper == 'isvattrs':
325    ncvar.isvattrs(opts.values, opts.ncfile, opts.varname)
326elif oper == 'ivars':
327    ncvar.ivars(opts.ncfile)
328elif oper == 'ivattrs':
329    ncvar.ivattrs(opts.ncfile, opts.varname)
330elif oper == 'list_operations':
331# From: http://www.diveintopython.net/power_of_introspection/all_together.html
332    object = ncvar
333    for opern in operations:
334        if  opern != 'list_operations': 
335            print opern + '_______ ______ _____ ____ ___ __ _'
336            print getattr(object, opern).__doc__
[1046]337elif oper == 'LMDZ_toCF':
[1090]338    ncvar.LMDZ_toCF(opts.values, opts.ncfile)
[192]339elif oper == 'maskvar':
340    ncvar.maskvar(opts.values, opts.ncfile, opts.varname)
[847]341elif oper == 'model_characteristics':
342    ncvar.model_characteristics(opts.values, opts.ncfile)
[192]343elif oper == 'ncreplace':
344    ncvar.ncreplace(opts.values, opts.ncfile, opts.varname)
[311]345elif oper == 'ncstepdiff':
346    ncvar.ncstepdiff(opts.values, opts.ncfile, opts.varname)
[192]347elif oper == 'netcdf_concatenation':
348    ncvar.netcdf_concatenation(opts.ncfile)
349elif oper == 'netcdf_fold_concatenation':
350    ncvar.netcdf_fold_concatenation(opts.values, opts.ncfile, opts.varname)
[905]351elif oper == 'netcdf_fold_concatenation_HMT':
352    ncvar.netcdf_fold_concatenation_HMT(opts.values, opts.ncfile, opts.varname)
[192]353elif oper == 'opersvarsfiles':
354    ncvar.compute_opersvarsfiles(opts.values, opts.varname)
[900]355elif oper == 'pinterp':
356    ncvar.pinterp(opts.values, opts.ncfile, opts.varname)
[409]357elif oper == 'remapnn':
358    ncvar.remapnn(opts.values, opts.ncfile, opts.varname)
[693]359elif oper == 'Partialmap_Entiremap':
360    ncvar.Partialmap_Entiremap(opts.values, opts.ncfile, opts.varname)
[716]361elif oper == 'Partialmap_EntiremapFor':
362    ncvar.Partialmap_EntiremapFor(opts.values, opts.ncfile, opts.varname)
[735]363elif oper == 'Partialmap_EntiremapForExact':
364    ncvar.Partialmap_EntiremapForExact(opts.values, opts.ncfile, opts.varname)
[1173]365elif oper == 'reproject':
366    ncvar.reproject(opts.values, opts.ncfile, opts.varname)
[192]367elif oper == 'seasmean':
368    ncvar.seasmean(timename, opts.ncfile, opts.varname)
369elif oper == 'sellonlatbox':
370    ncvar.sellonlatbox(opts.values, opts.ncfile, opts.varname)
371elif oper == 'sellonlatlevbox':
372    ncvar.sellonlatlevbox(opts.values, opts.ncfile, opts.varname)
[418]373elif oper == 'selvar':
374    ncvar.selvar(opts.values, opts.ncfile, opts.varname)
[192]375elif oper == 'setvar_asciivalues':
376    ncvar.setvar_asciivalues(opts.values, opts.ncfile, opts.varname)
377elif oper == 'sorttimesmat':
378    ncvar.sorttimesmat(opts.ncfile, opts.varname)
379elif oper == 'spacemean':
380    ncvar.spacemean(opts.ncfile, opts.varname)
[662]381elif oper == 'SpatialWeightedMean':
382    ncvar.SpatialWeightedMean(opts.values, opts.ncfile, opts.varname)
[192]383elif oper == 'statcompare_files':
384    ncvar.statcompare_files(opts.values)
[815]385elif oper == 'subbasin':
386    ncvar.subbasin(opts.values, opts.ncfile)
[192]387elif oper == 'submns':
388    ncvar.submns(opts.values, opts.ncfile, opts.varname)
389elif oper == 'subyrs':
390    ncvar.subyrs(opts.values, opts.ncfile, opts.varname)
391elif oper == 'TimeInf':
392    ncvar.TimeInf(opts.ncfile, opts.varname)
[1092]393elif oper == 'time_reset':
394    ncvar.time_reset(opts.values, opts.ncfile, opts.varname)
[533]395elif oper == 'TimeSplitmat':
396    ncvar.TimeSplitmat(opts.values, opts.ncfile, opts.varname)
[192]397elif oper == 'timemean':
398    ncvar.timemean(opts.values, opts.ncfile, opts.varname)
399elif oper == 'valmod':
400    ncvar.valmod(opts.values, opts.ncfile, opts.varname)
401elif oper == 'valmod_dim':
402    ncvar.valmod_dim(opts.values, opts.ncfile, opts.varname)
403elif oper == 'varaddattrk':
404    ncvar.varaddattrk(opts.values, opts.ncfile, opts.varname)
405elif oper == 'varaddattr':
406    ncvar.varaddattr(opts.values, opts.ncfile, opts.varname)
407elif oper == 'varaddref':
408    ncvar.varaddref(opts.values, opts.ncfile, opts.varname)
[387]409elif oper == 'var_creation':
410    ncvar.var_creation(opts.values, opts.ncfile, opts.varname)
[192]411elif oper == 'varout':
412    ncvar.varout(opts.values, opts.ncfile, opts.varname)
413elif oper == 'varoutold':
414    ncvar.varoutold(opts.values, opts.ncfile, opts.varname)
415elif oper == 'varrmattr':
416    ncvar.varrmattr(opts.values, opts.ncfile, opts.varname)
417elif oper == 'varrm':
418    ncvar.varrm(opts.ncfile, opts.varname)
[666]419elif oper == 'VarVal_FillValue':
420    ncvar.VarVal_FillValue(opts.values, opts.ncfile, opts.varname)
[192]421elif oper == 'vrattr':
422    ncvar.vrattr(opts.values, opts.ncfile, opts.varname)
423elif oper == 'WRF_d0Nref':
424    ncvar.WRF_d0Nref(opts.values, opts.ncfile)
425elif oper == 'WRF_CFlonlat_creation':
426    ncvar.WRF_CFlonlat_creation(opts.values, opts.ncfile, opts.varname)
427elif oper == 'WRF_CFtime_creation':
428    ncvar.WRF_CFtime_creation(opts.values, opts.ncfile, opts.varname)
429elif oper == 'WRF_CFxtime_creation':
430    ncvar.WRF_CFxtime_creation(opts.values, opts.ncfile, opts.varname)
[1005]431elif oper == 'WRF_toCF':
432    ncvar.WRF_toCF(opts.values, opts.ncfile)
[192]433else:
434    print errormsg
435    print '   The operation ' + oper + ' is not ready !!'
436    print errormsg
437    quit()
Note: See TracBrowser for help on using the repository browser.