CalibrationStats.hpp
1 #pragma once
2 
3 #include <opals/config.hpp>
4 #include <opals/Vector.hpp>
5 #include <opals/Path.hpp>
6 #include <opals/CustomOptionType.hpp>
7 
8 namespace opals {
9 
10  /// \brief CalibrationRegion stores calibration results of a single region based on a single ODM file.
11  ///
12  /// The id of the object corresponds to the polygon id within the calRegionFile (see ModuleRadioCal). The filename of the ODM from which the points were selected for calibration
13  /// is stored in the Filename member. Area contains the 2d area of the corresponding region. Details on the point counter can be found in the corresponding member description.
14  ///
15  class OPALS_API CalibrationRegion
16  {
17  public:
20 
21  void reset();
22 
23  bool isSetId() const;
24  bool isSetFilename() const;
25  bool isSetArea() const;
26  bool isSetPtsInRegion() const;
27  bool isSetPtsFiltered() const;
28  bool isSetPtsNoNormal() const;
29  bool isSetPtsExceededMaxSigma() const;
30  bool isSetPtsMultiEchos() const;
31  bool isSetPtsCalibrated() const;
32  bool isSetMean() const;
33  bool isSetStdDev() const;
34  bool isSetMedian() const;
35 
36  int64_t getId() const;
37  opals::Path getFilename() const;
38  double getArea() const;
39  int64_t getPtsInRegion() const;
40  int64_t getPtsFiltered() const;
41  int64_t getPtsNoNormal() const;
42  int64_t getPtsExceededMaxSigma() const;
43  int64_t getPtsMultiEchos() const;
44  int64_t getPtsCalibrated() const;
45  double getMean() const;
46  double getStdDev() const;
47  double getMedian() const;
48 
49  void setId(const int64_t& id);
50  void setFilename(const opals::Path& filename);
51  void setArea(const double &area);
52  void setPtsInRegion(const int64_t &pts);
53  void setPtsFiltered(const int64_t &pts);
54  void setPtsNoNormal(const int64_t &pts);
55  void setPtsExceededMaxSigma(const int64_t &pts);
56  void setPtsMultiEchos(const int64_t &pts);
57  void setPtsCalibrated(const int64_t &pts);
58  void setMean(const double &mean);
59  void setStdDev(const double &stdDev);
60  void setMedian(const double &median);
61 
62  String logCalibrationRegion() const; ///< for xml output
63 
64  protected:
65  int64_t _id;
66  opals::Path _filename;
67  double _area;
68  int64_t _ptsInRegion; ///< total number of points in the region
69  int64_t _ptsFiltered; ///< number of points that were filtered and therefore ignored for calibration constant estimation
70  int64_t _ptsNoNormal; ///< number of points that didn't have a normal vector information (ignored for calibration constant estimation)
71  int64_t _ptsExceededMaxSigma; ///< number of points that exceeded the max sigma threshold of its normal vector (ignored for calibration constant estimation)
72  int64_t _ptsMultiEchos; ///< number of multi echo points (ignored for calibration constant estimation)
73  int64_t _ptsCalibrated; ///< number of points that were used for calibration constant estimation
74 
75  double _mean;
76  double _stdDev;
77  double _median;
78  };
79 
80  /// \brief A CalibrationEntry object stores statistics and results of one calibration constant estimation.
81  ///
82  /// ModuleRadioCal estimates the calibration constant based on (multiple) defined regions with known reflectivity. For each region
83  /// a CalibrationRegion object is added to the region vector. The accumulated results of the regions are then stored within the object
84  /// itself. In case the splitByAttribute parameter was set for ModuleRadioCal run, the corresponding attribute value is also stored. If
85  /// the attribute is empty (isSetAttribute() == false) the object is considered as the default entry object.
86  ///
87  class OPALS_API CalibrationEntry
88  {
89  public:
91 
94 
95  void reset();
96 
97  bool isSetAttribute() const;
98  bool isSetPtsCalibrated() const;
99  bool isSetCalibrationConst() const;
100  bool isSetRegions() const;
101 
102  int64_t getAttribute() const;
103  int64_t getPtsCalibrated() const; ///< sum of calibrated points in all regions
104  double getCalibrationConst() const;
105  RegionVector getRegions() const;
106 
107  void setAttribute(const int64_t& attribute);
108  void setPtsCalibrated(const int64_t &pts);
109  void setCalibrationConst(const double& cal);
110  void setRegions(const RegionVector& regions);
111 
112  double computeWeightedMeanOfMedians() const; ///< computes the point weighted average of the median of all regions
113 
114  String logCalibrationEntry() const; ///< for xml output
115 
116  protected:
117  int64_t _attribute;
118  int64_t _ptsCalibrated;
119  double _calibrationConst;
120  RegionVector _regions;
121  };
122 
123  /// \class CalibrationStats
124  /// A CalibrationStats object stores full calibration results and statistics.
125  /** The object basically stores a vector of calibrations entries. Each entry corresponds to calibration constant estimation. In case only one calibration constant was estimated (standard), the vector has only one element. */
126  /** If ModuleRadioCal was run with splitByAttribute parameter,
127  an element for each unique attribute value is added to the entry vector. It is possible to store one default entry
128  (CalibrationEntry::isSetAttribute() == false) which is used for calibrating points that do not have an attribute matching element in the
129  entry vector
130 
131  The class provides three different string to object parser:
132  - a simple single real value parser -> creates default entry with the given calibration constant
133  - attribute-calibr.constant-matrix parser: "[[attr1 cal.const1] [attr2 cal.const2] ... ]" or "[[default.cal.const] [attr1 cal.const1] [attr2 cal.const2] ... ]"
134  - full syntax parser -> parses object to string representation. example:
135  "CalibrationEntry[Attribute[-15] PtsCalibrated[108] CalibrationConst[764.450] Regions[ CalibrationRegion[ Id[600001] Area[0.275] ...] ] ]"
136 
137  \author JO
138  \date 27.06.2018
139  */
140  class OPALS_API CalibrationStats : public CustomOptionType<CalibrationStats>
141  {
142  public:
144 
146  CalibrationStats(double singleCalValue); ///< create an object based on a single calibration constant
147  ~CalibrationStats();
148 
149  void reset(); ///< reset object (removes all entries)
150 
151  bool isSetEntries() const;
152  EntryVector getEntries() const;
153  void setEntries(const EntryVector &entries);
154 
155  int getDefaultCalibrationConstIndex() const; ///< get index of default calibration constant (-1 if no default calibration constant is set)
156  double computeDefaultCalibrationConst() const; ///< compute a default calibration constant (point count weighted average of all calibration constants)
157 
158  String logCalibrationStats() const; ///< for xml output
159 
160  static bool exportsPythonType();
161  static const char * help(bool);
162  static const char * syntax();
163 
164  protected:
165  EntryVector _entries;
166  };
167 }
168 
Definition: CalibrationStats.hpp:140
Base class for all custom parameter types.
Definition: CustomOptionType.hpp:39
int64_t _ptsCalibrated
number of points that were used for calibration constant estimation
Definition: CalibrationStats.hpp:73
int64_t _ptsMultiEchos
number of multi echo points (ignored for calibration constant estimation)
Definition: CalibrationStats.hpp:72
CalibrationRegion stores calibration results of a single region based on a single ODM file.
Definition: CalibrationStats.hpp:15
int64_t _ptsExceededMaxSigma
number of points that exceeded the max sigma threshold of its normal vector (ignored for calibration ...
Definition: CalibrationStats.hpp:71
A file/directory path.
Definition: Path.hpp:26
@ mean
Mean.
Contains the public interface of OPALS.
Definition: AbsValueOrQuantile.hpp:8
int64_t _ptsInRegion
total number of points in the region
Definition: CalibrationStats.hpp:68
@ area
Calculate only the area.
int64_t _ptsNoNormal
number of points that didn't have a normal vector information (ignored for calibration constant estim...
Definition: CalibrationStats.hpp:70
A CalibrationEntry object stores statistics and results of one calibration constant estimation.
Definition: CalibrationStats.hpp:87
int64_t _ptsFiltered
number of points that were filtered and therefore ignored for calibration constant estimation
Definition: CalibrationStats.hpp:69
A dynamic character string whose interface conforms to STL's std::string.
Definition: String.hpp:35