RAVE
composite.c File Reference

Provides functionality for creating composites. More...

#include "composite.h"
#include "polarvolume.h"
#include "raveobject_list.h"
#include "rave_types.h"
#include "rave_debug.h"
#include "rave_alloc.h"
#include "rave_datetime.h"
#include "projection_pipeline.h"
#include <string.h>
#include "rave_field.h"
#include <float.h>
#include <stdio.h>
#include <math.h>

Classes

struct  _Composite_t
 Represents the cartesian product. More...
 
struct  CompositeRadarItem
 
struct  CompositingParameter_t
 Structure for keeping track on parameters that should be composited. More...
 
struct  CompositeValuePosition_t
 Structure for holding information regarding a specific position and values connected with it. More...
 
struct  CompositeValues_t
 Structure for keeping track on values / parameter. More...
 
struct  CompositeValuesVector_t
 

Macros

#define MAX_NO_OF_SURROUNDING_POSITIONS   8
 
#define DISTANCE_TO_RADAR_RESOLUTION   2000.0
 The resolution to use for scaling the distance from pixel to used radar.
 
#define HEIGHT_RESOLUTION   100.0
 Same for height, scaled to 100 m resolution up to 25.5 km.
 
#define DISTANCE_TO_RADAR_HOW_TASK   "se.smhi.composite.distance.radar"
 The name of the task for specifying distance to radar.
 
#define HEIGHT_ABOVE_SEA_HOW_TASK   "se.smhi.composite.height.radar"
 The name of the task for specifying height above sea level.
 
#define RADAR_INDEX_HOW_TASK   "se.smhi.composite.index.radar"
 The name of the task for indexing the radars used.
 

Typedefs

typedef struct CompositeRadarItem CompositeRadarItem_t
 
typedef struct CompositingParameter_t CompositingParameter_t
 Structure for keeping track on parameters that should be composited.
 
typedef struct CompositeValuePosition_t CompositeValuePosition_t
 Structure for holding information regarding a specific position and values connected with it.
 
typedef struct CompositeValues_t CompositeValues_t
 Structure for keeping track on values / parameter.
 
typedef struct CompositeValuesVector_t CompositeValuesVector_t
 
typedef enum CompositeInterpolationDimension_t CompositeInterpolationDimension_t
 Direction in which to perform interpolation.
 
typedef int(* FUNC_PREPARE_VALUEPOS) (Composite_t *, RaveCoreObject *, const char *, const char *, CompositeValuePosition_t[], int, int[])
 Function pointer definition for functions where value positions are prepared with values prior to interpolation.
 

Enumerations

enum  CompositeInterpolationDimension_t { CompositeInterpolationDimension_AZIMUTH = 0 , CompositeInterpolationDimension_RANGE , CompositeInterpolationDimension_HEIGHT , NO_OF_COMPOSITE_INTERPOLATION_DIMENSIONS }
 Direction in which to perform interpolation. More...
 

Functions

int Composite_add (Composite_t *composite, RaveCoreObject *object)
 Adds one RaveCoreObject, currently, the only supported type is volumes but this might be enhanced in the future to also allow for cartesian products to be added.
 
int Composite_getNumberOfObjects (Composite_t *composite)
 Returns the number of objects this composite will process.
 
RaveCoreObjectComposite_get (Composite_t *composite, int index)
 Return the object at position index.
 
int Composite_getRadarIndexValue (Composite_t *composite, int index)
 Return the radar index value that has been assigned to the object as position index.
 
void Composite_setProduct (Composite_t *composite, Rave_ProductType type)
 Sets the product type that should be generated when generating the composite.
 
Rave_ProductType Composite_getProduct (Composite_t *composite)
 Returns the product type.
 
int Composite_setSelectionMethod (Composite_t *self, CompositeSelectionMethod_t method)
 Sets the selection method to use.
 
CompositeSelectionMethod_t Composite_getSelectionMethod (Composite_t *self)
 Returns the selection method.
 
int Composite_setInterpolationMethod (Composite_t *self, CompositeInterpolationMethod_t interpolationMethod)
 Sets the interpolation method to use.
 
CompositeInterpolationMethod_t Composite_getInterpolationMethod (Composite_t *self)
 Returns the interpolation method.
 
void Composite_setInterpolateUndetect (Composite_t *self, int interpolateUndetect)
 Sets if undetect should be used in the interpolation.
 
int Composite_getInterpolateUndetect (Composite_t *self)
 Returns the if interpolation should be performed using undetect or not.
 
void Composite_setHeight (Composite_t *composite, double height)
 Sets the height that should be used when generating a composite as CAPPI, PCAPPI or PMAX.
 
double Composite_getHeight (Composite_t *composite)
 Returns the height that is used for composite generation.
 
void Composite_setElevationAngle (Composite_t *composite, double angle)
 Sets the elevation angle that should be used when generating a composite as PPI.
 
double Composite_getElevationAngle (Composite_t *composite)
 Returns the elevation angle that is used for composite generation.
 
void Composite_setRange (Composite_t *self, double range)
 Sets the range that should be used when generating the Pseudo MAX.
 
double Composite_getRange (Composite_t *self)
 Returns the range in meters.
 
int Composite_setQualityIndicatorFieldName (Composite_t *self, const char *qiFieldName)
 If this field name is set, then the composite will be generated by first using the quality indicator field for determining radar usage.
 
const char * Composite_getQualityIndicatorFieldName (Composite_t *self)
 
int Composite_addParameter (Composite_t *composite, const char *quantity, double gain, double offset, double minvalue)
 Adds a parameter to be processed.
 
int Composite_hasParameter (Composite_t *composite, const char *quantity)
 Returns if this composite generator is going to process specified parameter.
 
int Composite_getParameterCount (Composite_t *composite)
 Returns the number of parameters to be processed.
 
const char * Composite_getParameter (Composite_t *composite, int index, double *gain, double *offset)
 Returns the parameter at specified index.
 
int Composite_setTime (Composite_t *composite, const char *value)
 Sets the nominal time.
 
const char * Composite_getTime (Composite_t *composite)
 Returns the nominal time.
 
int Composite_setDate (Composite_t *composite, const char *value)
 Sets the nominal date.
 
const char * Composite_getDate (Composite_t *composite)
 Returns the nominal date.
 
int Composite_applyRadarIndexMapping (Composite_t *composite, RaveObjectHashTable_t *mapping)
 If you want the objects included in the composite to have a specific index value when generating the quality field se.smhi.composite.index.radar, then you can provide a hash table that maps source with a RaveAttribute_t containing a long value.
 
Cartesian_tComposite_generate (Composite_t *composite, Area_t *area, RaveList_t *qualityflags)
 Generates a composite according to the configured parameters in the composite structure.
 
void Composite_setAlgorithm (Composite_t *composite, CompositeAlgorithm_t *algorithm)
 Sets the algorithm to use when generating the composite.
 
CompositeAlgorithm_tComposite_getAlgorithm (Composite_t *composite)
 Returns the currently used algorithm.
 

Variables

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

Detailed Description

Provides functionality for creating composites.

Author
Anders Henja (Swedish Meteorological and Hydrological Institute, SMHI)
Date
2010-01-19

Macro Definition Documentation

◆ DISTANCE_TO_RADAR_HOW_TASK

#define DISTANCE_TO_RADAR_HOW_TASK   "se.smhi.composite.distance.radar"

The name of the task for specifying distance to radar.

◆ DISTANCE_TO_RADAR_RESOLUTION

#define DISTANCE_TO_RADAR_RESOLUTION   2000.0

The resolution to use for scaling the distance from pixel to used radar.

By multiplying the values in the distance field by 2000, we get the value in unit meters.

◆ HEIGHT_ABOVE_SEA_HOW_TASK

#define HEIGHT_ABOVE_SEA_HOW_TASK   "se.smhi.composite.height.radar"

The name of the task for specifying height above sea level.

◆ HEIGHT_RESOLUTION

#define HEIGHT_RESOLUTION   100.0

Same for height, scaled to 100 m resolution up to 25.5 km.

◆ RADAR_INDEX_HOW_TASK

#define RADAR_INDEX_HOW_TASK   "se.smhi.composite.index.radar"

The name of the task for indexing the radars used.

Typedef Documentation

◆ CompositeInterpolationDimension_t

Direction in which to perform interpolation.

NOTE: order is of importance here. The order controls in which order interpolation is done, if done in several dimensions. Since height interpolation must the be done last, it should be last in this enum.

◆ CompositeValuePosition_t

typedef struct CompositeValuePosition_t CompositeValuePosition_t

Structure for holding information regarding a specific position and values connected with it.

◆ CompositeValues_t

typedef struct CompositeValues_t CompositeValues_t

Structure for keeping track on values / parameter.

◆ CompositingParameter_t

typedef struct CompositingParameter_t CompositingParameter_t

Structure for keeping track on parameters that should be composited.

◆ FUNC_PREPARE_VALUEPOS

typedef int(* FUNC_PREPARE_VALUEPOS) (Composite_t *, RaveCoreObject *, const char *, const char *, CompositeValuePosition_t[], int, int[])

Function pointer definition for functions where value positions are prepared with values prior to interpolation.

This type of function shall be provided to CompositeInternal_getInterpolatedValue()

Enumeration Type Documentation

◆ CompositeInterpolationDimension_t

Direction in which to perform interpolation.

NOTE: order is of importance here. The order controls in which order interpolation is done, if done in several dimensions. Since height interpolation must the be done last, it should be last in this enum.

Function Documentation

◆ Composite_add()

int Composite_add ( Composite_t * composite,
RaveCoreObject * object )

Adds one RaveCoreObject, currently, the only supported type is volumes but this might be enhanced in the future to also allow for cartesian products to be added.

Parameters
[in]composite- self
[in]object- the item to be added to the composite
Returns
1 on success, otherwise 0

◆ Composite_addParameter()

int Composite_addParameter ( Composite_t * composite,
const char * quantity,
double gain,
double offset,
double minvalue )

Adds a parameter to be processed.

Parameters
[in]composite- self
[in]quantity- the parameter quantity
[in]gain- the gain to be used for the parameter
[in]offset- the offset to be used for the parameter
[in]minvalue- the minimum value that can be represented for this quantity in the composite
Returns
1 on success

◆ Composite_applyRadarIndexMapping()

int Composite_applyRadarIndexMapping ( Composite_t * composite,
RaveObjectHashTable_t * mapping )

If you want the objects included in the composite to have a specific index value when generating the quality field se.smhi.composite.index.radar, then you can provide a hash table that maps source with a RaveAttribute_t containing a long value.

The source should be the full source as defined in the added objects. The indexes must be unique values, preferrably starting from 1. If there is a mapping missing, the default behaviour is to take first available integer closest to 1.

Note, that in order to the mapping to take, this call must be performed after all the objects has been added to the generator and before calling Composite_generate.

Parameters
[in]composite- self
[in]mapping- the source - index mapping
Returns
1 on success, otherwise 0.

◆ Composite_generate()

Cartesian_t * Composite_generate ( Composite_t * composite,
Area_t * area,
RaveList_t * qualityflags )

Generates a composite according to the configured parameters in the composite structure.

Parameters
[in]composite- self
[in]area- the area that should be used for defining the composite.
[in]qualityflags- A list of char pointers identifying how/task values in the quality fields of the polar data. Each entry in this list will result in the atempt to generate a corresponding quality field in the resulting cartesian product. (MAY BE NULL)
Returns
the generated composite.

◆ Composite_get()

RaveCoreObject * Composite_get ( Composite_t * composite,
int index )

Return the object at position index.

Parameters
[in]composite- self
[in]index- the index, should be >= 0 and < getNumberOfObjects
Returns
the object or NULL if outside range

◆ Composite_getAlgorithm()

CompositeAlgorithm_t * Composite_getAlgorithm ( Composite_t * composite)

Returns the currently used algorithm.

Parameters
[in]composite- self
Returns
the algorithm (or NULL)

◆ Composite_getDate()

const char * Composite_getDate ( Composite_t * composite)

Returns the nominal date.

Parameters
[in]composite- self
Returns
the nominal time (or NULL if there is none)

◆ Composite_getElevationAngle()

double Composite_getElevationAngle ( Composite_t * composite)

Returns the elevation angle that is used for composite generation.

Parameters
[in]composite- self
Returns
the elevation angle in radians

◆ Composite_getHeight()

double Composite_getHeight ( Composite_t * composite)

Returns the height that is used for composite generation.

Parameters
[in]composite- self
Returns
the height

◆ Composite_getInterpolateUndetect()

int Composite_getInterpolateUndetect ( Composite_t * self)

Returns the if interpolation should be performed using undetect or not.

Parameters
[in]self- self
Returns
if undetect should be used in interpolation or not

◆ Composite_getInterpolationMethod()

CompositeInterpolationMethod_t Composite_getInterpolationMethod ( Composite_t * self)

Returns the interpolation method.

See also
CompositeInterpolationMethod_t
Parameters
[in]self- self
Returns
the interpolation method

◆ Composite_getNumberOfObjects()

int Composite_getNumberOfObjects ( Composite_t * composite)

Returns the number of objects this composite will process.

Parameters
[in]composite- self
Returns
the number of objects

◆ Composite_getParameter()

const char * Composite_getParameter ( Composite_t * composite,
int index,
double * gain,
double * offset )

Returns the parameter at specified index.

Parameters
[in]composite- self
[in]index- the index
[out]gain- the gain to be used for the parameter (MAY BE NULL)
[out]offset- the offset to be used for the parameter (MAY BE NULL)
Returns
the parameter name

◆ Composite_getParameterCount()

int Composite_getParameterCount ( Composite_t * composite)

Returns the number of parameters to be processed.

Parameters
[in]composite- self
Returns
the number of parameters

◆ Composite_getProduct()

Rave_ProductType Composite_getProduct ( Composite_t * composite)

Returns the product type.

Returns
the product type

◆ Composite_getQualityIndicatorFieldName()

const char * Composite_getQualityIndicatorFieldName ( Composite_t * self)
Parameters
[in]self- self
Returns
the quality indicator field name, can be NULL

◆ Composite_getRadarIndexValue()

int Composite_getRadarIndexValue ( Composite_t * composite,
int index )

Return the radar index value that has been assigned to the object as position index.

Parameters
[in]composite- self
[in]index- the index, should be >= 0 and < getNumberOfObjects
Returns
the radar index or 0 if no index has been assigned yet.

◆ Composite_getRange()

double Composite_getRange ( Composite_t * composite)

Returns the range in meters.

Parameters
[in]composite- self
Returns
the range in meters

◆ Composite_getSelectionMethod()

CompositeSelectionMethod_t Composite_getSelectionMethod ( Composite_t * self)

Returns the selection method.

See also
CompositeSelectionMethod_t
Parameters
[in]self- self
Returns
the selection method

◆ Composite_getTime()

const char * Composite_getTime ( Composite_t * composite)

Returns the nominal time.

Parameters
[in]composite- self
Returns
the nominal time (or NULL if there is none)

◆ Composite_hasParameter()

int Composite_hasParameter ( Composite_t * composite,
const char * quantity )

Returns if this composite generator is going to process specified parameter.

Parameters
[in]composite- self
[in]quantity- the parameter quantity
Returns
1 if yes otherwise 0

◆ Composite_setAlgorithm()

void Composite_setAlgorithm ( Composite_t * composite,
CompositeAlgorithm_t * algorithm )

Sets the algorithm to use when generating the composite.

Parameters
[in]composite- self
[in]algorithm- the actual algorithm to be run (MAY BE NULL, indicating nothing particular should be done)

◆ Composite_setDate()

int Composite_setDate ( Composite_t * composite,
const char * value )

Sets the nominal date.

Parameters
[in]composite- self
[in]value- the date in the format YYYYMMDD
Returns
1 on success, otherwise 0

◆ Composite_setElevationAngle()

void Composite_setElevationAngle ( Composite_t * composite,
double angle )

Sets the elevation angle that should be used when generating a composite as PPI.

Parameters
[in]composite- self
[in]angle- the angle in radians

◆ Composite_setHeight()

void Composite_setHeight ( Composite_t * composite,
double height )

Sets the height that should be used when generating a composite as CAPPI, PCAPPI or PMAX.

Parameters
[in]composite- self
[in]height- the height

◆ Composite_setInterpolateUndetect()

void Composite_setInterpolateUndetect ( Composite_t * self,
int interpolateUndetect )

Sets if undetect should be used in the interpolation.

This requires proper setting of minvalue in the parameter list. The recommended way is to threat undetect and nodata in the same way since Undetect only represents that nothing has been detected. If not interpolation should be performed using undetect the following behaviour will be done.

If all values are UNDETECT, then result will be UNDETECT. If only one value is DATA, then use that value. If more than one value is DATA, then interpolation. If all values are NODATA, then NODATA. If all values are either NODATA or UNDETECT, then UNDETECT.

Parameters
[in]self- self
[in]interpolateUndetect- If interpolation should be used on undetect or not
Returns
1 on success otherwise 0

◆ Composite_setInterpolationMethod()

int Composite_setInterpolationMethod ( Composite_t * self,
CompositeInterpolationMethod_t interpolationMethod )

Sets the interpolation method to use.

See also
CompositeInterpolationMethod_t.
Parameters
[in]self- self
[in]interpolationMethod- the interpolation method to use
Returns
1 on success otherwise 0

◆ Composite_setProduct()

void Composite_setProduct ( Composite_t * composite,
Rave_ProductType type )

Sets the product type that should be generated when generating the composite.

Height/Elevation angle and range are used in combination with the products. PPI requires elevation angle CAPPI, PCAPPI and PMAX requires height above sea level PMAX also requires range in meters

Parameters
[in]composite- self
[in]type- the product type, PPI, CAPPI, PCAPPI and PMAX are currently supported.

◆ Composite_setQualityIndicatorFieldName()

int Composite_setQualityIndicatorFieldName ( Composite_t * self,
const char * qiFieldName )

If this field name is set, then the composite will be generated by first using the quality indicator field for determining radar usage.

If the field name is NULL, then the selection method will be used instead.

Parameters
[in]self- self
[in]qiFieldName- the quality indicator field name
Returns
1 on success, 0 on failure (for example on memory allocation error)

◆ Composite_setRange()

void Composite_setRange ( Composite_t * composite,
double range )

Sets the range that should be used when generating the Pseudo MAX.

This range is the limit in meters for when the vertical max should be used. When outside this range, the PCAPPI value is used instead.

Parameters
[in]composite- self
[in]angle- the range in meters

◆ Composite_setSelectionMethod()

int Composite_setSelectionMethod ( Composite_t * self,
CompositeSelectionMethod_t method )

Sets the selection method to use.

See also
CompositeSelectionMethod_t.
Parameters
[in]self- self
[in]method- the method to use
Returns
1 on success otherwise 0

◆ Composite_setTime()

int Composite_setTime ( Composite_t * composite,
const char * value )

Sets the nominal time.

Parameters
[in]composite- self
[in]value- the time in the format HHmmss
Returns
1 on success, otherwise 0

Variable Documentation

◆ Composite_TYPE

RaveCoreObjectType Composite_TYPE
Initial value:
= {
"Composite",
sizeof(Composite_t),
Composite_constructor,
Composite_destructor,
Composite_copyconstructor
}
struct _Composite_t Composite_t
Defines a Composite generator.
Definition composite.h:82

Type definition to use when creating a rave object.