RAVE
rave_field.c File Reference

Generic field that only provides a 2-dim data field and a number of dynamic attributes. More...

#include "rave_field.h"
#include "rave_debug.h"
#include "rave_alloc.h"
#include "raveobject_hashtable.h"
#include "rave_utilities.h"
#include "rave_attribute_table.h"
#include <string.h>

Classes

struct  _RaveField_t
 Represents the cartesian volume. More...
 

Functions

int RaveField_setData (RaveField_t *field, long xsize, long ysize, void *data, RaveDataType type)
 Sets the data in the rave field.
 
int RaveField_setLazyDataset (RaveField_t *field, LazyDataset_t *lazyDataset)
 Sets a lazy dataset as data member.
 
int RaveField_createData (RaveField_t *field, long xsize, long ysize, RaveDataType type)
 Creates a empty data field.
 
int RaveField_setDatafield (RaveField_t *field, RaveData2D_t *datafield)
 Sets the rave data 2d field.
 
void * RaveField_getData (RaveField_t *field)
 Returns a pointer to the internal data storage.
 
RaveData2D_tRaveField_getDatafield (RaveField_t *field)
 Returns the 2d field associated with this rave field.
 
int RaveField_getValue (RaveField_t *field, long x, long y, double *v)
 Returns the value at the specified index.
 
int RaveField_setValue (RaveField_t *field, long x, long y, double value)
 Sets the value at specified position.
 
int RaveField_getConvertedValue (RaveField_t *field, long x, long y, double *v)
 Returns the converted value at the specified index.
 
long RaveField_getXsize (RaveField_t *field)
 Returns the xsize / number of bins.
 
long RaveField_getYsize (RaveField_t *field)
 Returns the ysize / number of rays.
 
RaveDataType RaveField_getDataType (RaveField_t *field)
 Returns the data type.
 
int RaveField_addAttribute (RaveField_t *field, RaveAttribute_t *attribute)
 Adds a rave attribute to the parameter.
 
int RaveField_addAttributeVersion (RaveField_t *field, RaveAttribute_t *attribute, RaveIO_ODIM_Version version)
 Adds a rave attribute to the parameter.
 
RaveAttribute_tRaveField_getAttribute (RaveField_t *field, const char *name)
 Returns the rave attribute that is named accordingly.
 
int RaveField_hasAttribute (RaveField_t *field, const char *name)
 Returns if the specified attribute exists.
 
RaveList_tRaveField_getAttributeNames (RaveField_t *field)
 Returns a list of attribute names.
 
RaveList_tRaveField_getAttributeNamesVersion (RaveField_t *field, RaveIO_ODIM_Version version)
 Returns a list of attribute names.
 
RaveObjectList_tRaveField_getAttributeValues (RaveField_t *field)
 Returns a list of attribute values that has been set for this field.
 
RaveObjectList_tRaveField_getAttributeValuesVersion (RaveField_t *field, RaveIO_ODIM_Version version)
 Returns a list of attribute values that has been set for this field and version.
 
RaveObjectList_tRaveField_getInternalAttributeValues (RaveField_t *field)
 Returns a reference to the internally stored attributes.
 
void RaveField_removeAttributes (RaveField_t *field)
 Removes all attributes from the field.
 
int RaveField_hasAttributeStringValue (RaveField_t *field, const char *name, const char *value)
 Checks if the field has the attribute named name that is of type string and has a matching value.
 
RaveField_tRaveField_concatX (RaveField_t *field, RaveField_t *other)
 Concatenates field with other horizontally and returns the new field.
 
int RaveField_circshiftData (RaveField_t *field, int nx, int ny)
 Circular shift of the internal field in x & y dimension.
 

Variables

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

Detailed Description

Generic field that only provides a 2-dim data field and a number of dynamic attributes.

Author
Anders Henja (Swedish Meteorological and Hydrological Institute, SMHI)
Date
2010-07-05

Function Documentation

◆ RaveField_addAttribute()

int RaveField_addAttribute ( RaveField_t * field,
RaveAttribute_t * attribute )

Adds a rave attribute to the parameter.

Parameters
[in]field- self
[in]attribute- the attribute
Returns
1 on success otherwise 0

◆ RaveField_addAttributeVersion()

int RaveField_addAttributeVersion ( RaveField_t * field,
RaveAttribute_t * attribute,
RaveIO_ODIM_Version version )

Adds a rave attribute to the parameter.

NOTE! This method is usually only used internally.

Parameters
[in]field- self
[in]attribute- the attribute
[in]version- the version of the attribute added
Returns
1 on success otherwise 0

◆ RaveField_circshiftData()

int RaveField_circshiftData ( RaveField_t * field,
int nx,
int ny )

Circular shift of the internal field in x & y dimension.

Parameters
[in]field- the field to be shifted
[in]nx- the number of steps to be shifted in x-direction. Can be both positive and negative
[in]ny- the number of steps to be shifted in y-direction. Can be both positive and negative
Returns
1 if shift was successful otherwise 0

◆ RaveField_concatX()

RaveField_t * RaveField_concatX ( RaveField_t * field,
RaveField_t * other )

Concatenates field with other horizontally and returns the new field.

The fields and others y-dimension must be the same as well as the data type.

Parameters
[in]field- self
[in]other- the field to contatenate
Returns
the concatenated field on success otherwise NULL

◆ RaveField_createData()

int RaveField_createData ( RaveField_t * field,
long xsize,
long ysize,
RaveDataType type )

Creates a empty data field.

Parameters
[in]field- self
[in]xsize- the xsize
[in]ysize- the ysize
[in]type- the data type
Returns
1 on success otherwise 0

◆ RaveField_getAttribute()

RaveAttribute_t * RaveField_getAttribute ( RaveField_t * field,
const char * name )

Returns the rave attribute that is named accordingly.

Parameters
[in]field- self
[in]name- the name of the attribute
Returns
the attribute if found otherwise NULL

◆ RaveField_getAttributeNames()

RaveList_t * RaveField_getAttributeNames ( RaveField_t * field)

Returns a list of attribute names.

Release with @ref RaveList_freeAndDestroy.

Parameters
[in]field- self
Returns
a list of attribute names

◆ RaveField_getAttributeNamesVersion()

RaveList_t * RaveField_getAttributeNamesVersion ( RaveField_t * field,
RaveIO_ODIM_Version version )

Returns a list of attribute names.

Release with @ref RaveList_freeAndDestroy. NOTE! This method is usually only used internally.

Parameters
[in]field- self
[in]version- version requested
Returns
a list of attribute names

◆ RaveField_getAttributeValues()

RaveObjectList_t * RaveField_getAttributeValues ( RaveField_t * field)

Returns a list of attribute values that has been set for this field.

Parameters
[in]field- self
Returns
a list of RaveAttributes.

◆ RaveField_getAttributeValuesVersion()

RaveObjectList_t * RaveField_getAttributeValuesVersion ( RaveField_t * field,
RaveIO_ODIM_Version version )

Returns a list of attribute values that has been set for this field and version.

NOTE! This method is usually only used internally.

Parameters
[in]field- self
[in]version- version requested
Returns
a list of RaveAttributes.

◆ RaveField_getConvertedValue()

int RaveField_getConvertedValue ( RaveField_t * field,
long x,
long y,
double * v )

Returns the converted value at the specified index.

Corresponds to getAttribute("what/offset") + getAttribute("what/gain") * getValue(x,y).

Parameters
[in]field- self
[in]x- the x-pos / bin index
[in]y- the y-pos / ray index
[out]v- the data at the specified index
Returns
1 on success, 0 otherwise

◆ RaveField_getData()

void * RaveField_getData ( RaveField_t * field)

Returns a pointer to the internal data storage.

Parameters
[in]field- self
Returns
the internal data pointer (NOTE! Do not release this pointer)

◆ RaveField_getDatafield()

RaveData2D_t * RaveField_getDatafield ( RaveField_t * field)

Returns the 2d field associated with this rave field.

Note, it is a clone so don't expect that any modifications will modify the rave fields data array.

Parameters
[in]field- self
Returns
a clone of the internal data array on success otherwise NULL

◆ RaveField_getDataType()

RaveDataType RaveField_getDataType ( RaveField_t * field)

Returns the data type.

Parameters
[in]field- self
Returns
the data type

◆ RaveField_getInternalAttributeValues()

RaveObjectList_t * RaveField_getInternalAttributeValues ( RaveField_t * field)

Returns a reference to the internally stored attributes.

NOTE! This method is usually only used internally.

Parameters
[in]field- self
Returns
a list of RaveAttributes.

◆ RaveField_getValue()

int RaveField_getValue ( RaveField_t * field,
long x,
long y,
double * v )

Returns the value at the specified index.

Parameters
[in]field- self
[in]x- the x-pos / bin index
[in]y- the y-pos / ray index
[out]v- the data at the specified index
Returns
1 on success, 0 otherwise

◆ RaveField_getXsize()

long RaveField_getXsize ( RaveField_t * field)

Returns the xsize / number of bins.

Parameters
[in]field- self
Returns
the xsize / number of bins

◆ RaveField_getYsize()

long RaveField_getYsize ( RaveField_t * field)

Returns the ysize / number of rays.

Parameters
[in]field- self
Returns
the ysize / number of rays

◆ RaveField_hasAttribute()

int RaveField_hasAttribute ( RaveField_t * field,
const char * name )

Returns if the specified attribute exists.

Parameters
[in]field- self
[in]name- the name of the attribute
Returns
1 if attribute exists, otherwise 0

◆ RaveField_hasAttributeStringValue()

int RaveField_hasAttributeStringValue ( RaveField_t * field,
const char * name,
const char * value )

Checks if the field has the attribute named name that is of type string and has a matching value.

Parameters
[in]field- the field
[in]name- the name of the attribute
[in]value- the value of the attribute
Returns
1 if there is such a match, otherwise 0

◆ RaveField_removeAttributes()

void RaveField_removeAttributes ( RaveField_t * field)

Removes all attributes from the field.

◆ RaveField_setData()

int RaveField_setData ( RaveField_t * field,
long xsize,
long ysize,
void * data,
RaveDataType type )

Sets the data in the rave field.

Parameters
[in]field- self
[in]xsize- the xsize
[in]ysize- the ysize
[in]data- the data
[in]type- the data type
Returns
1 on success otherwise 0

◆ RaveField_setDatafield()

int RaveField_setDatafield ( RaveField_t * field,
RaveData2D_t * datafield )

Sets the rave data 2d field.

This will create a clone from the provided data field.

Parameters
[in]field- self
[in]datafield- the data field to use (MAY NOT BE NULL)
Returns
1 on success otherwise 0

◆ RaveField_setLazyDataset()

int RaveField_setLazyDataset ( RaveField_t * field,
LazyDataset_t * lazyDataset )

Sets a lazy dataset as data member.

On any requests to receive data, the lazy dataset will be used to populate the internal data field.

Parameters
[in]

◆ RaveField_setValue()

int RaveField_setValue ( RaveField_t * field,
long x,
long y,
double value )

Sets the value at specified position.

Parameters
[in]field- self
[in]x- x coordinate
[in]y- y coordinate
[in]value- the value to be set at specified coordinate

Variable Documentation

◆ RaveField_TYPE

RaveCoreObjectType RaveField_TYPE
Initial value:
= {
"RaveField",
sizeof(RaveField_t),
RaveField_constructor,
RaveField_destructor,
RaveField_copyconstructor
}
struct _RaveField_t RaveField_t
Defines a Rave field.
Definition rave_field.h:38

Type definition to use when creating a rave object.