Isis Developer Reference
Statistics.h
Go to the documentation of this file.
1 #ifndef Statistics_h
2 #define Statistics_h
3 
8 /* SPDX-License-Identifier: CC0-1.0 */
9 
10 #include <QObject>
11 #include <QString>
12 
13 #include "Constants.h"
14 #include "PvlGroup.h"
15 #include "SpecialPixel.h"
16 #include "XmlStackedHandler.h"
17 
18 class QDataStream;
19 class QUuid;
20 class QXmlStreamWriter;
21 
22 namespace Isis {
23  class Project;// ??? does xml stuff need project???
24  class XmlStackedHandlerReader;
94  class Statistics : public QObject {
95  Q_OBJECT
96  public:
97  Statistics(QObject *parent = 0);
98  Statistics(Project *project, XmlStackedHandlerReader *xmlReader, QObject *parent = 0);
99  Statistics(const PvlGroup &inStats, QObject *parent = 0);
100  // TODO: does xml read/write stuff need Project input???
101  Statistics(const Statistics &other);
102  virtual ~Statistics();
103  Statistics &operator=(const Statistics &other);
104 
105  void Reset();
106 
107  void AddData(const double *data, const unsigned int count);
108  void AddData(const double data);
109 
110  void RemoveData(const double *data, const unsigned int count);
111  void RemoveData(const double data);
112 
113  void SetValidRange(const double minimum = Isis::ValidMinimum,
114  const double maximum = Isis::ValidMaximum);
115 
116  double ValidMinimum() const;
117  double ValidMaximum() const;
118  bool InRange(const double value);
119  bool AboveRange(const double value);
120  bool BelowRange(const double value);
121 
122  double Average() const;
123  double StandardDeviation() const;
124  double Variance() const;
125  double Sum() const;
126  double SumSquare() const;
127  double Rms() const;
128 
129  double Minimum() const;
130  double Maximum() const;
131  double ChebyshevMinimum(const double percent = 99.5) const;
132  double ChebyshevMaximum(const double percent = 99.5) const;
133  double BestMinimum(const double percent = 99.5) const;
134  double BestMaximum(const double percent = 99.5) const;
135  double ZScore(const double value) const;
136 
137  BigInt TotalPixels() const;
138  BigInt ValidPixels() const;
139  BigInt OverRangePixels() const;
140  BigInt UnderRangePixels() const;
141  BigInt NullPixels() const;
142  BigInt LisPixels() const;
143  BigInt LrsPixels() const;
144  BigInt HisPixels() const;
145  BigInt HrsPixels() const;
146  BigInt OutOfRangePixels() const;
147  bool RemovedData() const;
148 
149  PvlGroup toPvl(QString name = "Statistics") const;
150 
151  void save(QXmlStreamWriter &stream, const Project *project) const;
152  // TODO: does xml stuff need project???
153 
154  QDataStream &write(QDataStream &stream) const;
155  QDataStream &read(QDataStream &stream);
156 
157  private:
158 
159  void fromPvl(const PvlGroup &inStats);
160 
167  class XmlHandler : public XmlStackedHandler {
168  public:
169  XmlHandler(Statistics *statistics, Project *project);
170  // TODO: does xml stuff need project???
171  ~XmlHandler();
172 
173  virtual bool startElement(const QString &namespaceURI, const QString &localName,
174  const QString &qName, const QXmlAttributes &atts);
175  virtual bool characters(const QString &ch);
176  virtual bool endElement(const QString &namespaceURI, const QString &localName,
177  const QString &qName);
178 
179  private:
180  Q_DISABLE_COPY(XmlHandler);
181 
182  Statistics *m_xmlHandlerStatistics;
183  Project *m_xmlHandlerProject;
184  // TODO: does xml stuff need project???
185  QString m_xmlHandlerCharacters;
186  };
187 
188 // QUuid *m_id; /**< A unique ID for this object (useful for others to reference
189 // this object when saving to disk).*/
190  double m_sum;
191  double m_sumsum;
193  double m_minimum;
194  double m_maximum;
195  double m_validMinimum;
196  double m_validMaximum;
197  BigInt m_totalPixels;
198  BigInt m_validPixels;
199  BigInt m_nullPixels;
200  BigInt m_lrsPixels;
201  BigInt m_lisPixels;
202  BigInt m_hrsPixels;
203  BigInt m_hisPixels;
204  BigInt m_underRangePixels;
205  BigInt m_overRangePixels;
206  bool m_removedData;
208  };
209 
210  // operators to read/write Statistics to/from binary data
211  QDataStream &operator<<(QDataStream &stream, const Statistics &statistics);
212  QDataStream &operator>>(QDataStream &stream, Statistics &statistics);
213 
214 } // end namespace isis
215 
216 #endif
217 
Isis::ValidMaximum
const double ValidMaximum
The maximum valid double value for Isis pixels.
Definition: SpecialPixel.h:122
Isis::Statistics::SumSquare
double SumSquare() const
Returns the sum of all the squared data.
Definition: Statistics.cpp:351
Isis::Statistics::NullPixels
BigInt NullPixels() const
Returns the total number of NULL pixels encountered.
Definition: Statistics.cpp:465
Isis::Statistics
This class is used to accumulate statistics on double arrays.
Definition: Statistics.h:94
Isis::Statistics::AddData
void AddData(const double *data, const unsigned int count)
Add an array of doubles to the accumulators and counters.
Definition: Statistics.cpp:141
Isis::Statistics::Sum
double Sum() const
Returns the sum of all the data.
Definition: Statistics.cpp:341
Isis::operator<<
QDebug operator<<(QDebug debug, const Hillshade &hillshade)
Print this class out to a QDebug object.
Definition: Hillshade.cpp:314
Isis::Statistics::TotalPixels
BigInt TotalPixels() const
Returns the total number of pixels processed (valid and invalid).
Definition: Statistics.cpp:420
Isis::PvlKeyword
A single keyword-value pair.
Definition: PvlKeyword.h:82
Project.h
Isis::Statistics::read
QDataStream & read(QDataStream &stream)
Definition: Statistics.cpp:879
Isis::Statistics::InRange
bool InRange(const double value)
Definition: Statistics.cpp:279
SpecialPixel.h
PvlGroup.h
Isis::XmlStackedHandlerReader::pushContentHandler
virtual void pushContentHandler(XmlStackedHandler *newHandler)
Push a contentHandler and maybe continue parsing...
Definition: XmlStackedHandlerReader.cpp:55
Isis::IsNullPixel
bool IsNullPixel(const double d)
Returns if the input pixel is null.
Definition: SpecialPixel.h:235
Isis::Statistics::ValidMaximum
double ValidMaximum() const
Definition: Statistics.cpp:274
Isis::Statistics::Maximum
double Maximum() const
Returns the absolute maximum double found in all data passed through the AddData method.
Definition: Statistics.cpp:403
Isis::Statistics::Reset
void Reset()
Reset all accumulators and counters to zero.
Definition: Statistics.cpp:113
Isis::Statistics::HrsPixels
BigInt HrsPixels() const
Returns the total number of high representation saturation (HRS) pixels encountered.
Definition: Statistics.cpp:509
Isis::IsHrsPixel
bool IsHrsPixel(const double d)
Returns if the input pixel is high representation saturation.
Definition: SpecialPixel.h:271
Isis::XmlStackedHandler::startElement
virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
Definition: XmlStackedHandler.cpp:44
Isis::Statistics::ValidPixels
BigInt ValidPixels() const
Returns the total number of valid pixels processed.
Definition: Statistics.cpp:433
Isis::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
Isis::Statistics::SetValidRange
void SetValidRange(const double minimum=Isis::ValidMinimum, const double maximum=Isis::ValidMaximum)
Definition: Statistics.cpp:255
Isis::Statistics::OverRangePixels
BigInt OverRangePixels() const
Returns the total number of pixels over the valid range encountered.
Definition: Statistics.cpp:444
Isis::XmlStackedHandlerReader
Manage a stack of content handlers for reading XML files.
Definition: XmlStackedHandlerReader.h:30
IString.h
Isis::Project
The main project for ipce.
Definition: Project.h:289
Isis::Statistics::operator=
Statistics & operator=(const Statistics &other)
Definition: Statistics.cpp:83
Isis::Statistics::RemoveData
void RemoveData(const double *data, const unsigned int count)
Remove an array of doubles from the accumulators and counters.
Definition: Statistics.cpp:206
Isis::Statistics::HisPixels
BigInt HisPixels() const
Returns the total number of high instrument saturation (HIS) pixels encountered.
Definition: Statistics.cpp:498
Isis::Statistics::Variance
double Variance() const
Computes and returns the variance.
Definition: Statistics.cpp:328
Isis::Statistics::UnderRangePixels
BigInt UnderRangePixels() const
Returns the total number of pixels under the valid range encountered.
Definition: Statistics.cpp:455
Isis::Statistics::LisPixels
BigInt LisPixels() const
Returns the total number of low instrument saturation (LIS) pixels encountered.
Definition: Statistics.cpp:476
Isis::Statistics::ChebyshevMaximum
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:572
Isis::Statistics::Rms
double Rms() const
Computes and returns the rms.
Definition: Statistics.cpp:365
Isis::PvlGroup
Contains multiple PvlContainers.
Definition: PvlGroup.h:41
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
Isis::toBigInt
BigInt toBigInt(const QString &string)
Global function to convert from a string to a "big" integer.
Definition: IString.cpp:115
Isis::Statistics::StandardDeviation
double StandardDeviation() const
Computes and returns the standard deviation.
Definition: Statistics.cpp:312
Isis::Statistics::Minimum
double Minimum() const
Returns the absolute minimum double found in all data passed through the AddData method.
Definition: Statistics.cpp:382
Isis::Statistics::save
void save(QXmlStreamWriter &stream, const Project *project) const
Definition: Statistics.cpp:726
Isis::NULL8
const double NULL8
Definition: SpecialPixel.h:94
Isis::BigInt
long long int BigInt
Big int.
Definition: Constants.h:49
Isis::Statistics::BestMaximum
double BestMaximum(const double percent=99.5) const
This method returns the better of the absolute maximum or the Chebyshev maximum.
Definition: Statistics.cpp:625
Isis::Statistics::ZScore
double ZScore(const double value) const
This method returns the better of the z-score of the given value.
Definition: Statistics.cpp:649
Isis::XmlStackedHandler::endElement
virtual bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)
Definition: XmlStackedHandler.cpp:55
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::IsLisPixel
bool IsLisPixel(const double d)
Returns if the input pixel is low instrument saturation.
Definition: SpecialPixel.h:295
Isis::Statistics::OutOfRangePixels
BigInt OutOfRangePixels() const
Returns the total number of pixels outside of the valid range encountered.
Definition: Statistics.cpp:520
Isis::Statistics::toPvl
PvlGroup toPvl(QString name="Statistics") const
Serialize statistics as a pvl group.
Definition: Statistics.cpp:695
Isis::IsLrsPixel
bool IsLrsPixel(const double d)
Returns if the input pixel is low representation saturation.
Definition: SpecialPixel.h:307
Isis::Statistics::Average
double Average() const
Computes and returns the average.
Definition: Statistics.cpp:300
Isis::IsHisPixel
bool IsHisPixel(const double d)
Returns if the input pixel is high instrument saturation.
Definition: SpecialPixel.h:283
Isis::Statistics::AboveRange
bool AboveRange(const double value)
Definition: Statistics.cpp:284
Statistics.h
IException.h
Isis::toDouble
double toDouble(const QString &string)
Global function to convert from a string to a double.
Definition: IString.cpp:149
Isis::ValidMinimum
const double ValidMinimum
The minimum valid double value for Isis pixels.
Definition: SpecialPixel.h:87
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
Isis::Statistics::RemovedData
bool RemovedData() const
Definition: Statistics.cpp:525
std
Namespace for the standard library.
Isis::Statistics::BestMinimum
double BestMinimum(const double percent=99.5) const
This method returns the better of the absolute minimum or the Chebyshev minimum.
Definition: Statistics.cpp:598
Isis::Statistics::Statistics
Statistics(QObject *parent=0)
Constructs an IsisStats object with accumulators and counters set to zero.
Definition: Statistics.cpp:28
Isis::toBool
bool toBool(const QString &string)
Global function to convert from a string to a boolean.
Definition: IString.cpp:38
PvlKeyword.h
Isis::XmlStackedHandler
XML Handler that parses XMLs in a stack-oriented way.
Definition: XmlStackedHandler.h:118
Isis::Statistics::BelowRange
bool BelowRange(const double value)
Definition: Statistics.cpp:289
Isis::Statistics::write
QDataStream & write(QDataStream &stream) const
Order saved must match the offsets in the static compoundH5DataType() method.
Definition: Statistics.cpp:856
Constants.h
Isis::Statistics::ChebyshevMinimum
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:545
Isis::Statistics::ValidMinimum
double ValidMinimum() const
Definition: Statistics.cpp:269
Isis::Statistics::~Statistics
virtual ~Statistics()
Destroys the IsisStats object.
Definition: Statistics.cpp:77
QObject
Isis::Statistics::LrsPixels
BigInt LrsPixels() const
Returns the total number of low representation saturation (LRS) pixels encountered.
Definition: Statistics.cpp:487
Isis::operator>>
std::istream & operator>>(std::istream &is, CSVReader &csv)
Input read operator for input stream sources.
Definition: CSVReader.cpp:447
XmlStackedHandlerReader.h
XmlStackedHandler.h
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16