31#ifndef RACK_RADAR_WINDOWS_H
32#define RACK_RADAR_WINDOWS_H
37#include <drain/TypeUtils.h>
38#include <drain/image/Window.h>
39#include <drain/image/SlidingWindow.h>
42#include "data/PolarODIM.h"
96 this->widthM = widthM;
97 this->heightD = heightD;
126 this->widthM = widthM;
127 this->heightD = heightD;
172template <
class C,
class R=RadarWindowCore>
197 mout.debug2(
"src props for odim: " , src.getProperties() );
199 this->odimSrc.updateFromMap(src.getProperties());
206 mout.debug2(
"src Scaling: " , src.getScaling() );
225 if (drain::Type::call<drain::typeIsSmallInt>(this->dst.
getType())){
228 mout.info(
"(not implemented: functor scaling for small int dst)" );
237 this->coordinateHandler.set(this->src.getGeometry(),
this->src.getCoordinatePolicy());
246 if (this->odimSrc.area.height == 0)
247 mout.error(
"src odim.area.height==0" );
250 const double r =
static_cast<double>(this->odimSrc.area.height) / (2.0*
M_PI);
251 const int max =
static_cast<int>(this->odimSrc.area.width);
253 rangeNorm =
static_cast<int>(r);
255 rangeNormEnd =
static_cast<int>(r *
static_cast<double>(this->conf.frame.height));
256 if ((rangeNorm <= 0) || (rangeNormEnd >= max)){
257 mout.note(rangeNorm ,
'-' , rangeNormEnd );
274 else if (this->
location.x < rangeNormEnd){
275 this->
setLoopLimits(this->conf.frame.width, (rangeNorm *
this->conf.frame.height)/(
this->location.x+1) );
291template <
class C,
class R=RadarWindowCore>
306 if (this->coordinateHandler.
validate(p)){
308 if ((x != this->odimSrc.nodata) && (x !=
this->odimSrc.undetect))
315 if (this->coordinateHandler.
validate(p)){
317 if ((x != this->odimSrc.nodata) && (x !=
this->odimSrc.undetect))
406 this->dst.
put(this->
location, this->odimSrc.undetect);
454 if (this->coordinateHandler.
validate(p)){
456 if (this->odimSrc.isValue(x)){
457 this->w = this->srcWeight.template
get<sum_t>(p);
458 this->sum += w*this->odimSrc.scaling.fwd(x);
467 if (this->coordinateHandler.
validate(p)){
469 if (this->odimSrc.isValue(x)){
470 this->w = this->srcWeight.template
get<sum_t>(p);
471 this->sum -= w*this->odimSrc.scaling.fwd(x);
481 this->dst.
put(this->
location, this->odimSrc.scaling.inv(
this->sum/sumW));
483 this->dstWeight.put(this->
location, sumW/
static_cast<sum_t>(this->count));
486 this->dst.
put(this->
location, this->odimSrc.undetect);
487 this->dstWeight.put(this->
location, 0);
534 void setCoeff(
double c){
536 throw std::runtime_error(
"RadarWindowSoftMax: zero coeff");
557 sum -= ::exp(coeff * x);
563 sum += ::exp(coeff * x);
631 double countD =
static_cast<double>(count);
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition Log.h:326
tuplebase_t & assignSequence(T &sequence, bool LENIENT=false)
Proposed for tuples only; derived classes should not shadow this.
Definition TupleBase.h:287
Tuple of N elements of type T.
Definition UniTuple.h:65
bool validate(Point2D< int > &p) const
Handles the coordinate, returning true if the position is reversible.
Definition CoordinateHandler.h:235
Image with static geometry.
Definition ImageFrame.h:62
void putScaled(size_t i, double x) const
Put intensity using original physical value.
Definition ImageFrame.h:239
void put(size_t i, T x)
Sets the intensity in location i to x.
Definition ImageFrame.h:191
const std::type_info & getType() const
Get the storage type.
Definition ImageLike.h:105
Window implementation that uses incremental update of state.
Definition SlidingWindow.h:50
virtual bool reset()
Returns false, if traversal should be ended.
Definition SlidingWindow.h:215
Base class for configurations applied in image processing windows, e.g. for operators of type WindowO...
Definition Window.h:55
bool resetAtEdges
To avoid accumulated numerical errors esp. with floats, reset the statistics at row/cols ends....
Definition Window.h:527
Point2D< int > location
Current location of this window.
Definition Window.h:521
size_t getSamplingArea()
Returns the area which has eventually been scaled (in a non-linear coordinate system)
Definition Window.h:490
void setLoopLimits()
Sets the actual traversal range inside the window. Sometimes applied dynamically by reset().
Definition Window.h:606
A map of radar data, indexed by quantity code (DBZH, VRAD, etc).
Definition Data.h:1293
Structure for data storage type, scaling and marker codes. Does not contain quantity.
Definition EncodingODIM.h:70
Metadata structure for single-radar data (polar scans, volumes and products).
Definition PolarODIM.h:45
Definition RadarWindows.h:339
virtual void write()
Write the result in the target image.
Definition RadarWindows.h:399
virtual void removeTrailingValue(double x)
Handles the converted (natural-scaled) value.
Definition RadarWindows.h:387
virtual void addLeadingValue(double x)
Handles the converted (natural-scaled) value.
Definition RadarWindows.h:393
virtual void clear()
Clears the applied statistics. Redefined in derived classes.
Definition RadarWindows.h:381
Definition RadarWindows.h:75
RadarWindowConfig(int widthM=1500, double heightD=3.0, double contributionThreshold=0.5, bool invertPolar=false, bool relativeScale=false)
Definition RadarWindows.h:92
RadarWindowConfig(const FT &ftor, int widthM=1500, double heightD=3.0, double contributionThreshold=0.5, bool invertPolar=false, bool relativeScale=false)
Definition RadarWindows.h:120
void adjustMyConf(const RadarWindowConfig &conf, const PolarODIM &inputODIM)
Copies configuration from conf and update pixel frame (width x height).
Definition RadarWindows.cpp:54
void setPixelConf(RadarWindowConfig &conf, const PolarODIM &inputODIM) const
Copies configuration to conf and update its pixel frame (width x height).
Definition RadarWindows.cpp:37
bool invertPolar
Compensate the polar coordinate system to correspond the Cartesian one in computations.
Definition RadarWindows.h:83
bool relativeScale
If true, use speed up to -1.0...+1.0 instead of -Vnyq...+Vnyq.
Definition RadarWindows.h:86
double contributionThreshold
Minimum percentage of detected values in a window (not undetect and nodata)
Definition RadarWindows.h:80
Definition RadarWindows.h:145
double NI
Definition RadarWindows.h:160
RadarWindowCore()
Will act as base class: Window<RadarWindowCore> : public RadarWindowCore {...}, init currently not su...
Definition RadarWindows.h:153
Like pixel window, but width is metres and height is degrees.
Definition RadarWindows.h:56
Definition RadarWindows.h:525
virtual void write()
Write the result in the target image.
Definition RadarWindows.h:570
virtual void removeTrailingValue(double x)
Handles the converted (natural-scaled) value.
Definition RadarWindows.h:556
virtual void addLeadingValue(double x)
Handles the converted (natural-scaled) value.
Definition RadarWindows.h:562
virtual void clear()
Clears the applied statistics. Redefined in derived classes.
Definition RadarWindows.h:550
Sliding window for computing standard deviation of scalar quantities.
Definition RadarWindows.h:586
virtual void write()
Write the result in the target image.
Definition RadarWindows.h:628
virtual void removeTrailingValue(double x)
Handles the converted (natural-scaled) value.
Definition RadarWindows.h:610
virtual void addLeadingValue(double x)
Handles the converted (natural-scaled) value.
Definition RadarWindows.h:618
virtual void clear()
Clears the applied statistics. Redefined in derived classes.
Definition RadarWindows.h:602
Definition RadarWindows.h:417
virtual void addPixel(drain::Point2D< int > &p) final
Adds a pixel to window statistics. Unvalidated location.
Definition RadarWindows.h:453
virtual void removePixel(drain::Point2D< int > &p) final
Removes a pixel from window statistics. Unvalidated location.
Definition RadarWindows.h:466
virtual void write() final
Write the result in the target image.
Definition RadarWindows.h:479
virtual void clear() final
Clears the applied statistics. Redefined in derived classes.
Definition RadarWindows.h:445
A two-dimensional image processing window that handles the special ODIM codes and scales the result....
Definition RadarWindows.h:173
void setImageLimits() const
Sets internal limits corresponding to image geometries. Typically using coordHandler.
Definition RadarWindows.h:236
void setSrcFrame(const drain::image::ImageFrame &src)
Sets input image and retrieves ODIM metadata from image Properties.
Definition RadarWindows.h:193
virtual void initialize() override
Sets class-specific initial values. Does not change general window state (e.g. location)....
Definition RadarWindows.h:221
virtual bool reset()
Returns false, if traversal should be ended.
Definition RadarWindows.h:269
void setRangeNorm()
To compensate polar geometry, set applicable range for pixel area scaling.
Definition RadarWindows.h:242
Definition RadarWindows.h:292
virtual void addPixel(drain::Point2D< int > &p)
Adds a pixel to window statistics. Unvalidated location.
Definition RadarWindows.h:314
virtual void removePixel(drain::Point2D< int > &p)
Removes a pixel from window statistics. Unvalidated location.
Definition RadarWindows.h:305
virtual void removeTrailingValue(double x)
Handles the converted (natural-scaled) value.
Definition RadarWindows.h:324
virtual void addLeadingValue(double x)
Handles the converted (natural-scaled) value.
Definition RadarWindows.h:328
Namespace for images and image processing tools.
Definition AccumulationArray.cpp:45
Definition AltitudeOp.cpp:42