Public Types | Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Composite Class Reference

Cartesian composite (mosaic) of data from several radars. More...

#include <Composite.h>

Inheritance diagram for Composite:
Inheritance graph
[legend]
Collaboration diagram for Composite:
Collaboration graph
[legend]

Public Types

enum  FieldType {
  DATA_SPECIFIC = 32 , QUALITY = 256 , DATA = 'd' , WEIGHT = 'w'|QUALITY ,
  COUNT = 'c'|QUALITY , DEVIATION = 's'|QUALITY , WEIGHT_DS = 'W'|QUALITY , COUNT_DS = 'C'|QUALITY ,
  DEVIATION_DS = 'S'|QUALITY
}
 
typedef drain::Dictionary< std::string, unsigned long > FieldDict
 
- Public Types inherited from RadarAccumulator< drain::image::AccumulatorGeo, CartesianODIM >
typedef PlainData< SrcType< CartesianODIM const > > pdata_src_t
 Input data type.
 
typedef PlainData< DstType< CartesianODIM > > pdata_dst_t
 

Public Member Functions

 Composite ()
 
void extractNEW2 (DataSet< DstType< CartesianODIM > > &dstProduct, const std::string &fields="d", const drain::Rectangle< int > &cropArea={0, 0}, const std::string &encoding="C")
 
void extractNEW (DataSet< DstType< CartesianODIM > > &dstProduct, FieldType field=DATA, const drain::Rectangle< int > &cropArea={0, 0}, const std::string &encoding="C")
 
void setCropping (bool cropping=true)
 If cropping is set, calling addPolar() also crops the bounding box to intersection of radar area and original area. More...
 
bool isCropping ()
 
void checkQuantity (const std::string &quantity)
 Sets quantity. Warns if input has a different quantity.
 
void addPolar (const PlainData< PolarSrc > &src, const PlainData< PolarSrc > &srcQuality, double weight, bool autoProj)
 Projects radar data in polar coordinates to Cartesian coordinates. More...
 
void addCartesian (const PlainData< CartesianSrc > &src, const PlainData< CartesianSrc > &srcQuality, double weight=1.0, int i=0, int j=0)
 Add data that matches the Cartesian projection and scaling of the composite. More...
 
double getTimeDifferenceMinute (const CartesianODIM &odimIn) const
 
void updateGeoData ()
 Updates xscale, rscale and secondary Bounding Box attributes. More...
 
void updateInputSelector (const std::string &select)
 Set input selector. See @DataSelector . More...
 
void createBinIndex (Hi5Tree &dst)
 
void createBinIndex (Hi5Tree &dst, const PolarODIM &odim)
 
- Public Member Functions inherited from RadarAccumulator< drain::image::AccumulatorGeo, CartesianODIM >
 RadarAccumulator ()
 Default constructor.
 
void addData (const pdata_src_t &srcData, const pdata_src_t &srcQuality, double weight, int i0, int j0)
 Adds data that is in the same coordinate system as the accumulator. Weighted with quality.
 
void addData (const pdata_src_t &srcData, const pdata_src_t &srcQuality, const pdata_src_t &srcCount)
 Adds data that is in the same coordinate system as the accumulator.
 
void extractOLD (const CartesianODIM &odimOut, DataSet< DstType< CartesianODIM > > &dstProduct, const std::string &fields, const drain::Rectangle< int > &crop={0, 0, 0, 0}) const
 
void setTargetEncoding (const std::string &encoding)
 Not critical. If set, needed to warn if input data does not match the expected / potential targetEncoding.
 
void consumeTargetEncoding (std::string &encoding)
 
const std::string & getTargetEncoding ()
 
virtual std::ostream & toStream (std::ostream &ostr) const
 
bool checkCompositingMethod (const ODIM &srcODIM) const
 Warns if data scaling involves risks in using WAVG (weighted averaging)
 
- Public Member Functions inherited from AccumulatorGeo
virtual void setGeometry (unsigned int width, unsigned int height)
 
virtual void allocate ()
 This should be called after setGeometry, unless the projection is used as a frame.
 
void reset ()
 
void addUnprojected (double lon, double lat, double value, double weight)
 
- Public Member Functions inherited from Accumulator
 Accumulator ()
 
 Accumulator (const Accumulator &acc)
 
void setMethod (const std::string &method)
 Set method to some of the predefined methods.
 
void setMethod (const std::string &name, const std::string &params)
 Set method to some of the predefined methods.
 
void setMethod (const AccumulationMethod &method)
 Copies the method and its parameters. More...
 
bool isMethodSet () const
 
const AccumulationMethodgetMethod () const
 
AccumulationMethodgetMethod ()
 
void add (const size_t i, double value, double weight)
 Adds decoded data that applies natural scaling.
 
void add (const size_t i, double value, double weight, unsigned int count)
 Adds decoded data that applies natural scaling.
 
void addData (const Image &src, const AccumulationConverter &converter, double weight=1.0, int iOffset=0, int jOffset=0)
 Add (accumulate) data with given prior weight. More...
 
void addData (const Image &src, const Image &srcQuality, const AccumulationConverter &converter, double weight=1.0, int iOffset=0, int jOffset=0)
 Add (accumulate) data weighted with input quality. More...
 
void addData (const Image &src, const Image &srcQuality, const Image &srcCount, const AccumulationConverter &converter)
 Add (accumulate) data weighted with input quality and count; each data(i,j) contributes count(i,j) times. More...
 
void extractField (char field, const AccumulationConverter &converter, Image &dst, const drain::Rectangle< int > &crop) const
 Extracts the accumulated quantity or secondary quantities like weight and standard deviation. More...
 
- Public Member Functions inherited from GeoFrame
 GeoFrame (unsigned int width=0, unsigned int height=0)
 Default constructor.
 
void reset ()
 
bool projectionIsSet () const
 Returns true, if the geographical extent has been set.
 
bool geometryIsSet () const
 Return true, if array area is greater than zero.
 
bool bboxIsSet () const
 Returns true, if the bounding box (geographical extent) has been set. More...
 
bool isDefined () const
 Returns true, if the projection, array area and geographical extent bounding box has been set. More...
 
int getFrameWidth () const
 Return the nominal width, not the width of the memory array which does not have to be allocated.
 
int getFrameHeight () const
 Return the nominal height, not the height of the memory array which does not have to be allocated.
 
void setBoundingBox (double lonLL, double latLL, double lonUR, double latUR)
 Sets bounding box in degrees OR in metres in the target coordinate system. More...
 
void setBoundingBox (const drain::Rectangle< double > &bbox)
 Sets bounding box in degrees in the target coordinate system.
 
void setBoundingBoxD (double lonLL, double latLL, double lonUR, double latUR)
 Sets bounding box in degrees in the target coordinate system.
 
void setBoundingBoxD (const drain::Rectangle< double > &bboxD)
 Sets bounding box in degrees in the target coordinate system.
 
void setBoundingBoxR (double lonLL, double latLL, double lonUR, double latUR)
 Sets bounding box in radians in the target coordinate system.
 
void setBoundingBoxR (const drain::Rectangle< double > &bboxR)
 Sets bounding box in radians in the target coordinate system.
 
void setBoundingBoxM (double xLL, double yLL, double xUR, double yUR)
 Sets bounding box in meters in the target coordinate system. More...
 
void setBoundingBoxM (const drain::UniTuple< double, 4 > &bboxM)
 Sets bounding box in meters in the target coordinate system.
 
const drain::Rectangle< double > & getBoundingBoxDeg () const
 Returns the geographical scope in Degrees.
 
const drain::Rectangle< double > & getBoundingBoxNat () const
 Returns the geographical scope in Meters.
 
const drain::Rectangle< double > & getBoundingBoxRad () const
 Returns the geographical scope in Radians.
 
void getCenterPixel (drain::Rectangle< double > &pixelD) const
 
double getXScale () const
 Return horizontal resolution of a pixel in meters (if metric) or degrees (if unprojected, "latlon").
 
double getYScale () const
 Return vertical resolution of a pixel in meters (if metric) or degrees (if unprojected, "latlon").
 
void cropWithM (drain::Rectangle< double > &bboxM)
 Crops the initial bounding box with a given bounding box.
 
void cropWithM (double xLL, double yLL, double xUR, double yUR)
 Crops the initial bounding box with a given bounding box. More...
 
virtual void deg2pix (double lon, double lat, int &i, int &j) const
 Projects geographic coordinates to image coordinates.
 
void deg2pix (const drain::Point2D< double > &loc, drain::Point2D< int > &pix) const
 Project geographic coordinates to image coordinates.
 
virtual void deg2m (double lon, double lat, double &x, double &y) const
 Convert metric coordinates to degrees.
 
void deg2m (const drain::Point2D< double > &pDeg, drain::Point2D< double > &pMet) const
 
virtual void pix2deg (int i, int j, double &lon, double &lat) const
 Calculates the geographic coordinates of the center of a pixel at (i,j).
 
virtual void pix2rad (int i, int j, double &lon, double &lat) const
 Calculates the geographic coordinates [rad] of the center of a pixel at (i,j).
 
void pix2deg (const drain::Point2D< int > &pix, drain::Point2D< double > &loc) const
 Calculates the geographic coordinates of the center of a pixel at (i,j).
 
virtual void pix2LLdeg (int i, int j, double &lon, double &lat) const
 Calculates the geographic coordinates of the lower left corner of a pixel at (i,j).
 
virtual void m2deg (double x, double y, double &lon, double &lat) const
 Convert metric coordinates to degrees.
 
virtual void m2deg (const drain::Point2D< double > &pMetric, drain::Point2D< double > &pDeg) const
 Convert metric coordinates to degrees.
 
virtual void m2pix (double x, double y, int &i, int &j) const
 Scales geographic map coordinates to image coordinates. More...
 
virtual void m2pix (const drain::Point2D< double > &pMetric, drain::Point2D< int > &pImage) const
 
virtual void pix2m (int i, int j, double &x, double &y) const
 Scales image coordinates (i,j) to geographic map coordinates (x,y) in the pixel centres. More...
 
virtual void pix2m (const drain::Point2D< int > &pImage, drain::Point2D< double > &pMetric) const
 
virtual void pix2LLm (int i, int j, double &x, double &y) const
 Scales image coordinates (i,j) to geographic map coordinates (x,y) of the lower left corner pixel. More...
 
void setProjection (const std::string &projDef)
 Sets the projection of the image as a Proj string.
 
void setProjectionEPSG (int epsg)
 Sets the projection of the image as a EPSG code.
 
void updateProjection ()
 Updates bboxex, if needed.
 
const std::string & getProjection () const
 Returns the projection of the composite image as a proj4 std::string.
 
const std::string & getCoordinateSystem () const
 Returns the source projection (should be radian array, lon & lat).
 
const drain::Rectangle< double > & getDataBBoxNat () const
 Return the actual geographical boundingBox suggested by implied by input data.
 
const drain::Rectangle< double > & getDataOverlapBBoxNat () const
 Return the common overlapping geographical area (intersection) implied by input data.
 
void updateDataExtentDeg (const drain::Rectangle< double > &inputBBoxDeg)
 Extend to include this input. More...
 
void updateDataExtentNat (const drain::Rectangle< double > &inputBBoxNat)
 
bool isLongLat () const
 

Public Attributes

bool extracting = false
 
double decay
 Weight decrease (0.0...1.0), per minute, in the weighting of delayed data. Zero means no change in weighting.
 
drain::VariableMap nodeMap
 Node keys (like "fivan") associated with upper left corner pixel coordinates [int] of the "tile".
 
drain::VariableMap metadataMap
 EXPERIMENTAL: save elangles TODO: consider rename metadataMap (for hairy details)
 
- Public Attributes inherited from RadarAccumulator< drain::image::AccumulatorGeo, CartesianODIM >
DataSelector dataSelector
 Input data selector.
 
CartesianODIM odim
 For storing the scaling and encoding of (1st) input or user-defined values. Also for bookkeeping of date, time, sources etc.
 
double defaultQuality
 If source data has no quality field, this value is applied for (detected) data.
 
size_t counter
 Book-keeping for new data. Finally, in extraction phase, added to odim.ACCnum . More...
 
- Public Attributes inherited from Accumulator
AccumulationArray accArray
 Todo: export.
 
- Public Attributes inherited from GeoFrame
drain::Proj6 projGeo2Native
 Radial to metric.
 

Static Public Attributes

static FieldDict dict
 

Protected Member Functions

void addPolarInnerLoop (const PlainData< PolarSrc > &srcData, const PlainData< PolarSrc > &srcQuality, double priorWeight, const RadarProj &pRadarToComposite, const drain::Rectangle< int > &bboxPix)
 
void updateNodeMap (const std::string &node, int i, int j)
 
- Protected Member Functions inherited from Accumulator
void initDst (const AccumulationConverter &coder, Image &dst, drain::Rectangle< int > &cropArea) const
 
- Protected Member Functions inherited from GeoFrame
void updateBoundingBoxR ()
 Proj 6 NEW: Given BBox in geo coords [deg], adjust geo coords [rad]. More...
 
void updateBoundingBoxD ()
 Given BBox in geo coords [rad], adjust geo coords [deg]. More...
 
void updateBoundingBoxM ()
 Given BBox in geo coords [rad], adjust metric bounding box. Do not update xScale or yScale.
 
void updateScaling ()
 Geometric scaling. More...
 

Protected Attributes

bool cropping
 
- Protected Attributes inherited from RadarAccumulator< drain::image::AccumulatorGeo, CartesianODIM >
std::string targetEncoding
 
- Protected Attributes inherited from Accumulator
AccumulationMethod undefinedMethod
 A Some predefined methods, that can be set with setMethod(const std::string & key).
 
AccumulationMethodmethodPtr
 
- Protected Attributes inherited from GeoFrame
int frameWidth
 
int frameHeight
 
drain::Rectangle< double > bBoxR
 Geographical scope in Radians.
 
drain::Rectangle< double > bBoxD
 Geographical scope in Degrees.
 
drain::Rectangle< double > bBoxNative
 Geographical scope in meters, or degrees in case of long/lat.
 
drain::Rectangle< double > dataBBoxNat
 For deriving extent (~union) of input data.
 
drain::Rectangle< double > dataOverlapBBoxNat
 For deriving common extent (~intersection) of input data.
 
double xScale = 0.0
 Utility for deriving extent (degrees) required by input data. More...
 
double yScale = 0.0
 

Detailed Description

Cartesian composite (mosaic) of data from several radars.

Main features:

Cumulation. The compositing starts by initiating the target image.

Each input radar image is projected on the target image cumulatively, see execute(). Finally, the cumulation is completed by normalizing the result with the number/weight of cumulated inputs.

The weights are stored in the first alphaChannel (index 0) of the target image.

In cumulation, ...

\[ x = \sqrt[p]{\frac{\sum_i {q_i}^r x_i^p}{\sum_i {q_i}^r } } \]

The default type of target image, that is, cumulation array, is double. If no (float valued) weighting is applied, target image could be long int as well.

Handling special codes undetect and nodata

The implementation behind a composite is based on drain::Cumulator class, which essentially consists of four 2D arrays: accumulated data ( $\sum w_ix_i$), weights ( $\sum w_i$), squared sum ( $\sum w_ix_i^2$) and count of samples ( $N$).

For radar data ODIM standard defines two essential special codes, undetect and nodata, which above all mark samples that are beyond the sensitivity or the range of a radar, respectively. nodata is also applied in marking samples where data has been rejected due to noise and str anomalies. These codes imply adding special rules to the basically "mathematical" accumulation.

In the accumulation stage, each valid data sample with data value $ x_i $ and its weight $ w_i $ is accumulated to the arrays by calling Cumulator::add(), with the following std::exceptions:

In the extraction stage, a result with data value $ x_i $ and weight $ w_i $ are extracted at each data point according to compositing principle (AVG, MAX,...) with the following special cases:

Member Enumeration Documentation

◆ FieldType

enum FieldType
Enumerator
QUALITY 

Ascii bit for lower-case chars, see below

DATA 

Marker for non-data

WEIGHT 

Main data, of named quantity

COUNT 

Separation

DEVIATION 

Number of samples

WEIGHT_DS 

Separation: std.dev or difference

COUNT_DS 

Separation

DEVIATION_DS 

Number of samples

Constructor & Destructor Documentation

◆ Composite()

Composite ( )

!

Member Function Documentation

◆ addCartesian()

void addCartesian ( const PlainData< CartesianSrc > &  src,
const PlainData< CartesianSrc > &  srcQuality,
double  weight = 1.0,
int  i = 0,
int  j = 0 
)

Add data that matches the Cartesian projection and scaling of the composite.

If the composite does not already have a bounding box, it will be equal to input data.

Parameters
src- input data structure
weight-
autoProj- use AEQD centered at the radar location.

Cartesian

◆ addPolar()

void addPolar ( const PlainData< PolarSrc > &  src,
const PlainData< PolarSrc > &  srcQuality,
double  weight,
bool  autoProj 
)

Projects radar data in polar coordinates to Cartesian coordinates.

If the composite does not already have a bounding box, it will be initialized as azimuthal equidistant projection matched to the composite.

Parameters
src- input data structure
srcQuality-
weight-
autoProj- use AEQD centered at the radar location.

GEOGRAPHIC DEFINITIONS: USE THOSE OF THE MAIN COMPOSITE, OR USE AEQD FOR SINGLE RADAR

Note: area not yet defined.

Check mapping for the origin (= location of the radar)?


DATA PROJECTION (MAIN LOOP)


◆ addPolarInnerLoop()

void addPolarInnerLoop ( const PlainData< PolarSrc > &  srcData,
const PlainData< PolarSrc > &  srcQuality,
double  priorWeight,
const RadarProj pRadarToComposite,
const drain::Rectangle< int > &  bboxPix 
)
protected

DATA PROJECTION (MAIN LOOP)

if (((pComp.y%15)==0) && ((pComp.x % 15) ==0)){ std::cerr << pMetric.x << ' '; };

◆ createBinIndex() [1/2]

void createBinIndex ( Hi5Tree &  dst)

Automatically creates some metadata.

◆ createBinIndex() [2/2]

void createBinIndex ( Hi5Tree &  dst,
const PolarODIM odim 
)

Automatically creates some metadata.

◆ extractNEW()

void extractNEW ( DataSet< DstType< CartesianODIM > > &  dstProduct,
FieldType  field = DATA,
const drain::Rectangle< int > &  cropArea = {0,0},
const std::string &  encoding = "C" 
)

Determines if quality is stored in /dataset1/quality1/ or /dataset1/data1/quality1/

Also available: if (type.isSet()) ...

◆ setCropping()

void setCropping ( bool  cropping = true)
inline

If cropping is set, calling addPolar() also crops the bounding box to intersection of radar area and original area.

Useful in tiling.

◆ updateGeoData()

void updateGeoData ( )

Updates xscale, rscale and secondary Bounding Box attributes.

Secondary BBOX means the minimum BBOX spanned by the data only.

◆ updateInputSelector()

void updateInputSelector ( const std::string &  select)

Set input selector. See @DataSelector .

  • if unset, use quantity
  • warn if changes detected

Member Data Documentation

◆ dict

Composite::FieldDict dict
static
Initial value:
= {
{"DATA", rack::Composite::FieldType::DATA},
{"WEIGHT", rack::Composite::FieldType::WEIGHT},
{"COUNT", rack::Composite::FieldType::COUNT},
{"DEVIATION", rack::Composite::FieldType::DEVIATION}
}

The documentation for this class was generated from the following files: