Isis 3.0 Programmer Reference
Back | Home
Statistics.cpp
Go to the documentation of this file.
1 
20 #include "Statistics.h"
21 
22 #include <QDataStream>
23 #include <QDebug>
24 #include <QString>
25 #include <QUuid>
26 #include <QXmlStreamWriter>
27 
28 #include <float.h>
29 
30 #include <H5Cpp.h>
31 #include <hdf5_hl.h>
32 #include <hdf5.h>
33 
34 #include "IException.h"
35 #include "IString.h"
36 #include "Project.h"
37 #include "PvlGroup.h"
38 #include "PvlKeyword.h"
39 #include "XmlStackedHandlerReader.h"
40 
41 using namespace std;
42 
43 namespace Isis {
45  Statistics::Statistics(QObject *parent) : QObject(parent) {
46 // m_id = NULL;
47 // m_id = new QUuid(QUuid::createUuid());
48  SetValidRange();
49  Reset(); // initialize
50  }
51 
52 
53  Statistics::Statistics(Project *project, XmlStackedHandlerReader *xmlReader, QObject *parent) { // TODO: does xml stuff need project???
54 // m_id = NULL;
55  SetValidRange();
56  Reset(); // initialize
57  xmlReader->pushContentHandler(new XmlHandler(this, project)); // TODO: does xml stuff need project???
58  }
59 
65  Statistics::Statistics(const PvlGroup &inStats, QObject *parent) {
66  SetValidRange();
67  Reset();
68  fromPvl(inStats);
69  }
70 
71 
73  : m_sum(other.m_sum),
74  m_sumsum(other.m_sumsum),
75  m_minimum(other.m_minimum),
76  m_maximum(other.m_maximum),
77  m_validMinimum(other.m_validMinimum),
78  m_validMaximum(other.m_validMaximum),
79  m_totalPixels(other.m_totalPixels),
80  m_validPixels(other.m_validPixels),
81  m_nullPixels(other.m_nullPixels),
82  m_lrsPixels(other.m_lrsPixels),
83  m_lisPixels(other.m_lisPixels),
84  m_hrsPixels(other.m_hrsPixels),
85  m_hisPixels(other.m_hisPixels),
86  m_underRangePixels(other.m_underRangePixels),
87  m_overRangePixels(other.m_overRangePixels),
88  m_removedData(other.m_removedData) {
89  }
90  // : m_id(new QUuid(other.m_id->toString())),
91 
92 
95 // delete m_id;
96 // m_id = NULL;
97  }
98 
99 
100  Statistics &Statistics::operator=(const Statistics &other) {
101 
102  if (&other != this) {
103 // delete m_id;
104 // m_id = NULL;
105 // m_id = new QUuid(other.m_id->toString());
106 
107  m_sum = other.m_sum;
108  m_sumsum = other.m_sumsum;
109  m_minimum = other.m_minimum;
110  m_maximum = other.m_maximum;
115  m_nullPixels = other.m_nullPixels;
116  m_lrsPixels = other.m_lrsPixels;
117  m_lisPixels = other.m_lisPixels;
118  m_hrsPixels = other.m_hrsPixels;
119  m_hisPixels = other.m_hisPixels;
123  }
124  return *this;
125 
126  }
127 
128 
131  m_sum = 0.0;
132  m_sumsum = 0.0;
133  m_minimum = DBL_MAX;
134  m_maximum = -DBL_MAX;
135  m_totalPixels = 0;
136  m_validPixels = 00;
137  m_nullPixels = 0;
138  m_lisPixels = 0;
139  m_lrsPixels = 0;
140  m_hrsPixels = 0;
141  m_hisPixels = 0;
142  m_overRangePixels = 0;
143  m_underRangePixels = 0;
144  m_removedData = false;
145  }
146 
147 
158  void Statistics::AddData(const double *data, const unsigned int count) {
159  for(unsigned int i = 0; i < count; i++) {
160  double value = data[i];
161  AddData(value);
162  }
163  }
164 
165 
175  void Statistics::AddData(const double data) {
176  m_totalPixels++;
177 
178  if (Isis::IsNullPixel(data)) {
179  m_nullPixels++;
180  }
181  else if (Isis::IsHisPixel(data)) {
182  m_hisPixels++;
183  }
184  else if (Isis::IsHrsPixel(data)) {
185  m_hrsPixels++;
186  }
187  else if (Isis::IsLisPixel(data)) {
188  m_lisPixels++;
189  }
190  else if (Isis::IsLrsPixel(data)) {
191  m_lrsPixels++;
192  }
193  else if (AboveRange(data)) {
195  }
196  else if (BelowRange(data)) {
198  }
199  else { // if (Isis::IsValidPixel(data) && InRange(data)) {
200  m_sum += data;
201  m_sumsum += data * data;
202  if (data < m_minimum) m_minimum = data;
203  if (data > m_maximum) m_maximum = data;
204  m_validPixels++;
205  }
206 
207  }
208 
209 
223  void Statistics::RemoveData(const double *data, const unsigned int count) {
224 
225  for(unsigned int i = 0; i < count; i++) {
226  double value = data[i];
227  RemoveData(value);
228  }
229 
230  }
231 
232 
233  void Statistics::RemoveData(const double data) {
234  m_removedData = true;
235  m_totalPixels--;
236 
237  if (Isis::IsNullPixel(data)) {
238  m_nullPixels--;
239  }
240  else if (Isis::IsHisPixel(data)) {
241  m_hisPixels--;
242  }
243  else if (Isis::IsHrsPixel(data)) {
244  m_hrsPixels--;
245  }
246  else if (Isis::IsLisPixel(data)) {
247  m_lisPixels--;
248  }
249  else if (Isis::IsLrsPixel(data)) {
250  m_lrsPixels--;
251  }
252  else if (AboveRange(data)) {
254  }
255  else if (BelowRange(data)) {
257  }
258  else { // if (IsValidPixel(data) && InRange(data)) {
259  m_sum -= data;
260  m_sumsum -= data * data;
261  m_validPixels--;
262  }
263 
264  if (m_totalPixels < 0) {
265  QString msg = "You are removing non-existant data in [Statistics::RemoveData]";
266  throw IException(IException::Programmer, msg, _FILEINFO_);
267  }
268  // what happens to saved off min/max???
269  }
270 
271 
272  void Statistics::SetValidRange(const double minimum, const double maximum) {
273  m_validMinimum = minimum;
274  m_validMaximum = maximum;
275 
277  // get the min and max DN values in the chosen range
278  QString msg = "Invalid Range: Minimum [" + toString(minimum)
279  + "] must be less than the Maximum [" + toString(maximum) + "].";
280  throw IException(IException::Programmer, msg, _FILEINFO_);
281  }
282  //??? throw exception if data has already been added???
283  }
284 
285 
286  double Statistics::ValidMinimum() const {
287  return m_validMinimum;
288  }
289 
290 
291  double Statistics::ValidMaximum() const {
292  return m_validMaximum;
293  }
294 
295 
296  bool Statistics::InRange(const double value) {
297  return (!BelowRange(value) && !AboveRange(value));
298  }
299 
300 
301  bool Statistics::AboveRange(const double value) {
302  return (value > m_validMaximum);
303  }
304 
305 
306  bool Statistics::BelowRange(const double value) {
307  return (value < m_validMinimum);
308  }
309 
310 
317  double Statistics::Average() const {
318  if (m_validPixels < 1) return Isis::NULL8;
319  return m_sum / m_validPixels;
320  }
321 
322 
330  if (m_validPixels <= 1) return Isis::NULL8;
331  return sqrt(Variance());
332  }
333 
334 
345  double Statistics::Variance() const {
346  if (m_validPixels <= 1) return Isis::NULL8;
347  double temp = m_validPixels * m_sumsum - m_sum * m_sum;
348  if (temp < 0.0) temp = 0.0; // This should happen unless roundoff occurs
349  return temp / ((m_validPixels - 1.0) * m_validPixels);
350  }
351 
352 
358  double Statistics::Sum() const {
359  return m_sum;
360  }
361 
362 
368  double Statistics::SumSquare() const {
369  return m_sumsum;
370  }
371 
372 
382  double Statistics::Rms() const {
383  if (m_validPixels < 1) return Isis::NULL8;
384  double temp = m_sumsum / m_validPixels;
385  if (temp < 0.0) temp = 0.0;
386  return sqrt(temp);
387  }
388 
389 
399  double Statistics::Minimum() const {
400  if (m_removedData) {
401  QString msg = "Minimum is invalid since you removed data";
403  }
404 
405  if (m_validPixels < 1) return Isis::NULL8;
406  return m_minimum;
407  }
408 
409 
420  double Statistics::Maximum() const {
421  if (m_removedData) {
422  QString msg = "Maximum is invalid since you removed data";
424  }
425 
426  if (m_validPixels < 1) return Isis::NULL8;
427  return m_maximum;
428  }
429 
430 
437  BigInt Statistics::TotalPixels() const {
438  return m_totalPixels;
439  }
440 
441 
450  BigInt Statistics::ValidPixels() const {
451  return m_validPixels;
452  }
453 
454 
462  return m_overRangePixels;
463  }
464 
465 
473  return m_underRangePixels;
474  }
475 
476 
482  BigInt Statistics::NullPixels() const {
483  return m_nullPixels;
484  }
485 
486 
493  BigInt Statistics::LisPixels() const {
494  return m_lisPixels;
495  }
496 
497 
504  BigInt Statistics::LrsPixels() const {
505  return m_lrsPixels;
506  }
507 
508 
515  BigInt Statistics::HisPixels() const {
516  return m_hisPixels;
517  }
518 
519 
526  BigInt Statistics::HrsPixels() const {
527  return m_hrsPixels;
528  }
529 
530 
539  }
540 
541 
542  bool Statistics::RemovedData() const {
543  return m_removedData;
544  }
545 
546 
562  double Statistics::ChebyshevMinimum(const double percent) const {
563  if ((percent <= 0.0) || (percent >= 100.0)) {
564  QString msg = "Invalid value for percent";
566  }
567 
568  if (m_validPixels < 1) return Isis::NULL8;
569  double k = sqrt(1.0 / (1.0 - percent / 100.0));
570  return Average() - k * StandardDeviation();
571  }
572 
573 
589  double Statistics::ChebyshevMaximum(const double percent) const {
590  if ((percent <= 0.0) || (percent >= 100.0)) {
591  QString msg = "Invalid value for percent";
593  }
594 
595  if (m_validPixels < 1) return Isis::NULL8;
596  double k = sqrt(1.0 / (1.0 - percent / 100.0));
597  return Average() + k * StandardDeviation();
598  }
599 
600 
615  double Statistics::BestMinimum(const double percent) const {
616  if (m_validPixels < 1) return Isis::NULL8;
617  double min = ChebyshevMinimum(percent);
618  if (Minimum() > min) min = Minimum();
619  return min;
620  }
621 
622 
638  double Statistics::BestMaximum(const double percent) const {
639  if (m_validPixels < 1) return Isis::NULL8;
640  double max = ChebyshevMaximum(percent);
641  if (Maximum() < max) max = Maximum();
642  return max;
643  }
644 
645 
658  double Statistics::ZScore(const double value) const {
659  if (StandardDeviation() == 0) {
660  if (value == Maximum()) return 0;
661  else {
662  QString msg = "Undefined Z-score. Standard deviation is zero and the input value["
663  + toString(value) + "] is out of range [" + toString(Maximum()) + "].";
665  }
666  }
667  return (value - Average()) / StandardDeviation();
668  }
669 
670 
676  void Statistics::fromPvl(const PvlGroup &inStats) {
677  Reset();
678  m_sum = inStats["Sum"];
679  m_sumsum = inStats["SumSquare"];
680  m_minimum = inStats["Minimum"];
681  m_maximum = inStats["Maximum"];
682  m_validMinimum = inStats["ValidMinimum"];
683  m_validMaximum = inStats["ValidMaximum"];
684  m_totalPixels = inStats["TotalPixels"];
685  m_validPixels = inStats["ValidPixels"];
686  m_nullPixels = inStats["NullPixels"];
687  m_lrsPixels = inStats["LrsPixels"];
688  m_lisPixels = inStats["LisPixels"];
689  m_hrsPixels = inStats["HrsPixels"];
690  m_hisPixels = inStats["HisPixels"];
691  m_underRangePixels = inStats["UnderValidMinimumPixels"];
692  m_overRangePixels = inStats["OverValidMaximumPixels"];
693  m_removedData = false; //< Is this the correct state?
694  }
695 
696 
704  PvlGroup Statistics::toPvl(QString name) const {
705  if (name.isEmpty()) {
706  name = "Statistics";
707  }
708  // Construct a label with the results
709  PvlGroup results(name);
710  results += PvlKeyword("Sum", toString(Sum()));
711  results += PvlKeyword("SumSquare", toString(SumSquare()));
712  results += PvlKeyword("Minimum", toString(Minimum()));
713  results += PvlKeyword("Maximum", toString(Maximum()));
714  results += PvlKeyword("ValidMinimum", toString(ValidMinimum()));
715  results += PvlKeyword("ValidMaximum", toString(ValidMaximum()));
716  if (ValidPixels() != 0) {
717  results += PvlKeyword("Average", toString(Average()));
718  results += PvlKeyword("StandardDeviation", toString(StandardDeviation()));
719  results += PvlKeyword("Variance", toString(Variance()));
720  }
721  results += PvlKeyword("TotalPixels", toString(TotalPixels()));
722  results += PvlKeyword("ValidPixels", toString(ValidPixels()));
723  results += PvlKeyword("OverValidMaximumPixels", toString(OverRangePixels()));
724  results += PvlKeyword("UnderValidMinimumPixels", toString(UnderRangePixels()));
725  results += PvlKeyword("NullPixels", toString(NullPixels()));
726  results += PvlKeyword("LisPixels", toString(LisPixels()));
727  results += PvlKeyword("LrsPixels", toString(LrsPixels()));
728  results += PvlKeyword("HisPixels", toString(HisPixels()));
729  results += PvlKeyword("HrsPixels", toString(HrsPixels()));
730 
731  return results;
732  }
733 
734 
735  void Statistics::save(QXmlStreamWriter &stream, const Project *project) const { // TODO: does xml stuff need project???
736 
737  stream.writeStartElement("statistics");
738 // stream.writeTextElement("id", m_id->toString());
739 
740  stream.writeTextElement("sum", toString(m_sum));
741  stream.writeTextElement("sumSquares", toString(m_sumsum));
742 
743  stream.writeStartElement("range");
744  stream.writeTextElement("minimum", toString(m_minimum));
745  stream.writeTextElement("maximum", toString(m_maximum));
746  stream.writeTextElement("validMinimum", toString(m_validMinimum));
747  stream.writeTextElement("validMaximum", toString(m_validMaximum));
748  stream.writeEndElement(); // end range
749 
750  stream.writeStartElement("pixelCounts");
751  stream.writeTextElement("totalPixels", toString(m_totalPixels));
752  stream.writeTextElement("validPixels", toString(m_validPixels));
753  stream.writeTextElement("nullPixels", toString(m_nullPixels));
754  stream.writeTextElement("lisPixels", toString(m_lisPixels));
755  stream.writeTextElement("lrsPixels", toString(m_lrsPixels));
756  stream.writeTextElement("hisPixels", toString(m_hisPixels));
757  stream.writeTextElement("hrsPixels", toString(m_hrsPixels));
758  stream.writeTextElement("underRangePixels", toString(m_underRangePixels));
759  stream.writeTextElement("overRangePixels", toString(m_overRangePixels));
760  stream.writeEndElement(); // end pixelCounts
761 
762  stream.writeTextElement("removedData", toString(m_removedData));
763  stream.writeEndElement(); // end statistics
764 
765  }
766 
767 
768  Statistics::XmlHandler::XmlHandler(Statistics *statistics, Project *project) { // TODO: does xml stuff need project???
769  m_xmlHandlerStatistics = statistics;
770  m_xmlHandlerProject = project; // TODO: does xml stuff need project???
771  m_xmlHandlerCharacters = "";
772  }
773 
774 
775  Statistics::XmlHandler::~XmlHandler() {
776  // do not delete this pointer... we don't own it, do we??? passed into StatCumProbDistDynCalc constructor as pointer
777  // delete m_xmlHandlerProject; // TODO: does xml stuff need project???
778  m_xmlHandlerProject = NULL;
779  }
780 
781 
782  bool Statistics::XmlHandler::startElement(const QString &namespaceURI,
783  const QString &localName,
784  const QString &qName,
785  const QXmlAttributes &atts) {
786  m_xmlHandlerCharacters = "";
787  if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) {
788  // no element attibutes to evaluate
789  }
790  return true;
791  }
792 
793 
794  bool Statistics::XmlHandler::characters(const QString &ch) {
795  m_xmlHandlerCharacters += ch;
796  return XmlStackedHandler::characters(ch);
797  }
798 
799 
800  bool Statistics::XmlHandler::endElement(const QString &namespaceURI, const QString &localName,
801  const QString &qName) {
802  if (!m_xmlHandlerCharacters.isEmpty()) {
803  if (localName == "id") {
804 // m_xmlHandlerStatistics->m_id = NULL;
805 // m_xmlHandlerStatistics->m_id = new QUuid(m_xmlHandlerCharacters);
806  }
807  if (localName == "sum") {
808  m_xmlHandlerStatistics->m_sum = toDouble(m_xmlHandlerCharacters);
809  }
810  if (localName == "sumSquares") {
811  m_xmlHandlerStatistics->m_sumsum = toDouble(m_xmlHandlerCharacters);
812  }
813  if (localName == "minimum") {
814  m_xmlHandlerStatistics->m_minimum = toDouble(m_xmlHandlerCharacters);
815  }
816  if (localName == "maximum") {
817  m_xmlHandlerStatistics->m_maximum = toDouble(m_xmlHandlerCharacters);
818  }
819  if (localName == "validMinimum") {
820  m_xmlHandlerStatistics->m_validMinimum = toDouble(m_xmlHandlerCharacters);
821  }
822  if (localName == "validMaximum") {
823  m_xmlHandlerStatistics->m_validMaximum = toDouble(m_xmlHandlerCharacters);
824  }
825  if (localName == "totalPixels") {
826  m_xmlHandlerStatistics->m_totalPixels = toBigInt(m_xmlHandlerCharacters);
827  }
828  if (localName == "validPixels") {
829  m_xmlHandlerStatistics->m_validPixels = toBigInt(m_xmlHandlerCharacters);
830  }
831  if (localName == "nullPixels") {
832  m_xmlHandlerStatistics->m_nullPixels = toBigInt(m_xmlHandlerCharacters);
833  }
834  if (localName == "lisPixels") {
835  m_xmlHandlerStatistics->m_lisPixels = toBigInt(m_xmlHandlerCharacters);
836  }
837  if (localName == "lrsPixels") {
838  m_xmlHandlerStatistics->m_lrsPixels = toBigInt(m_xmlHandlerCharacters);
839  }
840  if (localName == "hisPixels") {
841  m_xmlHandlerStatistics->m_hisPixels = toBigInt(m_xmlHandlerCharacters);
842  }
843  if (localName == "hrsPixels") {
844  m_xmlHandlerStatistics->m_hrsPixels = toBigInt(m_xmlHandlerCharacters);
845  }
846  if (localName == "underRangePixels") {
847  m_xmlHandlerStatistics->m_underRangePixels = toBigInt(m_xmlHandlerCharacters);
848  }
849  if (localName == "overRangePixels") {
850  m_xmlHandlerStatistics->m_overRangePixels = toBigInt(m_xmlHandlerCharacters);
851  }
852  if (localName == "removedData") {
853  m_xmlHandlerStatistics->m_removedData = toBool(m_xmlHandlerCharacters);
854  }
855  m_xmlHandlerCharacters = "";
856  }
857  return XmlStackedHandler::endElement(namespaceURI, localName, qName);
858  }
859 
860 
865  QDataStream &Statistics::write(QDataStream &stream) const {
866  stream.setByteOrder(QDataStream::LittleEndian);
867  stream << m_sum
868  << m_sumsum
869  << m_minimum
870  << m_maximum
871  << m_validMinimum
872  << m_validMaximum
873  << (qint64)m_totalPixels
874  << (qint64)m_validPixels
875  << (qint64)m_nullPixels
876  << (qint64)m_lrsPixels
877  << (qint64)m_lisPixels
878  << (qint64)m_hrsPixels
879  << (qint64)m_hisPixels
880  << (qint64)m_underRangePixels
881  << (qint64)m_overRangePixels
882  << (qint32)m_removedData;
883  return stream;
884 // stream << m_id->toString()
885  }
886 
887 
888  QDataStream &Statistics::read(QDataStream &stream) {
889 
890 // QString id;
891  qint64 totalPixels, validPixels, nullPixels, lrsPixels, lisPixels,
892  hrsPixels, hisPixels, underRangePixels, overRangePixels;
893  qint32 removedData;
894 
895  stream.setByteOrder(QDataStream::LittleEndian);
896 // stream >> id
897  stream >> m_sum
898  >> m_sumsum
899  >> m_minimum
900  >> m_maximum
901  >> m_validMinimum
902  >> m_validMaximum
903  >> totalPixels
904  >> validPixels
905  >> nullPixels
906  >> lrsPixels
907  >> lisPixels
908  >> hrsPixels
909  >> hisPixels
910  >> underRangePixels
911  >> overRangePixels
912  >> removedData;
913 
914 // delete m_id;
915 // m_id = NULL;
916 // m_id = new QUuid(id);
917 
918  m_totalPixels = (BigInt)totalPixels;
919  m_validPixels = (BigInt)validPixels;
920  m_nullPixels = (BigInt)nullPixels;
921  m_lrsPixels = (BigInt)lrsPixels;
922  m_lisPixels = (BigInt)lisPixels;
923  m_hrsPixels = (BigInt)hrsPixels;
924  m_hisPixels = (BigInt)hisPixels;
925  m_underRangePixels = (BigInt)underRangePixels;
926  m_overRangePixels = (BigInt)overRangePixels;
927  m_removedData = (bool)removedData;
928 
929  return stream;
930  }
931 
932 
933  QDataStream &operator<<(QDataStream &stream, const Statistics &statistics) {
934  return statistics.write(stream);
935  }
936 
937 
938  QDataStream &operator>>(QDataStream &stream, Statistics &statistics) {
939  return statistics.read(stream);
940  }
941 
942 //??? not working for prog14/15???
943 // dyld: Symbol not found: __ZN2H58PredType12NATIVE_INT64E
944 // Referenced from: /usgs/pkgs/isis3beta2015-12-24/isis/bin/../lib/libisis3.4.12.dylib
945 // Expected in: flat namespace
946 // in /usgs/pkgs/isis3beta2015-12-24/isis/bin/../lib/libisis3.4.12.dylib
947 
953 
954  H5::CompType compoundDataType((size_t)124);
955 
956  size_t offset = 0;
957  compoundDataType.insertMember("Sum", offset, H5::PredType::NATIVE_DOUBLE);
958 
959  // offset += sizeof(m_sum);
960  offset += sizeof(double);
961  compoundDataType.insertMember("SumSquared", offset, H5::PredType::NATIVE_DOUBLE);
962 
963  // offset += sizeof(m_sumsum);
964  offset += sizeof(double);
965  compoundDataType.insertMember("Minimum", offset, H5::PredType::NATIVE_DOUBLE);
966 
967  // offset += sizeof(m_minimum);
968  offset += sizeof(double);
969  compoundDataType.insertMember("Maximum", offset, H5::PredType::NATIVE_DOUBLE);
970 
971  // offset += sizeof(m_maximum);
972  offset += sizeof(double);
973  compoundDataType.insertMember("ValidMinimum", offset, H5::PredType::NATIVE_DOUBLE);
974 
975  // offset += sizeof(m_validMinimum);
976  offset += sizeof(double);
977  compoundDataType.insertMember("ValidMaximum", offset, H5::PredType::NATIVE_DOUBLE);
978 
979  // offset += sizeof(m_validMaximum);
980  offset += sizeof(double);
981  compoundDataType.insertMember("TotalPixels", offset, H5::PredType::NATIVE_INT64);
982 
983  // offset += sizeof(m_totalPixels);
984  offset += sizeof(BigInt);
985  compoundDataType.insertMember("ValidPixels", offset, H5::PredType::NATIVE_INT64);
986 
987  // offset += sizeof(m_validPixels);
988  offset += sizeof(BigInt);
989  compoundDataType.insertMember("NullPixels", offset, H5::PredType::NATIVE_INT64);
990 
991  // offset += sizeof(m_nullPixels);
992  offset += sizeof(BigInt);
993  compoundDataType.insertMember("LRSPixels", offset, H5::PredType::NATIVE_INT64);
994 
995  // offset += sizeof(m_lrsPixels);
996  offset += sizeof(BigInt);
997  compoundDataType.insertMember("LISPixels", offset, H5::PredType::NATIVE_INT64);
998 
999  // offset += sizeof(m_lisPixels);
1000  offset += sizeof(BigInt);
1001  compoundDataType.insertMember("HRSPixels", offset, H5::PredType::NATIVE_INT64);
1002 
1003  // offset += sizeof(m_hrsPixels);
1004  offset += sizeof(BigInt);
1005  compoundDataType.insertMember("HISPixels", offset, H5::PredType::NATIVE_INT64);
1006 
1007  // offset += sizeof(m_hisPixels);
1008  offset += sizeof(BigInt);
1009  compoundDataType.insertMember("UnderRangePixels", offset, H5::PredType::NATIVE_INT64);
1010 
1011  // offset += sizeof(m_underRangePixels);
1012  offset += sizeof(BigInt);
1013  compoundDataType.insertMember("OverRangePixels", offset, H5::PredType::NATIVE_INT64);
1014 
1015  // offset += sizeof(m_overRangePixels);
1016  offset += sizeof(BigInt);
1017  compoundDataType.insertMember("RemovedData", offset, H5::PredType::NATIVE_HBOOL);
1018  // mac osx has problem with "sizeof" commented lines and the native data
1019  // types too... will consider this later when ready to add serialization.
1020 
1021  return compoundDataType;
1022  }
1023 
1024 } // end namespace isis
BigInt LisPixels() const
Returns the total number of low instrument saturation (LIS) pixels encountered.
Definition: Statistics.cpp:493
bool IsLisPixel(const double d)
Returns if the input pixel is low instrument saturation.
Definition: SpecialPixel.h:297
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:589
void RemoveData(const double *data, const unsigned int count)
Remove an array of doubles from the accumulators and counters.
Definition: Statistics.cpp:223
BigInt m_nullPixels
Count of null pixels processed.
Definition: Statistics.h:216
The main project for cnetsuite.
Definition: Project.h:105
QDataStream & write(QDataStream &stream) const
Order saved must match the offsets in the static compoundH5DataType() method.
Definition: Statistics.cpp:865
BigInt NullPixels() const
Returns the total number of NULL pixels encountered.
Definition: Statistics.cpp:482
bool IsLrsPixel(const double d)
Returns if the input pixel is low representation saturation.
Definition: SpecialPixel.h:309
static H5::CompType compoundH5DataType()
H5 compound data type uses the offesets from the QDataStream returned by the write(QDataStream &amp;strea...
Definition: Statistics.cpp:952
double Minimum() const
Returns the absolute minimum double found in all data passed through the AddData method.
Definition: Statistics.cpp:399
double BestMaximum(const double percent=99.5) const
This method returns the better of the absolute maximum or the Chebyshev maximum.
Definition: Statistics.cpp:638
double Rms() const
Computes and returns the rms.
Definition: Statistics.cpp:382
BigInt m_lisPixels
Count of low representation saturation pixels processed.
Definition: Statistics.h:218
BigInt HisPixels() const
Returns the total number of high instrument saturation (HIS) pixels encountered.
Definition: Statistics.cpp:515
void fromPvl(const PvlGroup &inStats)
Unserializes a Statistics object from a pvl group.
Definition: Statistics.cpp:676
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:226
PvlGroup toPvl(QString name="Statistics") const
Serialize statistics as a pvl group.
Definition: Statistics.cpp:704
BigInt toBigInt(const QString &string)
Global function to convert from a string to a &quot;big&quot; integer.
Definition: IString.cpp:130
double toDouble(const QString &string)
Global function to convert from a string to a double.
Definition: IString.cpp:164
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:154
bool IsHisPixel(const double d)
Returns if the input pixel is high instrument saturation.
Definition: SpecialPixel.h:285
double Variance() const
Computes and returns the variance.
Definition: Statistics.cpp:345
bool IsHrsPixel(const double d)
Returns if the input pixel is high representation saturation.
Definition: SpecialPixel.h:273
double m_sum
The sum accumulator, i.e. the sum of added data values.
Definition: Statistics.h:207
double StandardDeviation() const
Computes and returns the standard deviation.
Definition: Statistics.cpp:329
double Sum() const
Returns the sum of all the data.
Definition: Statistics.cpp:358
double ZScore(const double value) const
This method returns the better of the z-score of the given value.
Definition: Statistics.cpp:658
BigInt m_hrsPixels
Count of high instrument saturation pixels processed.
Definition: Statistics.h:219
This class is used to accumulate statistics on double arrays.
Definition: Statistics.h:109
BigInt HrsPixels() const
Returns the total number of high representation saturation (HRS) pixels encountered.
Definition: Statistics.cpp:526
BigInt TotalPixels() const
Returns the total number of pixels processed (valid and invalid).
Definition: Statistics.cpp:437
BigInt m_validPixels
Count of valid pixels (non-special) processed.
Definition: Statistics.h:215
BigInt ValidPixels() const
Returns the total number of valid pixels processed.
Definition: Statistics.cpp:450
Contains multiple PvlContainers.
Definition: PvlGroup.h:57
double Average() const
Computes and returns the average.
Definition: Statistics.cpp:317
void Reset()
Reset all accumulators and counters to zero.
Definition: Statistics.cpp:130
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:38
BigInt LrsPixels() const
Returns the total number of low representation saturation (LRS) pixels encountered.
Definition: Statistics.cpp:504
std::istream & operator>>(std::istream &is, CSVReader &csv)
Input read operator for input stream sources.
Definition: CSVReader.cpp:463
A single keyword-value pair.
Definition: PvlKeyword.h:98
double m_sumsum
The sum-squared accumulator, i.e.
Definition: Statistics.h:208
double m_minimum
Minimum double value encountered.
Definition: Statistics.h:210
double Maximum() const
Returns the absolute maximum double found in all data passed through the AddData method.
Definition: Statistics.cpp:420
BigInt OutOfRangePixels() const
Returns the total number of pixels outside of the valid range encountered.
Definition: Statistics.cpp:537
Statistics(QObject *parent=0)
Constructs an IsisStats object with accumulators and counters set to zero.
Definition: Statistics.cpp:45
bool m_removedData
Indicates the RemoveData method was called which implies m_minimum and m_maximum are invalid...
Definition: Statistics.h:223
BigInt UnderRangePixels() const
Returns the total number of pixels under the valid range encountered.
Definition: Statistics.cpp:472
double SumSquare() const
Returns the sum of all the squared data.
Definition: Statistics.cpp:368
BigInt m_overRangePixels
Count of pixels greater than the valid range.
Definition: Statistics.h:222
bool toBool(const QString &string)
Global function to convert from a string to a boolean.
Definition: IString.cpp:53
double m_maximum
Maximum double value encountered.
Definition: Statistics.h:211
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:562
Isis exception class.
Definition: IException.h:99
BigInt m_totalPixels
Count of total pixels processed.
Definition: Statistics.h:214
bool IsNullPixel(const double d)
Returns if the input pixel is null.
Definition: SpecialPixel.h:237
double m_validMaximum
Maximum valid pixel value.
Definition: Statistics.h:213
QDebug operator<<(QDebug debug, const Hillshade &hillshade)
Print this class out to a QDebug object.
Definition: Hillshade.cpp:308
void AddData(const double *data, const unsigned int count)
Add an array of doubles to the accumulators and counters.
Definition: Statistics.cpp:158
double BestMinimum(const double percent=99.5) const
This method returns the better of the absolute minimum or the Chebyshev minimum.
Definition: Statistics.cpp:615
BigInt m_hisPixels
Count of high instrument representation pixels processed.
Definition: Statistics.h:220
double m_validMinimum
Minimum valid pixel value.
Definition: Statistics.h:212
BigInt m_lrsPixels
Count of low instrument saturation pixels processed.
Definition: Statistics.h:217
his enables stack-based XML parsing of XML files.
virtual ~Statistics()
Destroys the IsisStats object.
Definition: Statistics.cpp:94
BigInt m_underRangePixels
Count of pixels less than the valid range.
Definition: Statistics.h:221
BigInt OverRangePixels() const
Returns the total number of pixels over the valid range encountered.
Definition: Statistics.cpp:461

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:29:53