Unverified Commit 0f2f7ac0 authored by Lauren Adoram-Kershner's avatar Lauren Adoram-Kershner Committed by GitHub
Browse files

Adds hooks for Normallized Residual Gross Outlier Detection (#4563)



* correcting swapped line sample prints in output file

* Updating unit test truth data to check Results Group

* I forgot to add the changed test

* Adding hooks for new norm res gross outlier detection

* changing default prob level from 0.05 to 0.95

* Fixing whitespaces

* updating grossOutlierRejection setter

* fixing whitespace II

Co-authored-by: default avatarLauren Adoram-Kershner <ladoramkershner@prog28.wr.usgs.gov>
parent ea414cc2
Loading
Loading
Loading
Loading
+32 −2
Original line number Diff line number Diff line
@@ -95,6 +95,7 @@ namespace Isis {
        m_rmsYResiduals(src.m_rmsYResiduals),
        m_rmsXYResiduals(src.m_rmsXYResiduals),
        m_rejectionLimit(src.m_rejectionLimit),
        m_grossRejectionLimit(src.m_grossRejectionLimit),
        m_numberObservations(src.m_numberObservations),
        m_numberRejectedObservations(src.m_numberRejectedObservations),
        m_numberUnknownParameters(src.m_numberUnknownParameters),
@@ -180,6 +181,7 @@ namespace Isis {
      m_rmsYResiduals = src.m_rmsYResiduals;
      m_rmsXYResiduals = src.m_rmsXYResiduals;
      m_rejectionLimit = src.m_rejectionLimit;
      m_grossRejectionLimit = src.m_grossRejectionLimit;
      m_numberObservations = src.m_numberObservations;
      m_numberRejectedObservations = src.m_numberRejectedObservations;
      m_numberUnknownParameters = src.m_numberUnknownParameters;
@@ -291,6 +293,9 @@ namespace Isis {
    // set by compute rejection limit
    m_rejectionLimit = 0.0;

    // set by compute gross rejection limit
    m_grossRejectionLimit = 0.0;

    // set by flag outliers
    m_numberRejectedObservations = 0;

@@ -629,14 +634,25 @@ namespace Isis {


  /**
   * Sets the rejection limit.
   * Sets the rejection limit for median absolute deviation
   * outlier rejection.
   *
   * @param rejectionLimit The rejection limit.
   * @param rejectionLimit The rejection limit for median absolute deviation.
   */
  void BundleResults::setRejectionLimit(double rejectionLimit) {
    m_rejectionLimit = rejectionLimit;
  }

  /**
   * Sets the rejection limit for gross outlier detection 
   * with normalized residuals.
   * 
   * @param grossRejectionLimit The rejection limit for normalized residuals.
   */
  void BundleResults::setGrossRejectionLimit(double grossRejectionLimit) {
    m_grossRejectionLimit = grossRejectionLimit;
  }


  /**
   * Sets the number of rejected observations.
@@ -1147,6 +1163,16 @@ namespace Isis {
  }
  

  /**
   * Returns the rejection limit for normalized residuals.
   *
   * @return @b double The rejection limit for normalized residuals
   */
  double BundleResults::grossRejectionLimit() const {
    return m_grossRejectionLimit;
  }


  /**
   * Returns the number of observation that were rejected.
   *
@@ -1489,6 +1515,7 @@ namespace Isis {
    stream.writeTextElement("numberIgnoredPoints", toString(numberIgnoredPoints()));
    stream.writeTextElement("numberHeldImages", toString(numberHeldImages()));
    stream.writeTextElement("rejectionLimit", toString(rejectionLimit()));
    stream.writeTextElement("grossRejectionLimit", toString(grossRejectionLimit()));
    stream.writeTextElement("numberRejectedObservations", toString(numberRejectedObservations()));
    stream.writeTextElement("numberObservations", toString(numberObservations()));
    stream.writeTextElement("numberImageParameters", toString(numberImageParameters()));
@@ -2174,6 +2201,9 @@ namespace Isis {
      else if (qName == "rejectionLimit") {
        m_xmlHandlerBundleResults->m_rejectionLimit = toDouble(m_xmlHandlerCharacters);
      }
      else if (qName == "grossRejectionLimit") {
        m_xmlHandlerBundleResults->m_grossRejectionLimit = toDouble(m_xmlHandlerCharacters);
      }
      else if (qName == "numberRejectedObservations") {
        m_xmlHandlerBundleResults->m_numberRejectedObservations = toInt(m_xmlHandlerCharacters);
      }
+4 −1
Original line number Diff line number Diff line
@@ -129,6 +129,7 @@ namespace Isis {
                                   int numObservations);
#endif
      void setRejectionLimit(double rejectionLimit);
      void setGrossRejectionLimit(double grossRejectionLimit);
#if 0
      double computeResiduals(
               ControlNet *pCnet,
@@ -199,6 +200,7 @@ namespace Isis {
      double rmsRy() const;  // currently unused ???
      double rmsRxy() const; // currently unused ???
      double rejectionLimit() const;
      double grossRejectionLimit() const;
      int numberRejectedObservations() const;
      int numberObservations() const;

@@ -296,7 +298,8 @@ namespace Isis {
      double m_rmsYResiduals;                 //!< rms of y residuals
      double m_rmsXYResiduals;                //!< rms of all x and y residuals

      double m_rejectionLimit;                //!< current rejection limit
      double m_rejectionLimit;                //!< current rejection limit (for median absolute deviation)
      double m_grossRejectionLimit;           //!< currnet gross rejection limit (for normalized residuals)
      // TODO:??? reorder read/write data stream, init, copy constructor, operator=
      int m_numberObservations;                //!< number of image coordinate observations
      int m_numberRejectedObservations;        //!< number of rejected image coordinate observations
+81 −10
Original line number Diff line number Diff line
@@ -57,7 +57,9 @@ namespace Isis {
    m_createInverseMatrix   = false;
    m_cubeList              =    "";
    m_outlierRejection      = false;
    m_grossOutlierRejection = false;
    m_outlierRejectionMultiplier = 3.0;
    m_grossOutlierProbabilityLevel = 0.95;

    // Parameter Uncertainties (Weighting)
    // The units are meters for either coordinate type
@@ -131,6 +133,8 @@ namespace Isis {
        m_createInverseMatrix(other.m_createInverseMatrix),
        m_outlierRejection(other.m_outlierRejection),
        m_outlierRejectionMultiplier(other.m_outlierRejectionMultiplier),
        m_grossOutlierRejection(other.m_grossOutlierRejection),
        m_grossOutlierProbabilityLevel(other.m_grossOutlierProbabilityLevel),
        m_globalPointCoord1AprioriSigma(other.m_globalPointCoord1AprioriSigma),
        m_globalPointCoord2AprioriSigma(other.m_globalPointCoord2AprioriSigma),
        m_globalPointCoord3AprioriSigma(other.m_globalPointCoord3AprioriSigma),
@@ -177,6 +181,8 @@ namespace Isis {
      m_createInverseMatrix = other.m_createInverseMatrix;
      m_outlierRejection = other.m_outlierRejection;
      m_outlierRejectionMultiplier = other.m_outlierRejectionMultiplier;
      m_grossOutlierRejection = other.m_grossOutlierRejection;
      m_grossOutlierProbabilityLevel = other.m_grossOutlierProbabilityLevel;
      m_globalPointCoord1AprioriSigma = other.m_globalPointCoord1AprioriSigma;
      m_globalPointCoord2AprioriSigma = other.m_globalPointCoord2AprioriSigma;
      m_globalPointCoord3AprioriSigma = other.m_globalPointCoord3AprioriSigma;
@@ -320,10 +326,11 @@ namespace Isis {


  /**
   * Set the outlier rejection options for the bundle adjustment.
   * Set the median absolute deviation outlier rejection options for the bundle adjustment.
   *
   * @param outlierRejection Indicates whether to perform automatic outlier
   *                         rejection during the bundle adjustment.
   *                         rejection based on median absolute deviation
   *                         during the bundle adjustment.
   * @param mutliplier The outlier rejection multiplier.
   */
  void BundleSettings::setOutlierRejection(bool outlierRejection, double multiplier) {
@@ -336,6 +343,22 @@ namespace Isis {
    }
  }

  /**
   * Set the normalized residual outlier rejection options for the bundle adjustment.
   *
   * @param grossOutlierRejection Indicates whether to perform automatic outlier
   *                              rejection based on the normalized residuals
   *                              during the bunlde adjustment.
   *
   * @param probabilityLevel The probability level the normalized residual 
   *                         must fit within to be considered an inlier.
   */
  void BundleSettings::setGrossOutlierRejection(bool grossOutlierRejection, 
                                                double probabilityLevel) {
    m_grossOutlierRejection = grossOutlierRejection;
    m_grossOutlierProbabilityLevel = probabilityLevel;
  }


  /**
   * Add the list of solve options for each observation.
@@ -395,7 +418,7 @@ namespace Isis {

  /**
   * This method is used to determine whether outlier rejection will be
   * performed on this bundle adjustment.
   * performed on median absolute deviation during the  bundle adjustment.
   *
   * @return @b bool Indicates whether to perform automatic outlier
   *                 rejection during the bundle adjustment.
@@ -404,6 +427,17 @@ namespace Isis {
    return m_outlierRejection;
  }

  /**
   * This method is used to determine whether outlier rejection will be
   * performed on normalized residuals during the bundle adjustment.
   *
   * @return @b bool Indicates whether to perform automatic outlier
   *                 rejection during the bundle adjustment.
   */
  bool BundleSettings::grossOutlierRejection() const {
    return m_grossOutlierRejection;
  }


  /**
   * This method is used to determine whether this bundle adjustment will solve
@@ -478,6 +512,16 @@ namespace Isis {
  }


  /**
   * Retrieves the gross outlier rejection probability level for the 
   * bundle adjustment.
   *
   * @return @b double The outlier rejection probability level.
   */
  double BundleSettings::grossOutlierProbabilityLevel() const {
    return m_grossOutlierProbabilityLevel;
  }

  /**
   * Retrieves global a priori sigma for 1st coordinate of points for this bundle
   *
@@ -1095,6 +1139,16 @@ namespace Isis {
    }
    stream.writeEndElement();

    stream.writeStartElement("grossOutlierRejectionOptions");
    stream.writeAttribute("rejection", toString(grossOutlierRejection()));
    if (grossOutlierRejection()) {
      stream.writeAttribute("probabilityLevel", toString(grossOutlierProbabilityLevel()));
    }
    else {
      stream.writeAttribute("probabilityLevel", "N/A");
    }
    stream.writeEndElement();

    stream.writeStartElement("convergenceCriteriaOptions");
    stream.writeAttribute("convergenceCriteria",
                          convergenceCriteriaToString(convergenceCriteria()));
@@ -1273,6 +1327,23 @@ namespace Isis {
          }
        }
      }
      else if (localName == "grossOutlierRejectionOptions") {
        QString grossOutlierRejectionStr = attributes.value("grossRejection");
        if (!grossOutlierRejectionStr.isEmpty()) {
          m_xmlHandlerBundleSettings->m_grossOutlierRejection = toBool(grossOutlierRejectionStr);
        }

        QString grossOutlierProbabilityLevelStr = attributes.value("probabilityLevel");
        if (!grossOutlierProbabilityLevelStr.isEmpty()) {
          if (grossOutlierProbabilityLevelStr!= "N/A") {
            m_xmlHandlerBundleSettings->m_grossOutlierProbabilityLevel
                = toDouble(grossOutlierProbabilityLevelStr);
          }
          else {
            m_xmlHandlerBundleSettings->m_grossOutlierProbabilityLevel= 0.95;
          }
        }
      }
      else if (localName == "convergenceCriteriaOptions") {

        QString convergenceCriteriaStr = attributes.value("convergenceCriteria");
+10 −1
Original line number Diff line number Diff line
@@ -163,6 +163,8 @@ namespace Isis {
                           double globalPointCoord3AprioriSigma = Isis::Null);
      void setOutlierRejection(bool outlierRejection,
                               double multiplier = 1.0);
      void setGrossOutlierRejection(bool grossOutlierRejection,
                                    double probabilityLevel = 0.95);
      void setObservationSolveOptions(QList<BundleObservationSolveSettings> obsSolveSettingsList);
      void setCreateInverseMatrix(bool createMatrix);

@@ -175,7 +177,9 @@ namespace Isis {
      bool updateCubeLabel() const;
      bool errorPropagation() const;
      bool outlierRejection() const;
      bool grossOutlierRejection() const;
      double outlierRejectionMultiplier() const;
      double grossOutlierProbabilityLevel() const;
// These sigmas are either for planetocentric lat/lon/radius or body-fixed x/y/z
      double globalPointCoord1AprioriSigma() const;
      double globalPointCoord2AprioriSigma() const;
@@ -351,9 +355,14 @@ namespace Isis {
      bool m_errorPropagation; //!< Indicates whether to perform error propagation.
      bool m_createInverseMatrix; //!< Indicates whether to create the inverse matrix file.
      bool m_outlierRejection; /**< Indicates whether to perform automatic
                                    outlier detection/rejection.*/
                                    outlier detection/rejection based on median absolute deviation.*/
      double m_outlierRejectionMultiplier; /**< The multiplier value for outlier rejection.
                                                Defaults to 1, so no change if rejection = false.*/
      bool m_grossOutlierRejection; /** < Indicates whether to perform automatic
					  outlier detection/rejection based on normalized residuals.*/
      double m_grossOutlierProbabilityLevel; /**< The probability level for calculating the
						  critical value for gross outlier detection.
      						  Defaults to 0.95, so no change if grossRejection = false.*/

      // Parameter Uncertainties (Weighting)
      double m_globalPointCoord1AprioriSigma;   //!< The global a priori sigma for latitude or X.