Has all functions for the H4CF Conversion Library.
More...
#include "h4cf_header.h"
Go to the source code of this file.
The h4cf.h contains all APIs that user need to know to access the variables and attributes in HDF4 files following the CF conventions.
h4cf_close terminates access to the opened file by releasing the resources held by the library. The opened file should be closed by calling this function when it is no longer needed.
- Returns
- none
| const int h4cf_get_attr_count |
( |
attr * |
a | ) |
|
h4cf_get_attr_count returns the number of elements stored in an attribute pointed by a.
For example, if coordsys attribute has type CHAR8 and value "Cartesian", the count will be 9. If valid_range attribute has type INT8 and value "0, -2", the count will be 2.
- Parameters
-
| a | a pointer to an attribute |
- Returns
- a number of elements.
| const string h4cf_get_attr_name |
( |
attr * |
a | ) |
|
h4cf_get_attr_name returns the name of an attribute pointed by a. The attribute name follows the CF conventions.
- Parameters
-
| a | a pointer to an attribute |
- Returns
- a string
| const h4cf_data_type h4cf_get_attr_type |
( |
attr * |
a | ) |
|
h4cf_get_attr_type returns the data type of an attribute pointed by a. The data type can be:
CHAR8
UCHAR8
INT8
UINT8
INT16
UINT16
INT32
UINT32
FLOAT
DOUBLE
- Parameters
-
| a | a pointer to an attribute |
- Returns
- a data type
| void h4cf_get_attr_value |
( |
vector< char > * |
buf, |
|
|
attr * |
a |
|
) |
| |
h4cf_get_attr_value reads the data values stored in an attribute pointed by a and saves them into buf vector.
- Parameters
-
| [out] | buf | a pointer to store values |
| [in] | a | a pointer to an attribute |
- Returns
- none
| const map<string, int> h4cf_get_dims |
( |
| ) |
|
h4cf_get_dims retrieves the dimension information and returns the pairs of name and size of dimension in map. The name of dimension follows the CF conventions.
For example, if the opening file has two dimensions XDim and YDim with their size 360 and 180 respectively, the returned map will be
- map[XDim] = 360
- map[YDim] = 180
- Returns
- a map containing dimension definitions. The key value in map is the name of the dimension and the mapped value is the size of the dimension.
| const list<attr*> h4cf_get_file_attrs |
( |
| ) |
|
h4cf_get_file_attrs returns the list of attributes.
- Returns
- a list of attributes.
| const attr* h4cf_get_var_attr_by_name |
( |
string |
str, |
|
|
var * |
v |
|
) |
| |
h4cf_get_var_attr_by_name returns the pointer to the attribute in a variable pointed by v if the attribute's name matches the str parameter.
- Parameters
-
| str | an attribute name to be searched for |
| v | a pointer to a variable |
- Returns
- a pointer to the matching attribute if present, otherwise NULL.
| const list<attr*> h4cf_get_var_attrs |
( |
var * |
v | ) |
|
h4cf_get_var_attrs returns the list of attributes in a variable pointed by v.
- Parameters
-
- Returns
- a list of attributes.
| const vector< map<string, int> > h4cf_get_var_dims |
( |
var * |
v | ) |
|
h4cf_get_var_dims retrieves the dimensions of a given variable and returns them in a C++ vector. Each dimension is a pair of name and size. The name of dimension follows the CF conventions.
For example, for a variable with two dimensions XDim and YDim with their size 360 and 180 respectively, the returned vector will be:
- vector[0] = <XDim, 360>
- vector[1] = <YDim, 180>
- Parameters
-
- Returns
- a vector of maps that have dimension name and size
| const string h4cf_get_var_name |
( |
var * |
v | ) |
|
h4cf_get_var_name returns the name of a variable pointed by v. The variable name follows the CF conventions.
- Parameters
-
- Returns
- a string
| const int h4cf_get_var_rank |
( |
var * |
v | ) |
|
h4cf_get_var_rank returns the number of dimensions of a variable pointed by v. For example, if v is O3[10][20][30], this function will return 3.
- Parameters
-
- Returns
- the rank of variable
| const h4cf_data_type h4cf_get_var_type |
( |
var * |
v | ) |
|
h4cf_get_var_type returns the data type of a variable pointed by v. The data type can be:
CHAR8
UCHAR8
INT8
UINT8
INT16
UINT16
INT32
UINT32
FLOAT
DOUBLE
- Parameters
-
- Returns
- a data type
| void h4cf_get_var_value |
( |
vector< char > * |
buf, |
|
|
var * |
v |
|
) |
| |
h4cf_get_var_value reads the data values stored in a variable pointed by v and saves them into the buf vector.
- Parameters
-
| [out] | buf | a pointer to store values |
| [in] | v | a pointer to a variable |
- Returns
- none
| void h4cf_get_var_value |
( |
vector< char > * |
buf, |
|
|
var * |
v, |
|
|
int32 * |
start, |
|
|
int32 * |
stride, |
|
|
int32 * |
edge |
|
) |
| |
h4cf_get_var_value returns the subset data values stored in a variable pointed by v and saves them into buf vector. The subsetting is controlled by the parameters stored in start, stride, and edge.
For example, if v has values like:
- v[0] = 0
- v[1] = 1
- v[2] = 2
- v[3] = 3
specifying start[0] = 1, stride[0] = 2, and edge[0] = 2 to this function will return
- Parameters
-
| [out] | buf | a pointer to store values |
| [in] | v | a pointer to a variable |
| [in] | start | a pointer to array containing the position at which this function will start for each dimension |
| [in] | stride | a pointer to array specifying the interval between the data values that will be read along each dimension |
| [in] | edge | a pointer to array containing the number of data elements along each dimension |
- Returns
- none
| const list<var*> h4cf_get_vars |
( |
| ) |
|
h4cf_get_vars returns a list of pointers of all variables in the file.
- Returns
- a list containing variable pointers.
| void h4cf_open |
( |
char * |
filename | ) |
|
h4cf_open opens filename file and initializes the library.
- Parameters
-
| filename | name of the file to be opened. |