9#include "CsmBundleObservation.h"
16#include "BundleImage.h"
17#include "BundleControlPoint.h"
18#include "BundleObservationSolveSettings.h"
19#include "BundleTargetBody.h"
22#include "LinearAlgebra.h"
23#include "SpicePosition.h"
24#include "SpiceRotation.h"
48 if (bundleTargetBody) {
49 QString msg =
"Target body parameters cannot be solved for with CSM observations.";
108 m_corrections.clear();
127 m_corrections.resize(nParams);
131 for (
int i = 0; i < nParams; i++) {
166 QString msg =
"Invalid correction vector passed to observation.";
172 for (
size_t i = 0; i < corrections.size(); i++) {
177 m_corrections += corrections;
209 QVector<double> finalParameterValues;
217 for (
int i = 0; i < nParameters; i++) {
218 parameterNamesList.append(csmCamera->getParameterName(
m_paramIndices[i]));
219 parameterUnitList.append(csmCamera->getParameterUnits(
m_paramIndices[i]));
220 finalParameterValues.append(csmCamera->getParameterValue(
m_paramIndices[i]));
226 QString adjustedSigma;
229 for (
int i = 0; i < nParameters; i++) {
231 correction = m_corrections(i);
235 snprintf(buf,
sizeof(buf),
"%.11s", parameterNamesList.at(i).toStdString().c_str());
237 snprintf(buf,
sizeof(buf),
"%18.8lf ", finalParameterValues[i] - correction);
239 snprintf(buf,
sizeof(buf),
"%20.8lf ", correction);
241 snprintf(buf,
sizeof(buf),
"%23.8lf ", finalParameterValues[i]);
243 snprintf(buf,
sizeof(buf),
" ");
245 snprintf(buf,
sizeof(buf),
"%6s", sigma.toStdString().c_str());
247 snprintf(buf,
sizeof(buf),
" ");
249 if (errorPropagation) {
250 snprintf(buf,
sizeof(buf),
"%s", adjustedSigma.toStdString().c_str());
253 snprintf(buf,
sizeof(buf),
"%s",
"N/A");
256 snprintf(buf,
sizeof(buf),
" ");
258 snprintf(buf,
sizeof(buf),
"%s\n", parameterUnitList.at(i).toStdString().c_str());
275 QString finalqStr =
"";
280 finalqStr +=
toString(finalValue - m_corrections[i]) +
",";
281 finalqStr +=
toString(m_corrections[i]) +
",";
282 finalqStr +=
toString(finalValue) +
",";
284 if (errorPropagation) {
310 paramList.push_back(csmCamera->getParameterName(paramIndex));
330 if (bundleTargetBody) {
331 QString msg =
"Target body parameters cannot be solved for with CSM observations.";
354 SurfacePoint groundPoint = measure.parentControlPoint()->adjustedSurfacePoint();
358 vector<double> partials = csmCamera->getSensorPartials(
m_paramIndices[i], groundPoint);
359 coeffImage(0, i) = partials[1];
360 coeffImage(1, i) = partials[0];
382 coeffPoint3D.clear();
387 SurfacePoint groundPoint = measure.parentControlPoint()->adjustedSurfacePoint();
388 vector<double> groundPartials = measureCamera->GroundPartials(groundPoint);
399 coeffPoint3D(1,0) = groundPartials[0] * 1000;
400 coeffPoint3D(1,1) = groundPartials[1] * 1000;
401 coeffPoint3D(1,2) = groundPartials[2] * 1000;
402 coeffPoint3D(0,0) = groundPartials[3] * 1000;
403 coeffPoint3D(0,1) = groundPartials[4] * 1000;
404 coeffPoint3D(0,2) = groundPartials[5] * 1000;
408 std::vector<double> lonDerivative = groundPoint.LatitudinalDerivative(SurfacePoint::Two);
409 std::vector<double> radDerivative = groundPoint.LatitudinalDerivative(SurfacePoint::Three);
412 coeffPoint3D(1,0) = 1000 * (groundPartials[0]*latDerivative[0] + groundPartials[1]*latDerivative[1] + groundPartials[2]*latDerivative[2]);
413 coeffPoint3D(1,1) = 1000 * (groundPartials[0]*lonDerivative[0] + groundPartials[1]*lonDerivative[1] + groundPartials[2]*lonDerivative[2]);
414 coeffPoint3D(1,2) = 1000 * (groundPartials[0]*radDerivative[0] + groundPartials[1]*radDerivative[1] + groundPartials[2]*radDerivative[2]);
417 coeffPoint3D(0,0) = 1000 * (groundPartials[3]*latDerivative[0] + groundPartials[4]*latDerivative[1] + groundPartials[5]*latDerivative[2]);
418 coeffPoint3D(0,1) = 1000 * (groundPartials[3]*lonDerivative[0] + groundPartials[4]*lonDerivative[1] + groundPartials[5]*lonDerivative[2]);
419 coeffPoint3D(0,2) = 1000 * (groundPartials[3]*radDerivative[0] + groundPartials[4]*radDerivative[1] + groundPartials[5]*radDerivative[2]);
422 IString msg =
"Unknown surface point coordinate type enum [" +
toString(coordType) +
"]." ;
445 Camera *measureCamera = measure.camera();
450 QString msg =
"Unable to map apriori surface point for measure ";
451 msg += measure.cubeSerialNumber() +
" on point " + point->
id() +
" back into image.";
454 double computedSample = measureCamera->Sample();
455 double computedLine = measureCamera->Line();
459 double deltaSample = measure.sample() - computedSample;
460 double deltaLine = measure.line() - computedLine;
462 coeffRHS(0) = deltaSample;
463 coeffRHS(1) = deltaLine;
This class holds information about a control point that BundleAdjust needs to run correctly.
SurfacePoint adjustedSurfacePoint() const
Accesses the adjusted SurfacePoint associated with this BundleControlPoint.
QString id() const
Accesses the Point ID associated with this BundleControlPoint.
A container class for a ControlMeasure.
Abstract base class for an observation in bundle adjustment.
LinearAlgebra::Vector m_aprioriSigmas
A posteriori (adjusted) parameter sigmas.
LinearAlgebra::Vector m_adjustedSigmas
A posteriori (adjusted) parameter sigmas.
LinearAlgebra::Vector m_weights
Parameter weights. Cumulative parameter correction vector.
This class is used to modify and manage solve settings for 1 to many BundleObservations.
@ 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.
double getParameterValue(int index)
Get the value of a parameter.
void applyParameterCorrection(int index, double correction)
Adjust the value of a parameter.
Class for observations that use CSM camera models in bundle adjustment.
bool computeRHSPartials(LinearAlgebra::Vector &coeffRHS, BundleMeasure &measure)
Calculates the sample, line residuals between the values measured in the image and the ground-to-imag...
CsmBundleObservation & operator=(const CsmBundleObservation &src)
Assignment operator.
int numberParameters()
Returns the number of total parameters there are for solving.
QString bundleOutputCSV(bool errorPropagation)
Creates and returns a formatted QString representing the bundle coefficients and parameters in csv fo...
bool computeTargetPartials(LinearAlgebra::Matrix &coeffTarget, BundleMeasure &measure, BundleSettingsQsp &bundleSettings, BundleTargetBodyQsp &bundleTargetBody)
Cannot compute target body parameters for a CSM observation, so always throws an exception.
bool computeImagePartials(LinearAlgebra::Matrix &coeffImage, BundleMeasure &measure)
Calculates the sensor partials with respect to the solve parameters and populates the coeffImage matr...
bool applyParameterCorrections(LinearAlgebra::Vector corrections)
Applies the parameter corrections.
const BundleObservationSolveSettingsQsp solveSettings()
Accesses the solve settings.
std::vector< int > m_paramIndices
The indices of the parameters the observation is solving for.
~CsmBundleObservation()
Destructor.
virtual QStringList parameterList()
Returns the list of observation parameter names.
void bundleOutputString(std::ostream &fpOut, bool errorPropagation)
Takes in an open std::ofstream and writes out information which goes into the bundleout....
bool computePoint3DPartials(LinearAlgebra::Matrix &coeffPoint3D, BundleMeasure &measure, SurfacePoint::CoordinateType coordType)
Calculates the ground partials for the line, sample currently set in the sensor model.
virtual bool setSolveSettings(BundleObservationSolveSettings solveSettings)
Set solve parameters.
CsmBundleObservation()
Constructs a CsmBundleObservation initialized to a default state.
double computeObservationValue(BundleMeasure &measure, double deltaVal)
Returns the observed value in (sample, line) coordinates.
BundleObservationSolveSettingsQsp m_solveSettings
Solve settings for this observation.
@ 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.
Adds specific functionality to C++ strings.
boost::numeric::ublas::vector< double > Vector
Definition for an Isis::LinearAlgebra::Vector of doubles.
boost::numeric::ublas::matrix< double > Matrix
Definition for an Isis::LinearAlgebra::Matrix of doubles.
This class defines a body-fixed surface point.
CoordinateType
Defines the coordinate typ, units, and coordinate index for some of the output methods.
@ Latitudinal
Planetocentric latitudinal (lat/lon/rad) coordinates.
@ Rectangular
Body-fixed rectangular x/y/z coordinates.
std::vector< double > LatitudinalDerivative(CoordIndex index)
Compute partial derivative of the conversion of the latitudinal coordinates to body-fixed rectangular...
This is free and unencumbered software released into the public domain.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
QSharedPointer< BundleObservationSolveSettings > BundleObservationSolveSettingsQsp
Definition for BundleObservationSolveSettingsQsp, a QSharedPointer to a BundleObservationSolveSetting...
bool IsSpecial(const double d)
Returns if the input pixel is special.
Namespace for the standard library.