RAVE
odim_io_utilities.c File Reference

Utilities when working with ODIM H5 files. More...

#include "odim_io_utilities.h"
#include "rave_debug.h"
#include "rave_alloc.h"
#include "rave_hlhdf_utilities.h"
#include "hlhdf_compound_utils.h"
#include "rave_legend.h"
#include <string.h>
#include <math.h>

Macros

#define SPEED_OF_LIGHT   299792458 /* m/s */
 
#define DEFAULT_MINKEYLEN   64
 
#define DEFAULT_MINVALUELEN   32
 

Functions

int OdimIoUtilities_convertGainOffsetFromInternalRave (const char *quantity, RaveIO_ODIM_Version version, double *gain, double *offset)
 Converts the gain and offset so that quantity is adjusted for ODIM version to be written.
 
int OdimIoUtilities_convertGainOffsetToInternalRave (const char *quantity, RaveIO_ODIM_Version version, double *gain, double *offset)
 Converts the gain and offset so that quantity is adjusted for the internally used quantity.
 
int OdimIoUtilities_addRaveField (RaveField_t *field, HL_NodeList *nodelist, RaveIO_ODIM_Version version, const char *fmt,...)
 Adds a rave field to a nodelist.
 
int OdimIoUtilities_addQualityFields (RaveObjectList_t *fields, HL_NodeList *nodelist, RaveIO_ODIM_Version version, const char *fmt,...)
 Adds a list of quality fields (RaveField_t) to a nodelist.
 
RaveField_tOdimIoUtilities_loadField (LazyNodeListReader_t *lazyReader, RaveIO_ODIM_Version version, const char *fmt,...)
 Loads a rave field.
 
RaveLegend_tOdimIOUtilities_loadLegend (LazyNodeListReader_t *lazyReader, RaveIO_ODIM_Version version, const char *fmt,...)
 Loads a rave legend.
 
int OdimIoUtilities_getIdFromSource (const char *source, const char *id, char *buf, size_t buflen)
 Gets the specified id from the source string, for example.
 
int OdimIoUtilities_getNodOrCmtFromSource (const char *source, char *buf, size_t buflen)
 Like OdimIoUtilities_getIdFromSource but will first check NOD: and then CMT:
 
int OdimIoUtilities_createLegend (RaveLegend_t *legend, HL_NodeList *nodelist, RaveIO_ODIM_Version version, const char *fmt,...)
 Adds a legend (RaveLegend_t) to a nodelist.
 

Detailed Description

Utilities when working with ODIM H5 files.

Author
Anders Henja (Swedish Meteorological and Hydrological Institute, SMHI)
Date
2011-09-30

Function Documentation

◆ OdimIoUtilities_addQualityFields()

int OdimIoUtilities_addQualityFields ( RaveObjectList_t * fields,
HL_NodeList * nodelist,
RaveIO_ODIM_Version version,
const char * fmt,
... )

Adds a list of quality fields (RaveField_t) to a nodelist.

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

◆ OdimIoUtilities_addRaveField()

int OdimIoUtilities_addRaveField ( RaveField_t * field,
HL_NodeList * nodelist,
RaveIO_ODIM_Version outversion,
const char * fmt,
... )

Adds a rave field to a nodelist.

Parameters
[in]field- the field
[in]nodelist- the hlhdf node list
[in]outversion- the version of file to be written
[in]fmt- the varargs format string
[in]...- the varargs
Returns
1 on success otherwise 0

◆ OdimIoUtilities_convertGainOffsetFromInternalRave()

int OdimIoUtilities_convertGainOffsetFromInternalRave ( const char * quantity,
RaveIO_ODIM_Version version,
double * gain,
double * offset )

Converts the gain and offset so that quantity is adjusted for ODIM version to be written.

Parameters
[in]quantity- the quantity that is affected
[in]version- ODIM version that should be written
[in,out]gain- the gain. Will be adjusted according to needs
[in,out]offset- the offset. Will be adjusted according to needs
Returns
1 on success

◆ OdimIoUtilities_convertGainOffsetToInternalRave()

int OdimIoUtilities_convertGainOffsetToInternalRave ( const char * quantity,
RaveIO_ODIM_Version version,
double * gain,
double * offset )

Converts the gain and offset so that quantity is adjusted for the internally used quantity.

Parameters
[in]quantity- the quantity that is affected
[in]version- ODIM version that should be written
[in,out]gain- the gain. Will be adjusted according to needs
[in,out]offset- the offset. Will be adjusted according to needs
Returns
1 on success

◆ OdimIoUtilities_createLegend()

int OdimIoUtilities_createLegend ( RaveLegend_t * legend,
HL_NodeList * nodelist,
RaveIO_ODIM_Version version,
const char * fmt,
... )

Adds a legend (RaveLegend_t) to a nodelist.

Parameters
[in]legend- the legend
[in]nodelist- the hlhdf node list
[in]outversion- the version of file to be written
[in]fmt- the varargs format string
[in]...- the varargs
Returns
1 on success otherwise 0

◆ OdimIoUtilities_getIdFromSource()

int OdimIoUtilities_getIdFromSource ( const char * source,
const char * id,
char * buf,
size_t buflen )

Gets the specified id from the source string, for example.

If source string contains CMT:abc,NOD:selek,RAD:se50 then if id = NOD: buf will be filled with selek

Parameters
[in]source- the what/source string
[in]id- the id to search for ended with a :, for example NOD:
[in,out]buf- the buffer filled with the found id
[in]buflen- the length of buf
Returns
1 if id was found and did fit into buf, otherwise 0

◆ OdimIoUtilities_getNodOrCmtFromSource()

int OdimIoUtilities_getNodOrCmtFromSource ( const char * source,
char * buf,
size_t buflen )

Like OdimIoUtilities_getIdFromSource but will first check NOD: and then CMT:

Parameters
[in]source- the what/source string
[in]id- the id to search for ended with a :, for example NOD:
[in,out]buf- the buffer filled with the found id
[in]buflen- the length of buf
Returns
1 if id was found and did fit into buf, otherwise 0

◆ OdimIoUtilities_loadField()

RaveField_t * OdimIoUtilities_loadField ( LazyNodeListReader_t * lazyReader,
RaveIO_ODIM_Version version,
const char * fmt,
... )

Loads a rave field.

A rave field can be just about anything with a mapping between attributes and a dataset.

Parameters
[in]nodelist- the hlhdf node list
[in]nodelist- version of the file read
[in]fmt- the variable argument list string format
[in]...- the variable argument list
Returns
a rave field on success otherwise NULL

◆ OdimIOUtilities_loadLegend()

RaveLegend_t * OdimIOUtilities_loadLegend ( LazyNodeListReader_t * lazyReader,
RaveIO_ODIM_Version version,
const char * fmt,
... )

Loads a rave legend.

The compound type should have been written in a dataset according to the specification.

Parameters
[in]lazyReader- the wrapper around the hlhdf node list
[in]version- version of the file read
[in]fmt- the variable argument list string format
[in]...- the variable argument list
Returns
a rave legend on success otherwise NULL