Loading isis/src/base/objs/StatCumProbDistDynCalc/StatCumProbDistDynCalc.h +7 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,13 @@ namespace Isis { ~StatCumProbDistDynCalc(); //empty destructor void addObs(double obs); void set(int numberCells, int numberQuantiles, QList<double> quantiles, QList<double> idealNum, QList<int> n, QVector<double> quantileValues, int numberObservations); double cumProb(double value); //given a value return the cumulative probility double value(double cumProb); //given a cumulative probibility return a value Loading isis/src/base/objs/Statistics/Statistics.cpp +165 −83 Original line number Diff line number Diff line Loading @@ -35,26 +35,61 @@ namespace Isis { Reset(); } //! Destroys the IsisStats object. Statistics::~Statistics() { } //! Reset all accumulators and counters to zero. void Statistics::Reset() { p_sum = 0.0; p_sumsum = 0.0; p_minimum = DBL_MAX; p_maximum = -DBL_MAX; p_totalPixels = 0; p_validPixels = 00; p_nullPixels = 0; p_lisPixels = 0; p_lrsPixels = 0; p_hrsPixels = 0; p_hisPixels = 0; p_overRangePixels = 0; p_underRangePixels = 0; p_removedData = false; m_sum = 0.0; m_sumsum = 0.0; m_minimum = DBL_MAX; m_maximum = -DBL_MAX; m_totalPixels = 0; m_validPixels = 00; m_nullPixels = 0; m_lisPixels = 0; m_lrsPixels = 0; m_hrsPixels = 0; m_hisPixels = 0; m_overRangePixels = 0; m_underRangePixels = 0; m_removedData = false; } //! Destroys the IsisStats object. Statistics::~Statistics() {}; /** * This method sets the Statistics class members with known values instead of * using the AddData() and RemoveData() methods to do so. */ void Statistics::set(int validPixels, int nullPixels, int lrsPixels, int lisPixels, int hrsPixels, int hisPixels, int underRangePixels, int overRangePixels, double sum, double minimum, double maximum, double validMinimum, double validMaximum, bool removedData) { m_sum = sum; m_sumsum = sum*sum; m_minimum = minimum; m_maximum = maximum; m_totalPixels = validPixels + nullPixels + lrsPixels + lisPixels + hrsPixels + hisPixels + underRangePixels + overRangePixels; m_validPixels = validPixels; m_nullPixels = nullPixels; m_lrsPixels = lrsPixels; m_lisPixels = lisPixels; m_hrsPixels = hrsPixels; m_hisPixels = hisPixels; m_underRangePixels = underRangePixels; m_overRangePixels = overRangePixels; m_removedData = removedData; } /** * Add an array of doubles to the accumulators and counters. Loading @@ -75,6 +110,50 @@ namespace Isis { } /** * Add a double to the accumulators and counters. This method * can be invoked multiple times (for example: once for each * pixel in a cube) before obtaining statistics. * * @param data The data to be added to the data set used for statistical * calculations. * */ void Statistics::AddData(const double data) { m_totalPixels++; if(Isis::IsValidPixel(data) && InRange(data)) { m_sum += data; m_sumsum += data * data; if(data < m_minimum) m_minimum = data; if(data > m_maximum) m_maximum = data; m_validPixels++; } else if(Isis::IsNullPixel(data)) { m_nullPixels++; } else if(Isis::IsHisPixel(data)) { m_hisPixels++; } else if(Isis::IsHrsPixel(data)) { m_hrsPixels++; } else if(Isis::IsLisPixel(data)) { m_lisPixels++; } else if(Isis::IsLrsPixel(data)) { m_lrsPixels++; } else if(AboveRange(data)) { m_overRangePixels++; } else { m_underRangePixels++; } } /** * Remove an array of doubles from the accumulators and counters. * Note that is invalidates the absolute minimum and maximum. They Loading @@ -89,40 +168,40 @@ namespace Isis { * doesn't exist. */ void Statistics::RemoveData(const double *data, const unsigned int count) { p_removedData = true; m_removedData = true; for(unsigned int i = 0; i < count; i++) { p_totalPixels--; m_totalPixels--; if(IsValidPixel(data[i]) && InRange(data[i])) { p_sum -= data[i]; p_sumsum -= data[i] * data[i]; p_validPixels--; m_sum -= data[i]; m_sumsum -= data[i] * data[i]; m_validPixels--; } else if(Isis::IsNullPixel(data[i])) { p_nullPixels--; m_nullPixels--; } else if(Isis::IsHisPixel(data[i])) { p_hisPixels--; m_hisPixels--; } else if(Isis::IsHrsPixel(data[i])) { p_hrsPixels--; m_hrsPixels--; } else if(Isis::IsLisPixel(data[i])) { p_lisPixels--; m_lisPixels--; } else if(Isis::IsLrsPixel(data[i])) { p_lrsPixels--; m_lrsPixels--; } else if(AboveRange(data[i])) { p_overRangePixels--; m_overRangePixels--; } else { p_underRangePixels--; m_underRangePixels--; } } if(p_totalPixels < 0) { if(m_totalPixels < 0) { QString msg = "You are removing non-existant data in [Statistics::RemoveData]"; throw IException(IException::Programmer, msg, _FILEINFO_); } Loading @@ -133,10 +212,10 @@ namespace Isis { } void Statistics::SetValidRange(const double minimum, const double maximum) { p_validMinimum = minimum; p_validMaximum = maximum; m_validMinimum = minimum; m_validMaximum = maximum; if(p_validMaximum < p_validMinimum) { if(m_validMaximum < m_validMinimum) { // get the min and max DN values in the chosen range QString msg = "Invalid Range: Minimum [" + toString(minimum) + "] must be less than the Maximum [" + toString(maximum) + "]."; Loading @@ -150,8 +229,8 @@ namespace Isis { * @return The Average */ double Statistics::Average() const { if(p_validPixels < 1) return Isis::NULL8; return p_sum / p_validPixels; if(m_validPixels < 1) return Isis::NULL8; return m_sum / m_validPixels; } /** Loading @@ -161,7 +240,7 @@ namespace Isis { * @return The standard deviation */ double Statistics::StandardDeviation() const { if(p_validPixels <= 1) return Isis::NULL8; if(m_validPixels <= 1) return Isis::NULL8; return sqrt(Variance()); } Loading @@ -176,10 +255,10 @@ namespace Isis { * using n*(n-1) instead of n*n. */ double Statistics::Variance() const { if(p_validPixels <= 1) return Isis::NULL8; double temp = p_validPixels * p_sumsum - p_sum * p_sum; if(m_validPixels <= 1) return Isis::NULL8; double temp = m_validPixels * m_sumsum - m_sum * m_sum; if(temp < 0.0) temp = 0.0; // This should happen unless roundoff occurs return temp / ((p_validPixels - 1.0) * p_validPixels); return temp / ((m_validPixels - 1.0) * m_validPixels); } /** Loading @@ -192,8 +271,8 @@ namespace Isis { * @history 2011-06-13 Ken Edmundson. */ double Statistics::Rms() const { if(p_validPixels < 1) return Isis::NULL8; double temp = p_sumsum / p_validPixels; if(m_validPixels < 1) return Isis::NULL8; double temp = m_sumsum / m_validPixels; if(temp < 0.0) temp = 0.0; return sqrt(temp); } Loading @@ -208,13 +287,13 @@ namespace Isis { * invalid. */ double Statistics::Minimum() const { if(p_removedData) { if(m_removedData) { QString msg = "Minimum is invalid since you removed data"; throw IException(IException::Programmer, msg, _FILEINFO_); } if(p_validPixels < 1) return Isis::NULL8; return p_minimum; if(m_validPixels < 1) return Isis::NULL8; return m_minimum; } /** Loading @@ -228,13 +307,13 @@ namespace Isis { * invalid. */ double Statistics::Maximum() const { if(p_removedData) { if(m_removedData) { QString msg = "Maximum is invalid since you removed data"; throw IException(IException::Programmer, msg, _FILEINFO_); } if(p_validPixels < 1) return Isis::NULL8; return p_maximum; if(m_validPixels < 1) return Isis::NULL8; return m_maximum; } /** Loading @@ -244,7 +323,7 @@ namespace Isis { * @return The number of pixels (data) processed */ BigInt Statistics::TotalPixels() const { return p_totalPixels; return m_totalPixels; } /** Loading @@ -256,7 +335,7 @@ namespace Isis { * @return The number of valid pixels (data) processed */ BigInt Statistics::ValidPixels() const { return p_validPixels; return m_validPixels; } /** Loading @@ -266,7 +345,7 @@ namespace Isis { * @return The number of pixels less than the ValidMaximum() processed */ BigInt Statistics::OverRangePixels() const { return p_overRangePixels; return m_overRangePixels; } /** Loading @@ -276,7 +355,7 @@ namespace Isis { * @return The number of pixels less than the ValidMinimum() processed */ BigInt Statistics::UnderRangePixels() const { return p_underRangePixels; return m_underRangePixels; } /** Loading @@ -285,7 +364,7 @@ namespace Isis { * @return The number of NULL pixels (data) processed */ BigInt Statistics::NullPixels() const { return p_nullPixels; return m_nullPixels; } /** Loading @@ -295,7 +374,7 @@ namespace Isis { * @return The number of LIS pixels (data) processed */ BigInt Statistics::LisPixels() const { return p_lisPixels; return m_lisPixels; } /** Loading @@ -305,7 +384,7 @@ namespace Isis { * @return The number of LRS pixels (data) processed */ BigInt Statistics::LrsPixels() const { return p_lrsPixels; return m_lrsPixels; } /** Loading @@ -315,7 +394,7 @@ namespace Isis { * @return The number of HIS pixels (data) processed */ BigInt Statistics::HisPixels() const { return p_hisPixels; return m_hisPixels; } /** Loading @@ -325,7 +404,7 @@ namespace Isis { * @return The number of HRS pixels (data) processed */ BigInt Statistics::HrsPixels() const { return p_hrsPixels; return m_hrsPixels; } /** Loading @@ -335,9 +414,12 @@ namespace Isis { * @return The number of Out of Range pixels (data) processed */ BigInt Statistics::OutOfRangePixels() const { return p_overRangePixels + p_underRangePixels; return m_overRangePixels + m_underRangePixels; } bool Statistics::RemovedData() const { return m_removedData; } /** * This method returns a minimum such that X percent * of the data will fall with K standard deviations Loading @@ -359,7 +441,7 @@ namespace Isis { throw IException(IException::Programmer, msg, _FILEINFO_); } if(p_validPixels < 1) return Isis::NULL8; if(m_validPixels < 1) return Isis::NULL8; double k = sqrt(1.0 / (1.0 - percent / 100.0)); return Average() - k * StandardDeviation(); } Loading @@ -385,7 +467,7 @@ namespace Isis { throw IException(IException::Programmer, msg, _FILEINFO_); } if(p_validPixels < 1) return Isis::NULL8; if(m_validPixels < 1) return Isis::NULL8; double k = sqrt(1.0 / (1.0 - percent / 100.0)); return Average() + k * StandardDeviation(); } Loading @@ -405,7 +487,7 @@ namespace Isis { * Statistics::ChebyshevMinimum */ double Statistics::BestMinimum(const double percent) const { if(p_validPixels < 1) return Isis::NULL8; if(m_validPixels < 1) return Isis::NULL8; double min = ChebyshevMinimum(percent); if(Minimum() > min) min = Minimum(); return min; Loading @@ -427,7 +509,7 @@ namespace Isis { * Statistics::ChebyshevMaximum */ double Statistics::BestMaximum(const double percent) const { if(p_validPixels < 1) return Isis::NULL8; if(m_validPixels < 1) return Isis::NULL8; double max = ChebyshevMaximum(percent); if(Maximum() < max) max = Maximum(); return max; Loading Loading @@ -460,22 +542,22 @@ namespace Isis { QDataStream &Statistics::write(QDataStream &stream) const { stream << p_sum << p_sumsum << p_minimum << p_maximum << p_validMinimum << p_validMaximum << (qint32)p_totalPixels << (qint32)p_validPixels << (qint32)p_nullPixels << (qint32)p_lrsPixels << (qint32)p_lisPixels << (qint32)p_hrsPixels << (qint32)p_hisPixels << (qint32)p_underRangePixels << (qint32)p_overRangePixels << p_removedData; stream << m_sum << m_sumsum << m_minimum << m_maximum << m_validMinimum << m_validMaximum << (qint32)m_totalPixels << (qint32)m_validPixels << (qint32)m_nullPixels << (qint32)m_lrsPixels << (qint32)m_lisPixels << (qint32)m_hrsPixels << (qint32)m_hisPixels << (qint32)m_underRangePixels << (qint32)m_overRangePixels << m_removedData; return stream; } Loading @@ -486,12 +568,12 @@ namespace Isis { qint32 totalPixels, validPixels, nullPixels, lrsPixels, lisPixels, hrsPixels, hisPixels, underRangePixels, overRangePixels; stream >> p_sum >> p_sumsum >> p_minimum >> p_maximum >> p_validMinimum >> p_validMaximum stream >> m_sum >> m_sumsum >> m_minimum >> m_maximum >> m_validMinimum >> m_validMaximum >> totalPixels >> validPixels >> nullPixels Loading @@ -501,7 +583,7 @@ namespace Isis { >> hisPixels >> underRangePixels >> overRangePixels >> p_removedData; >> m_removedData; return stream; } Loading isis/src/base/objs/Statistics/Statistics.h +33 −65 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ namespace Isis { * * @ingroup Statistics * * @author 2002-05-06 Jeff Anderson * @author 2002-05-06 Jeff Andersonzz * * @internal * @history 2002-05-08 Jeff Anderson - Added Chebyshev and Best minimum/maximum methods. Loading @@ -79,66 +79,33 @@ namespace Isis { ~Statistics(); void Reset(); void set(int validPixels, int nullPixels, int lrsPixels, int lisPixels, int hrsPixels, int hisPixels, int underRangePixels, int overRangePixels, double sum, double minimum, double maximum, double validMinimum, double validMaximum, bool removedData); void AddData(const double *data, const unsigned int count); /** * Add a double to the accumulators and counters. This method * can be invoked multiple times (for example: once for each * pixel in a cube) before obtaining statistics. * * @param data The data to be added to the data set used for statistical * calculations. * */ inline void AddData(const double data) { p_totalPixels++; if(Isis::IsValidPixel(data) && InRange(data)) { p_sum += data; p_sumsum += data * data; if(data < p_minimum) p_minimum = data; if(data > p_maximum) p_maximum = data; p_validPixels++; } else if(Isis::IsNullPixel(data)) { p_nullPixels++; } else if(Isis::IsHisPixel(data)) { p_hisPixels++; } else if(Isis::IsHrsPixel(data)) { p_hrsPixels++; } else if(Isis::IsLisPixel(data)) { p_lisPixels++; } else if(Isis::IsLrsPixel(data)) { p_lrsPixels++; } else if(AboveRange(data)) { p_overRangePixels++; } else { p_underRangePixels++; } } void AddData(const double data); void RemoveData(const double *data, const unsigned int count); void RemoveData(const double data); void SetValidRange(const double minimum = Isis::ValidMinimum, const double maximum = Isis::ValidMaximum); double ValidMinimum() const { return p_validMinimum; return m_validMinimum; } double ValidMaximum() const { return p_validMaximum; return m_validMaximum; } bool InRange(const double value) { return (value >= p_validMinimum && value <= p_validMaximum); return (value >= m_validMinimum && value <= m_validMaximum); } bool AboveRange(const double value) { return (value > p_validMaximum); return (value > m_validMaximum); } bool BelowRange(const double value) { return (value < p_validMinimum); return (value < m_validMinimum); } double Average() const; Loading @@ -164,6 +131,7 @@ namespace Isis { BigInt HisPixels() const; BigInt HrsPixels() const; BigInt OutOfRangePixels() const; bool RemovedData() const; /** Loading @@ -172,7 +140,7 @@ namespace Isis { * @return The sum of the data */ double Sum() const { return p_sum; return m_sum; }; /** Loading @@ -181,30 +149,30 @@ namespace Isis { * @return The sum of the squared data */ double SumSquare() const { return p_sumsum; return m_sumsum; }; QDataStream &write(QDataStream &stream) const; QDataStream &read(QDataStream &stream); private: double p_sum; //!< Sum accumulator. double p_sumsum; //!< Sum-squared accumulator. double p_minimum; //!< Minimum double value encountered. double p_maximum; //!< Maximum double value encountered. double p_validMinimum; //!< Minimum valid pixel value double p_validMaximum; //!< Maximum valid pixel value BigInt p_totalPixels; //!< Count of total pixels processed. BigInt p_validPixels; //!< Count of valid pixels (non-special) processed. BigInt p_nullPixels; //!< Count of null pixels processed. BigInt p_lrsPixels; //!< Count of low instrument saturation pixels processed. BigInt p_lisPixels; //!< Count of low representation saturation pixels processed. BigInt p_hrsPixels; //!< Count of high instrument saturation pixels processed. BigInt p_hisPixels; //!< Count of high instrument representation pixels processed. BigInt p_underRangePixels; //!< Count of pixels less than the valid range BigInt p_overRangePixels; //!< Count of pixels greater than the valid range bool p_removedData; /**< Indicates the RemoveData method was called which implies p_minimum and p_maximum are invalid. */ double m_sum; //!< Sum accumulator. double m_sumsum; //!< Sum-squared accumulator. double m_minimum; //!< Minimum double value encountered. double m_maximum; //!< Maximum double value encountered. double m_validMinimum; //!< Minimum valid pixel value double m_validMaximum; //!< Maximum valid pixel value BigInt m_totalPixels; //!< Count of total pixels processed. BigInt m_validPixels; //!< Count of valid pixels (non-special) processed. BigInt m_nullPixels; //!< Count of null pixels processed. BigInt m_lrsPixels; //!< Count of low instrument saturation pixels processed. BigInt m_lisPixels; //!< Count of low representation saturation pixels processed. BigInt m_hrsPixels; //!< Count of high instrument saturation pixels processed. BigInt m_hisPixels; //!< Count of high instrument representation pixels processed. BigInt m_underRangePixels; //!< Count of pixels less than the valid range BigInt m_overRangePixels; //!< Count of pixels greater than the valid range bool m_removedData; /**< Indicates the RemoveData method was called which implies m_minimum and m_maximum are invalid. */ }; // operators to read/write Statistics to/from binary data Loading isis/src/control/objs/BundleResults/BundleResults.cpp +102 −213 File changed.Preview size limit exceeded, changes collapsed. Show changes isis/src/control/objs/BundleResults/BundleResults.h +18 −17 Original line number Diff line number Diff line Loading @@ -23,14 +23,15 @@ * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on * http://www.usgs.gov/privacy.html. */ #include <QObject> #include <QString> #include "XmlStackedHandler.h" class QDataStream; class QXmlStreamWriter; class QUuid; class QXmlStreamWriter; namespace Isis { class BundleSettings; Loading Loading @@ -63,20 +64,23 @@ namespace Isis { BundleResults(const BundleResults &other); ~BundleResults(); BundleResults &operator=(const BundleResults &other); void setOutputStatistics(BundleStatistics statisticsResults); void setRunTime(QString runTime); QString id() const; QString controlNetworkFileName() const; BundleSettings *bundleSettings(); // TODO: change return value to const reference or copy... unsafe to return pointers to member data??? BundleStatistics *bundleStatistics(); // TODO: change return value to const reference or copy... unsafe to return pointers to member data??? // ??? const BundleSettings *bundleSettings() const; // ??? const BundleStatistics *bundleStatistics() const; QString runTime() const; PvlObject pvlObject(QString resultsName = "BundleResults", QString settingsName = "InputSettings", QString statisticsName = "StatisticsResults"); QDataStream &write(QDataStream &stream) const; QDataStream &read(QDataStream &stream); QString id() const; void setRunTime(QString runTime); QString runTime() const; QString controlNetworkFileName(); BundleSettings *bundleSettings(); BundleStatistics *bundleStatistics(); void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const; Loading @@ -90,12 +94,10 @@ namespace Isis { class XmlHandler : public XmlStackedHandler { public: XmlHandler(BundleResults *bundleResults, Project *project); ~XmlHandler(); virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts); virtual bool characters(const QString &ch); virtual bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName); private: Q_DISABLE_COPY(XmlHandler); Loading @@ -107,18 +109,17 @@ namespace Isis { private: BundleResults(); FileName *m_controlNetworkFileName; BundleSettings *m_settings; BundleStatistics *m_statisticsResults; QList<ImageList *> *m_images; /** * A unique ID for this BundleResults object (useful for others to reference this object * when saving to disk). */ QUuid *m_id; QString m_runTime; FileName *m_controlNetworkFileName; BundleSettings *m_settings; BundleStatistics *m_statisticsResults; QList<ImageList *> *m_images; }; // operators to read/write BundleResults to/from binary data QDataStream &operator<<(QDataStream &stream, const BundleResults &bundleResults); Loading Loading
isis/src/base/objs/StatCumProbDistDynCalc/StatCumProbDistDynCalc.h +7 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,13 @@ namespace Isis { ~StatCumProbDistDynCalc(); //empty destructor void addObs(double obs); void set(int numberCells, int numberQuantiles, QList<double> quantiles, QList<double> idealNum, QList<int> n, QVector<double> quantileValues, int numberObservations); double cumProb(double value); //given a value return the cumulative probility double value(double cumProb); //given a cumulative probibility return a value Loading
isis/src/base/objs/Statistics/Statistics.cpp +165 −83 Original line number Diff line number Diff line Loading @@ -35,26 +35,61 @@ namespace Isis { Reset(); } //! Destroys the IsisStats object. Statistics::~Statistics() { } //! Reset all accumulators and counters to zero. void Statistics::Reset() { p_sum = 0.0; p_sumsum = 0.0; p_minimum = DBL_MAX; p_maximum = -DBL_MAX; p_totalPixels = 0; p_validPixels = 00; p_nullPixels = 0; p_lisPixels = 0; p_lrsPixels = 0; p_hrsPixels = 0; p_hisPixels = 0; p_overRangePixels = 0; p_underRangePixels = 0; p_removedData = false; m_sum = 0.0; m_sumsum = 0.0; m_minimum = DBL_MAX; m_maximum = -DBL_MAX; m_totalPixels = 0; m_validPixels = 00; m_nullPixels = 0; m_lisPixels = 0; m_lrsPixels = 0; m_hrsPixels = 0; m_hisPixels = 0; m_overRangePixels = 0; m_underRangePixels = 0; m_removedData = false; } //! Destroys the IsisStats object. Statistics::~Statistics() {}; /** * This method sets the Statistics class members with known values instead of * using the AddData() and RemoveData() methods to do so. */ void Statistics::set(int validPixels, int nullPixels, int lrsPixels, int lisPixels, int hrsPixels, int hisPixels, int underRangePixels, int overRangePixels, double sum, double minimum, double maximum, double validMinimum, double validMaximum, bool removedData) { m_sum = sum; m_sumsum = sum*sum; m_minimum = minimum; m_maximum = maximum; m_totalPixels = validPixels + nullPixels + lrsPixels + lisPixels + hrsPixels + hisPixels + underRangePixels + overRangePixels; m_validPixels = validPixels; m_nullPixels = nullPixels; m_lrsPixels = lrsPixels; m_lisPixels = lisPixels; m_hrsPixels = hrsPixels; m_hisPixels = hisPixels; m_underRangePixels = underRangePixels; m_overRangePixels = overRangePixels; m_removedData = removedData; } /** * Add an array of doubles to the accumulators and counters. Loading @@ -75,6 +110,50 @@ namespace Isis { } /** * Add a double to the accumulators and counters. This method * can be invoked multiple times (for example: once for each * pixel in a cube) before obtaining statistics. * * @param data The data to be added to the data set used for statistical * calculations. * */ void Statistics::AddData(const double data) { m_totalPixels++; if(Isis::IsValidPixel(data) && InRange(data)) { m_sum += data; m_sumsum += data * data; if(data < m_minimum) m_minimum = data; if(data > m_maximum) m_maximum = data; m_validPixels++; } else if(Isis::IsNullPixel(data)) { m_nullPixels++; } else if(Isis::IsHisPixel(data)) { m_hisPixels++; } else if(Isis::IsHrsPixel(data)) { m_hrsPixels++; } else if(Isis::IsLisPixel(data)) { m_lisPixels++; } else if(Isis::IsLrsPixel(data)) { m_lrsPixels++; } else if(AboveRange(data)) { m_overRangePixels++; } else { m_underRangePixels++; } } /** * Remove an array of doubles from the accumulators and counters. * Note that is invalidates the absolute minimum and maximum. They Loading @@ -89,40 +168,40 @@ namespace Isis { * doesn't exist. */ void Statistics::RemoveData(const double *data, const unsigned int count) { p_removedData = true; m_removedData = true; for(unsigned int i = 0; i < count; i++) { p_totalPixels--; m_totalPixels--; if(IsValidPixel(data[i]) && InRange(data[i])) { p_sum -= data[i]; p_sumsum -= data[i] * data[i]; p_validPixels--; m_sum -= data[i]; m_sumsum -= data[i] * data[i]; m_validPixels--; } else if(Isis::IsNullPixel(data[i])) { p_nullPixels--; m_nullPixels--; } else if(Isis::IsHisPixel(data[i])) { p_hisPixels--; m_hisPixels--; } else if(Isis::IsHrsPixel(data[i])) { p_hrsPixels--; m_hrsPixels--; } else if(Isis::IsLisPixel(data[i])) { p_lisPixels--; m_lisPixels--; } else if(Isis::IsLrsPixel(data[i])) { p_lrsPixels--; m_lrsPixels--; } else if(AboveRange(data[i])) { p_overRangePixels--; m_overRangePixels--; } else { p_underRangePixels--; m_underRangePixels--; } } if(p_totalPixels < 0) { if(m_totalPixels < 0) { QString msg = "You are removing non-existant data in [Statistics::RemoveData]"; throw IException(IException::Programmer, msg, _FILEINFO_); } Loading @@ -133,10 +212,10 @@ namespace Isis { } void Statistics::SetValidRange(const double minimum, const double maximum) { p_validMinimum = minimum; p_validMaximum = maximum; m_validMinimum = minimum; m_validMaximum = maximum; if(p_validMaximum < p_validMinimum) { if(m_validMaximum < m_validMinimum) { // get the min and max DN values in the chosen range QString msg = "Invalid Range: Minimum [" + toString(minimum) + "] must be less than the Maximum [" + toString(maximum) + "]."; Loading @@ -150,8 +229,8 @@ namespace Isis { * @return The Average */ double Statistics::Average() const { if(p_validPixels < 1) return Isis::NULL8; return p_sum / p_validPixels; if(m_validPixels < 1) return Isis::NULL8; return m_sum / m_validPixels; } /** Loading @@ -161,7 +240,7 @@ namespace Isis { * @return The standard deviation */ double Statistics::StandardDeviation() const { if(p_validPixels <= 1) return Isis::NULL8; if(m_validPixels <= 1) return Isis::NULL8; return sqrt(Variance()); } Loading @@ -176,10 +255,10 @@ namespace Isis { * using n*(n-1) instead of n*n. */ double Statistics::Variance() const { if(p_validPixels <= 1) return Isis::NULL8; double temp = p_validPixels * p_sumsum - p_sum * p_sum; if(m_validPixels <= 1) return Isis::NULL8; double temp = m_validPixels * m_sumsum - m_sum * m_sum; if(temp < 0.0) temp = 0.0; // This should happen unless roundoff occurs return temp / ((p_validPixels - 1.0) * p_validPixels); return temp / ((m_validPixels - 1.0) * m_validPixels); } /** Loading @@ -192,8 +271,8 @@ namespace Isis { * @history 2011-06-13 Ken Edmundson. */ double Statistics::Rms() const { if(p_validPixels < 1) return Isis::NULL8; double temp = p_sumsum / p_validPixels; if(m_validPixels < 1) return Isis::NULL8; double temp = m_sumsum / m_validPixels; if(temp < 0.0) temp = 0.0; return sqrt(temp); } Loading @@ -208,13 +287,13 @@ namespace Isis { * invalid. */ double Statistics::Minimum() const { if(p_removedData) { if(m_removedData) { QString msg = "Minimum is invalid since you removed data"; throw IException(IException::Programmer, msg, _FILEINFO_); } if(p_validPixels < 1) return Isis::NULL8; return p_minimum; if(m_validPixels < 1) return Isis::NULL8; return m_minimum; } /** Loading @@ -228,13 +307,13 @@ namespace Isis { * invalid. */ double Statistics::Maximum() const { if(p_removedData) { if(m_removedData) { QString msg = "Maximum is invalid since you removed data"; throw IException(IException::Programmer, msg, _FILEINFO_); } if(p_validPixels < 1) return Isis::NULL8; return p_maximum; if(m_validPixels < 1) return Isis::NULL8; return m_maximum; } /** Loading @@ -244,7 +323,7 @@ namespace Isis { * @return The number of pixels (data) processed */ BigInt Statistics::TotalPixels() const { return p_totalPixels; return m_totalPixels; } /** Loading @@ -256,7 +335,7 @@ namespace Isis { * @return The number of valid pixels (data) processed */ BigInt Statistics::ValidPixels() const { return p_validPixels; return m_validPixels; } /** Loading @@ -266,7 +345,7 @@ namespace Isis { * @return The number of pixels less than the ValidMaximum() processed */ BigInt Statistics::OverRangePixels() const { return p_overRangePixels; return m_overRangePixels; } /** Loading @@ -276,7 +355,7 @@ namespace Isis { * @return The number of pixels less than the ValidMinimum() processed */ BigInt Statistics::UnderRangePixels() const { return p_underRangePixels; return m_underRangePixels; } /** Loading @@ -285,7 +364,7 @@ namespace Isis { * @return The number of NULL pixels (data) processed */ BigInt Statistics::NullPixels() const { return p_nullPixels; return m_nullPixels; } /** Loading @@ -295,7 +374,7 @@ namespace Isis { * @return The number of LIS pixels (data) processed */ BigInt Statistics::LisPixels() const { return p_lisPixels; return m_lisPixels; } /** Loading @@ -305,7 +384,7 @@ namespace Isis { * @return The number of LRS pixels (data) processed */ BigInt Statistics::LrsPixels() const { return p_lrsPixels; return m_lrsPixels; } /** Loading @@ -315,7 +394,7 @@ namespace Isis { * @return The number of HIS pixels (data) processed */ BigInt Statistics::HisPixels() const { return p_hisPixels; return m_hisPixels; } /** Loading @@ -325,7 +404,7 @@ namespace Isis { * @return The number of HRS pixels (data) processed */ BigInt Statistics::HrsPixels() const { return p_hrsPixels; return m_hrsPixels; } /** Loading @@ -335,9 +414,12 @@ namespace Isis { * @return The number of Out of Range pixels (data) processed */ BigInt Statistics::OutOfRangePixels() const { return p_overRangePixels + p_underRangePixels; return m_overRangePixels + m_underRangePixels; } bool Statistics::RemovedData() const { return m_removedData; } /** * This method returns a minimum such that X percent * of the data will fall with K standard deviations Loading @@ -359,7 +441,7 @@ namespace Isis { throw IException(IException::Programmer, msg, _FILEINFO_); } if(p_validPixels < 1) return Isis::NULL8; if(m_validPixels < 1) return Isis::NULL8; double k = sqrt(1.0 / (1.0 - percent / 100.0)); return Average() - k * StandardDeviation(); } Loading @@ -385,7 +467,7 @@ namespace Isis { throw IException(IException::Programmer, msg, _FILEINFO_); } if(p_validPixels < 1) return Isis::NULL8; if(m_validPixels < 1) return Isis::NULL8; double k = sqrt(1.0 / (1.0 - percent / 100.0)); return Average() + k * StandardDeviation(); } Loading @@ -405,7 +487,7 @@ namespace Isis { * Statistics::ChebyshevMinimum */ double Statistics::BestMinimum(const double percent) const { if(p_validPixels < 1) return Isis::NULL8; if(m_validPixels < 1) return Isis::NULL8; double min = ChebyshevMinimum(percent); if(Minimum() > min) min = Minimum(); return min; Loading @@ -427,7 +509,7 @@ namespace Isis { * Statistics::ChebyshevMaximum */ double Statistics::BestMaximum(const double percent) const { if(p_validPixels < 1) return Isis::NULL8; if(m_validPixels < 1) return Isis::NULL8; double max = ChebyshevMaximum(percent); if(Maximum() < max) max = Maximum(); return max; Loading Loading @@ -460,22 +542,22 @@ namespace Isis { QDataStream &Statistics::write(QDataStream &stream) const { stream << p_sum << p_sumsum << p_minimum << p_maximum << p_validMinimum << p_validMaximum << (qint32)p_totalPixels << (qint32)p_validPixels << (qint32)p_nullPixels << (qint32)p_lrsPixels << (qint32)p_lisPixels << (qint32)p_hrsPixels << (qint32)p_hisPixels << (qint32)p_underRangePixels << (qint32)p_overRangePixels << p_removedData; stream << m_sum << m_sumsum << m_minimum << m_maximum << m_validMinimum << m_validMaximum << (qint32)m_totalPixels << (qint32)m_validPixels << (qint32)m_nullPixels << (qint32)m_lrsPixels << (qint32)m_lisPixels << (qint32)m_hrsPixels << (qint32)m_hisPixels << (qint32)m_underRangePixels << (qint32)m_overRangePixels << m_removedData; return stream; } Loading @@ -486,12 +568,12 @@ namespace Isis { qint32 totalPixels, validPixels, nullPixels, lrsPixels, lisPixels, hrsPixels, hisPixels, underRangePixels, overRangePixels; stream >> p_sum >> p_sumsum >> p_minimum >> p_maximum >> p_validMinimum >> p_validMaximum stream >> m_sum >> m_sumsum >> m_minimum >> m_maximum >> m_validMinimum >> m_validMaximum >> totalPixels >> validPixels >> nullPixels Loading @@ -501,7 +583,7 @@ namespace Isis { >> hisPixels >> underRangePixels >> overRangePixels >> p_removedData; >> m_removedData; return stream; } Loading
isis/src/base/objs/Statistics/Statistics.h +33 −65 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ namespace Isis { * * @ingroup Statistics * * @author 2002-05-06 Jeff Anderson * @author 2002-05-06 Jeff Andersonzz * * @internal * @history 2002-05-08 Jeff Anderson - Added Chebyshev and Best minimum/maximum methods. Loading @@ -79,66 +79,33 @@ namespace Isis { ~Statistics(); void Reset(); void set(int validPixels, int nullPixels, int lrsPixels, int lisPixels, int hrsPixels, int hisPixels, int underRangePixels, int overRangePixels, double sum, double minimum, double maximum, double validMinimum, double validMaximum, bool removedData); void AddData(const double *data, const unsigned int count); /** * Add a double to the accumulators and counters. This method * can be invoked multiple times (for example: once for each * pixel in a cube) before obtaining statistics. * * @param data The data to be added to the data set used for statistical * calculations. * */ inline void AddData(const double data) { p_totalPixels++; if(Isis::IsValidPixel(data) && InRange(data)) { p_sum += data; p_sumsum += data * data; if(data < p_minimum) p_minimum = data; if(data > p_maximum) p_maximum = data; p_validPixels++; } else if(Isis::IsNullPixel(data)) { p_nullPixels++; } else if(Isis::IsHisPixel(data)) { p_hisPixels++; } else if(Isis::IsHrsPixel(data)) { p_hrsPixels++; } else if(Isis::IsLisPixel(data)) { p_lisPixels++; } else if(Isis::IsLrsPixel(data)) { p_lrsPixels++; } else if(AboveRange(data)) { p_overRangePixels++; } else { p_underRangePixels++; } } void AddData(const double data); void RemoveData(const double *data, const unsigned int count); void RemoveData(const double data); void SetValidRange(const double minimum = Isis::ValidMinimum, const double maximum = Isis::ValidMaximum); double ValidMinimum() const { return p_validMinimum; return m_validMinimum; } double ValidMaximum() const { return p_validMaximum; return m_validMaximum; } bool InRange(const double value) { return (value >= p_validMinimum && value <= p_validMaximum); return (value >= m_validMinimum && value <= m_validMaximum); } bool AboveRange(const double value) { return (value > p_validMaximum); return (value > m_validMaximum); } bool BelowRange(const double value) { return (value < p_validMinimum); return (value < m_validMinimum); } double Average() const; Loading @@ -164,6 +131,7 @@ namespace Isis { BigInt HisPixels() const; BigInt HrsPixels() const; BigInt OutOfRangePixels() const; bool RemovedData() const; /** Loading @@ -172,7 +140,7 @@ namespace Isis { * @return The sum of the data */ double Sum() const { return p_sum; return m_sum; }; /** Loading @@ -181,30 +149,30 @@ namespace Isis { * @return The sum of the squared data */ double SumSquare() const { return p_sumsum; return m_sumsum; }; QDataStream &write(QDataStream &stream) const; QDataStream &read(QDataStream &stream); private: double p_sum; //!< Sum accumulator. double p_sumsum; //!< Sum-squared accumulator. double p_minimum; //!< Minimum double value encountered. double p_maximum; //!< Maximum double value encountered. double p_validMinimum; //!< Minimum valid pixel value double p_validMaximum; //!< Maximum valid pixel value BigInt p_totalPixels; //!< Count of total pixels processed. BigInt p_validPixels; //!< Count of valid pixels (non-special) processed. BigInt p_nullPixels; //!< Count of null pixels processed. BigInt p_lrsPixels; //!< Count of low instrument saturation pixels processed. BigInt p_lisPixels; //!< Count of low representation saturation pixels processed. BigInt p_hrsPixels; //!< Count of high instrument saturation pixels processed. BigInt p_hisPixels; //!< Count of high instrument representation pixels processed. BigInt p_underRangePixels; //!< Count of pixels less than the valid range BigInt p_overRangePixels; //!< Count of pixels greater than the valid range bool p_removedData; /**< Indicates the RemoveData method was called which implies p_minimum and p_maximum are invalid. */ double m_sum; //!< Sum accumulator. double m_sumsum; //!< Sum-squared accumulator. double m_minimum; //!< Minimum double value encountered. double m_maximum; //!< Maximum double value encountered. double m_validMinimum; //!< Minimum valid pixel value double m_validMaximum; //!< Maximum valid pixel value BigInt m_totalPixels; //!< Count of total pixels processed. BigInt m_validPixels; //!< Count of valid pixels (non-special) processed. BigInt m_nullPixels; //!< Count of null pixels processed. BigInt m_lrsPixels; //!< Count of low instrument saturation pixels processed. BigInt m_lisPixels; //!< Count of low representation saturation pixels processed. BigInt m_hrsPixels; //!< Count of high instrument saturation pixels processed. BigInt m_hisPixels; //!< Count of high instrument representation pixels processed. BigInt m_underRangePixels; //!< Count of pixels less than the valid range BigInt m_overRangePixels; //!< Count of pixels greater than the valid range bool m_removedData; /**< Indicates the RemoveData method was called which implies m_minimum and m_maximum are invalid. */ }; // operators to read/write Statistics to/from binary data Loading
isis/src/control/objs/BundleResults/BundleResults.cpp +102 −213 File changed.Preview size limit exceeded, changes collapsed. Show changes
isis/src/control/objs/BundleResults/BundleResults.h +18 −17 Original line number Diff line number Diff line Loading @@ -23,14 +23,15 @@ * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on * http://www.usgs.gov/privacy.html. */ #include <QObject> #include <QString> #include "XmlStackedHandler.h" class QDataStream; class QXmlStreamWriter; class QUuid; class QXmlStreamWriter; namespace Isis { class BundleSettings; Loading Loading @@ -63,20 +64,23 @@ namespace Isis { BundleResults(const BundleResults &other); ~BundleResults(); BundleResults &operator=(const BundleResults &other); void setOutputStatistics(BundleStatistics statisticsResults); void setRunTime(QString runTime); QString id() const; QString controlNetworkFileName() const; BundleSettings *bundleSettings(); // TODO: change return value to const reference or copy... unsafe to return pointers to member data??? BundleStatistics *bundleStatistics(); // TODO: change return value to const reference or copy... unsafe to return pointers to member data??? // ??? const BundleSettings *bundleSettings() const; // ??? const BundleStatistics *bundleStatistics() const; QString runTime() const; PvlObject pvlObject(QString resultsName = "BundleResults", QString settingsName = "InputSettings", QString statisticsName = "StatisticsResults"); QDataStream &write(QDataStream &stream) const; QDataStream &read(QDataStream &stream); QString id() const; void setRunTime(QString runTime); QString runTime() const; QString controlNetworkFileName(); BundleSettings *bundleSettings(); BundleStatistics *bundleStatistics(); void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const; Loading @@ -90,12 +94,10 @@ namespace Isis { class XmlHandler : public XmlStackedHandler { public: XmlHandler(BundleResults *bundleResults, Project *project); ~XmlHandler(); virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts); virtual bool characters(const QString &ch); virtual bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName); private: Q_DISABLE_COPY(XmlHandler); Loading @@ -107,18 +109,17 @@ namespace Isis { private: BundleResults(); FileName *m_controlNetworkFileName; BundleSettings *m_settings; BundleStatistics *m_statisticsResults; QList<ImageList *> *m_images; /** * A unique ID for this BundleResults object (useful for others to reference this object * when saving to disk). */ QUuid *m_id; QString m_runTime; FileName *m_controlNetworkFileName; BundleSettings *m_settings; BundleStatistics *m_statisticsResults; QList<ImageList *> *m_images; }; // operators to read/write BundleResults to/from binary data QDataStream &operator<<(QDataStream &stream, const BundleResults &bundleResults); Loading