Isis 3 Programmer Reference
Statistics.h
Go to the documentation of this file.
1 #ifndef Statistics_h
2 #define Statistics_h
3 
23 #include <QObject>
24 #include <QString>
25 
26 #include "Constants.h"
27 #include "PvlGroup.h"
28 #include "SpecialPixel.h"
29 #include "XmlStackedHandler.h"
30 
31 class QDataStream;
32 class QUuid;
33 class QXmlStreamWriter;
34 
35 namespace Isis {
36  class Project;// ??? does xml stuff need project???
37  class XmlStackedHandlerReader;
107  class Statistics : public QObject {
108  Q_OBJECT
109  public:
110  Statistics(QObject *parent = 0);
111  Statistics(Project *project, XmlStackedHandlerReader *xmlReader, QObject *parent = 0);
112  Statistics(const PvlGroup &inStats, QObject *parent = 0);
113  // TODO: does xml read/write stuff need Project input???
114  Statistics(const Statistics &other);
115  virtual ~Statistics();
116  Statistics &operator=(const Statistics &other);
117 
118  void Reset();
119 
120  void AddData(const double *data, const unsigned int count);
121  void AddData(const double data);
122 
123  void RemoveData(const double *data, const unsigned int count);
124  void RemoveData(const double data);
125 
126  void SetValidRange(const double minimum = Isis::ValidMinimum,
127  const double maximum = Isis::ValidMaximum);
128 
129  double ValidMinimum() const;
130  double ValidMaximum() const;
131  bool InRange(const double value);
132  bool AboveRange(const double value);
133  bool BelowRange(const double value);
134 
135  double Average() const;
136  double StandardDeviation() const;
137  double Variance() const;
138  double Sum() const;
139  double SumSquare() const;
140  double Rms() const;
141 
142  double Minimum() const;
143  double Maximum() const;
144  double ChebyshevMinimum(const double percent = 99.5) const;
145  double ChebyshevMaximum(const double percent = 99.5) const;
146  double BestMinimum(const double percent = 99.5) const;
147  double BestMaximum(const double percent = 99.5) const;
148  double ZScore(const double value) const;
149 
150  BigInt TotalPixels() const;
151  BigInt ValidPixels() const;
152  BigInt OverRangePixels() const;
153  BigInt UnderRangePixels() const;
154  BigInt NullPixels() const;
155  BigInt LisPixels() const;
156  BigInt LrsPixels() const;
157  BigInt HisPixels() const;
158  BigInt HrsPixels() const;
159  BigInt OutOfRangePixels() const;
160  bool RemovedData() const;
161 
162  PvlGroup toPvl(QString name = "Statistics") const;
163 
164  void save(QXmlStreamWriter &stream, const Project *project) const;
165  // TODO: does xml stuff need project???
166 
167  QDataStream &write(QDataStream &stream) const;
168  QDataStream &read(QDataStream &stream);
169 
170  private:
171 
172  void fromPvl(const PvlGroup &inStats);
173 
180  class XmlHandler : public XmlStackedHandler {
181  public:
182  XmlHandler(Statistics *statistics, Project *project);
183  // TODO: does xml stuff need project???
184  ~XmlHandler();
185 
186  virtual bool startElement(const QString &namespaceURI, const QString &localName,
187  const QString &qName, const QXmlAttributes &atts);
188  virtual bool characters(const QString &ch);
189  virtual bool endElement(const QString &namespaceURI, const QString &localName,
190  const QString &qName);
191 
192  private:
193  Q_DISABLE_COPY(XmlHandler);
194 
195  Statistics *m_xmlHandlerStatistics;
196  Project *m_xmlHandlerProject;
197  // TODO: does xml stuff need project???
198  QString m_xmlHandlerCharacters;
199  };
200 
201 // QUuid *m_id; /**< A unique ID for this object (useful for others to reference
202 // this object when saving to disk).*/
203  double m_sum;
204  double m_sumsum;
206  double m_minimum;
207  double m_maximum;
208  double m_validMinimum;
209  double m_validMaximum;
221  };
222 
223  // operators to read/write Statistics to/from binary data
224  QDataStream &operator<<(QDataStream &stream, const Statistics &statistics);
225  QDataStream &operator>>(QDataStream &stream, Statistics &statistics);
226 
227 } // end namespace isis
228 
229 #endif
230 
long long int BigInt
Big int.
Definition: Constants.h:65
void RemoveData(const double *data, const unsigned int count)
Remove an array of doubles from the accumulators and counters.
Definition: Statistics.cpp:219
BigInt m_nullPixels
Count of null pixels processed.
Definition: Statistics.h:212
The main project for ipce.
Definition: Project.h:289
double Sum() const
Returns the sum of all the data.
Definition: Statistics.cpp:354
const double ValidMinimum
The minimum valid double value for Isis pixels.
Definition: SpecialPixel.h:102
double StandardDeviation() const
Computes and returns the standard deviation.
Definition: Statistics.cpp:325
double Minimum() const
Returns the absolute minimum double found in all data passed through the AddData method.
Definition: Statistics.cpp:395
double SumSquare() const
Returns the sum of all the squared data.
Definition: Statistics.cpp:364
double BestMaximum(const double percent=99.5) const
This method returns the better of the absolute maximum or the Chebyshev maximum.
Definition: Statistics.cpp:634
BigInt m_lisPixels
Count of low representation saturation pixels processed.
Definition: Statistics.h:214
BigInt HrsPixels() const
Returns the total number of high representation saturation (HRS) pixels encountered.
Definition: Statistics.cpp:522
void fromPvl(const PvlGroup &inStats)
Unserializes a Statistics object from a pvl group.
Definition: Statistics.cpp:672
BigInt ValidPixels() const
Returns the total number of valid pixels processed.
Definition: Statistics.cpp:446
BigInt HisPixels() const
Returns the total number of high instrument saturation (HIS) pixels encountered.
Definition: Statistics.cpp:511
BigInt NullPixels() const
Returns the total number of NULL pixels encountered.
Definition: Statistics.cpp:478
BigInt OverRangePixels() const
Returns the total number of pixels over the valid range encountered.
Definition: Statistics.cpp:457
double m_sum
The sum accumulator, i.e. the sum of added data values.
Definition: Statistics.h:203
BigInt TotalPixels() const
Returns the total number of pixels processed (valid and invalid).
Definition: Statistics.cpp:433
double Maximum() const
Returns the absolute maximum double found in all data passed through the AddData method.
Definition: Statistics.cpp:416
BigInt m_hrsPixels
Count of high instrument saturation pixels processed.
Definition: Statistics.h:215
This class is used to accumulate statistics on double arrays.
Definition: Statistics.h:107
QDataStream & write(QDataStream &stream) const
Order saved must match the offsets in the static compoundH5DataType() method.
Definition: Statistics.cpp:861
double BestMinimum(const double percent=99.5) const
This method returns the better of the absolute minimum or the Chebyshev minimum.
Definition: Statistics.cpp:611
BigInt OutOfRangePixels() const
Returns the total number of pixels outside of the valid range encountered.
Definition: Statistics.cpp:533
PvlGroup toPvl(QString name="Statistics") const
Serialize statistics as a pvl group.
Definition: Statistics.cpp:700
BigInt LisPixels() const
Returns the total number of low instrument saturation (LIS) pixels encountered.
Definition: Statistics.cpp:489
BigInt m_validPixels
Count of valid pixels (non-special) processed.
Definition: Statistics.h:211
Contains multiple PvlContainers.
Definition: PvlGroup.h:57
void Reset()
Reset all accumulators and counters to zero.
Definition: Statistics.cpp:126
std::istream & operator>>(std::istream &is, CSVReader &csv)
Input read operator for input stream sources.
Definition: CSVReader.cpp:463
double m_sumsum
The sum-squared accumulator, i.e.
Definition: Statistics.h:204
XML Handler that parses XMLs in a stack-oriented way.
double Variance() const
Computes and returns the variance.
Definition: Statistics.cpp:341
double m_minimum
Minimum double value encountered.
Definition: Statistics.h:206
BigInt UnderRangePixels() const
Returns the total number of pixels under the valid range encountered.
Definition: Statistics.cpp:468
Statistics(QObject *parent=0)
Constructs an IsisStats object with accumulators and counters set to zero.
Definition: Statistics.cpp:41
double ChebyshevMaximum(const double percent=99.5) const
This method returns a maximum such that X percent of the data will fall with K standard deviations of...
Definition: Statistics.cpp:585
double Rms() const
Computes and returns the rms.
Definition: Statistics.cpp:378
bool m_removedData
Indicates the RemoveData method was called which implies m_minimum and m_maximum are invalid...
Definition: Statistics.h:219
BigInt LrsPixels() const
Returns the total number of low representation saturation (LRS) pixels encountered.
Definition: Statistics.cpp:500
BigInt m_overRangePixels
Count of pixels greater than the valid range.
Definition: Statistics.h:218
const double ValidMaximum
The maximum valid double value for Isis pixels.
Definition: SpecialPixel.h:137
double m_maximum
Maximum double value encountered.
Definition: Statistics.h:207
double ChebyshevMinimum(const double percent=99.5) const
This method returns a minimum such that X percent of the data will fall with K standard deviations of...
Definition: Statistics.cpp:558
BigInt m_totalPixels
Count of total pixels processed.
Definition: Statistics.h:210
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
double m_validMaximum
Maximum valid pixel value.
Definition: Statistics.h:209
QDebug operator<<(QDebug debug, const Hillshade &hillshade)
Print this class out to a QDebug object.
Definition: Hillshade.cpp:308
double ZScore(const double value) const
This method returns the better of the z-score of the given value.
Definition: Statistics.cpp:654
void AddData(const double *data, const unsigned int count)
Add an array of doubles to the accumulators and counters.
Definition: Statistics.cpp:154
BigInt m_hisPixels
Count of high instrument representation pixels processed.
Definition: Statistics.h:216
double m_validMinimum
Minimum valid pixel value.
Definition: Statistics.h:208
BigInt m_lrsPixels
Count of low instrument saturation pixels processed.
Definition: Statistics.h:213
double Average() const
Computes and returns the average.
Definition: Statistics.cpp:313
Manage a stack of content handlers for reading XML files.
virtual ~Statistics()
Destroys the IsisStats object.
Definition: Statistics.cpp:90
BigInt m_underRangePixels
Count of pixels less than the valid range.
Definition: Statistics.h:217