RAVE
composite_utils.c File Reference

Contains various utility functions when creating composites. More...

#include "composite_utils.h"
#include "cartesian.h"
#include "cartesianparam.h"
#include "cartesianvolume.h"
#include "compositearguments.h"
#include "projection_pipeline.h"
#include "rave_debug.h"
#include "rave_alloc.h"
#include "rave_object.h"
#include "rave_types.h"
#include "polarvolume.h"
#include "polarscan.h"
#include "raveobject_hashtable.h"
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <limits.h>

Functions

CompositeQualityFlagDefinition_tCompositeUtils_createQualityFlagDefinition (const char *qualityFieldName, RaveDataType datatype, double offset, double gain)
 Creates a flag definition from field name, datatype, offset and gain.
 
int CompositeUtils_registerQualityFlagDefinition (RaveObjectHashTable_t *qualityFlags, CompositeQualityFlagDefinition_t *definition)
 Utility function to create and register a quality flag definition in the hash table of quality flag definitions.
 
int CompositeUtils_registerQualityFlagDefinitionFromArguments (RaveObjectHashTable_t *qualityFlags, const char *qualityFieldName, RaveDataType datatype, double offset, double gain)
 Utility function to register a quality flag definition.
 
int CompositeUtils_registerQualityFlagDefinitionFromSettings (RaveObjectHashTable_t *qualityFlags, CompositeQualityFlagSettings_t *settings)
 Initiates the hash table of quality flags with the settings.
 
int CompositeUtils_isValidCartesianArguments (CompositeArguments_t *arguments)
 Validates the arguments so that it is possible to create a cartesian product from the existing information.
 
Cartesian_tCompositeUtils_createCartesianFromArguments (CompositeArguments_t *arguments)
 Creates a cartesian product from the arguments.
 
CompositeUtilValue_tCompositeUtils_createCompositeValues (CompositeArguments_t *arguments, Cartesian_t *cartesian, int *nentries)
 Creates an array of CompositeUtilValue_t.
 
void CompositeUtils_resetCompositeValues (CompositeArguments_t *arguments, CompositeUtilValue_t *cvalues, int nentries)
 Resets the array of composite values except the CartesianParam parameter.
 
void CompositeUtils_freeCompositeValueParameters (CompositeUtilValue_t **cvalues, int nparam)
 Frees the composite value array and ensures that all associated parameters are released.
 
Projection_tCompositeUtils_getProjection (RaveCoreObject *obj)
 Tries to get the projection from the provided RaveCoreObject.
 
int CompositeUtils_getObjectSource (RaveCoreObject *obj, char *source, int nlen)
 Tries to get the source from the provided RaveCoreObject.
 
CompositeRaveObjectBinding_tCompositeUtils_createRaveObjectBinding (CompositeArguments_t *arguments, Cartesian_t *cartesian, int *nobjects, OdimSources_t *sources)
 Creates the binding between radar objects and the pipelines that are relevant when creating composites.
 
void CompositeUtils_releaseRaveObjectBinding (CompositeRaveObjectBinding_t **arr, int nobjects)
 Releases the objects and then deallocates the array.
 
void CompositeUtils_getQualityFlagSettings (CompositeQualityFlagSettings_t *settings, const char *flagname, double *offset, double *gain, RaveDataType *datatype)
 Returns the offset, gain and datatype for the specified flag that has been defined in the settings.
 
int CompositeUtils_addQualityFlagsToCartesian (CompositeArguments_t *arguments, Cartesian_t *cartesian, RaveObjectHashTable_t *qualityFlagDefinitions)
 Creates all quality flags specified in the arguments and add them to the cartesian product.
 
int CompositeUtils_addQualityFlagsToCartesianFromSettings (CompositeArguments_t *arguments, Cartesian_t *cartesian, CompositeQualityFlagSettings_t *settings)
 Creates all quality flags specified in the arguments and add them to the cartesian product.
 
int CompositeUtils_addGainAndOffsetToField (RaveField_t *field, double gain, double offset)
 Adds what/gain and what/offset to the RaveField.
 
RaveField_tCompositeUtils_createQualityField (const char *howtaskvaluestr, int xsize, int ysize, RaveDataType datatype, double gain, double offset)
 Creates a quality field.
 
int CompositeUtils_getPolarValueAtPosition (RaveCoreObject *obj, const char *quantity, PolarNavigationInfo *nav, const char *qiFieldName, RaveValueType *type, double *value, double *qualityValue)
 Gets the value(s) at the specified position for the specified quantity.
 
int CompositeUtils_getPolarQualityValueAtPosition (RaveCoreObject *obj, const char *quantity, const char *qualityField, PolarNavigationInfo *nav, double *value)
 Gets the quality value at the specified position for the specified quantity and quality field in a polar object.
 
int CompositeUtils_getVerticalMaxValue (RaveCoreObject *object, const char *quantity, const char *qiFieldName, double lon, double lat, RaveValueType *vtype, double *vvalue, PolarNavigationInfo *navinfo, double *qiv)
 Returns the vertical max value for the specified quantity at the provided lon/lat position.
 
RaveList_tCompositeUtils_cloneRaveListStrings (RaveList_t *inlist)
 Clones a RaveList of strings.
 

Variables

RaveCoreObjectType CompositeQualityFlagDefinition_TYPE
 Allow CompositeQualityFlagDefinition to be instantiated like any RaveCoreObject.
 

Detailed Description

Contains various utility functions when creating composites.

Author
Anders Henja (Swedish Meteorological and Hydrological Institute, SMHI)
Date
2025-0!-17

Function Documentation

◆ CompositeUtils_addGainAndOffsetToField()

int CompositeUtils_addGainAndOffsetToField ( RaveField_t * field,
double gain,
double offset )

Adds what/gain and what/offset to the RaveField.

Parameters
[in]field- the field that should get gain & offset set
[in]gain- gain
[in]offset- offset
Returns
1 on success otherwise 0

◆ CompositeUtils_addQualityFlagsToCartesian()

int CompositeUtils_addQualityFlagsToCartesian ( CompositeArguments_t * arguments,
Cartesian_t * cartesian,
RaveObjectHashTable_t * definitions )

Creates all quality flags specified in the arguments and add them to the cartesian product.

Parameters
[in]arguments- the arguments (containing the list of quality flags)
[in]cartesian- the product to which the quality fields should be added
[in]definitions- the definitions of specific quality flags. Values in hash table should be CompositeQualityFlagDefinition_t
Returns
1 on success otherwise 0

◆ CompositeUtils_addQualityFlagsToCartesianFromSettings()

int CompositeUtils_addQualityFlagsToCartesianFromSettings ( CompositeArguments_t * arguments,
Cartesian_t * cartesian,
CompositeQualityFlagSettings_t * settings )

Creates all quality flags specified in the arguments and add them to the cartesian product.

Parameters
[in]arguments- the arguments (containing the list of quality flags)
[in]cartesian- the product to which the quality fields should be added
[in]settings- the settings of specific quality flags. Should be defined as CompositeQualityFlagSettings_t settings[] = { {qualityflag, datatype, offset, gain}, .... {NULL, RaveDataType_UNDEFINED, 0.0, 0.0} }; since the loop will break at the first qualityflag == NULL.
Returns
1 on success otherwise 0

◆ CompositeUtils_cloneRaveListStrings()

RaveList_t * CompositeUtils_cloneRaveListStrings ( RaveList_t * inlist)

Clones a RaveList of strings.

Parameters
[in]inlist- the list to clone
Returns
the cloned list on success, otherwise NULL

◆ CompositeUtils_createCartesianFromArguments()

Cartesian_t * CompositeUtils_createCartesianFromArguments ( CompositeArguments_t * arguments)

Creates a cartesian product from the arguments.

Parameters
[in]arguments- the argument object
Returns
The created cartesian product or NULL if not possible

◆ CompositeUtils_createCompositeValues()

CompositeUtilValue_t * CompositeUtils_createCompositeValues ( CompositeArguments_t * arguments,
Cartesian_t * cartesian,
int * nentries )

Creates an array of CompositeUtilValue_t.

The array length will be the same as number of parameters and the parameter in the struct will be associated with corresponding parameter in the cartesian product.

Parameters
[in]arguments- the arguments structure
[in]cartesian- the cartesian that was created from the arguments
[in]nentries- number of entries in the composite util value struct
Returns
the array on success or NULL on failure

◆ CompositeUtils_createQualityField()

RaveField_t * CompositeUtils_createQualityField ( const char * howtaskvaluestr,
int xsize,
int ysize,
RaveDataType datatype,
double gain,
double offset )

Creates a quality field.

Parameters
[in]howtaskvaluestr- the how/task string
[in]xsize- xsize
[in]ysize- ysize
[in]datatype- the data type
[in]gain- the gain
[in]offset- the offset
Returns
the created field on success otherwise NULL

◆ CompositeUtils_createQualityFlagDefinition()

CompositeQualityFlagDefinition_t * CompositeUtils_createQualityFlagDefinition ( const char * qualityFieldName,
RaveDataType datatype,
double offset,
double gain )

Creates a flag definition from field name, datatype, offset and gain.

Parameters
[in]qualityFieldName- the name of the quality field
[in]datatype- datatype of the field
[in]offset- the offset '
[in]gain- the gain
Returns
the definition on success otherwise NULL

◆ CompositeUtils_createRaveObjectBinding()

CompositeRaveObjectBinding_t * CompositeUtils_createRaveObjectBinding ( CompositeArguments_t * arguments,
Cartesian_t * cartesian,
int * nobjects,
OdimSources_t * sources )

Creates the binding between radar objects and the pipelines that are relevant when creating composites.

The order of the binding will be the same as the objects in the arguments at time the object is

Parameters
[in]arguments- the arguments (containing the radar objects)
[in]cartesian- the target composite
[out]nobjects- the number of items in the returned array
[in]sources- an OPTIONAL odim sources (MAY BE NULL). When creating binding, if possible to identify the odim source it will be attached to the binding.
Returns
the array of bindings or NULL on failure

◆ CompositeUtils_freeCompositeValueParameters()

void CompositeUtils_freeCompositeValueParameters ( CompositeUtilValue_t ** cvalues,
int nparam )

Frees the composite value array and ensures that all associated parameters are released.

Parameters
[in,out]cvalues- the cvalue struct.
[in]nparam- number of entries in the array

◆ CompositeUtils_getObjectSource()

int CompositeUtils_getObjectSource ( RaveCoreObject * obj,
char * source,
int nlen )

Tries to get the source from the provided RaveCoreObject.

Currently supported object types are PolarScan, PolarVolume, Cartesian and CartesianVolume.

Parameters
[in]obj- the object
[in,out]source- the source
[in]nlen- length of source array
Returns
string length (excluding the terminating \0)

◆ CompositeUtils_getPolarQualityValueAtPosition()

int CompositeUtils_getPolarQualityValueAtPosition ( RaveCoreObject * obj,
const char * quantity,
const char * qualityField,
PolarNavigationInfo * nav,
double * value )

Gets the quality value at the specified position for the specified quantity and quality field in a polar object.

Parameters
[in]obj- the object (Must be PolarScan or PolarVolume)
[in]quantity- the quantity
[in]qualityField- the quality field
[in]nav- the navigation information
[out]value- the value
Returns
1 on success or 0 if value not could be retrieved

◆ CompositeUtils_getPolarValueAtPosition()

int CompositeUtils_getPolarValueAtPosition ( RaveCoreObject * obj,
const char * quantity,
PolarNavigationInfo * nav,
const char * qiFieldName,
RaveValueType * type,
double * value,
double * qualityValue )

Gets the value(s) at the specified position for the specified quantity.

Parameters
[in]obj- the object
[in]quantity- the quantity
[in]nav- the navigation information
[in]qiFieldName- the name of the quality field (may be NULL)
[out]type- the value type
[out]value- the value
[out]qualityValue- the quality value, may be NULL
Returns
1 on success or 0 if value not could be retrieved

◆ CompositeUtils_getProjection()

Projection_t * CompositeUtils_getProjection ( RaveCoreObject * obj)

Tries to get the projection from the provided RaveCoreObject.

Currently supported object types are PolarScan, PolarVolume, Cartesian and CartesianVolume.

Parameters
[in]obj- the object
Returns
the projection if possible, otherwise NULL

◆ CompositeUtils_getQualityFlagSettings()

void CompositeUtils_getQualityFlagSettings ( CompositeQualityFlagSettings_t * settings,
const char * flagname,
double * offset,
double * gain,
RaveDataType * datatype )

Returns the offset, gain and datatype for the specified flag that has been defined in the settings.

If the flagname doesn't exist in settings or if settings is NULL. Offset, gain and datatype will be set to 0.0, 1.0/UCHAR_MAX and RaveDataType_UCHAR.

Parameters
[in]settings- the array of settings
[in]flagname- name of the quality field
[out]offset- offset, may be NULL.
[out]gain- gain, may be NULL.
[out]datatype- datatype, may be NULL.

◆ CompositeUtils_getVerticalMaxValue()

int CompositeUtils_getVerticalMaxValue ( RaveCoreObject * object,
const char * quantity,
const char * qiFieldName,
double lon,
double lat,
RaveValueType * vtype,
double * vvalue,
PolarNavigationInfo * navinfo,
double * qiv )

Returns the vertical max value for the specified quantity at the provided lon/lat position.

If no suitable value is found, vtype and vvalue will be left as is.

Parameters
[in]object- the polar object (MUST NOT BE NULL)
[in]quantity- the parameter
[in]qiFieldName- the quality field name (if qiv should be set), may be NULL
[in]lon- longitude in radians
[in]lat- latitude in radians
[out]vtype- the value type (MUST NOT BE NULL)
[out]vvalue- the value (MUST NOT BE NULL)
[out]navinfo- the navigation information (MAY BE NULL)
[out]qiv- the quality value (MAY BE NULL)
Returns
1 on success or 0 on failure.

◆ CompositeUtils_isValidCartesianArguments()

int CompositeUtils_isValidCartesianArguments ( CompositeArguments_t * arguments)

Validates the arguments so that it is possible to create a cartesian product from the existing information.

Parameters
[in]arguments- the argument object
Returns
1 if possible to create the cartesian from arguments

◆ CompositeUtils_registerQualityFlagDefinition()

int CompositeUtils_registerQualityFlagDefinition ( RaveObjectHashTable_t * qualityFlags,
CompositeQualityFlagDefinition_t * definition )

Utility function to create and register a quality flag definition in the hash table of quality flag definitions.

Utility function to create a quality flag setting instance.

◆ CompositeUtils_registerQualityFlagDefinitionFromArguments()

int CompositeUtils_registerQualityFlagDefinitionFromArguments ( RaveObjectHashTable_t * qualityFlags,
const char * qualityFieldName,
RaveDataType datatype,
double offset,
double gain )

Utility function to register a quality flag definition.

◆ CompositeUtils_registerQualityFlagDefinitionFromSettings()

int CompositeUtils_registerQualityFlagDefinitionFromSettings ( RaveObjectHashTable_t * qualityFlags,
CompositeQualityFlagSettings_t * settings )

Initiates the hash table of quality flags with the settings.

◆ CompositeUtils_releaseRaveObjectBinding()

void CompositeUtils_releaseRaveObjectBinding ( CompositeRaveObjectBinding_t ** arr,
int nobjects )

Releases the objects and then deallocates the array.

Parameters
[in,out]arr- the array to release
[in]nobjects- number of items in array

◆ CompositeUtils_resetCompositeValues()

void CompositeUtils_resetCompositeValues ( CompositeArguments_t * arguments,
CompositeUtilValue_t * cvalues,
int nentries )

Resets the array of composite values except the CartesianParam parameter.

Parameters
[in]arguments- the arguments structure
[in]cvalues- pointer at the array
[in]nentries- number of cvalues

Variable Documentation

◆ CompositeQualityFlagDefinition_TYPE

RaveCoreObjectType CompositeQualityFlagDefinition_TYPE
Initial value:
= {
"CompositeQualityFlagDefinition",
CompositeQualityFlagDefinition_constructor,
CompositeQualityFlagDefinition_destructor,
CompositeQualityFlagDefinition_copyconstructor
}
Can be used to define if a quality flag requires different gain/offset or datatype than the default v...
Definition composite_utils.h:105

Allow CompositeQualityFlagDefinition to be instantiated like any RaveCoreObject.