RAVE
rave_hlhdf_utilities.h File Reference

Utilities for working with H5 files. More...

#include "hlhdf.h"
#include "rave_utilities.h"
#include "rave_types.h"
#include <stdarg.h>

Go to the source code of this file.

Macros

#define RAVE_ODIM_VERSION_2_0_STR   "ODIM_H5/V2_0"
 ODIM Version string 2.0.
 
#define RAVE_ODIM_VERSION_2_1_STR   "ODIM_H5/V2_1"
 ODIM Version string 2.1.
 
#define RAVE_ODIM_VERSION_2_2_STR   "ODIM_H5/V2_2"
 ODIM Version string 2.2.
 
#define RAVE_ODIM_VERSION_2_3_STR   "ODIM_H5/V2_3"
 ODIM Version string 2.3.
 
#define RAVE_ODIM_VERSION_2_4_STR   "ODIM_H5/V2_4"
 ODIM Version string 2.4.
 
#define RAVE_ODIM_H5RAD_VERSION_2_0_STR   "H5rad 2.0"
 ODIM H5 rad version string 2.0.
 
#define RAVE_ODIM_H5RAD_VERSION_2_1_STR   "H5rad 2.1"
 ODIM H5 rad version string 2.1.
 
#define RAVE_ODIM_H5RAD_VERSION_2_2_STR   "H5rad 2.2"
 ODIM H5 rad version string 2.2.
 
#define RAVE_ODIM_H5RAD_VERSION_2_3_STR   "H5rad 2.3"
 ODIM H5 rad version string 2.3.
 
#define RAVE_ODIM_H5RAD_VERSION_2_4_STR   "H5rad 2.4"
 ODIM H5 rad version string 2.4.
 

Typedefs

typedef int(* RaveHL_attr_f) (void *object, RaveAttribute_t *attr)
 Attribute function called when an attribute is found.
 
typedef int(* RaveHL_data_f) (void *object, hsize_t xsize, hsize_t ysize, void *data, RaveDataType dtype, const char *nodeName)
 Data function called when an dataset is found.
 
typedef int(* RaveHL_group_f) (void *object, const char *groupname, const char *name)
 Group function called when a group is found.
 

Functions

const char * RaveHL_convertAttributeName (const char *name)
 Translates an attribute name from 2.0/2.1 ODIM into 2.2 ODIM.
 
const char * RaveHL_convertQuantity (const char *name)
 Translates a quantity from 2.0/2.1 ODIM into 2.2 ODIM.
 
const char * RaveHL_getOdimVersionString (RaveIO_ODIM_Version version)
 Returns the string representation of the specified odim version.
 
RaveIO_ODIM_Version RaveHL_getOdimVersionFromString (const char *str)
 Returns the odim version for the string representation of the ODIM version.
 
const char * RaveHL_getH5RadVersionStringFromOdimVersion (RaveIO_ODIM_Version version)
 Returns the h5rad string representation of the specified odim version since we can assume that the h5rad and odim version will follow each other.
 
RaveAttribute_tRaveHL_createAttribute (HL_Node *node)
 Creates a rave attribute from a HLHDF node value.
 
RaveAttribute_tRaveHL_getAttribute (HL_NodeList *nodelist, const char *fmt,...)
 Tries to find the node as defined by the varargs string and then create a rave attribute from it.
 
int RaveHL_hasNodeByName (HL_NodeList *nodelist, const char *fmt,...)
 Verifies if the file contains a node with the name as specified by the variable argument list.
 
int RaveHL_getStringValue (HL_NodeList *nodelist, char **value, const char *fmt,...)
 Gets a string value from a nodelist that is represented by a node named according to the varargs formatter string.
 
int RaveHL_createGroup (HL_NodeList *nodelist, const char *fmt,...)
 Creates a group node in the node list.
 
int RaveHL_createGroupUnlessExists (HL_NodeList *nodelist, const char *fmt,...)
 Creates a group node in the node list unless it already exists.
 
int RaveHL_createStringValue (HL_NodeList *nodelist, const char *value, const char *fmt,...)
 Adds a string value to a nodelist.
 
int RaveHL_addAttribute (HL_NodeList *nodelist, RaveAttribute_t *attribute, const char *fmt,...)
 Puts an attribute in the nodelist as a hlhdf node.
 
int RaveHL_addAttributes (HL_NodeList *nodelist, RaveObjectList_t *attributes, const char *name)
 Stores the attributes from the object into the nodelist name/how/..., name/where/... and name/what/... If the groups name/how, name/where, name/what does not exist they will be created for you.
 
int RaveHL_createDataset (HL_NodeList *nodelist, void *data, long xsize, long ysize, RaveDataType dataType, const char *fmt,...)
 Creates a dataset with the provided 2-dimensional array.
 
int RaveHL_addData (HL_NodeList *nodelist, void *data, long xsize, long ysize, RaveDataType dataType, const char *fmt,...)
 Adds a data field to the node list according to ODIM H5.
 
HL_FormatSpecifier RaveHL_raveToHlhdfType (RaveDataType format)
 Translates a rave data type into a hlhdf format specifier.
 
RaveDataType RaveHL_hlhdfToRaveType (HL_FormatSpecifier format)
 Translates a hlhdf format specified into a rave data type.
 
int RaveHL_loadAttributesAndData (HL_NodeList *nodelist, void *object, RaveHL_attr_f attrf, RaveHL_data_f dataf, const char *fmt,...)
 Loads the attributes from the nodelist name and calls the attrf and dataf respectively depending on what type is found.
 

Detailed Description

Utilities for working with H5 files.

Author
Anders Henja (Swedish Meteorological and Hydrological Institute, SMHI)
Date
2010-09-10

Macro Definition Documentation

◆ RAVE_ODIM_H5RAD_VERSION_2_0_STR

#define RAVE_ODIM_H5RAD_VERSION_2_0_STR   "H5rad 2.0"

ODIM H5 rad version string 2.0.

◆ RAVE_ODIM_H5RAD_VERSION_2_1_STR

#define RAVE_ODIM_H5RAD_VERSION_2_1_STR   "H5rad 2.1"

ODIM H5 rad version string 2.1.

◆ RAVE_ODIM_H5RAD_VERSION_2_2_STR

#define RAVE_ODIM_H5RAD_VERSION_2_2_STR   "H5rad 2.2"

ODIM H5 rad version string 2.2.

◆ RAVE_ODIM_H5RAD_VERSION_2_3_STR

#define RAVE_ODIM_H5RAD_VERSION_2_3_STR   "H5rad 2.3"

ODIM H5 rad version string 2.3.

◆ RAVE_ODIM_H5RAD_VERSION_2_4_STR

#define RAVE_ODIM_H5RAD_VERSION_2_4_STR   "H5rad 2.4"

ODIM H5 rad version string 2.4.

◆ RAVE_ODIM_VERSION_2_0_STR

#define RAVE_ODIM_VERSION_2_0_STR   "ODIM_H5/V2_0"

ODIM Version string 2.0.

◆ RAVE_ODIM_VERSION_2_1_STR

#define RAVE_ODIM_VERSION_2_1_STR   "ODIM_H5/V2_1"

ODIM Version string 2.1.

◆ RAVE_ODIM_VERSION_2_2_STR

#define RAVE_ODIM_VERSION_2_2_STR   "ODIM_H5/V2_2"

ODIM Version string 2.2.

◆ RAVE_ODIM_VERSION_2_3_STR

#define RAVE_ODIM_VERSION_2_3_STR   "ODIM_H5/V2_3"

ODIM Version string 2.3.

◆ RAVE_ODIM_VERSION_2_4_STR

#define RAVE_ODIM_VERSION_2_4_STR   "ODIM_H5/V2_4"

ODIM Version string 2.4.

Typedef Documentation

◆ RaveHL_attr_f

typedef int(* RaveHL_attr_f) (void *object, RaveAttribute_t *attr)

Attribute function called when an attribute is found.

Parameters
[in]object- the object passed on from the loading functions
[in]attr- the attribute
Returns
1 on success or 0 at failure

◆ RaveHL_data_f

typedef int(* RaveHL_data_f) (void *object, hsize_t xsize, hsize_t ysize, void *data, RaveDataType dtype, const char *nodeName)

Data function called when an dataset is found.

Parameters
[in]object- the object passed on from the loading functions
[in]xsize- the xsize
[in]ysize- the ysize
[in]data- the dataset data
[in]dtype- the data type
[in]nodeName- the name of the data type
Returns
1 on success or 0 at failure

◆ RaveHL_group_f

typedef int(* RaveHL_group_f) (void *object, const char *groupname, const char *name)

Group function called when a group is found.

Parameters
[in]object- the object passed on from the loading functions
[in]groupname- the name of the group
[in]name- the attribute name
Returns
1 on success or 0 at failure

Function Documentation

◆ RaveHL_addAttribute()

int RaveHL_addAttribute ( HL_NodeList * nodelist,
RaveAttribute_t * attribute,
const char * fmt,
... )

Puts an attribute in the nodelist as a hlhdf node.

Parameters
[in]nodelist- the node list
[in]attribute- the attribute, the name of the attribute will be used as attr-member
[in]fmt- the root name, specified as a varargs
[in]...- the varargs list
Returns
1 on success otherwise 0

◆ RaveHL_addAttributes()

int RaveHL_addAttributes ( HL_NodeList * nodelist,
RaveObjectList_t * attributes,
const char * name )

Stores the attributes from the object into the nodelist name/how/..., name/where/... and name/what/... If the groups name/how, name/where, name/what does not exist they will be created for you.

All other groups you will have to add your self.

Parameters
[in]nodelist- the hlhdf list
[in]name- the name of the object
[in]object- the object to fill

As of ODIM 2.3 we should support subgroups in how

◆ RaveHL_addData()

int RaveHL_addData ( HL_NodeList * nodelist,
void * data,
long xsize,
long ysize,
RaveDataType dataType,
const char * fmt,
... )

Adds a data field to the node list according to ODIM H5.

If data type is UCHAR, the nessecary attributes for viewing in HdfView will also be added. The name will always be <root>/data since that is according to ODIM H5 as well.

Parameters
[in]nodelist- the node list that should get nodes added
[in]data- the array data
[in]xsize- the xsize
[in]ysize- the ysize
[in]dataType- type of data
[in]fmt- the varargs format
[in]...- the vararg list
Returns
1 on success otherwise 0

◆ RaveHL_convertAttributeName()

const char * RaveHL_convertAttributeName ( const char * name)

Translates an attribute name from 2.0/2.1 ODIM into 2.2 ODIM.

For example how/TXloss => how/TXlossH.

Parameters
[in]name- name of current attribute
Returns
the original name if no conversion can be done otherwise the translated name

◆ RaveHL_convertQuantity()

const char * RaveHL_convertQuantity ( const char * name)

Translates a quantity from 2.0/2.1 ODIM into 2.2 ODIM.

For example VRAD => VRADH.

Parameters
[in]name- name of current quantity
Returns
the original name if no conversion can be done otherwise the translated name

◆ RaveHL_createAttribute()

RaveAttribute_t * RaveHL_createAttribute ( HL_Node * node)

Creates a rave attribute from a HLHDF node value.

Node must contain data that can be translated to long, double or strings otherwise NULL will be returned. Note, the name will not be set on the attribute and has to be set after this function has been called.

Parameters
[in]node- the HLHDF node
Returns
the rave attribute on success, otherwise NULL.

◆ RaveHL_createDataset()

int RaveHL_createDataset ( HL_NodeList * nodelist,
void * data,
long xsize,
long ysize,
RaveDataType dataType,
const char * fmt,
... )

Creates a dataset with the provided 2-dimensional array.

Parameters
[in]nodelist- the node list
[in]data- the data
[in]xsize- the xsize
[in]ysize- the ysize
[in]dataType- the type of data
[in]fmt- the variable argument format
[in]...- the arguments.
Returns
1 on success, otherwise 0

◆ RaveHL_createGroup()

int RaveHL_createGroup ( HL_NodeList * nodelist,
const char * fmt,
... )

Creates a group node in the node list.

Parameters
[in]nodelist- the node list
[in]fmt- the variable argument format
[in]...- the arguments.

◆ RaveHL_createGroupUnlessExists()

int RaveHL_createGroupUnlessExists ( HL_NodeList * nodelist,
const char * fmt,
... )

Creates a group node in the node list unless it already exists.

Parameters
[in]nodelist- the node list
[in]fmt- the variable argument format
[in]...- the arguments.

◆ RaveHL_createStringValue()

int RaveHL_createStringValue ( HL_NodeList * nodelist,
const char * value,
const char * fmt,
... )

Adds a string value to a nodelist.

Parameters
[in]nodelist- the hlhdf node list
[in]value- the string value
[in]fmt- the varargs format string
Returns
1 on success otherwise 0

◆ RaveHL_getAttribute()

RaveAttribute_t * RaveHL_getAttribute ( HL_NodeList * nodelist,
const char * fmt,
... )

Tries to find the node as defined by the varargs string and then create a rave attribute from it.

Parameters
[in]nodelist- the node list
[in]fmt- the varargs format
[in]...- the varargs

◆ RaveHL_getH5RadVersionStringFromOdimVersion()

const char * RaveHL_getH5RadVersionStringFromOdimVersion ( RaveIO_ODIM_Version version)

Returns the h5rad string representation of the specified odim version since we can assume that the h5rad and odim version will follow each other.

Parameters
[in]version- the ODIM version
Returns
the string representation or UNDEFINED if not found

◆ RaveHL_getOdimVersionFromString()

RaveIO_ODIM_Version RaveHL_getOdimVersionFromString ( const char * str)

Returns the odim version for the string representation of the ODIM version.

Parameters
[in]str- the string representation
Returns
the odim version or undefined if not found

◆ RaveHL_getOdimVersionString()

const char * RaveHL_getOdimVersionString ( RaveIO_ODIM_Version version)

Returns the string representation of the specified odim version.

Parameters
[in]version- the ODIM version
Returns
the string representation or UNDEFINED if not found

◆ RaveHL_getStringValue()

int RaveHL_getStringValue ( HL_NodeList * nodelist,
char ** value,
const char * fmt,
... )

Gets a string value from a nodelist that is represented by a node named according to the varargs formatter string.

The returned string is pointing to internal memory in the nodelist so DO NOT FREE!!

Parameters
[in]nodelist- the node list
[in|out]value - the value (Pointing to internal memory, DO NOT FREE)
[in]fmt- the varargs formatter string
[in]...- the varargs
Returns
1 on success otherwise 0

◆ RaveHL_hasNodeByName()

int RaveHL_hasNodeByName ( HL_NodeList * nodelist,
const char * fmt,
... )

Verifies if the file contains a node with the name as specified by the variable argument list.

Parameters
[in]nodelist- the hlhdf nodelist
[in]fmt- the variable argument format specifier
[in]...- the variable argument list
Returns
1 if the node could be found, otherwise 0

◆ RaveHL_hlhdfToRaveType()

RaveDataType RaveHL_hlhdfToRaveType ( HL_FormatSpecifier format)

Translates a hlhdf format specified into a rave data type.

Parameters
[in]format- the hlhdf format specified
Returns
the RaveDataType

◆ RaveHL_loadAttributesAndData()

int RaveHL_loadAttributesAndData ( HL_NodeList * nodelist,
void * object,
RaveHL_attr_f attrf,
RaveHL_data_f dataf,
const char * fmt,
... )

Loads the attributes from the nodelist name and calls the attrf and dataf respectively depending on what type is found.

E.g. name/how/..., name/where/... and name/what/...

Parameters
[in]nodelist- the hlhdf list
[in]object- the object to fill
[in]fmt- the varargs name of the object
[in]...- the varargs
Returns
1 on success otherwise 0

Loads the attributes from the nodelist name and calls the attrf and dataf respectively depending on what type is found.

I.e. name/how/..., name/where/... and name/what/...

Parameters
[in]nodelist- the hlhdf list
[in]object- the object to fill
[in]fmt- the varargs name of the object
[in]...- the varargs
Returns
1 on success otherwise 0

◆ RaveHL_raveToHlhdfType()

HL_FormatSpecifier RaveHL_raveToHlhdfType ( RaveDataType format)

Translates a rave data type into a hlhdf format specifier.

Parameters
[in]format- the rave data type
Returns
the hlhdf format specifier