Variable
-
group
harp_variable
The HARP Variables module contains everything related to HARP variables.
Typedefs
-
typedef struct harp_variable_struct
harp_variable
HARP Variable typedef
Functions
-
int
harp_variable_convert_unit
(harp_variable *variable, const char *target_unit) Perform unit conversion on a variable
Apply an automatic conversion on the variable to arrive at the new given unit. If there is no conversion available from the current unit to the new unit then an error will be raised. The data type of the variable will be changed to ‘double’ as part of the conversion.
- Return
0
, Success.-1
, Error occurred (check harp_errno).
- Parameters
variable
-Variable on which the apply unit conversion.
target_unit
-Unit to which the variable should be converted (use udunits2 compliant units).
-
int
harp_variable_new
(const char *name, harp_data_type data_type, int num_dimensions, const harp_dimension_type *dimension_type, const long *dimension, harp_variable **new_variable) Create new variable.
- Return
0
, Success.-1
, Error occurred (check harp_errno).
- Parameters
name
-Name of the variable.
data_type
-Storage type of the variable data.
num_dimensions
-Number of array dimensions (use ‘0’ for scalar data).
dimension_type
-Array with the dimension type for each of the dimensions.
dimension
-Array with length for each of the dimensions.
new_variable
-Pointer to the C variable where the new HARP variable will be stored.
-
void
harp_variable_delete
(harp_variable *variable) Delete variable. Remove variable and all attached attributes.
- Parameters
variable
-HARP variable
-
int
harp_variable_copy
(const harp_variable *other_variable, harp_variable **new_variable) Create a copy of a variable. The function will create a deep-copy of the given HARP variable, also creating copyies of all attributes.
- Return
0
, Success.-1
, Error occurred (check harp_errno).
- Parameters
other_variable
-Variable that should be copied.
new_variable
-Pointer to the C variable where the new HARP variable will be stored.
-
int
harp_variable_rename
(harp_variable *variable, const char *name) Change the name of a variable.
- Return
0
, Success.-1
, Error occurred (check harp_errno).
- Parameters
variable
-The variable for which the name should be changed.
name
-The new name of the variable.
-
int
harp_variable_convert_data_type
(harp_variable *variable, harp_data_type target_data_type) Convert the data for the variable such that it matches the given data type. The memory for the block holding the data for the attribute will be resized to match the new data type if needed. You cannot convert string data to numeric data or vice-versa. Conversion from floating point to integer data (or vice versa) is allowed though.
- Return
0
, Success.-1
, Error occurred (check harp_errno).
- Parameters
variable
-Variable whose data should be aligned with the given data type.
target_data_type
-Data type to which the data for the variable should be converted.
-
int
harp_variable_has_dimension_type
(const harp_variable *variable, harp_dimension_type dimension_type) Test if variable contains at least one dimension equal to the specified dimension type.
- Return
0
, Variable does not contain a dimension of the given dimension type1
, Variable contains at least one dimension of the given dimension type
- Parameters
variable
-Variable to check.
dimension_type
-Requested dimension type
-
int
harp_variable_has_dimension_types
(const harp_variable *variable, int num_dimensions, const harp_dimension_type *dimension_type) Test if variable has dimensions equal to the specified list of dimension types.
- Return
0
, Variable does not match the dimension types1
, Variable matches number of dimensions and specified type for each dimension.
- Parameters
variable
-Variable to check.
num_dimensions
-Number of dimensions the variable should have.
dimension_type
-Requested dimension type for each of the dimensions of the variable
-
int
harp_variable_has_unit
(const harp_variable *variable, const char *unit) Test if variable has a unit equal to the specified unit.
- Return
0
, The unit of the variable does not equal the given unit1
, The unit of the variable equals the given unit
- Parameters
variable
-Variable to check.
unit
-Number of dimensions the variable should have.
-
struct
harp_variable_struct
- #include <harp.h>
HARP Variable struct
Public Members
-
char *
name
name of variable
-
harp_data_type
data_type
storage type of the data
-
int
num_dimensions
number of array dimensions
-
harp_dimension_type
dimension_type
[HARP_MAX_NUM_DIMS] type of each of the array dimensions
-
long
dimension
[HARP_MAX_NUM_DIMS] length of each of the array dimensions
-
long
num_elements
total number of elements (equals product of array dimensions)
-
harp_array
data
array data of the variable
-
char *
description
corresponds to netCDF long_name
-
char *
unit
corresponds to netCDF units
-
harp_scalar
valid_min
corresponds to netCDF valid_min or valid_range[0]
-
harp_scalar
valid_max
corresponds to netCDF valid_max or valid_range[1]
-
char *
-
typedef struct harp_variable_struct