|
TECA
The Toolkit for Extreme Climate Analysis
|
Codes dealing with NetCDF I/O calls. More...
Functions | |
| void | crtrim (char *s, long n) |
| std::mutex & | get_netcdf_mutex () |
| TECA_EXPORT int | read_attribute (int parent_id, int var_id, const std::string &att_name, teca_metadata &atts) |
| TECA_EXPORT int | read_attribute (int parent_id, int var_id, int att_id, teca_metadata &atts) |
| TECA_EXPORT int | read_variable_attributes (netcdf_handle &fh, const std::string &parent_group, int var_id, const std::string &x_variable, const std::string &y_variable, const std::string &z_variable, const std::string &t_variable, const std::string &ensemble_dimension_name, int clamp_dimensions_of_one, std::string &name, teca_metadata &atts) |
| TECA_EXPORT int | read_variable_attributes (netcdf_handle &fh, const std::string &parent_group, int var_id, std::string &name, teca_metadata &atts) |
| TECA_EXPORT int | get_varid (netcdf_handle &fh, const std::string &var_name, int *parent_id, int *var_id) |
| TECA_EXPORT int | read_variable_attributes (netcdf_handle &fh, const std::string &name, const std::string &x_variable, const std::string &y_variable, const std::string &z_variable, const std::string &t_variable, const std::string &ensemble_dim_name, int clamp_dimensions_of_one, teca_metadata &atts) |
| TECA_EXPORT int | read_variable_attributes (netcdf_handle &fh, const std::string &var_name, teca_metadata &atts) |
| TECA_EXPORT int | write_variable_attributes (int parent_id, int var_id, teca_metadata &array_atts) |
Codes dealing with NetCDF I/O calls.
| void teca_netcdf_util::crtrim | ( | char * | s, |
| long | n | ||
| ) |
To deal with fortran fixed length strings which are not properly nulll terminated.
| std::mutex& teca_netcdf_util::get_netcdf_mutex | ( | ) |
NetCDF 3 is not threadsafe. The HDF5 C-API can be compiled to be threadsafe, but it is usually not. NetCDF uses HDF5-HL API to access HDF5, but HDF5-HL API is not threadsafe without the –enable-unsupported flag. For all those reasons it's best for the time being to protect all NetCDF I/O.
| TECA_EXPORT int teca_netcdf_util::get_varid | ( | netcdf_handle & | fh, |
| const std::string & | var_name, | ||
| int * | parent_id, | ||
| int * | var_id | ||
| ) |
Get the variable ID in a NetCDF file where var_name can be a fully qualified path including group names, such as "global/lat"
| TECA_EXPORT int teca_netcdf_util::read_attribute | ( | int | parent_id, |
| int | var_id, | ||
| const std::string & | att_name, | ||
| teca_metadata & | atts | ||
| ) |
Read the specified variable attribute by name. Its value is stored in the metadata object return is non-zero if an error occurred.
| TECA_EXPORT int teca_netcdf_util::read_attribute | ( | int | parent_id, |
| int | var_id, | ||
| int | att_id, | ||
| teca_metadata & | atts | ||
| ) |
Read the specified variable attribute by id. Its value is stored in the metadata object return is non-zero if an error occurred.
| TECA_EXPORT int teca_netcdf_util::read_variable_attributes | ( | netcdf_handle & | fh, |
| const std::string & | name, | ||
| const std::string & | x_variable, | ||
| const std::string & | y_variable, | ||
| const std::string & | z_variable, | ||
| const std::string & | t_variable, | ||
| const std::string & | ensemble_dim_name, | ||
| int | clamp_dimensions_of_one, | ||
| teca_metadata & | atts | ||
| ) |
Read the specified variable's dimensions, and it's associated NetCDF attributes into the metadata object. See CF Attributes for details of attributes returned. returns non-zero if an error occurred.
| TECA_EXPORT int teca_netcdf_util::read_variable_attributes | ( | netcdf_handle & | fh, |
| const std::string & | parent_group, | ||
| int | var_id, | ||
| const std::string & | x_variable, | ||
| const std::string & | y_variable, | ||
| const std::string & | z_variable, | ||
| const std::string & | t_variable, | ||
| const std::string & | ensemble_dimension_name, | ||
| int | clamp_dimensions_of_one, | ||
| std::string & | name, | ||
| teca_metadata & | atts | ||
| ) |
Read the specified variable's name, dimensions, and it's associated NetCDF attributes into the metadata object. Additionally the following key/value pairs are added and useful for subsequent I/O and processing
| Key | Description |
|---|---|
| cf_parent_group | The name of the group containing the NetCF variable |
| id or an empty string if variable is in the root | |
| group (likely the most common case) | |
| cf_id | The NetCDF variable id that can be used to read the |
| variable. | |
| cf_dims | A vector of the NetCDF dimension lengths (i.e. the |
| variable's shape). | |
| cf_dim_names | A vector of the names of the NetCDF dimensions. |
| cf_type_code | The NetCDF type code. |
| type_code | The teca_variant_array::code type code. |
| centering | The mesh centering, point_centering or no_centering |
| have_mesh_dim | Flags indicating the presence of the x,y,z, and t |
| mesh dimensions | |
| mesh_dim_active | Flags indicating if the x,y,z, and t dimension is |
| active. |
In order for centering and have_mesh_dim flags to be set, the x_variable, y_variable, z_variable, and t_variable must be specified.
If dimension is 1 and clamp_dimensions_of_one is set then the dimension is marked as inactive.
returns non-zero if an error occurred.
| TECA_EXPORT int teca_netcdf_util::read_variable_attributes | ( | netcdf_handle & | fh, |
| const std::string & | parent_group, | ||
| int | var_id, | ||
| std::string & | name, | ||
| teca_metadata & | atts | ||
| ) |
Read the specified variable's name, dimensions, and it's associated NetCDF attributes into the metadata object. See CF Attributes for details of attributes returned. returns non-zero if an error occurred.
| TECA_EXPORT int teca_netcdf_util::read_variable_attributes | ( | netcdf_handle & | fh, |
| const std::string & | var_name, | ||
| teca_metadata & | atts | ||
| ) |
Read the specified variable's dimensions, and it's associated NetCDF attributes into the metadata object. See CF Attributes for details of attributes returned. returns non-zero if an error occurred.
| TECA_EXPORT int teca_netcdf_util::write_variable_attributes | ( | int | parent_id, |
| int | var_id, | ||
| teca_metadata & | array_atts | ||
| ) |
Write the attributes in array_atts to the variable identified by var_id the name is used in error messages. Returns zero of successful.