RAVE
rave_hlhdf_utilities.c File Reference

Utilities for working with H5 files. More...

#include "rave_hlhdf_utilities.h"
#include "rave_debug.h"
#include "rave_alloc.h"
#include "rave_utilities.h"
#include "string.h"
#include "stdarg.h"

Classes

struct  RaveToHlhdfTypeMap
 Mapping between hlhdf format and rave data type. More...
 
struct  OdimVersionToStrTypeMap
 Type for keeping mapping. More...
 

Macros

#define RAVEHL_GET_ATOMIC_NODEVALUE(vt, nn, ss, ot, ov)
 Quick access function for reading one atomic value from a HLHDF node.
 
#define RAVEHL_GET_ARRAY_NODEVALUE(vt, nn, ss, ot, ov, dd)
 Quick access function for reading a simple array from a HLHDF node.
 

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.
 
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.
 
RaveIO_ODIM_Version RaveHL_getOdimVersionFromString (const char *str)
 Returns the odim version for the string representation of the ODIM version.
 
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.
 
RaveList_tRaveHL_extractSubGroups (const char *attrname)
 
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 name into the RaveCoreObject.
 

Variables

const char * ATTRIBUTE_NAMES_20_to_22 [][2]
 Attribute names that has to be translated when jumping from 2.0/2.1 up to 2.2.
 
const char * QUANTITIES_20_to_22 [][2]
 Quantities that has to be translated when jumping from 2.0/2.1 to 2.2.
 

Detailed Description

Utilities for working with H5 files.

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

Macro Definition Documentation

◆ RAVEHL_GET_ARRAY_NODEVALUE

#define RAVEHL_GET_ARRAY_NODEVALUE ( vt,
nn,
ss,
ot,
ov,
dd )
Value:
{ \
int rhlidx; \
for (rhlidx=0; rhlidx<dd; rhlidx++) { \
ov[rhlidx] = (ot)((vt*)HLNode_getData(nn))[rhlidx]; \
} \
}

Quick access function for reading a simple array from a HLHDF node.

Parameters
[in]vt- the type for the read data
[in]nn- the node
[in]ss- the size of the data type
[in]ot- the type of the output value where assignment will be done.
[in]ov- the output value
[in]dd- the dimension

◆ RAVEHL_GET_ATOMIC_NODEVALUE

#define RAVEHL_GET_ATOMIC_NODEVALUE ( vt,
nn,
ss,
ot,
ov )
Value:
{ \
vt v; \
memcpy(&v, HLNode_getData(nn), ss); \
ov = (ot)v; \
}

Quick access function for reading one atomic value from a HLHDF node.

Parameters
[in]vt- the type for the read data
[in]nn- the node
[in]ss- the size of the data type
[in]ot- the type of the output value where assignment will be done.
[in]ov- the output value

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 name into the RaveCoreObject.

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

Variable Documentation

◆ ATTRIBUTE_NAMES_20_to_22

const char* ATTRIBUTE_NAMES_20_to_22[][2]
Initial value:
= {
{"how/TXloss", "how/TXlossH"},
{"how/injectloss", "how/injectlossH"},
{"how/RXloss", "how/RXlossH"},
{"how/radomeloss", "how/radomelossH"},
{"how/antgain", "how/antgainH"},
{"how/beamw", "how/beamwH"},
{"how/beamwidth", "how/beamwH"},
{"how/radconst", "how/radconstH"},
{"how/NEZ", "how/NEZH"},
{"how/zcal", "how/zcalH"},
{"how/nsample", "how/nsampleH"},
{NULL, NULL}
}

Attribute names that has to be translated when jumping from 2.0/2.1 up to 2.2.

◆ QUANTITIES_20_to_22

const char* QUANTITIES_20_to_22[][2]
Initial value:
= {
{"DBZ", "DBZH"},
{"SQI", "SQIH"},
{"SNR", "SNRH"},
{"CCOR", "CCORH"},
{"VRAD", "VRADH"},
{"WRAD", "WRADH"},
{NULL, NULL}
}

Quantities that has to be translated when jumping from 2.0/2.1 to 2.2.