List of available functions to manage netCDD files. Most of them follow a similar structure:
$ python nc_var.py -o [operation] -f [file(or files)] -S [values] -v [variables]
In most of the cases
[values] is a string which contains a list of values separated by a character
[sep], becomming the value as:
[values]=[val1][sep][val2][sep][...[valN]]
One can obtain all the list of operations and their instructions by demanding to the script:
$ python nc_var.py -o list_operations
For almost all operations, one can obtain all the help of a specific operation by:
$ python nc_var.py -o [operation] -S h
One should be able to obtain an example of execution by
$ cat nc_var.py | grep [operation] | grep 'e.g.'
The netcdf-managing script has two steps:
- nc_var.py: Main script which mainly gets the values
- nc_var_tools.py: Script which perform the operations and its used by nc_var.py
- generic_tools.py: Script which contains generic operations and it is used by both scripts
In order to use some of the functions, is necessary to compile previously the related Fortran subroutines and link them to python. It is already prepared for different computers via specific
Makefile.[machine].[compiler]
Available functions:
- addvals: Function to add values to a given variable at a given dimension
- CDO_toCF: Function to pass a CDO output file to CF-conventions
- chdimname: Changing the name of the dimension
- changevartype: Function to change the type of a variable (when possible)
- checkallvars: Function to check all variables of a file
- checkAllValues: Function to check for variables with along all their dimensions with the same value in a file
- checkNaNs: Function to check for NaN values over all variables in a file
- chgtimestep: Function to change the values of a given time-step of a variable inside a netCDF for values from a nother file
- chvarname: Changing the name of the variable
- cleaning_varsfile: Function to keep a list of variabales from a file
- compute_opersvarsfiles: Function to compute opersvarfiles: operation of variables from different files (OPER1.FILE1_VAR1 OPER2.FILE2_VAR2), operations are going to be sequentially made
- curve_section: Function to provide a section of a file following a given curve
- DatesFiles: Function to find different time values on a series of WRF files in a folder
- DataSetSection: Function to get a section (values along a dimension) of a given data-set
- DataSetSection_multidims: Function to get a section (values along multiple dimensions) of a given data-set
- DataSetSection_multivars: Function to get a section (values along multiple variables) of a given data-set
- dimToUnlimited: Operation to create an unlimited dimension from an existing one
- dimVar_creation: Function to add a 1D variable with the size of a given dimension in a file
- fattradd: Adding attributes from a reference file
- fdimadd: Adding dimension from another reference file
- fgaddattr: Adding global attributes from a reference file
- field_stats: Function to retrieve statistics from a field
- field_stats_dim: Function to retrieve statistics from a field along dimensions
- file_creation: Operation to create a file with one variable with a given set of dimensions
- file_oper_alongdims: Function to operate a file along different dimensions of a variable
- filter_2dim: Function to filter along 2 dimensions (moving grid-box means of a given size) values of the netCDF file
- flipdim: flips the value following one dimension
- fvaradd: Adding variable (and all its attributes and dimensions) from a reference file to a file
- gaddattrk: Add a global attribute to a netCDF caring about the type. Removes previous attribute if it exist
- gaddattr: Add a global attribute to a netCDF. Removes previous attribute if it exist
- get_attribute: Function to get an attribute from a netCDF file
- get_namelist_vars: Function to get namelist-like values ([varname] = [value])
- get_Variables: Function to get a list of variables from an existing file
- getvalues_lonlat: Function to retrieve the values from the closest grid point to a set of longitude, latitude values
- grattr: Function to read a global attribute
- grmattr: Removing a global attribute
- idims: Give all the dimensions names of a file
- igattrs: Give all the global attributes of a file
- 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
- isgattrs: Give a single global attribute of a file and its type
- isvattrs: Give a single attribute of a variable
- ivars: Give all the variable names of a file
- ivattrs: Give all the attributes of a variable and its type
- LMDZ_toCF: Function to pass a LMDZ original file to CF-conventions
- maskvar: Function to mask a variable using another variable to mask it. Only need to share at least 1 dimension with the same size (no need same name)
- model_characteristics: Function to provide major characteristics of a given model output
- ncreplace: Function to replace something from a netCDF file
- ncstepdiff: Function to compute differences between time-steps (de-accumulate) a netCDF file
- netcdf_concatenation: Function to concatenate netCDF files for a given set of variables
- netcdf_fold_concatenation: Function to concatenate netCDF files in a given folder for a given set of variables
- netcdf_fold_concatenation_HMT: Function to concatenate netCDF files in a given folder for a given set of variables giving Header, Middle, Tail for the name files
- reproject: Function to re-project values to another one
- Partialmap_Entiremap: Function to transform from a partial global map (e.g.: only land points) to an entire one Coincidence of points is done throughout a first guess from fractions of the total domain of search
- Partialmap_EntiremapFor: Function to transform from a partial global map (e.g.: only land points) to an entire one using Fortran code Coincidence of points is done throughout a first guess from fractions of the total domain of search
- Partialmap_EntiremapForExact: Function to transform from a partial global map (e.g.: only land points) to an entire one using Fortran code with exact location Coincidence of points is done throughout a first guess from fractions of the total domain of search
- pinterp: Function to vertically interpolate using subroutines from the p_interp.F90 NCAR program
- remapnn: Function to remap to the nearest neighbor a variable using projection from another file
- seasmean: Function to compute the seasonal mean of a variable
- sellonlatbox: Function to select a lotlan box from a data-set
- sellonlatlevbox: Function to select a lotlan box and a given level from a data-set
- selvar: Function to select a series of variables from a netcdf file. Variables with
- setvar_asciivalues: Function to set the values of a variable with an ASCII file (common
- sorttimesmat: Function to sort the time values of a given file
- spacemean: Function to retrieve a space mean series from a multidimensional variable of a file
- SpatialWeightedMean: Function to compute the spatial mean using weights from a netCDF file
- statcompare_files: Python script to statistically compare two different files
- subbasin: Function to retrieve the subbasin (all the sub-flows until a a given lon,lat)
- submns: Function to retrieve a series of months from a file
- subyrs: Function to retrieve a series of years from a file
- TimeInf: Function to print all the information from the variable time
- time_reset: Function to re-set the time axis of a file
- TimeSplitmat: Function to transform a file with CFtimes to a matrix [Nyear,Nmonth,Nday,Nhour,Nminute,Nsecond]
- timemean: Function to retrieve a time mean series from a multidimensional variable of a file
- valmod: Function to modify the value of a variable
- valmod_dim: Function to modify the value of a variable at a given dimension and value
- varaddattrk: Add an attribute to a variable caring about the type
- varaddattr: Add an attribute to a variable. Removes previous attribute if it exists
- varaddref: Function to add a variable in an existing file copying characteristics from an existing one
- var_creation: Operation to create a new variable in a file with a given set of dimensions
- varout: Function when we want to output variable values
- varrmattr: Removing an attribute from a variable
- varrm: Removing a variable from a file
- VarVal_FillValue: Function to transform a given value from a given variable to _FillValue in a netCDF file
- vrattr: Function to remove an attribute from a variable
- WRF_d0Nref: Function for the generation of an extra WRF domain from a given one
- WRF_CFlonlat_creation: Function to add a CF-convention longitude/latitude variables in a WRF file
- WRF_CFtime_creation: Function to add a CF-convention time unit in a WRF file
- WRF_CFxtime_creation: Function to add a CF-convention time unit in a WRF file using variable 'XTIME'
- WRF_toCF: Function to pass a WRF original file to CF-conventions