9#include "BundleObservationSolveSettings.h"
18#include <QXmlInputSource>
19#include <QXmlStreamWriter>
21#include "BundleImage.h"
24#include "IException.h"
27#include "PvlKeyword.h"
50 readSolveSettings(xmlReader);
61 if (scParameterGroup.hasKeyword(
"CKDEGREE")) {
62 m_ckDegree = (int)(scParameterGroup.findKeyword(
"CKDEGREE"));
66 if (scParameterGroup.hasKeyword(
"CKSOLVEDEGREE")) {
67 m_ckSolveDegree = (int) (scParameterGroup.findKeyword(
"CKSOLVEDEGREE"));
72 QString csolve =
"NONE";
73 csolve = (QString)scParameterGroup.findKeyword(
"CAMSOLVE");
74 csolve = csolve.toUpper();
75 if (csolve ==
"NONE") {
79 else if (csolve ==
"ANGLES") {
83 else if (csolve ==
"VELOCITIES") {
87 else if (csolve ==
"ACCELERATIONS") {
91 else if (csolve ==
"ALL"){
97 if (scParameterGroup.hasKeyword(
"OVEREXISTING")) {
98 QString parval = (QString)scParameterGroup.findKeyword(
"OVEREXISTING");
99 parval = parval.toUpper();
100 if (parval ==
"TRUE" || parval ==
"YES") {
104 else if (parval ==
"FALSE" || parval ==
"NO") {
109 QString msg =
"The OVEREXISTING parameter must be set to TRUE or FALSE; YES or NO";
115 if (scParameterGroup.hasKeyword(
"SPKDEGREE"))
116 m_spkDegree = (int)(scParameterGroup.findKeyword(
"SPKDEGREE"));
119 if (scParameterGroup.hasKeyword(
"SPKSOLVEDEGREE"))
124 QString ssolve =
"NONE";
125 ssolve = (QString)scParameterGroup.findKeyword(
"SPSOLVE");
126 ssolve = ssolve.toUpper();
127 if (ssolve ==
"NONE") {
131 else if (ssolve ==
"POSITION") {
135 else if (ssolve ==
"VELOCITIES") {
139 else if (ssolve ==
"ACCELERATIONS") {
143 else if (csolve ==
"ALL"){
149 if (scParameterGroup.hasKeyword(
"TWIST")) {
150 QString parval = (QString)scParameterGroup.findKeyword(
"TWIST");
151 parval = parval.toUpper();
152 if (parval ==
"TRUE" || parval ==
"YES") {
155 else if (parval ==
"FALSE" || parval ==
"NO") {
159 QString msg =
"The TWIST parameter must be set to TRUE or FALSE; YES or NO";
164 if (scParameterGroup.hasKeyword(
"OVERHERMITE")) {
165 QString parval = (QString)scParameterGroup.findKeyword(
"OVERHERMITE");
166 parval = parval.toUpper();
167 if (parval ==
"TRUE" || parval ==
"YES") {
171 else if (parval ==
"FALSE" || parval ==
"NO") {
176 QString msg =
"The OVERHERMITE parameter must be set to TRUE or FALSE; YES or NO";
182 if (scParameterGroup.hasKeyword(
"CAMERA_ANGLES_SIGMA")) {
188 if (scParameterGroup.hasKeyword(
"CAMERA_ANGULAR_VELOCITY_SIGMA")){
190 (
double)(scParameterGroup.findKeyword(
"CAMERA_ANGULAR_VELOCITY_SIGMA")));
195 if (scParameterGroup.hasKeyword(
"CAMERA_ANGULAR_ACCELERATION_SIGMA")){
197 (
double)(scParameterGroup.findKeyword(
"CAMERA_ANGULAR_ACCELERATION_SIGMA")));
202 if (scParameterGroup.hasKeyword(
"ADDITIONAL_CAMERA_POINTING_SIGMAS")) {
203 PvlKeyword additionalSigmas = scParameterGroup.findKeyword(
"ADDITIONAL_CAMERA_POINTING_SIGMAS");
204 for (
int i = 0; i < additionalSigmas.size(); i++ ) {
211 if (scParameterGroup.hasKeyword(
"SPACECRAFT_POSITION_SIGMA")) {
217 if (scParameterGroup.hasKeyword(
"SPACECRAFT_VELOCITY_SIGMA")){
223 if (scParameterGroup.hasKeyword(
"SPACECRAFT_ACCELERATION_SIGMA")) {
229 if (scParameterGroup.hasKeyword(
"ADDITIONAL_SPACECRAFT_POSITION_SIGMAS")) {
230 PvlKeyword additionalSigmas = scParameterGroup.findKeyword(
"ADDITIONAL_SPACECRAFT_POSITION_SIGMAS");
231 for (
int i = 0; i < additionalSigmas.size(); i++ ) {
238 if (scParameterGroup.hasKeyword(
"CSMSOLVESET")) {
241 else if (scParameterGroup.hasKeyword(
"CSMSOLVETYPE")) {
244 else if (scParameterGroup.hasKeyword(
"CSMSOLVELIST")) {
245 PvlKeyword csmSolveListKey = scParameterGroup.findKeyword(
"CSMSOLVELIST");
247 for (
int i = 0; i < csmSolveListKey.size(); i++) {
248 csmSolveList.append(csmSolveListKey[i]);
263 m_id =
new QUuid(other.m_id->toString());
312 if (&other !=
this) {
315 m_id =
new QUuid(other.m_id->toString());
357 m_id =
new QUuid(QUuid::createUuid());
467 if (option.compare(
"NoCSMParameters", Qt::CaseInsensitive) == 0) {
470 else if (option.compare(
"Set", Qt::CaseInsensitive) == 0) {
473 else if (option.compare(
"Type", Qt::CaseInsensitive) == 0) {
476 else if (option.compare(
"List", Qt::CaseInsensitive) == 0) {
481 "Unknown bundle CSM solve option " + option +
".",
496 return "NoCSMParameters";
509 "Unknown CSM solve option enum [" +
toString(option) +
"].",
523 if (set.compare(
"VALID", Qt::CaseInsensitive) == 0) {
524 return csm::param::VALID;
526 else if (set.compare(
"ADJUSTABLE", Qt::CaseInsensitive) == 0) {
527 return csm::param::ADJUSTABLE;
529 else if (set.compare(
"NON_ADJUSTABLE", Qt::CaseInsensitive) == 0) {
530 return csm::param::NON_ADJUSTABLE;
534 "Unknown bundle CSM parameter set " + set +
".",
548 if (set == csm::param::VALID) {
551 else if (set == csm::param::ADJUSTABLE) {
554 else if (set == csm::param::NON_ADJUSTABLE) {
555 return "NON_ADJUSTABLE";
559 "Unknown CSM parameter set enum [" +
toString(set) +
"].",
573 if (type.compare(
"NONE", Qt::CaseInsensitive) == 0) {
574 return csm::param::NONE;
576 else if (type.compare(
"FICTITIOUS", Qt::CaseInsensitive) == 0) {
577 return csm::param::FICTITIOUS;
579 else if (type.compare(
"REAL", Qt::CaseInsensitive) == 0) {
580 return csm::param::REAL;
582 else if (type.compare(
"FIXED", Qt::CaseInsensitive) == 0) {
583 return csm::param::FIXED;
587 "Unknown bundle CSM parameter type " + type +
".",
601 if (type == csm::param::NONE) {
604 else if (type == csm::param::FICTITIOUS) {
607 else if (type == csm::param::REAL) {
610 else if (type == csm::param::FIXED) {
615 "Unknown CSM parameter type enum [" +
toString(type) +
"].",
713 if (option.compare(
"NONE", Qt::CaseInsensitive) == 0) {
716 else if (option.compare(
"NoPointingFactors", Qt::CaseInsensitive) == 0) {
719 else if (option.compare(
"ANGLES", Qt::CaseInsensitive) == 0) {
722 else if (option.compare(
"AnglesOnly", Qt::CaseInsensitive) == 0) {
725 else if (option.compare(
"VELOCITIES", Qt::CaseInsensitive) == 0) {
728 else if (option.compare(
"AnglesAndVelocity", Qt::CaseInsensitive) == 0) {
731 else if (option.compare(
"ACCELERATIONS", Qt::CaseInsensitive) == 0) {
734 else if (option.compare(
"AnglesVelocityAndAcceleration", Qt::CaseInsensitive) == 0) {
737 else if (option.compare(
"ALL", Qt::CaseInsensitive) == 0) {
740 else if (option.compare(
"AllPolynomialCoefficients", Qt::CaseInsensitive) == 0) {
745 "Unknown bundle instrument pointing solve option " + option +
".",
764 else if (option ==
AnglesOnly)
return "AnglesOnly";
769 "Unknown pointing solve option enum [" +
toString(option) +
"].",
792 bool solvePolynomialOverExisting,
793 double anglesAprioriSigma,
794 double angularVelocityAprioriSigma,
795 double angularAccelerationAprioriSigma,QList<double> * additionalPointingSigmas) {
822 if (anglesAprioriSigma > 0.0) {
830 if (angularVelocityAprioriSigma > 0.0) {
838 if (angularAccelerationAprioriSigma > 0.0) {
848 if (additionalPointingSigmas) {
849 for (
int i=0;i < additionalPointingSigmas->count();i++) {
973 if (option.compare(
"NONE", Qt::CaseInsensitive) == 0) {
976 else if (option.compare(
"NoPositionFactors", Qt::CaseInsensitive) == 0) {
979 else if (option.compare(
"POSITIONS", Qt::CaseInsensitive) == 0) {
982 else if (option.compare(
"PositionOnly", Qt::CaseInsensitive) == 0) {
985 else if (option.compare(
"VELOCITIES", Qt::CaseInsensitive) == 0) {
988 else if (option.compare(
"PositionAndVelocity", Qt::CaseInsensitive) == 0) {
991 else if (option.compare(
"ACCELERATIONS", Qt::CaseInsensitive) == 0) {
994 else if (option.compare(
"PositionVelocityAndAcceleration", Qt::CaseInsensitive) == 0) {
997 else if (option.compare(
"ALL", Qt::CaseInsensitive) == 0) {
1000 else if (option.compare(
"AllPolynomialCoefficients", Qt::CaseInsensitive) == 0) {
1005 "Unknown bundle instrument position solve option " + option +
".",
1024 else if (option ==
PositionOnly)
return "PositionOnly";
1029 "Unknown position solve option enum [" +
toString(option) +
"].",
1049 bool positionOverHermite,
1050 double positionAprioriSigma,
1051 double velocityAprioriSigma,
1052 double accelerationAprioriSigma,
1053 QList<double> *additionalPositionSigmas) {
1078 if (positionAprioriSigma > 0.0) {
1086 if (velocityAprioriSigma > 0.0) {
1094 if (accelerationAprioriSigma > 0.0) {
1104 if (additionalPositionSigmas) {
1105 for (
int i=0;i < additionalPositionSigmas->count();i++) {
1211 const Project *project)
const {
1213 stream.writeStartElement(
"bundleObservationSolveSettings");
1214 stream.writeTextElement(
"id",
m_id->toString());
1215 stream.writeTextElement(
"instrumentId",
instrumentId());
1218 stream.writeStartElement(
"instrumentPointingOptions");
1219 stream.writeAttribute(
"solveOption",
1228 stream.writeStartElement(
"aprioriPointingSigmas");
1231 stream.writeTextElement(
"sigma",
"N/A");
1237 stream.writeEndElement();
1238 stream.writeEndElement();
1241 stream.writeStartElement(
"instrumentPositionOptions");
1242 stream.writeAttribute(
"solveOption",
1250 stream.writeStartElement(
"aprioriPositionSigmas");
1253 stream.writeTextElement(
"sigma",
"N/A");
1259 stream.writeEndElement();
1260 stream.writeEndElement();
1262 stream.writeEndElement();
1266 void BundleObservationSolveSettings::readSolveSettings(QXmlStreamReader *xmlReader) {
1268 Q_ASSERT(xmlReader->name() ==
"bundleObservationSolveSettings");
1269 while (xmlReader->readNextStartElement()) {
1270 if (xmlReader->qualifiedName() ==
"instrumentId") {
1276 else if (xmlReader->qualifiedName() ==
"instrumentPointingOptions") {
1277 QStringRef solveOption = xmlReader->attributes().value(
"solveOption");
1278 if (!solveOption.isEmpty()) {
1281 QStringRef numberCoefSolved = xmlReader->attributes().value(
"numberCoefSolved");
1282 if (!numberCoefSolved.isEmpty()) {
1285 QStringRef degree = xmlReader->attributes().value(
"degree");
1286 if (!degree.isEmpty()) {
1289 QStringRef solveDegree = xmlReader->attributes().value(
"solveDegree");
1290 if (!solveDegree.isEmpty()) {
1293 QStringRef
solveTwist = xmlReader->attributes().value(
"solveTwist");
1297 QStringRef solveOverExisting = xmlReader->attributes().value(
"solveOverExisting");
1298 if (!solveOverExisting.isEmpty()) {
1301 QStringRef interpolationType = xmlReader->attributes().value(
"interpolationType");
1302 if (!interpolationType.isEmpty()) {
1303 if (interpolationType ==
"3") {
1306 else if (interpolationType ==
"4") {
1310 while (xmlReader->readNextStartElement()) {
1311 if (xmlReader->qualifiedName() ==
"aprioriPointingSigmas") {
1313 while (xmlReader->readNextStartElement()) {
1314 if (xmlReader->qualifiedName() ==
"sigma") {
1315 QString sigma = xmlReader->readElementText();
1316 if (!sigma.isEmpty()){
1317 if (sigma ==
"N/A") {
1326 xmlReader->skipCurrentElement();
1331 xmlReader->skipCurrentElement();
1335 else if (xmlReader->qualifiedName() ==
"instrumentPositionOptions") {
1336 QStringRef solveOption = xmlReader->attributes().value(
"solveOption");
1337 if (!solveOption.isEmpty()) {
1340 QStringRef numberCoefSolved = xmlReader->attributes().value(
"numberCoefSolved");
1341 if (!numberCoefSolved.isEmpty()) {
1344 QStringRef degree = xmlReader->attributes().value(
"degree");
1345 if (!degree.isEmpty()) {
1348 QStringRef solveDegree = xmlReader->attributes().value(
"solveDegree");
1349 if (!solveDegree.isEmpty()) {
1352 QStringRef solveOverHermiteSpline = xmlReader->attributes().value(
"solveOverHermiteSpline");
1353 if (!solveOverHermiteSpline.isEmpty()) {
1356 QStringRef interpolationType = xmlReader->attributes().value(
"interpolationType");
1357 if (!interpolationType.isEmpty()) {
1358 if (interpolationType ==
"3") {
1361 else if (interpolationType ==
"4") {
1365 while (xmlReader->readNextStartElement()) {
1366 if (xmlReader->qualifiedName() ==
"aprioriPositionSigmas") {
1368 while (xmlReader->readNextStartElement()) {
1369 if (xmlReader->qualifiedName() ==
"sigma") {
1370 QString sigma = xmlReader->readElementText();
1371 if (!sigma.isEmpty()){
1372 if (sigma ==
"N/A") {
1382 xmlReader->skipCurrentElement();
1387 xmlReader->skipCurrentElement();
1392 xmlReader->skipCurrentElement();
This class is used to modify and manage solve settings for 1 to many BundleObservations.
CSMSolveOption
Options for how to solve for CSM parameters.
@ NoCSMParameters
Do not solve for CSM parameters.
@ Set
Solve for all CSM parameters belonging to a specific set.
@ Type
Solve for all CSM parameters of a specific type.
@ List
Solve for an explicit list of CSM parameters.
static InstrumentPointingSolveOption stringToInstrumentPointingSolveOption(QString option)
Translates a QString InstrumentPointingSolveOption to its enumerated value.
InstrumentPositionSolveOption
Options for how to solve for instrument position.
@ PositionVelocity
Solve for instrument positions and velocities.
@ PositionVelocityAcceleration
Solve for instrument positions, velocities, and accelerations.
@ AllPositionCoefficients
Solve for all coefficients in the polynomials fit to the instrument positions.
@ PositionOnly
Solve for instrument positions only.
@ NoPositionFactors
Solve for none of the position factors.
static QString csmSolveTypeToString(csm::param::Type type)
Convert a CSM parameter type enumeration value to a string.
csm::param::Type m_csmSolveType
The CSM parameter type to solve for.
SpicePosition::Source m_positionInterpolationType
SpicePosition interpolation types.
CSMSolveOption csmSolveOption() const
Get how the CSM parameters to solve for are specified for this observation.
CSMSolveOption m_csmSolveOption
How the CSM solution is specified.
void addObservationNumber(QString observationNumber)
Associates an observation number with these solve settings.
~BundleObservationSolveSettings()
Destructor.
InstrumentPositionSolveOption instrumentPositionSolveOption() const
Accesses the instrument position solve option.
int m_numberCamAngleCoefSolved
The number of camera angle coefficients in solution.
void initialize()
Initializes the default state of this BundleObservationSolveSettings.
bool solveTwist() const
Accesses the flag for solving for twist.
void setCSMSolveType(csm::param::Type type)
Set the type of CSM parameters to solve for.
static QString csmSolveOptionToString(CSMSolveOption option)
Convert a CSM solve option enumeration value to a string.
int m_numberCamPosCoefSolved
The number of camera position coefficients in the solution.
BundleObservationSolveSettings & operator=(const BundleObservationSolveSettings &src)
Assigns the state of another BundleObservationSolveSettings to this one.
static csm::param::Set stringToCSMSolveSet(QString set)
Convert a string to its CSM parameter set enumeration value.
csm::param::Set csmParameterSet() const
Get the set of CSM parameters to solve for.
bool m_solvePositionOverHermiteSpline
The polynomial will be fit over an existing Hermite spline.
void setCSMSolveSet(csm::param::Set set)
Set the set of CSM parameters to solve for.
SpiceRotation::Source m_pointingInterpolationType
SpiceRotation interpolation type.
QSet< QString > m_observationNumbers
Associated observation numbers for these settings.
bool solvePolyOverPointing() const
Whether or not the solve polynomial will be fit over the existing pointing polynomial.
void setInstrumentPositionSettings(InstrumentPositionSolveOption option, int spkDegree=2, int spkSolveDegree=2, bool positionOverHermite=false, double positionAprioriSigma=-1.0, double velocityAprioriSigma=-1.0, double accelerationAprioriSigma=-1.0, QList< double > *additionalPositionSigmas=nullptr)
Sets the instrument pointing settings.
int m_spkDegree
Degree of the polynomial fit to the original camera position.
int numberCameraPositionCoefficientsSolved() const
Accesses the number of camera position coefficients in the solution.
void setInstrumentId(QString instrumentId)
Sets the instrument id for this observation.
QString m_instrumentId
The spacecraft instrument id for this observation.
void save(QXmlStreamWriter &stream, const Project *project) const
Saves this BundleObservationSolveSettings to an xml stream.
BundleObservationSolveSettings()
Constructor with default parameter initializations.
int ckDegree() const
Accesses the degree of polynomial fit to original camera angles (ckDegree).
QString instrumentId() const
Accesses the instrument id for this observation.
csm::param::Type csmParameterType() const
Get the type of CSM parameters to solve for.
QList< double > aprioriPositionSigmas() const
Accesses the a priori position sigmas.
QList< double > m_anglesAprioriSigma
The image position a priori sigmas.The size of the list is equal to the number of coefficients in the...
InstrumentPointingSolveOption m_instrumentPointingSolveOption
Option for how to solve for instrument pointing.
int m_spkSolveDegree
Degree of the camera position polynomial being fit to in the bundle adjustment.
bool m_solveTwist
Solve for "twist" angle.
static QString instrumentPointingSolveOptionToString(InstrumentPointingSolveOption option)
Tranlsates an enumerated InstrumentPointingSolveOption value to its string representation.
QList< double > aprioriPointingSigmas() const
Accesses the a priori pointing sigmas.
static InstrumentPositionSolveOption stringToInstrumentPositionSolveOption(QString option)
Translates a QString InstrumentPositionSolveOption to its enumerated value.
SpiceRotation::Source pointingInterpolationType() const
Accesses the SpiceRotation interpolation type for the instrument pointing.
static QString csmSolveSetToString(csm::param::Set set)
Convert a CSM parameter set enumeration value to a string.
int ckSolveDegree() const
Accesses the degree of the camera angles polynomial being fit to in the bundle adjustment (ckSolveDeg...
bool m_solvePointingPolynomialOverExisting
The polynomial will be fit over the existing pointing polynomial.
static CSMSolveOption stringToCSMSolveOption(QString option)
Convert a string to a CSM solve option enumeration value.
csm::param::Set m_csmSolveSet
The CSM parameter set to solve for.
void setInstrumentPointingSettings(InstrumentPointingSolveOption option, bool solveTwist, int ckDegree=2, int ckSolveDegree=2, bool solvePolynomialOverExisting=false, double anglesAprioriSigma=-1.0, double angularVelocityAprioriSigma=-1.0, double angularAccelerationAprioriSigma=-1.0, QList< double > *additionalPointingSigmas=nullptr)
Sets the instrument pointing settings.
bool solvePositionOverHermite() const
Whether or not the polynomial for solving will be fit over an existing Hermite spline.
InstrumentPositionSolveOption m_instrumentPositionSolveOption
Option for how to solve for instrument position.
QList< double > m_positionAprioriSigma
The instrument pointing a priori sigmas.
QStringList csmParameterList() const
Get the list of CSM parameters to solve for.
int m_ckSolveDegree
Degree of the camera angles polynomial being fit to in the bundle adjustment.
SpicePosition::Source positionInterpolationType() const
Accesses the SpicePosition interpolation type for the spacecraft position.
QSet< QString > observationNumbers() const
Returns a list of observation numbers associated with these solve settings.
static QString instrumentPositionSolveOptionToString(InstrumentPositionSolveOption option)
Translates an enumerated InstrumentPositionSolveOption to its string representation.
int numberCameraAngleCoefficientsSolved() const
Accesses the number of camera angle coefficients in the solution.
bool removeObservationNumber(QString observationNumber)
Removes an observation number from this solve settings.
int spkSolveDegree() const
Accesses the degree of thecamera position polynomial being fit to in the bundle adjustment (spkSolveD...
QUuid * m_id
A unique ID for this object (useful for others to reference this object when saving to disk).
InstrumentPointingSolveOption instrumentPointingSolveOption() const
Accesses the instrument pointing solve option.
void setCSMSolveParameterList(QStringList list)
Set an explicit list of CSM parameters to solve for.
QStringList m_csmSolveList
The names of the CSM parameters to solve for.
int m_ckDegree
Degree of the polynomial fit to the original camera angles.
InstrumentPointingSolveOption
Options for how to solve for instrument pointing.
@ AnglesVelocity
Solve for pointing angles and their angular velocities.
@ AnglesVelocityAcceleration
Solve for pointing angles, their velocities and their accelerations.
@ AllPointingCoefficients
Solve for all coefficients in the polynomials fit to the pointing angles.
@ AnglesOnly
Solve for pointing angles: right ascension, declination and, optionally, twist.
@ NoPointingFactors
Solve for none of the pointing factors.
int spkDegree() const
Accesses the degree of the polynomial fit to the original camera position (spkDegree).
static csm::param::Type stringToCSMSolveType(QString type)
Convert a string to its CSM parameter type enumeration value.
@ Unknown
A type of error that cannot be classified as any of the other error types.
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
@ Programmer
This error is for when a programmer made an API call that was illegal.
The main project for ipce.
Contains multiple PvlContainers.
Source
This enum indicates the status of the object.
@ PolyFunction
Object is calculated from nth degree polynomial.
@ PolyFunctionOverHermiteConstant
Object is reading from splined.
Source
The rotation can come from one of 3 places for an Isis cube.
@ PolyFunction
From nth degree polynomial.
@ PolyFunctionOverSpice
Kernels plus nth degree polynomial.
This is free and unencumbered software released into the public domain.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
const double Null
Value for an Isis Null pixel.
bool toBool(const QString &string)
Global function to convert from a string to a boolean.
bool IsSpecial(const double d)
Returns if the input pixel is special.
double toDouble(const QString &string)
Global function to convert from a string to a double.