Commit ceb3ce68 authored by jessemapel's avatar jessemapel Committed by Jesse Mapel
Browse files

Moved CSM settings into BOSS

parent b876e901
Loading
Loading
Loading
Loading
+39 −1
Original line number Diff line number Diff line
@@ -777,7 +777,7 @@ namespace Isis {


  /**
   * Get the indices of the parameters in a set.
   * Get the indices of the parameters that belong to a set.
   *
   * @param paramSet The set of indices to get
   *
@@ -788,6 +788,44 @@ namespace Isis {
  }


  /**
   * Get the indices of all parameters of a specific type
   *
   * @param paramType The type of parameters to get the indices of
   *
   * @return @b std::vector<int> Vector of the parameter indices
   */
  std::vector<int> CSMCamera::getParameterIndices(csm::param::Type paramType) const {
    std::vector<int> parameterIndices;
    for (int i = 0; i < m_model->getNumParameters(); i++) {
      if (m_model->getParameterType(i) == paramType) {
        parameterIndices.push_back(i);
      }
    }
    return parameterIndices;
  }


  /**
   * Get the indices of a list of parameters
   *
   * @param paramType The list of parameters to get the indices of
   *
   * @return @b std::vector<int> Vector of the parameter indices in the same order as the input list
   */
  std::vector<int> CSMCamera::getParameterIndices(QStringList paramList) const {
    std::vector<int> parameterIndices;
    for (int i = 0; i < paramList.size(); i++) {
      for (int j = 0; j < m_model->getNumParameters(); j++) {
        if (m_model->getParameterName(j) == paramList[i].toStdString()) {
          parameterIndices.push_back(i);
        }
      }
    }
    return parameterIndices;
  }


  /**
   * Adjust the value of a parameter.
   *
+3 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ find files of those names at the top level of this repository. **/

#include <QList>
#include <QPointF>
#include <QStringList>

#include "csm/csm.h"
#include "csm/RasterGM.h"
@@ -117,6 +118,8 @@ namespace Isis {
      virtual double Declination();

      std::vector<int> getParameterIndices(csm::param::Set paramSet) const;
      std::vector<int> getParameterIndices(csm::param::Type paramType) const;
      std::vector<int> getParameterIndices(QStringList paramList) const;
      void applyParameterCorrection(int index, double correction);
      double getParameterCovariance(int index1, int index2);

+103 −19
Original line number Diff line number Diff line
@@ -240,25 +240,6 @@ namespace Isis {
  }


//  BundleObservationSolveSettings::BundleObservationSolveSettings(const BundleObservationSolveSettings &other)
//      : m_id(new QUuid(other.m_id->toString())),
//        m_instrumentId(other.m_instrumentId),
//        m_instrumentPointingSolveOption(other.m_instrumentPointingSolveOption),
//        m_numberCamAngleCoefSolved(other.m_numberCamAngleCoefSolved),
//        m_ckDegree(other.m_ckDegree),
//        m_ckSolveDegree(other.m_ckSolveDegree),
//        m_solveTwist(other.m_solveTwist),
//        m_solvePointingPolynomialOverExisting(other.m_solvePointingPolynomialOverExisting),
//        m_anglesAprioriSigma(other.m_anglesAprioriSigma),
//        m_pointingInterpolationType(other.m_pointingInterpolationType),
//        m_instrumentPositionSolveOption(other.m_instrumentPositionSolveOption),
//        m_numberCamPosCoefSolved(other.m_numberCamPosCoefSolved),
//        m_spkDegree(other.m_spkDegree),
//        m_spkSolveDegree(other.m_spkSolveDegree),
//        m_solvePositionOverHermiteSpline(other.m_solvePositionOverHermiteSpline),
//        m_positionAprioriSigma(other.m_positionAprioriSigma),
//        m_positionInterpolationType(other.m_positionInterpolationType) {
//  }
  /**
   * Constructs a BundleObservationSolveSettings from another one.
   *
@@ -272,6 +253,10 @@ namespace Isis {
     // or intit all variables in all constructors

    m_instrumentId = other.m_instrumentId;
    m_csmSolveOption = other.m_csmSolveOption;
    m_csmSolveSet = other.m_csmSolveSet;
    m_csmSolveType = other.m_csmSolveType;
    m_csmSolveList = other.m_csmSolveList;
    m_instrumentPointingSolveOption = other.m_instrumentPointingSolveOption;
    m_observationNumbers = other.m_observationNumbers;
    m_numberCamAngleCoefSolved = other.m_numberCamAngleCoefSolved;
@@ -320,6 +305,12 @@ namespace Isis {
      m_instrumentId = other.m_instrumentId;
      m_observationNumbers = other.m_observationNumbers;

      // CSM related
      m_csmSolveOption = other.m_csmSolveOption;
      m_csmSolveSet = other.m_csmSolveSet;
      m_csmSolveType = other.m_csmSolveType;
      m_csmSolveList = other.m_csmSolveList;

      // pointing related
      m_instrumentPointingSolveOption = other.m_instrumentPointingSolveOption;
      m_numberCamAngleCoefSolved = other.m_numberCamAngleCoefSolved;
@@ -355,6 +346,12 @@ namespace Isis {

    m_instrumentId = "";

    // CSM solve options
    m_csmSolveOption = BundleObservationSolveSettings::NoCSMParameters;
    m_csmSolveSet = csm::param::ADJUSTABLE;
    m_csmSolveType = csm::param::REAL;
    m_csmSolveList = QStringList();

    // Camera Pointing Options
    // Defaults:
    //     m_instrumentPointingSolveOption = AnglesOnly;
@@ -441,6 +438,93 @@ namespace Isis {
  }


  // =============================================================================================//
  // ======================== CSM Options ========================================================//
  // =============================================================================================//


  BundleObservationSolveSettings::CSMSolveOption 
      BundleObservationSolveSettings::stringToCSMSolveOption(QString option) {
    if (option.compare("NoCSMParameters", Qt::CaseInsensitive) == 0) {
      return BundleObservationSolveSettings::NoCSMParameters;
    }
    else if (option.compare("Set", Qt::CaseInsensitive) == 0) {
      return BundleObservationSolveSettings::Set;
    }
    else if (option.compare("Type", Qt::CaseInsensitive) == 0) {
      return BundleObservationSolveSettings::Type;
    }
    else if (option.compare("List", Qt::CaseInsensitive) == 0) {
      return BundleObservationSolveSettings::List;
    }
    else {
      throw IException(IException::Unknown,
                       "Unknown bundle CSM solve option " + option + ".",
                       _FILEINFO_);
    }
  }


  QString BundleObservationSolveSettings::csmSolveOptionToString(CSMSolveOption option) {
    if (option == BundleObservationSolveSettings::NoCSMParameters) {
      return "NoCSMParameters";
    }
    else if (option == BundleObservationSolveSettings::Set)  {
      return "Set";
    }
    else if (option == BundleObservationSolveSettings::Type) {
      return "Type";
    }
    else if (option == BundleObservationSolveSettings::List) {
      return "List";
    }
    else {
      throw IException(IException::Programmer,
                       "Unknown CSM solve option enum [" + toString(option) + "].",
                       _FILEINFO_);
    }
  }


  void BundleObservationSolveSettings::setCSMSolveSet(csm::param::Set set) {
    m_csmSolveOption = BundleObservationSolveSettings::Set;
    m_csmSolveSet = set;
  }


  void BundleObservationSolveSettings::setCSMSolveType(csm::param::Type type) {
    m_csmSolveOption = BundleObservationSolveSettings::Type;
    m_csmSolveType = type;
  }


  void BundleObservationSolveSettings::setCSMSolveParameterList(QStringList list) {
    m_csmSolveOption = BundleObservationSolveSettings::List;
    m_csmSolveList = list;
  }


  BundleObservationSolveSettings::CSMSolveOption
      BundleObservationSolveSettings::csmSolveOption() const {
    return m_csmSolveOption;
  }


  csm::param::Set BundleObservationSolveSettings::csmParameterSet() const {
    return m_csmSolveSet;
  }


  csm::param::Type BundleObservationSolveSettings::csmParameterType() const {
    return m_csmSolveType;
  }


  QStringList BundleObservationSolveSettings::csmParameterList() const {
    return m_csmSolveList;
  }


  // =============================================================================================//
  // ======================== Camera Pointing Options ============================================//
  // =============================================================================================//
+25 −0
Original line number Diff line number Diff line
@@ -12,6 +12,9 @@ find files of those names at the top level of this repository. **/
#include <QList>
#include <QSet>
#include <QString>
#include <QStringList>

#include <csm.h>

#include "SpicePosition.h"
#include "SpiceRotation.h"
@@ -97,7 +100,23 @@ class BundleObservationSolveSettings {
      bool removeObservationNumber(QString observationNumber);
      QSet<QString> observationNumbers() const;

      //! Options for how to solve for CSM parameters.
      enum CSMSolveOption {
        NoCSMParameters = 0, /**< Do not solve for CSM parameters.*/
        Set             = 1, /**< Solve for all CSM parameters belonging to a specific set.*/
        Type            = 2, /**< Solve for all CSM parameters of a specific type.*/
        List            = 3  /**< Solve for an explicit list of CSM parameters.*/
      };

      static CSMSolveOption stringToCSMSolveOption(QString option);
      static QString csmSolveOptionToString(CSMSolveOption option);
      void setCSMSolveSet(csm::param::Set set);
      void setCSMSolveType(csm::param::Type type);
      void setCSMSolveParameterList(QStringList list);
      CSMSolveOption csmSolveOption() const;
      csm::param::Set csmParameterSet() const;
      csm::param::Type csmParameterType() const;
      QStringList csmParameterList() const;

      //! Options for how to solve for instrument pointing.
      enum InstrumentPointingSolveOption {
@@ -203,6 +222,12 @@ class BundleObservationSolveSettings {
      QString m_instrumentId;               //!< The spacecraft instrument id for this observation.
      QSet<QString> m_observationNumbers;  //!< Associated observation numbers for these settings.

      // CSM related parameters
      CSMSolveOption m_csmSolveOption;
      csm::param::Set m_csmSolveSet;
      csm::param::Type m_csmSolveType;
      QStringList m_csmSolveList;

      // pointing related parameters
      //! Option for how to solve for instrument pointing.
      InstrumentPointingSolveOption m_instrumentPointingSolveOption;
+19 −11
Original line number Diff line number Diff line
@@ -95,27 +95,35 @@ namespace Isis {
   * @param solveSettings The solve settings to use
   *
   * @return @b bool Returns true if settings were successfully set
   *
   * @internal
   *   @todo initParameterWeights() doesn't return false, so this methods always
   *         returns true.
   */
  bool CsmBundleObservation::setSolveSettings(CsmBundleObservationSolveSettingsQsp solveSettings) {
    // TODO implement for CSM

  bool CsmBundleObservation::setSolveSettings(BundleObservationSolveSettingsQsp solveSettings) {
    m_solveSettings = solveSettings;

    CSMCamera *csmCamera = dynamic_cast<CSMCamera*>(front()->camera());

    m_paramIndices = csmCamera->getParameterIndices(solveSettings->solveSet());
    m_paramIndices.clear();
    m_weights.clear();
    m_corrections.clear();
    m_adjustedSigmas.clear();

    if (solveSettings->csmSolveOption() == BundleObservationSolveSettings::Set) {
      m_paramIndices = csmCamera->getParameterIndices(solveSettings->csmParameterSet());
    }
    else if (solveSettings->csmSolveOption() == BundleObservationSolveSettings::Type) {
      m_paramIndices = csmCamera->getParameterIndices(solveSettings->csmParameterType());
    }
    else if (solveSettings->csmSolveOption() == BundleObservationSolveSettings::List) {
      m_paramIndices = csmCamera->getParameterIndices(solveSettings->csmParameterList());
    }
    else {
      return false;
    }

    int nParams = m_paramIndices.size();

    m_weights.resize(nParams);
    m_weights.clear();
    m_corrections.resize(nParams);
    m_corrections.clear();
    m_adjustedSigmas.resize(nParams);
    m_adjustedSigmas.clear();
    m_aprioriSigmas.resize(nParams);

    for (int i = 0; i < nParams; i++) {
Loading