Skip to content

Commit

Permalink
Csm clean up (#4483)
Browse files Browse the repository at this point in the history
* Added cms index list error

* Added CSMCameraTests for partials

* Observation clean-up

* Cleaned up vector
  • Loading branch information
jessemapel committed Jun 17, 2021
1 parent b885f17 commit 34aa246
Show file tree
Hide file tree
Showing 9 changed files with 260 additions and 95 deletions.
14 changes: 14 additions & 0 deletions isis/src/base/objs/CSMCamera/CSMCamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -861,14 +861,28 @@ namespace Isis {
*/
std::vector<int> CSMCamera::getParameterIndices(QStringList paramList) const {
std::vector<int> parameterIndices;
QStringList failedParams;
for (int i = 0; i < paramList.size(); i++) {
bool found = false;
for (int j = 0; j < m_model->getNumParameters(); j++) {
if (QString::compare(QString::fromStdString(m_model->getParameterName(j)).trimmed(),
paramList[i].trimmed(),
Qt::CaseInsensitive) == 0) {
parameterIndices.push_back(j);
found = true;
break;
}
}

if (!found) {
failedParams.push_back(paramList[i]);
}
}

if (!failedParams.empty()) {
QString msg = "Failed to find indices for the following parameters [" +
failedParams.join(",") + "].";
throw IException(IException::User, msg, _FILEINFO_);
}
return parameterIndices;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,28 +209,6 @@ namespace Isis {
}


/**
* Applies the parameter corrections
*
* @param corrections Vector of corrections to apply
*
* @throws IException::Unknown "Instrument position is NULL, but position solve option is
* [not NoPositionFactors]"
* @throws IException::Unknown "Instrument position is NULL, but pointing solve option is
* [not NoPointingFactors]"
* @throws IException::Unknown "Unable to apply parameter corrections to AbstractBundleObservation."
*
* @return @b bool Returns true upon successful application of corrections
*
* @internal
* @todo always returns true?
*/
// FIXME: can this work at parent level or should be pure virtual?
bool AbstractBundleObservation::applyParameterCorrections(LinearAlgebra::Vector corrections) {
return false;
}


/**
* Sets the index for the observation
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace Isis {

virtual const BundleObservationSolveSettingsQsp solveSettings() = 0;
virtual int numberParameters() = 0;
virtual bool applyParameterCorrections(LinearAlgebra::Vector corrections);
virtual bool applyParameterCorrections(LinearAlgebra::Vector corrections) = 0;

virtual void bundleOutputString(std::ostream &fpOut,bool errorPropagation) = 0;
virtual QString bundleOutputCSV(bool errorPropagation) = 0;
Expand All @@ -87,17 +87,16 @@ namespace Isis {
protected:
QString m_observationNumber; /**< This is typically equivalent to serial number
except in the case of "observation mode" (e.g.
Lunar Orbiter) where for each image in the
observation, the observation number is the serial number
augmented with an additional integer. **/
Lunar Orbiter) where the observation number is
the portion of the serial number shared between
all of the images in the observation. **/
int m_index; //!< Index of this observation.
//! Map between cube serial number and BundleImage pointers.
QMap<QString, BundleImageQsp> m_cubeSerialNumberToBundleImageMap;
QStringList m_serialNumbers; //!< List of all cube serial numbers in observation.
QStringList m_imageNames; //!< List of all cube names.
QString m_instrumentId; //!< Spacecraft instrument id.

// TODO??? change these to LinearAlgebra vectors...
LinearAlgebra::Vector m_weights; //!< Parameter weights.
//! Cumulative parameter correction vector.
LinearAlgebra::Vector m_corrections;
Expand Down
40 changes: 18 additions & 22 deletions isis/src/control/objs/BundleUtilities/BundleObservation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ namespace Isis {
BundleObservation::BundleObservation() {
m_instrumentPosition = NULL;
m_instrumentRotation = NULL;
// m_solveSettings?
// m_bundleTargetBody ?
}


Expand All @@ -49,7 +47,8 @@ namespace Isis {
* @param bundleTargetBody QSharedPointer to the target body of the observation
*/
BundleObservation::BundleObservation(BundleImageQsp image, QString observationNumber,
QString instrumentId, BundleTargetBodyQsp bundleTargetBody) : AbstractBundleObservation(image, observationNumber, instrumentId, bundleTargetBody) {
QString instrumentId, BundleTargetBodyQsp bundleTargetBody) :
AbstractBundleObservation(image, observationNumber, instrumentId, bundleTargetBody) {
m_bundleTargetBody = bundleTargetBody;
m_instrumentRotation = NULL;
m_instrumentPosition = NULL;
Expand All @@ -66,10 +65,6 @@ namespace Isis {
(image->camera()->instrumentRotation() ?
image->camera()->instrumentRotation() : NULL)
: NULL);

// set the observations target body spice rotation object from the primary image in the
// observation (this is, by design at the moment, the first image added to the observation)
// if the image, camera, or instrument position/orientation is null, then set to null
}
}

Expand All @@ -83,7 +78,7 @@ namespace Isis {
m_instrumentPosition = src.m_instrumentPosition;
m_instrumentRotation = src.m_instrumentRotation;
m_solveSettings = src.m_solveSettings;
// why not m_targetBody?
m_bundleTargetBody = src.m_bundleTargetBody;
}


Expand Down Expand Up @@ -111,7 +106,7 @@ namespace Isis {
m_instrumentPosition = src.m_instrumentPosition;
m_instrumentRotation = src.m_instrumentRotation;
m_solveSettings = src.m_solveSettings;
// why not m_targetBody?
m_bundleTargetBody = src.m_bundleTargetBody;
}
return *this;
}
Expand Down Expand Up @@ -148,12 +143,11 @@ namespace Isis {
m_adjustedSigmas.resize(nParameters);
m_adjustedSigmas.clear();
m_aprioriSigmas.resize(nParameters);
for ( int i = 0; i < nParameters; i++) // initialize apriori sigmas to -1.0
for ( int i = 0; i < nParameters; i++) {
m_aprioriSigmas[i] = Isis::Null;
}

if (!initParameterWeights()) {
// TODO: some message here!!!!!!!!!!!
// TODO: do we need this??? initParameterWeights() never returns false...
return false;
}

Expand Down Expand Up @@ -212,25 +206,26 @@ namespace Isis {
BundleImageQsp image = at(i);
SpicePosition *spicePosition = image->camera()->instrumentPosition();

// If this image isn't the first, copy the position from the first
if (i > 0) {
spicePosition->SetPolynomialDegree(m_solveSettings->spkSolveDegree());
spicePosition->SetOverrideBaseTime(positionBaseTime, positiontimeScale);
spicePosition->SetPolynomial(posPoly1, posPoly2, posPoly3,
m_solveSettings->positionInterpolationType());
}
// Otherwise we need to fit the initial position
else {
// first, set the degree of the spk polynomial to be fit for a priori values
spicePosition->SetPolynomialDegree(m_solveSettings->spkDegree());

// now, set what kind of interpolation to use (SPICE, memcache, hermitecache, polynomial
// function, or polynomial function over constant hermite spline)
// TODO: verify - I think this actually performs the a priori fit
// now, set what kind of interpolation to use (polynomial function or
// polynomial function over hermite spline)
spicePosition->SetPolynomial(m_solveSettings->positionInterpolationType());

// finally, set the degree of the spk polynomial actually used in the bundle adjustment
// finally, set the degree of the position polynomial actually used in the bundle adjustment
spicePosition->SetPolynomialDegree(m_solveSettings->spkSolveDegree());

if (m_instrumentPosition) { // ??? TODO: why is this different from rotation code below???
if (m_instrumentPosition) {
positionBaseTime = m_instrumentPosition->GetBaseTime();
positiontimeScale = m_instrumentPosition->GetTimeScale();
m_instrumentPosition->GetPolynomial(posPoly1, posPoly2, posPoly3);
Expand All @@ -250,22 +245,23 @@ namespace Isis {
BundleImageQsp image = at(i);
SpiceRotation *spicerotation = image->camera()->instrumentRotation();

// If this image isn't the first, copy the pointing from the first
if (i > 0) {
spicerotation->SetPolynomialDegree(m_solveSettings->ckSolveDegree());
spicerotation->SetOverrideBaseTime(rotationBaseTime, rotationtimeScale);
spicerotation->SetPolynomial(anglePoly1, anglePoly2, anglePoly3,
m_solveSettings->pointingInterpolationType());
}
// Otherwise we need to fit the initial pointing
else {
// first, set the degree of the spk polynomial to be fit for a priori values
// first, set the degree of the polynomial to be fit for a priori values
spicerotation->SetPolynomialDegree(m_solveSettings->ckDegree());

// now, set what kind of interpolation to use (SPICE, memcache, hermitecache, polynomial
// function, or polynomial function over constant hermite spline)
// TODO: verify - I think this actually performs the a priori fit
// now, set what kind of interpolation to use (polynomial function or
// polynomial function over a pointing cache)
spicerotation->SetPolynomial(m_solveSettings->pointingInterpolationType());

// finally, set the degree of the spk polynomial actually used in the bundle adjustment
// finally, set the degree of the pointing polynomial actually used in the bundle adjustment
spicerotation->SetPolynomialDegree(m_solveSettings->ckSolveDegree());

rotationBaseTime = spicerotation->GetBaseTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,13 @@ namespace Isis {
// =============================================================================================//


/**
* Convert a string to a CSM solve option enumeration value.
*
* @param option The option as a string
*
* @return @b CSMSolveOption The option's enumeration value
*/
BundleObservationSolveSettings::CSMSolveOption
BundleObservationSolveSettings::stringToCSMSolveOption(QString option) {
if (option.compare("NoCSMParameters", Qt::CaseInsensitive) == 0) {
Expand All @@ -481,6 +488,13 @@ namespace Isis {
}


/**
* Convert a CSM solve option enumeration value to a string.
*
* @param option The option's enumeration value
*
* @return @b QString The option as a string
*/
QString BundleObservationSolveSettings::csmSolveOptionToString(CSMSolveOption option) {
if (option == BundleObservationSolveSettings::NoCSMParameters) {
return "NoCSMParameters";
Expand All @@ -502,7 +516,13 @@ namespace Isis {
}



/**
* Convert a string to its CSM parameter set enumeration value.
*
* @param set The set name
*
* @return @b csm::param::Set The set's enumeration value
*/
csm::param::Set BundleObservationSolveSettings::stringToCSMSolveSet(QString set) {
if (set.compare("VALID", Qt::CaseInsensitive) == 0) {
return csm::param::VALID;
Expand All @@ -520,6 +540,14 @@ namespace Isis {
}
}


/**
* Convert a CSM parameter set enumeration value to a string.
*
* @param set The set's enumeration value
*
* @return @b QString The set's name
*/
QString BundleObservationSolveSettings::csmSolveSetToString(csm::param::Set set) {
if (set == csm::param::VALID) {
return "VALID";
Expand All @@ -538,6 +566,13 @@ namespace Isis {
}


/**
* Convert a string to its CSM parameter type enumeration value.
*
* @param type The type name
*
* @return @b csm::param::Type The types's enumeration value
*/
csm::param::Type BundleObservationSolveSettings::stringToCSMSolveType(QString type) {
if (type.compare("NONE", Qt::CaseInsensitive) == 0) {
return csm::param::NONE;
Expand All @@ -559,6 +594,13 @@ namespace Isis {
}


/**
* Convert a CSM parameter type enumeration value to a string.
*
* @param type The type's enumeration value
*
* @return @b QString The type's name
*/
QString BundleObservationSolveSettings::csmSolveTypeToString(csm::param::Type type) {
if (type == csm::param::NONE) {
return "NONE";
Expand All @@ -580,40 +622,76 @@ namespace Isis {
}


/**
* Set the set of CSM parameters to solve for. See the CSM API documentation
* for what the different set values mean.
*
* @param set The set to solve for
*/
void BundleObservationSolveSettings::setCSMSolveSet(csm::param::Set set) {
m_csmSolveOption = BundleObservationSolveSettings::Set;
m_csmSolveSet = set;
}


/**
* Set the type of CSM parameters to solve for.
*
* @param type The parameter type to solve for
*/
void BundleObservationSolveSettings::setCSMSolveType(csm::param::Type type) {
m_csmSolveOption = BundleObservationSolveSettings::Type;
m_csmSolveType = type;
}


/**
* Set an explicit list of CSM parameters to solve for.
*
* @param list The names of the parameters to solve for
*/
void BundleObservationSolveSettings::setCSMSolveParameterList(QStringList list) {
m_csmSolveOption = BundleObservationSolveSettings::List;
m_csmSolveList = list;
}


/**
* Get how the CSM parameters to solve for are specified for this observation.
*
* @return @b CSMSolveOption
*/
BundleObservationSolveSettings::CSMSolveOption
BundleObservationSolveSettings::csmSolveOption() const {
return m_csmSolveOption;
}


/**
* Get the set of CSM parameters to solve for
*
* @return @b csm::param::Set The CSM parameter set to solve for
*/
csm::param::Set BundleObservationSolveSettings::csmParameterSet() const {
return m_csmSolveSet;
}


/**
* Get the type of CSM parameters to solve for
*
* @return @b csm::param::Type The CSM parameter type to solve for
*/
csm::param::Type BundleObservationSolveSettings::csmParameterType() const {
return m_csmSolveType;
}


/**
* Get the list of CSM parameters to solve for
*
* @return @b QStringList The names of the CSM parameters to solve for
*/
QStringList BundleObservationSolveSettings::csmParameterList() const {
return m_csmSolveList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,13 @@ class BundleObservationSolveSettings {
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;
CSMSolveOption m_csmSolveOption; //!< How the CSM solution is specified
csm::param::Set m_csmSolveSet; /**< The CSM parameter set to solve for. Only valid
if the solve option is Set.*/
csm::param::Type m_csmSolveType; /**< The CSM parameter type to solve for. Only valid
if the solve option is Type.*/
QStringList m_csmSolveList; /**< The names of the CSM parameters to solve for. Only
valid if the solve option is List.*/

// pointing related parameters
//! Option for how to solve for instrument pointing.
Expand Down
Loading

0 comments on commit 34aa246

Please sign in to comment.