Commit e91fb9d3 authored by Jesse Mapel's avatar Jesse Mapel
Browse files

Moved write methods from BundleAdjust to BundleSolutionInfo. Fixes #4159.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce@7008 41f8697f-d340-4b68-9986-7bafba869bb8
parent e5316d0a
Loading
Loading
Loading
Loading
+34 −1438

File changed.

Preview size limit exceeded, changes collapsed.

+7 −10
Original line number Diff line number Diff line
@@ -200,13 +200,16 @@ namespace Isis {
   *   @history 2016-07-11 Jesse Mapel - Changed m_bundleControlPoints to be a vector of
   *                           QSharedPointers to BundleControlPoints instead of a
   *                           BundleControlPointVector.  Fixes #4099.
   *   @history 2016-07-11 Jeannie Backer - Removed initialize(). Implementation was moved the the
   *                           bottom of init() method. Fixes #4161.
   *   @history 2016-08-03 Jesse Mapel - Changed BundleObservationVector to a vector of
   *                           QSharedPointers.  Fixes #4150.
   *   @history 2016-08-10 Jeannie Backer - Replaced boost vectors and matrices with
   *                           Isis::LinearAlgebra::Vector and Isis::LinearAlgebra::Matrix,
   *                           respectively. References #4163.
   *   @history 2016-07-11 Jeannie Backer - Removed initialize(). Implementation was moved the the
   *                           bottom of init() method. Fixes #4161.
   *   @history 2016-08-15 Jesse Mapel - Moved write methods to BundleSolutionInfo.  Changed
   *                           constructors to always construct a new control network.
   *                           Fixes #4159.
   *   @history 2016-08-15 Ian Humphrey - Replaced ISIS ControlPoint and ControlMeasure uses with
   *                           BundleControlPoint and BundleMeasure. No longer need to check if the
   *                           BundleControlPoint or BundleMeasure is ignored before use, since we
@@ -257,7 +260,7 @@ namespace Isis {
      void             abortBundle();
///////////////////////////////////////////////////////////////////////////////////////////////////
      // accessors
      ControlNet       *controlNet() { return m_pCnet; } // TODO: change from pointer to const ref???
      ControlNetQsp    controlNet() { return m_pCnet; } // TODO: change from pointer to const ref???
      SerialNumberList *serialNumberList() { return m_pSnList; } // TODO: move implementation to cpp per ISIS standards
      int              images() const { return m_pSnList->size(); }// TODO: move implementation to cpp per ISIS standards
//      int              observations() const;
@@ -305,12 +308,6 @@ namespace Isis {

      // output methods
      void iterationSummary();
      bool output();
      bool outputHeader(std::ofstream  &fp_out);
      bool outputText();
      bool outputPointsCSV();
      bool outputImagesCSV();
      bool outputResiduals();
      bool wrapUp();
      BundleSolutionInfo bundleSolveInformation();
      bool computeBundleStatistics();
@@ -482,7 +479,7 @@ namespace Isis {
      QString m_strCnetFileName;                        //!< Control Net file specification

      //!< pointers to...
      ControlNet *m_pCnet;                              //!< 'ControlNet' object
      ControlNetQsp m_pCnet;                              //!< 'ControlNet' object
      SerialNumberList *m_pSnList;                      //!< list of image serial numbers
      SerialNumberList *m_pHeldSnList;                  //!< list of held image serial numbers

+127 −3
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@

#include "Camera.h"
#include "ControlMeasure.h"
#include "ControlNet.h"
#include "ControlPoint.h"
#include "CorrelationMatrix.h"
#include "Distance.h"
@@ -118,7 +117,12 @@ namespace Isis {
        m_sigma0(src.m_sigma0),
        m_elapsedTime(src.m_elapsedTime),
        m_elapsedTimeErrorProp(src.m_elapsedTimeErrorProp),
        m_radiansToMeters(src.m_radiansToMeters),
        m_converged(src.m_converged),
        m_bundleControlPoints(src.m_bundleControlPoints),
        m_outNet(src.m_outNet),
        m_iterations(src.m_iterations),
        m_observations(src.m_observations),
        m_rmsImageSampleResiduals(src.m_rmsImageSampleResiduals),
        m_rmsImageLineResiduals(src.m_rmsImageLineResiduals),
        m_rmsImageResiduals(src.m_rmsImageResiduals),
@@ -207,7 +211,12 @@ namespace Isis {
      m_sigma0 = src.m_sigma0;
      m_elapsedTime = src.m_elapsedTime;
      m_elapsedTimeErrorProp = src.m_elapsedTimeErrorProp;
      m_radiansToMeters = src.m_radiansToMeters;
      m_converged = src.m_converged;
      m_bundleControlPoints = src.m_bundleControlPoints;
      m_outNet = src.m_outNet;
      m_iterations = src.m_iterations;
      m_observations = src.m_observations;
      m_rmsImageSampleResiduals = src.m_rmsImageSampleResiduals;
      m_rmsImageLineResiduals = src.m_rmsImageLineResiduals;
      m_rmsImageResiduals = src.m_rmsImageResiduals;
@@ -323,6 +332,7 @@ namespace Isis {

    // solve and solve cholesky
    m_degreesOfFreedom = -1;
    m_iterations = 0;
    m_sigma0 = 0.0;
    m_elapsedTime = 0.0;
    m_elapsedTimeErrorProp = 0.0;
@@ -334,6 +344,10 @@ namespace Isis {
    m_maximumLikelihoodFunctions.clear();
    m_cumProRes = NULL;
    
    m_radiansToMeters = 0;
    m_observations.clear();
    m_outNet.clear();

  }


@@ -822,6 +836,16 @@ namespace Isis {
  }


  /**
   * Sets the radians to meters conversion constant for the target body.
   * 
   * @param rtm The (double) conversion factor.
   */
  void BundleResults::setRadiansToMeters(double rtm) {
    m_radiansToMeters = rtm;
  }


  /**
   * Sets if the bundle adjustment converged.
   * 
@@ -832,6 +856,46 @@ namespace Isis {
  }


  /**
   * Sets the bundle control point vector.
   * 
   * @param controlPoints The vector of BundleControlPointQsps.
   */
  void BundleResults::setBundleControlPoints(QVector<BundleControlPointQsp> controlPoints) {
    m_bundleControlPoints = controlPoints;
  }


  /**
   * Sets the output ControlNet.
   * 
   * @param outNet A QSharedPointer to the output ControlNet.
   */
  void BundleResults::setOutputControlNet(ControlNetQsp outNet) {
    m_outNet = outNet;
  }


  /**
   * Sets the number of iterations taken by the BundleAdjust.
   * 
   * @param iterations The number of iterations.
   */
  void BundleResults::setIterations(int iterations) {
    m_iterations = iterations;
  }


  /**
   * Sets the vector of BundleObservations.
   * 
   * @param observations The vector of BundleObservations.
   */
  void BundleResults::setObservations(BundleObservationVector observations) {
    m_observations = observations;
  }



  //************************* Accessors **********************************************************//
  
@@ -1115,6 +1179,16 @@ namespace Isis {
  }


  /**
   * Returns the radians to meters conversion factor for the target body.
   * 
   * @return @b double The conversion factor.
   */
  double BundleResults::radiansToMeters() const {
    return m_radiansToMeters;
  }


  /**
   * Returns the number of observation that were rejected.
   * 
@@ -1235,6 +1309,53 @@ namespace Isis {
  }


  /**
   * Returns a reference to the BundleControlPoint vector.
   * 
   * @return @b QVector<BundleControlPointQsp>& The BundleControlPoint vector.
   */
  QVector<BundleControlPointQsp> &BundleResults::bundleControlPoints() {
    return m_bundleControlPoints;
  }


  /**
   * Returns a shared pointer to the output control network.
   * 
   * @return @b ControlNetQsp A shared pointer to the output control network.
   * 
   * @throws IException::Programmer "Output Control Network has not been set."
   */
  ControlNetQsp BundleResults::outputControlNet() const {
    if (!m_outNet) {
      throw IException(IException::Programmer, 
                       "Output Control Network has not been set.",
                       _FILEINFO_);
    }
    return m_outNet;
  }


  /**
   * Returns the number of iterations taken by the BundleAdjust.
   * 
   * @return @b int The number of iterations.
   */
  int BundleResults::iterations() const {
    return m_iterations;
  }


  /**
   * Returns a reference to the observations used by the BundleAdjust.
   * 
   * @return @b BundleObservationVector& A reference to the observation vector.
   */
  const BundleObservationVector &BundleResults::observations() const {
    return m_observations;
  }


  /**
   * Returns how many maximum likelihood models were used in the bundle adjustment.
   * 
@@ -1334,6 +1455,7 @@ namespace Isis {
    pvl += PvlKeyword("RMSResidualY", toString(rmsRy()));
    pvl += PvlKeyword("RMSResidualXY", toString(rmsRxy()));
    pvl += PvlKeyword("RejectionLimit", toString(rejectionLimit()));
    pvl += PvlKeyword("RadiansToMeters", toString(radiansToMeters()));
    pvl += PvlKeyword("NumberRejectedObservations", toString(numberRejectedObservations()));
    pvl += PvlKeyword("NumberObservations", toString(numberObservations()));
    pvl += PvlKeyword("NumberImageParameters", toString(numberImageParameters()));
@@ -1348,6 +1470,7 @@ namespace Isis {
    pvl += PvlKeyword("Sigma0", toString(sigma0()));
    pvl += PvlKeyword("ElapsedTime", toString(elapsedTime()));
    pvl += PvlKeyword("ElapsedTimeErrorProp", toString(elapsedTimeErrorProp()));
    pvl += PvlKeyword("Iterations", toString(iterations()));
    pvl += PvlKeyword("Converged", toString(converged()));
#if 0
    // loop through these ??? what value to store???
@@ -2454,6 +2577,7 @@ namespace Isis {
                                            spc);
        att.write(H5::PredType::NATIVE_INT, &m_numberObservations);


        att = resultsGroup.createAttribute("numberRejectedObservations", 
                                            H5::PredType::NATIVE_INT,
                                            spc);
+59 −23
Original line number Diff line number Diff line
@@ -36,7 +36,10 @@
#include <hdf5.h>

// Isis Library
#include "BundleControlPoint.h"
#include "BundleObservationVector.h"
#include "BundleSettings.h"
#include "ControlNet.h"
#include "Distance.h"
#include "MaximumLikelihoodWFunctions.h"
#include "PvlObject.h"
@@ -80,6 +83,9 @@ namespace Isis {
   *                           merging from IPCE into ISIS. Fixes #3975.
   *   @history 2016-08-10 Jeannie Backer - Replaced boost vector with Isis::LinearAlgebra::Vector.
   *                           References #4163.
   *   @history 2016-08-15 Jesse Mapel - Added iteration count, radians to meters conversion,
   *                           observation vector, bundle control point vector, and output control
   *                           network for write methods in BundleSolutionInfo.  Fixes #4159.
   */
  class BundleResults : public QObject {
    Q_OBJECT
@@ -161,7 +167,12 @@ namespace Isis {
      void setSigma0(double sigma0);
      void setElapsedTime(double time);
      void setElapsedTimeErrorProp(double time);
      void setRadiansToMeters(double rtm);
      void setConverged(bool converged); // or initialze method
      void setBundleControlPoints(QVector<BundleControlPointQsp> controlPoints);
      void setOutputControlNet(ControlNetQsp outNet);
      void setIterations(int iterations);
      void setObservations(BundleObservationVector observations);
      
      // Accessors...
      QList<Statistics> rmsImageSampleResiduals() const;
@@ -192,6 +203,7 @@ namespace Isis {
      double rmsRy() const;  // currently unused ???
      double rmsRxy() const; // currently unused ???
      double rejectionLimit() const;
      double radiansToMeters() const;
      int numberRejectedObservations() const;
      int numberObservations() const;

@@ -205,6 +217,10 @@ namespace Isis {
      double elapsedTime() const;
      double elapsedTimeErrorProp() const;
      bool converged() const; // or initialze method
      QVector<BundleControlPointQsp> &bundleControlPoints();
      ControlNetQsp outputControlNet() const;
      int iterations() const;
      const BundleObservationVector &observations() const;
      
      int numberMaximumLikelihoodModels() const;
      int maximumLikelihoodModelIndex() const;
@@ -299,12 +315,14 @@ namespace Isis {
// ???       Statistics m_statsrxy;                     //!< xy residuals

      int m_numberFixedPoints;                //!< number of 'fixed' (ground) points (define)
      int m_numberIgnoredPoints;              //!< number of ignored points                  // currently set but unused ???
      // Currently set but unused
      int m_numberIgnoredPoints;              //!< number of ignored points
      int m_numberHeldImages;                 //!< number of 'held' images (define)          

      double m_rmsXResiduals;  // set but unused ???                   //!< rms of x residuals
      double m_rmsYResiduals;  // set but unused ???                   //!< rms of y residuals
      double m_rmsXYResiduals; // set but unused ???                   //!< rms of all x and y residuals
      // The following three members are set but unused.
      double m_rmsXResiduals;                 //!< rms of x residuals
      double m_rmsYResiduals;                 //!< rms of y residuals
      double m_rmsXYResiduals;                //!< rms of all x and y residuals
      
      double m_rejectionLimit;                //!< current rejection limit
      // TODO:??? reorder read/write data stream, init, copy constructor, operator= 
@@ -319,8 +337,26 @@ namespace Isis {
      double m_sigma0;                         //!< std deviation of unit weight
      double m_elapsedTime;                    //!< elapsed time for bundle
      double m_elapsedTimeErrorProp;           //!< elapsed time for error propagation
      double m_radiansToMeters;                //!< radian to meters conversion factor for the body
      bool m_converged;

      // Variables for output methods in BundleSolutionInfo
      
      QVector<BundleControlPointQsp> m_bundleControlPoints; /**< The vector of BundleControlPoints
                                                                 from BundleAdjust.  Equivalent to
                                                                 the output control net minus
                                                                 ignored points and measures.
                                                                 The contained points and members
                                                                 hold pointers to the points
                                                                 and measures in the output
                                                                 control net.*/
      ControlNetQsp m_outNet;                               /**< The output control net from
                                                                 BundleAdjust.*/
      int m_iterations;                                     /**< The number of iterations taken
                                                                 by BundleAdjust.*/
      BundleObservationVector m_observations;               /**< The vector of BundleObservations
                                                                 from BundleAdjust.*/


      //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      // variables set in computeBundleResults()
+30 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ Object = DefaultResultsObject
  RMSResidualY                      = 0.0
  RMSResidualXY                     = 0.0
  RejectionLimit                    = 0.0
  RadiansToMeters                   = 0.0
  NumberRejectedObservations        = 0
  NumberObservations                = 0
  NumberImageParameters             = 0
@@ -19,6 +20,7 @@ Object = DefaultResultsObject
  Sigma0                            = 0.0
  ElapsedTime                       = 0.0
  ElapsedTimeErrorProp              = 0.0
  Iterations                        = 0
  Converged                         = No
  MinSigmaLatitude                  = 1000000000000.0
  MinSigmaLatitudePointId           = Null
@@ -55,6 +57,7 @@ Object = CopyResultsObject
  RMSResidualY                      = 0.0
  RMSResidualXY                     = 0.0
  RejectionLimit                    = 0.0
  RadiansToMeters                   = 0.0
  NumberRejectedObservations        = 0
  NumberObservations                = 0
  NumberImageParameters             = 0
@@ -66,6 +69,7 @@ Object = CopyResultsObject
  Sigma0                            = 0.0
  ElapsedTime                       = 0.0
  ElapsedTimeErrorProp              = 0.0
  Iterations                        = 0
  Converged                         = No
  MinSigmaLatitude                  = 1000000000000.0
  MinSigmaLatitudePointId           = Null
@@ -112,6 +116,7 @@ Object = SelfAssignedResultsObject
  RMSResidualY                       = 0.0
  RMSResidualXY                      = 0.0
  RejectionLimit                     = 0.0
  RadiansToMeters                    = 0.0
  NumberRejectedObservations         = 0
  NumberObservations                 = 0
  NumberImageParameters              = 0
@@ -123,6 +128,7 @@ Object = SelfAssignedResultsObject
  Sigma0                             = 0.0
  ElapsedTime                        = 0.0
  ElapsedTimeErrorProp               = 0.0
  Iterations                         = 0
  Converged                          = No
  MinSigmaLatitude                   = 1000000000000.0
  MinSigmaLatitudePointId            = Null
@@ -161,6 +167,7 @@ Object = AssignedNewResultsObject
  RMSResidualY                       = 0.0
  RMSResidualXY                      = 0.0
  RejectionLimit                     = 0.0
  RadiansToMeters                    = 0.0
  NumberRejectedObservations         = 0
  NumberObservations                 = 0
  NumberImageParameters              = 0
@@ -172,6 +179,7 @@ Object = AssignedNewResultsObject
  Sigma0                             = 0.0
  ElapsedTime                        = 0.0
  ElapsedTimeErrorProp               = 0.0
  Iterations                         = 0
  Converged                          = No
  MinSigmaLatitude                   = 1000000000000.0
  MinSigmaLatitudePointId            = Null
@@ -211,6 +219,7 @@ Object = MutatedResultsObject
  RMSResidualY                       = 5.0
  RMSResidualXY                      = 6.0
  RejectionLimit                     = 7.0
  RadiansToMeters                    = 23.68
  NumberRejectedObservations         = 8
  NumberObservations                 = 9
  NumberImageParameters              = 10
@@ -222,6 +231,7 @@ Object = MutatedResultsObject
  Sigma0                             = 15.0
  ElapsedTime                        = 16.0
  ElapsedTimeErrorProp               = 17.0
  Iterations                         = 6
  Converged                          = Yes
  MinSigmaLatitude                   = 0.5
  MinSigmaLatitudePointId            = MinLatId
@@ -257,12 +267,25 @@ Testing more computation methods...
sigma0 =  "1.2139539573338"
sigma0 =  "0.0"

Testing storage for output methods...

Testing accessor methods...
maximum likelihood index =  "4"
maximum likelihood median r2 residuals =  "0.49504950495049"
maximum likelihood index,model,quantile = [ "0" ,  "Huber" ,  "0.1" ]
maximum likelihood index,model,quantile = [ "1" ,  "Welsch" ,  "0.2" ]
maximum likelihood index,model,quantile = [ "2" ,  "Chen" ,  "0.3" ]
bundle control points...
       FreePoint           FREE    1 of 1  3.54            Null            Null            Null             N/A             N/A             N/A

      FixedPoint          FIXED    0 of 0  0.00     90.00000000    180.00000000      0.01000000             N/A             N/A             N/A

output control network
2
2
bundle observations
"InstrumentId1"
("TestImageFileName")

Testing serialization...
Object = BundleResults
@@ -273,6 +296,7 @@ Object = BundleResults
  RMSResidualY                       = 5.0
  RMSResidualXY                      = 6.0
  RejectionLimit                     = 7.0
  RadiansToMeters                    = 0.0
  NumberRejectedObservations         = 8
  NumberObservations                 = 9
  NumberImageParameters              = 10
@@ -284,6 +308,7 @@ Object = BundleResults
  Sigma0                             = 0.0
  ElapsedTime                        = 16.0
  ElapsedTimeErrorProp               = 17.0
  Iterations                         = 0
  Converged                          = Yes
  MinSigmaLatitude                   = 0.5
  MinSigmaLatitudePointId            = MinLatId
@@ -325,6 +350,7 @@ Object = BundleResultsFromXml
  RMSResidualY                       = 5.0
  RMSResidualXY                      = 6.0
  RejectionLimit                     = 7.0
  RadiansToMeters                    = 0.0
  NumberRejectedObservations         = 8
  NumberObservations                 = 9
  NumberImageParameters              = 10
@@ -336,6 +362,7 @@ Object = BundleResultsFromXml
  Sigma0                             = 0.0
  ElapsedTime                        = 16.0
  ElapsedTimeErrorProp               = 17.0
  Iterations                         = 0
  Converged                          = Yes
  MinSigmaLatitude                   = 0.5
  MinSigmaLatitudePointId            = MinLatId
@@ -376,6 +403,7 @@ Object = BundleResultsFromEmptyXml
  RMSResidualY                      = 0.0
  RMSResidualXY                     = 0.0
  RejectionLimit                    = 0.0
  RadiansToMeters                   = 0.0
  NumberRejectedObservations        = 0
  NumberObservations                = 0
  NumberImageParameters             = 0
@@ -387,6 +415,7 @@ Object = BundleResultsFromEmptyXml
  Sigma0                            = 0.0
  ElapsedTime                       = 0.0
  ElapsedTimeErrorProp              = 0.0
  Iterations                        = 0
  Converged                         = No
  MinSigmaLatitude                  = 1000000000000.0
  MinSigmaLatitudePointId           = Null
@@ -417,3 +446,4 @@ End_Object
Testing error throws...
**I/O ERROR** Computed degrees of freedom [-1] is invalid.
**I/O ERROR** Computed degrees of freedom [0] is invalid.
**PROGRAMMER ERROR** Output Control Network has not been set.
Loading