Isis 3 Programmer Reference
Statistics.cpp
1
6/* SPDX-License-Identifier: CC0-1.0 */
7#include "Statistics.h"
8
9#include <QDataStream>
10#include <QDebug>
11#include <QString>
12#include <QUuid>
13#include <QXmlStreamWriter>
14#include <QXmlStreamReader>
15
16#include <float.h>
17
18#include "IException.h"
19#include "IString.h"
20#include "Project.h"
21#include "PvlGroup.h"
22#include "PvlKeyword.h"
23
24using namespace std;
25
26namespace Isis {
29// m_id = NULL;
30// m_id = new QUuid(QUuid::createUuid());
31 SetValidRange();
32 Reset(); // initialize
33 }
34
35 Statistics::Statistics(QXmlStreamReader *xmlReader, QObject *parent) { // TODO: does xml stuff need project???
36// m_id = NULL;
37 SetValidRange();
38 Reset(); // initialize
39 readStatistics(xmlReader);
40 }
41
42 void Statistics::readStatistics(QXmlStreamReader *xmlReader) {
43 Q_ASSERT(xmlReader->name() == "statistics");
44 while (xmlReader->readNextStartElement()) {
45 if (xmlReader->qualifiedName() == "sum") {
46 try {
47 m_sum = toDouble(xmlReader->readElementText());
48 }
49 catch (IException &e) {
50 m_sum = 0.0;
51 }
52 }
53 else if (xmlReader->qualifiedName() == "sumSquares") {
54 try {
55 m_sumsum = toDouble(xmlReader->readElementText());
56 }
57 catch (IException &e) {
58 m_sumsum = 0.0;
59 }
60 }
61 else if (xmlReader->qualifiedName() == "range") {
62 while (xmlReader->readNextStartElement()) {
63 if (xmlReader->qualifiedName() == "minimum") {
64 try {
65 m_minimum = toDouble(xmlReader->readElementText());
66 }
67 catch (IException &e) {
68 m_minimum = DBL_MAX;
69 }
70 }
71 else if (xmlReader->qualifiedName() == "maximum") {
72 try {
73 m_maximum = toDouble(xmlReader->readElementText());
74 }
75 catch (IException &e) {
76 m_maximum = -DBL_MAX;
77 }
78 }
79 else if (xmlReader->qualifiedName() == "validMinimum") {
80 try {
81 m_validMinimum = toDouble(xmlReader->readElementText());
82 }
83 catch (IException &e) {
85 }
86 }
87 else if (xmlReader->qualifiedName() == "validMaximum") {
88 try {
89 m_validMaximum = toDouble(xmlReader->readElementText());
90 }
91 catch (IException &e) {
93 }
94 }
95 else {
96 xmlReader->skipCurrentElement();
97 }
98 }
99 }
100 else if (xmlReader->qualifiedName() == "pixelCounts") {
101 while (xmlReader->readNextStartElement()) {
102 if (xmlReader->qualifiedName() == "totalPixels") {
103 try {
104 m_totalPixels = toBigInt(xmlReader->readElementText());
105 }
106 catch (IException &e) {
107 m_totalPixels = 0.0;
108 }
109 }
110 else if (xmlReader->qualifiedName() == "validPixels") {
111 try {
112 m_validPixels = toBigInt(xmlReader->readElementText());
113 }
114 catch (IException &e) {
115 m_validPixels = 0.0;
116 }
117 }
118 else if (xmlReader->qualifiedName() == "nullPixels") {
119 try {
120 m_nullPixels = toBigInt(xmlReader->readElementText());
121 }
122 catch (IException &e) {
123 m_nullPixels = 0.0;
124 }
125
126 }
127 else if (xmlReader->qualifiedName() == "lisPixels") {
128 try {
129 m_lisPixels = toBigInt(xmlReader->readElementText());
130 }
131 catch (IException &e) {
132 m_lisPixels = 0.0;
133 }
134 }
135 else if (xmlReader->qualifiedName() == "lrsPixels") {
136 try {
137 m_lrsPixels = toBigInt(xmlReader->readElementText());
138 }
139 catch (IException &e) {
140 m_lrsPixels = 0.0;
141 }
142 }
143 else if (xmlReader->qualifiedName() == "hisPixels") {
144 try {
145 m_hisPixels = toBigInt(xmlReader->readElementText());
146 }
147 catch (IException &e) {
148 m_hisPixels = 0.0;
149 }
150 }
151 else if (xmlReader->qualifiedName() == "hrsPixels") {
152 try {
153 m_hrsPixels = toBigInt(xmlReader->readElementText());
154 }
155 catch (IException &e) {
156 m_hrsPixels = 0.0;
157 }
158 }
159 else if (xmlReader->qualifiedName() == "underRangePixels") {
160 try {
161 m_underRangePixels = toBigInt(xmlReader->readElementText());
162 }
163 catch (IException &e) {
164 m_underRangePixels = 0.0;
165 }
166 }
167 else if (xmlReader->qualifiedName() == "overRangePixels") {
168 try {
169 m_overRangePixels = toBigInt(xmlReader->readElementText());
170 }
171 catch (IException &e) {
172 m_overRangePixels = 0.0;
173 }
174 }
175 else {
176 xmlReader->skipCurrentElement();
177 }
178 }
179 }
180 else if (xmlReader->qualifiedName() == "removedData") {
181 try {
182 m_removedData = toBool(xmlReader->readElementText());
183 }
184 catch (IException &e) {
185 m_removedData = false;
186 }
187 }
188 else {
189 xmlReader->skipCurrentElement();
190 }
191 }
192 }
193
199 Statistics::Statistics(const PvlGroup &inStats, QObject *parent) {
200 SetValidRange();
201 Reset();
202 fromPvl(inStats);
203 }
204
205
207 : m_sum(other.m_sum),
208 m_sumsum(other.m_sumsum),
209 m_minimum(other.m_minimum),
210 m_maximum(other.m_maximum),
211 m_validMinimum(other.m_validMinimum),
212 m_validMaximum(other.m_validMaximum),
213 m_totalPixels(other.m_totalPixels),
214 m_validPixels(other.m_validPixels),
215 m_nullPixels(other.m_nullPixels),
216 m_lrsPixels(other.m_lrsPixels),
217 m_lisPixels(other.m_lisPixels),
218 m_hrsPixels(other.m_hrsPixels),
219 m_hisPixels(other.m_hisPixels),
220 m_underRangePixels(other.m_underRangePixels),
221 m_overRangePixels(other.m_overRangePixels),
222 m_removedData(other.m_removedData) {
223 }
224 // : m_id(new QUuid(other.m_id->toString())),
225
226
229// delete m_id;
230// m_id = NULL;
231 }
232
233
234 Statistics &Statistics::operator=(const Statistics &other) {
235
236 if (&other != this) {
237// delete m_id;
238// m_id = NULL;
239// m_id = new QUuid(other.m_id->toString());
240
241 m_sum = other.m_sum;
242 m_sumsum = other.m_sumsum;
243 m_minimum = other.m_minimum;
244 m_maximum = other.m_maximum;
245 m_validMinimum = other.m_validMinimum;
246 m_validMaximum = other.m_validMaximum;
247 m_totalPixels = other.m_totalPixels;
248 m_validPixels = other.m_validPixels;
249 m_nullPixels = other.m_nullPixels;
250 m_lrsPixels = other.m_lrsPixels;
251 m_lisPixels = other.m_lisPixels;
252 m_hrsPixels = other.m_hrsPixels;
253 m_hisPixels = other.m_hisPixels;
254 m_underRangePixels = other.m_underRangePixels;
255 m_overRangePixels = other.m_overRangePixels;
256 m_removedData = other.m_removedData;
257 }
258 return *this;
259
260 }
261
262
265 m_sum = 0.0;
266 m_sumsum = 0.0;
267 m_minimum = DBL_MAX;
268 m_maximum = -DBL_MAX;
269 m_totalPixels = 0;
270 m_validPixels = 00;
271 m_nullPixels = 0;
272 m_lisPixels = 0;
273 m_lrsPixels = 0;
274 m_hrsPixels = 0;
275 m_hisPixels = 0;
278 m_removedData = false;
279 }
280
281
292 void Statistics::AddData(const double *data, const unsigned int count) {
293 for(unsigned int i = 0; i < count; i++) {
294 double value = data[i];
295 AddData(value);
296 }
297 }
298
299
309 void Statistics::AddData(const double data) {
311
312 if (Isis::IsNullPixel(data)) {
313 m_nullPixels++;
314 }
315 else if (Isis::IsHisPixel(data)) {
316 m_hisPixels++;
317 }
318 else if (Isis::IsHrsPixel(data)) {
319 m_hrsPixels++;
320 }
321 else if (Isis::IsLisPixel(data)) {
322 m_lisPixels++;
323 }
324 else if (Isis::IsLrsPixel(data)) {
325 m_lrsPixels++;
326 }
327 else if (AboveRange(data)) {
329 }
330 else if (BelowRange(data)) {
332 }
333 else { // if (Isis::IsValidPixel(data) && InRange(data)) {
334 m_sum += data;
335 m_sumsum += data * data;
336 if (data < m_minimum) m_minimum = data;
337 if (data > m_maximum) m_maximum = data;
339 }
340
341 }
342
343
357 void Statistics::RemoveData(const double *data, const unsigned int count) {
358
359 for(unsigned int i = 0; i < count; i++) {
360 double value = data[i];
361 RemoveData(value);
362 }
363
364 }
365
366
367 void Statistics::RemoveData(const double data) {
368 m_removedData = true;
370
371 if (Isis::IsNullPixel(data)) {
372 m_nullPixels--;
373 }
374 else if (Isis::IsHisPixel(data)) {
375 m_hisPixels--;
376 }
377 else if (Isis::IsHrsPixel(data)) {
378 m_hrsPixels--;
379 }
380 else if (Isis::IsLisPixel(data)) {
381 m_lisPixels--;
382 }
383 else if (Isis::IsLrsPixel(data)) {
384 m_lrsPixels--;
385 }
386 else if (AboveRange(data)) {
388 }
389 else if (BelowRange(data)) {
391 }
392 else { // if (IsValidPixel(data) && InRange(data)) {
393 m_sum -= data;
394 m_sumsum -= data * data;
396 }
397
398 if (m_totalPixels < 0) {
399 QString msg = "You are removing non-existant data in [Statistics::RemoveData]";
400 throw IException(IException::Programmer, msg, _FILEINFO_);
401 }
402 // what happens to saved off min/max???
403 }
404
405
406 void Statistics::SetValidRange(const double minimum, const double maximum) {
407 m_validMinimum = minimum;
408 m_validMaximum = maximum;
409
411 // get the min and max DN values in the chosen range
412 QString msg = "Invalid Range: Minimum [" + toString(minimum)
413 + "] must be less than the Maximum [" + toString(maximum) + "].";
414 throw IException(IException::Programmer, msg, _FILEINFO_);
415 }
416 //??? throw exception if data has already been added???
417 }
418
419
420 double Statistics::ValidMinimum() const {
421 return m_validMinimum;
422 }
423
424
425 double Statistics::ValidMaximum() const {
426 return m_validMaximum;
427 }
428
429
430 bool Statistics::InRange(const double value) {
431 return (!BelowRange(value) && !AboveRange(value));
432 }
433
434
435 bool Statistics::AboveRange(const double value) {
436 return (value > m_validMaximum);
437 }
438
439
440 bool Statistics::BelowRange(const double value) {
441 return (value < m_validMinimum);
442 }
443
444
451 double Statistics::Average() const {
452 if (m_validPixels < 1) return Isis::NULL8;
453 return m_sum / m_validPixels;
454 }
455
456
464 if (m_validPixels <= 1) return Isis::NULL8;
465 return sqrt(Variance());
466 }
467
468
479 double Statistics::Variance() const {
480 if (m_validPixels <= 1) return Isis::NULL8;
481 double temp = m_validPixels * m_sumsum - m_sum * m_sum;
482 if (temp < 0.0) temp = 0.0; // This should happen unless roundoff occurs
483 return temp / ((m_validPixels - 1.0) * m_validPixels);
484 }
485
486
492 double Statistics::Sum() const {
493 return m_sum;
494 }
495
496
502 double Statistics::SumSquare() const {
503 return m_sumsum;
504 }
505
506
516 double Statistics::Rms() const {
517 if (m_validPixels < 1) return Isis::NULL8;
518 double temp = m_sumsum / m_validPixels;
519 if (temp < 0.0) temp = 0.0;
520 return sqrt(temp);
521 }
522
523
533 double Statistics::Minimum() const {
534 if (m_removedData) {
535 QString msg = "Minimum is invalid since you removed data";
536 throw IException(IException::Programmer, msg, _FILEINFO_);
537 }
538
539 if (m_validPixels < 1) return Isis::NULL8;
540 return m_minimum;
541 }
542
543
554 double Statistics::Maximum() const {
555 if (m_removedData) {
556 QString msg = "Maximum is invalid since you removed data";
557 throw IException(IException::Programmer, msg, _FILEINFO_);
558 }
559
560 if (m_validPixels < 1) return Isis::NULL8;
561 return m_maximum;
562 }
563
564
572 return m_totalPixels;
573 }
574
575
585 return m_validPixels;
586 }
587
588
598
599
609
610
617 return m_nullPixels;
618 }
619
620
628 return m_lisPixels;
629 }
630
631
639 return m_lrsPixels;
640 }
641
642
650 return m_hisPixels;
651 }
652
653
661 return m_hrsPixels;
662 }
663
664
674
675
676 bool Statistics::RemovedData() const {
677 return m_removedData;
678 }
679
680
696 double Statistics::ChebyshevMinimum(const double percent) const {
697 if ((percent <= 0.0) || (percent >= 100.0)) {
698 QString msg = "Invalid value for percent";
699 throw IException(IException::Programmer, msg, _FILEINFO_);
700 }
701
702 if (m_validPixels < 1) return Isis::NULL8;
703 double k = sqrt(1.0 / (1.0 - percent / 100.0));
704 return Average() - k * StandardDeviation();
705 }
706
707
723 double Statistics::ChebyshevMaximum(const double percent) const {
724 if ((percent <= 0.0) || (percent >= 100.0)) {
725 QString msg = "Invalid value for percent";
726 throw IException(IException::Programmer, msg, _FILEINFO_);
727 }
728
729 if (m_validPixels < 1) return Isis::NULL8;
730 double k = sqrt(1.0 / (1.0 - percent / 100.0));
731 return Average() + k * StandardDeviation();
732 }
733
734
749 double Statistics::BestMinimum(const double percent) const {
750 if (m_validPixels < 1) return Isis::NULL8;
751 // ChebyshevMinimum can return erroneous values when the data is all a
752 // single value
753 // In this case, we just want to return the minimum
754 if (Minimum() == Maximum()) return Minimum();
755 double min = ChebyshevMinimum(percent);
756 if (Minimum() > min) min = Minimum();
757 return min;
758 }
759
760
776 double Statistics::BestMaximum(const double percent) const {
777 if (m_validPixels < 1) return Isis::NULL8;
778 // ChebyshevMaximum can return erroneous values when the data is all a
779 // single value
780 // In this case, we just want to return the maximum
781 if (Minimum() == Maximum()) return Maximum();
782 double max = ChebyshevMaximum(percent);
783 if (Maximum() < max) max = Maximum();
784 return max;
785 }
786
787
800 double Statistics::ZScore(const double value) const {
801 if (StandardDeviation() == 0) {
802 if (value == Maximum()) return 0;
803 else {
804 QString msg = "Undefined Z-score. Standard deviation is zero and the input value["
805 + toString(value) + "] is out of range [" + toString(Maximum()) + "].";
806 throw IException(IException::Programmer, msg, _FILEINFO_);
807 }
808 }
809 return (value - Average()) / StandardDeviation();
810 }
811
812
818 void Statistics::fromPvl(const PvlGroup &inStats) {
819 Reset();
820 m_sum = inStats["Sum"];
821 m_sumsum = inStats["SumSquare"];
822 m_minimum = inStats["Minimum"];
823 m_maximum = inStats["Maximum"];
824 m_validMinimum = inStats["ValidMinimum"];
825 m_validMaximum = inStats["ValidMaximum"];
826 m_totalPixels = inStats["TotalPixels"];
827 m_validPixels = inStats["ValidPixels"];
828 m_nullPixels = inStats["NullPixels"];
829 m_lrsPixels = inStats["LrsPixels"];
830 m_lisPixels = inStats["LisPixels"];
831 m_hrsPixels = inStats["HrsPixels"];
832 m_hisPixels = inStats["HisPixels"];
833 m_underRangePixels = inStats["UnderValidMinimumPixels"];
834 m_overRangePixels = inStats["OverValidMaximumPixels"];
835 m_removedData = false; //< Is this the correct state?
836 }
837
838
846 PvlGroup Statistics::toPvl(QString name) const {
847 if (name.isEmpty()) {
848 name = "Statistics";
849 }
850 // Construct a label with the results
851 PvlGroup results(name);
852 results += PvlKeyword("Sum", toString(Sum()));
853 results += PvlKeyword("SumSquare", toString(SumSquare()));
854 results += PvlKeyword("Minimum", toString(Minimum()));
855 results += PvlKeyword("Maximum", toString(Maximum()));
856 results += PvlKeyword("ValidMinimum", toString(ValidMinimum()));
857 results += PvlKeyword("ValidMaximum", toString(ValidMaximum()));
858 if (ValidPixels() != 0) {
859 results += PvlKeyword("Average", toString(Average()));
860 results += PvlKeyword("StandardDeviation", toString(StandardDeviation()));
861 results += PvlKeyword("Variance", toString(Variance()));
862 }
863 results += PvlKeyword("TotalPixels", toString(TotalPixels()));
864 results += PvlKeyword("ValidPixels", toString(ValidPixels()));
865 results += PvlKeyword("OverValidMaximumPixels", toString(OverRangePixels()));
866 results += PvlKeyword("UnderValidMinimumPixels", toString(UnderRangePixels()));
867 results += PvlKeyword("NullPixels", toString(NullPixels()));
868 results += PvlKeyword("LisPixels", toString(LisPixels()));
869 results += PvlKeyword("LrsPixels", toString(LrsPixels()));
870 results += PvlKeyword("HisPixels", toString(HisPixels()));
871 results += PvlKeyword("HrsPixels", toString(HrsPixels()));
872
873 return results;
874 }
875
876
877 void Statistics::save(QXmlStreamWriter &stream, const Project *project) const { // TODO: does xml stuff need project???
878
879 stream.writeStartElement("statistics");
880// stream.writeTextElement("id", m_id->toString());
881
882 stream.writeTextElement("sum", toString(m_sum));
883 stream.writeTextElement("sumSquares", toString(m_sumsum));
884
885 stream.writeStartElement("range");
886 stream.writeTextElement("minimum", toString(m_minimum));
887 stream.writeTextElement("maximum", toString(m_maximum));
888 stream.writeTextElement("validMinimum", toString(m_validMinimum));
889 stream.writeTextElement("validMaximum", toString(m_validMaximum));
890 stream.writeEndElement(); // end range
891
892 stream.writeStartElement("pixelCounts");
893 stream.writeTextElement("totalPixels", toString(m_totalPixels));
894 stream.writeTextElement("validPixels", toString(m_validPixels));
895 stream.writeTextElement("nullPixels", toString(m_nullPixels));
896 stream.writeTextElement("lisPixels", toString(m_lisPixels));
897 stream.writeTextElement("lrsPixels", toString(m_lrsPixels));
898 stream.writeTextElement("hisPixels", toString(m_hisPixels));
899 stream.writeTextElement("hrsPixels", toString(m_hrsPixels));
900 stream.writeTextElement("underRangePixels", toString(m_underRangePixels));
901 stream.writeTextElement("overRangePixels", toString(m_overRangePixels));
902 stream.writeEndElement(); // end pixelCounts
903
904 stream.writeTextElement("removedData", toString(m_removedData));
905 stream.writeEndElement(); // end statistics
906
907 }
908
909
914 QDataStream &Statistics::write(QDataStream &stream) const {
915 stream.setByteOrder(QDataStream::LittleEndian);
916 stream << m_sum
917 << m_sumsum
918 << m_minimum
919 << m_maximum
922 << (qint64)m_totalPixels
923 << (qint64)m_validPixels
924 << (qint64)m_nullPixels
925 << (qint64)m_lrsPixels
926 << (qint64)m_lisPixels
927 << (qint64)m_hrsPixels
928 << (qint64)m_hisPixels
929 << (qint64)m_underRangePixels
930 << (qint64)m_overRangePixels
931 << (qint32)m_removedData;
932 return stream;
933// stream << m_id->toString()
934 }
935
936
937 QDataStream &Statistics::read(QDataStream &stream) {
938
939// QString id;
940 qint64 totalPixels, validPixels, nullPixels, lrsPixels, lisPixels,
941 hrsPixels, hisPixels, underRangePixels, overRangePixels;
942 qint32 removedData;
943
944 stream.setByteOrder(QDataStream::LittleEndian);
945// stream >> id
946 stream >> m_sum
947 >> m_sumsum
948 >> m_minimum
949 >> m_maximum
952 >> totalPixels
953 >> validPixels
954 >> nullPixels
955 >> lrsPixels
956 >> lisPixels
957 >> hrsPixels
958 >> hisPixels
959 >> underRangePixels
960 >> overRangePixels
961 >> removedData;
962
963// delete m_id;
964// m_id = NULL;
965// m_id = new QUuid(id);
966
967 m_totalPixels = (BigInt)totalPixels;
968 m_validPixels = (BigInt)validPixels;
969 m_nullPixels = (BigInt)nullPixels;
970 m_lrsPixels = (BigInt)lrsPixels;
971 m_lisPixels = (BigInt)lisPixels;
972 m_hrsPixels = (BigInt)hrsPixels;
973 m_hisPixels = (BigInt)hisPixels;
974 m_underRangePixels = (BigInt)underRangePixels;
975 m_overRangePixels = (BigInt)overRangePixels;
976 m_removedData = (bool)removedData;
977
978 return stream;
979 }
980
981
982 QDataStream &operator<<(QDataStream &stream, const Statistics &statistics) {
983 return statistics.write(stream);
984 }
985
986
987 QDataStream &operator>>(QDataStream &stream, Statistics &statistics) {
988 return statistics.read(stream);
989 }
990
991} // end namespace isis
Isis exception class.
Definition IException.h:91
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition IException.h:146
The main project for ipce.
Definition Project.h:287
Contains multiple PvlContainers.
Definition PvlGroup.h:41
A single keyword-value pair.
Definition PvlKeyword.h:87
This class is used to accumulate statistics on double arrays.
Definition Statistics.h:93
BigInt m_hisPixels
Count of high instrument representation pixels processed.
Definition Statistics.h:176
BigInt NullPixels() const
Returns the total number of NULL pixels encountered.
double m_sum
The sum accumulator, i.e. the sum of added data values.
Definition Statistics.h:163
BigInt OverRangePixels() const
Returns the total number of pixels over the valid range encountered.
bool m_removedData
Indicates the RemoveData method was called which implies m_minimum and m_maximum are invalid.
Definition Statistics.h:179
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...
BigInt m_validPixels
Count of valid pixels (non-special) processed.
Definition Statistics.h:171
double Sum() const
Returns the sum of all the data.
BigInt UnderRangePixels() const
Returns the total number of pixels under the valid range encountered.
double Average() const
Computes and returns the average.
BigInt LisPixels() const
Returns the total number of low instrument saturation (LIS) pixels encountered.
virtual ~Statistics()
Destroys the IsisStats object.
double Minimum() const
Returns the absolute minimum double found in all data passed through the AddData method.
BigInt HrsPixels() const
Returns the total number of high representation saturation (HRS) pixels encountered.
BigInt HisPixels() const
Returns the total number of high instrument saturation (HIS) pixels encountered.
double m_validMinimum
Minimum valid pixel value.
Definition Statistics.h:168
double BestMinimum(const double percent=99.5) const
This method returns the better of the absolute minimum or the Chebyshev minimum.
BigInt m_lisPixels
Count of low representation saturation pixels processed.
Definition Statistics.h:174
BigInt OutOfRangePixels() const
Returns the total number of pixels outside of the valid range encountered.
BigInt m_nullPixels
Count of null pixels processed.
Definition Statistics.h:172
BigInt ValidPixels() const
Returns the total number of valid pixels processed.
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...
double ZScore(const double value) const
This method returns the better of the z-score of the given value.
BigInt m_totalPixels
Count of total pixels processed.
Definition Statistics.h:170
BigInt m_lrsPixels
Count of low instrument saturation pixels processed.
Definition Statistics.h:173
double SumSquare() const
Returns the sum of all the squared data.
BigInt TotalPixels() const
Returns the total number of pixels processed (valid and invalid).
QDataStream & write(QDataStream &stream) const
Order saved must match the offsets in the static compoundH5DataType() method.
PvlGroup toPvl(QString name="Statistics") const
Serialize statistics as a pvl group.
double m_minimum
Minimum double value encountered.
Definition Statistics.h:166
double m_maximum
Maximum double value encountered.
Definition Statistics.h:167
double m_validMaximum
Maximum valid pixel value.
Definition Statistics.h:169
void AddData(const double *data, const unsigned int count)
Add an array of doubles to the accumulators and counters.
double Rms() const
Computes and returns the rms.
double BestMaximum(const double percent=99.5) const
This method returns the better of the absolute maximum or the Chebyshev maximum.
double Maximum() const
Returns the absolute maximum double found in all data passed through the AddData method.
BigInt LrsPixels() const
Returns the total number of low representation saturation (LRS) pixels encountered.
void fromPvl(const PvlGroup &inStats)
Unserializes a Statistics object from a pvl group.
void RemoveData(const double *data, const unsigned int count)
Remove an array of doubles from the accumulators and counters.
double StandardDeviation() const
Computes and returns the standard deviation.
double Variance() const
Computes and returns the variance.
BigInt m_underRangePixels
Count of pixels less than the valid range.
Definition Statistics.h:177
BigInt m_hrsPixels
Count of high instrument saturation pixels processed.
Definition Statistics.h:175
BigInt m_overRangePixels
Count of pixels greater than the valid range.
Definition Statistics.h:178
Statistics(QObject *parent=0)
Constructs an IsisStats object with accumulators and counters set to zero.
void Reset()
Reset all accumulators and counters to zero.
double m_sumsum
The sum-squared accumulator, i.e.
Definition Statistics.h:164
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition IString.cpp:211
bool IsLrsPixel(const double d)
Returns if the input pixel is low representation saturation.
const double ValidMaximum
The maximum valid double value for Isis pixels.
bool IsNullPixel(const double d)
Returns if the input pixel is null.
bool IsHrsPixel(const double d)
Returns if the input pixel is high representation saturation.
BigInt toBigInt(const QString &string)
Global function to convert from a string to a "big" integer.
Definition IString.cpp:115
long long int BigInt
Big int.
Definition Constants.h:49
bool IsHisPixel(const double d)
Returns if the input pixel is high instrument saturation.
const double ValidMinimum
The minimum valid double value for Isis pixels.
bool toBool(const QString &string)
Global function to convert from a string to a boolean.
Definition IString.cpp:38
std::istream & operator>>(std::istream &is, CSVReader &csv)
Input read operator for input stream sources.
double toDouble(const QString &string)
Global function to convert from a string to a double.
Definition IString.cpp:149
bool IsLisPixel(const double d)
Returns if the input pixel is low instrument saturation.
QDebug operator<<(QDebug debug, const Hillshade &hillshade)
Print this class out to a QDebug object.
Namespace for the standard library.