RAVE
rave_io.c File Reference

Functions for performing rave related IO operations, mostly ODIM-formatted HDF5 files. More...

#include <lazy_nodelist_reader.h>
#include "rave_io.h"
#include "rave_debug.h"
#include "rave_alloc.h"
#include "rave_utilities.h"
#include "rave_data2d.h"
#include "hlhdf.h"
#include "hlhdf_alloc.h"
#include "hlhdf_debug.h"
#include "string.h"
#include "stdarg.h"
#include "raveobject_hashtable.h"
#include "raveobject_list.h"
#include "polarvolume.h"
#include "cartesianvolume.h"
#include "rave_field.h"
#include "rave_hlhdf_utilities.h"
#include "cartesian_odim_io.h"
#include "polar_odim_io.h"
#include "vp_odim_io.h"

Classes

struct  _RaveIO_t
 Defines the structure for the RaveIO in a volume. More...
 

Functions

void RaveIO_close (RaveIO_t *raveio)
 Closes the HDF5 file but will keep the RaveIO instance.
 
RaveIO_tRaveIO_open (const char *filename, int lazyLoading, const char *preloadQuantities)
 Opens a supported HDF5 file and loads it into the RaveIO instance.
 
int RaveIO_load (RaveIO_t *raveio, int lazyLoading, const char *preloadQuantities)
 Loads the HDF5 file into the raveio instance.
 
int RaveIO_save (RaveIO_t *raveio, const char *filename)
 Saves a rave object as specified according to ODIM HDF5 format specification.
 
void RaveIO_setObject (RaveIO_t *raveio, RaveCoreObject *object)
 Sets the object to be saved.
 
RaveCoreObjectRaveIO_getObject (RaveIO_t *raveio)
 Returns the loaded object/object to be saved.
 
int RaveIO_setFilename (RaveIO_t *raveio, const char *filename)
 Sets the filename that should be used when saving the object.
 
const char * RaveIO_getFilename (RaveIO_t *raveio)
 Returns the current filename.
 
Rave_ObjectType RaveIO_getObjectType (RaveIO_t *raveio)
 Returns the object type for the currently opened file.
 
int RaveIO_setOdimVersion (RaveIO_t *raveio, RaveIO_ODIM_Version version)
 Sets the ODIM version to use when saving the file.
 
RaveIO_ODIM_Version RaveIO_getOdimVersion (RaveIO_t *raveio)
 Returns the ODIM version that will be used to write the file.
 
RaveIO_ODIM_Version RaveIO_getReadOdimVersion (RaveIO_t *raveio)
 Returns the ODIM version of the file that was read.
 
int RaveIO_setH5radVersion (RaveIO_t *raveio, RaveIO_ODIM_H5rad_Version version)
 Sets the ODIM h5rad version to use when saving the file.
 
RaveIO_ODIM_H5rad_Version RaveIO_getH5radVersion (RaveIO_t *raveio)
 Returns the h5rad version.
 
RaveIO_ODIM_FileFormat RaveIO_getFileFormat (RaveIO_t *raveio)
 Will return the file format that this file was read as.
 
int RaveIO_setFileFormat (RaveIO_t *raveio, RaveIO_ODIM_FileFormat format)
 Sets what file format to use.
 
void RaveIO_setStrict (RaveIO_t *raveio, int strict)
 If writing should be done strictly.
 
int RaveIO_isStrict (RaveIO_t *raveio)
 If writing should be done strictly.
 
void RaveIO_setCompressionLevel (RaveIO_t *raveio, int lvl)
 Sets the compression level.
 
int RaveIO_getCompressionLevel (RaveIO_t *raveio)
 Returns the compression level.
 
void RaveIO_setUserBlock (RaveIO_t *raveio, unsigned long long userblock)
 Sets the user block.
 
unsigned long long RaveIO_getUserBlock (RaveIO_t *raveio)
 Returns the user block.
 
void RaveIO_setSizes (RaveIO_t *raveio, size_t sz, size_t addr)
 Sets the sizes.
 
void RaveIO_getSizes (RaveIO_t *raveio, size_t *sz, size_t *addr)
 Returns the sizes.
 
void RaveIO_setSymk (RaveIO_t *raveio, int ik, int lk)
 Sets the symk.
 
void RaveIO_getSymk (RaveIO_t *raveio, int *ik, int *lk)
 Returns the symk.
 
void RaveIO_setIStoreK (RaveIO_t *raveio, long k)
 Sets the istore_k value.
 
long RaveIO_getIStoreK (RaveIO_t *raveio)
 Returns the istore_k value.
 
void RaveIO_setMetaBlockSize (RaveIO_t *raveio, long sz)
 Sets the meta block size.
 
long RaveIO_getMetaBlockSize (RaveIO_t *raveio)
 Returns the meta block size.
 
int RaveIO_setBufrTableDir (RaveIO_t *raveio, const char *dname)
 Sets the bufr table directory to use when reading bufr files.
 
const char * RaveIO_getBufrTableDir (RaveIO_t *raveio)
 Returns the bufr table directory.
 
const char * RaveIO_getErrorMessage (RaveIO_t *raveio)
 If an error occurs during writing, you might get an indication for why by checking the error message.
 
int RaveIO_supports (RaveIO_ODIM_FileFormat format)
 Returns if the raveio supports the provided file format.
 

Variables

RaveCoreObjectType RaveIO_TYPE
 Type definition to use when creating a rave object.
 

Detailed Description

Functions for performing rave related IO operations, mostly ODIM-formatted HDF5 files.

Author
Anders Henja (Swedish Meteorological and Hydrological Institute, SMHI)
Date
2009-11-12

Function Documentation

◆ RaveIO_close()

void RaveIO_close ( RaveIO_t * raveio)

Closes the HDF5 file but will keep the RaveIO instance.

Parameters
[in]raveio- the rave IO instance

◆ RaveIO_getBufrTableDir()

const char * RaveIO_getBufrTableDir ( RaveIO_t * raveio)

Returns the bufr table directory.

Parameters
[in]raveio- self
Returns
the bufr table directory

◆ RaveIO_getCompressionLevel()

int RaveIO_getCompressionLevel ( RaveIO_t * raveio)

Returns the compression level.

Parameters
[in]raveio-self
Returns
the compression level

◆ RaveIO_getErrorMessage()

const char * RaveIO_getErrorMessage ( RaveIO_t * raveio)

If an error occurs during writing, you might get an indication for why by checking the error message.

Parameters
[in]raveio- rave io
Returns
the error message (will be an empty string if nothing to report).

◆ RaveIO_getFileFormat()

RaveIO_ODIM_FileFormat RaveIO_getFileFormat ( RaveIO_t * raveio)

Will return the file format that this file was read as.

Note, it is currently not possible to save data files in any other formats than HDF5.

Parameters
[in]raveio- self
Returns
the file format.

◆ RaveIO_getFilename()

const char * RaveIO_getFilename ( RaveIO_t * raveio)

Returns the current filename.

Parameters
[in]raveio- self
Returns
the current filename

◆ RaveIO_getH5radVersion()

RaveIO_ODIM_H5rad_Version RaveIO_getH5radVersion ( RaveIO_t * raveio)

Returns the h5rad version.

Parameters
[in]raveio- self
Returns
the h5rad version

◆ RaveIO_getIStoreK()

long RaveIO_getIStoreK ( RaveIO_t * raveio)

Returns the istore_k value.

Parameters
[in]raveio- self
Returns
the istore_k value

◆ RaveIO_getMetaBlockSize()

long RaveIO_getMetaBlockSize ( RaveIO_t * raveio)

Returns the meta block size.

Parameters
[in]raveio- self
Returns
the meta block size

◆ RaveIO_getObject()

RaveCoreObject * RaveIO_getObject ( RaveIO_t * raveio)

Returns the loaded object/object to be saved.

Parameters
[in]raveio- self
Returns
the object

◆ RaveIO_getObjectType()

Rave_ObjectType RaveIO_getObjectType ( RaveIO_t * raveio)

Returns the object type for the currently opened file.

Requires that a RaveCoreObject has been set.

Parameters
[in]raveio- the Rave IO instance
Returns
the object type or Rave_ObjectType_UNDEFINED on error.

◆ RaveIO_getOdimVersion()

RaveIO_ODIM_Version RaveIO_getOdimVersion ( RaveIO_t * raveio)

Returns the ODIM version that will be used to write the file.

Parameters
[in]raveio- self
Returns
the ODIM version

◆ RaveIO_getReadOdimVersion()

RaveIO_ODIM_Version RaveIO_getReadOdimVersion ( RaveIO_t * raveio)

Returns the ODIM version of the file that was read.

Parameters
[in]raveio- self
Returns
the ODIM version

◆ RaveIO_getSizes()

void RaveIO_getSizes ( RaveIO_t * raveio,
size_t * sz,
size_t * addr )

Returns the sizes.

Parameters
[in]raveio- self
[in]sz- same as sizes.sizeof_size
[in]addr- same as sizes.sizeof_addr

◆ RaveIO_getSymk()

void RaveIO_getSymk ( RaveIO_t * raveio,
int * ik,
int * lk )

Returns the symk.

Parameters
[in]raveio- self
[in]ik- same as sym_k.ik
[in]lk- same as sym_k.lk

◆ RaveIO_getUserBlock()

unsigned long long RaveIO_getUserBlock ( RaveIO_t * raveio)

Returns the user block.

Parameters
[in]raveio- self
Returns
the user block

◆ RaveIO_isStrict()

int RaveIO_isStrict ( RaveIO_t * raveio)

If writing should be done strictly.

From ODIM H5 2.4 several how-attributes are mandatory. If any of these are missing and strict is set to true, then the writing will fail.

Parameters
[in]raveio- self
Returns
if writing should be performed strictly or not

◆ RaveIO_load()

int RaveIO_load ( RaveIO_t * raveio,
int lazyLoading,
const char * preloadQuantities )

Loads the HDF5 file into the raveio instance.

Parameters
[in]raveio- self
[in]lazyLoading- if file should be loaded in lazy mode or not
[in]preloadQuantities- if lazy loading, then these quantities will be loaded immediately.*
Returns
the opened object

◆ RaveIO_open()

RaveIO_t * RaveIO_open ( const char * filename,
int lazyLoading,
const char * preloadQuantities )

Opens a supported HDF5 file and loads it into the RaveIO instance.

Same as: RaveIO_t* instance = RAVE_OBJECT_NEW(&RaveIO_TYPE); RaveIO_setFilename(instance, filename); RaveIO_load(instance);

Parameters
[in]filename- the HDF5 file to open
[in]lazyLoading- if file should be loaded in lazy mode or not
[in]preloadQuantities- if lazy loading, then these quantities will be loaded immediately.
Returns
The raveio instance on success, otherwise NULL.

◆ RaveIO_save()

int RaveIO_save ( RaveIO_t * raveio,
const char * filename )

Saves a rave object as specified according to ODIM HDF5 format specification.

Parameters
[in]raveio- self
[in]filename- the filename to save with. May be NULL, same as calling RaveIO_setFilename followed by RaveIO_save(..., NULL)
Returns
1 on success, otherwise 0

◆ RaveIO_setBufrTableDir()

int RaveIO_setBufrTableDir ( RaveIO_t * raveio,
const char * dname )

Sets the bufr table directory to use when reading bufr files.

This function is only relevant if BUFR support has been enabled otherwise it will just be a setter that isn't used.

Parameters
[in]raveio- self
[in]dname- the directory name
Returns
1 on success otherwise 0

◆ RaveIO_setCompressionLevel()

void RaveIO_setCompressionLevel ( RaveIO_t * raveio,
int lvl )

Sets the compression level.

Parameters
[in]raveio- self
[in]lvl- the compression level (0..9)

◆ RaveIO_setFileFormat()

int RaveIO_setFileFormat ( RaveIO_t * raveio,
RaveIO_ODIM_FileFormat format )

Sets what file format to use.

Parameters
[in]raveio- self
[in]format- the file format to use
Returns
1 on success otherwise 0

◆ RaveIO_setFilename()

int RaveIO_setFilename ( RaveIO_t * raveio,
const char * filename )

Sets the filename that should be used when saving the object.

Parameters
[in]raveio- self
[in]filename- the filename that should be used when saving.
Returns
1 on success, otherwise 0

◆ RaveIO_setH5radVersion()

int RaveIO_setH5radVersion ( RaveIO_t * raveio,
RaveIO_ODIM_H5rad_Version version )

Sets the ODIM h5rad version to use when saving the file.

Currently, the only supported version is 2.0.

Parameters
[in]raveio- self
[in]version- the version to be used
Returns
1 if the specified version is supported, otherwise 0.

◆ RaveIO_setIStoreK()

void RaveIO_setIStoreK ( RaveIO_t * raveio,
long k )

Sets the istore_k value.

Parameters
[in]raveio- self
[in]k- the istore_k value

◆ RaveIO_setMetaBlockSize()

void RaveIO_setMetaBlockSize ( RaveIO_t * raveio,
long sz )

Sets the meta block size.

Parameters
[in]raveio- self
[in]sz- the meta block size

◆ RaveIO_setObject()

void RaveIO_setObject ( RaveIO_t * raveio,
RaveCoreObject * object )

Sets the object to be saved.

Parameters
[in]raveio- self
[in]object- the object to be saved

◆ RaveIO_setOdimVersion()

int RaveIO_setOdimVersion ( RaveIO_t * raveio,
RaveIO_ODIM_Version version )

Sets the ODIM version to use when saving the file.

Parameters
[in]raveio- self
[in]version- the version to be used
Returns
1 if the specified version is supported, otherwise 0.

◆ RaveIO_setSizes()

void RaveIO_setSizes ( RaveIO_t * raveio,
size_t sz,
size_t addr )

Sets the sizes.

Parameters
[in]raveio- self
[in]sz- same as sizes.sizeof_size
[in]addr- same as sizes.sizeof_addr

◆ RaveIO_setStrict()

void RaveIO_setStrict ( RaveIO_t * raveio,
int strict )

If writing should be done strictly.

From ODIM H5 2.4 several how-attributes are mandatory. If any of these are missing and strict is set to true, then the writing will fail.

Parameters
[in]raveio- self
[in]strict- if writing should be performed strictly or not

◆ RaveIO_setSymk()

void RaveIO_setSymk ( RaveIO_t * raveio,
int ik,
int lk )

Sets the symk.

Parameters
[in]raveio- self
[in]ik- same as sym_k.ik
[in]lk- same as sym_k.lk

◆ RaveIO_setUserBlock()

void RaveIO_setUserBlock ( RaveIO_t * raveio,
unsigned long long userblock )

Sets the user block.

Parameters
[in]raveio- self
[in]userblock- the user block

◆ RaveIO_supports()

int RaveIO_supports ( RaveIO_ODIM_FileFormat format)

Returns if the raveio supports the provided file format.

Parameters
[in]format- the inquiried file format
Returns
1 if rave io supports the format, otherwise 0

Variable Documentation

◆ RaveIO_TYPE

RaveCoreObjectType RaveIO_TYPE
Initial value:
= {
"RaveIO",
sizeof(RaveIO_t),
RaveIO_constructor,
RaveIO_destructor
}
struct _RaveIO_t RaveIO_t
Defines a Rave IO instance.
Definition rave_io.h:49

Type definition to use when creating a rave object.