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;
217 for (
int i = 0; i < nParameters; 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) {
330 if (bundleTargetBody) {
331 QString msg =
"Target body parameters cannot be solved for with CSM observations.";
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();
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;
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) +
"]." ;
450 QString msg =
"Unable to map apriori surface point for measure ";
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.
double sample() const
Accesses the current sample measurement for this control measure.
double line() const
Accesses the current line measurement for this control measure.
QString cubeSerialNumber() const
Accesses the serial number of the cube containing this control measure.
BundleControlPoint * parentControlPoint()
Accesses the parent BundleControlPoint for this bundle measure.
Camera * camera() const
Accesses the associated camera for this bundle measure.
QString instrumentId()
Accesses the instrument id.
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.
BundleObservation()
Constructs a BundleObservation initialized to a default state.
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.
std::vector< int > getParameterIndices(csm::param::Set paramSet) const
Get the indices of the parameters that belong to a set.
QString getParameterUnits(int index)
Get the units of the parameter at a particular index.
double getParameterCovariance(int index1, int index2)
Get the covariance between two parameters.
virtual std::vector< double > GroundPartials(SurfacePoint groundPoint)
Compute the partial derivatives of the sample, line with respect to the x, y, z coordinates of the gr...
double getParameterValue(int index)
Get the value of a parameter.
QString getParameterName(int index)
Get the name of the parameter.
void applyParameterCorrection(int index, double correction)
Adjust the value of a parameter.
virtual double Line() const
Returns the current line number.
virtual double Sample() const
Returns the current sample number.
virtual bool SetGround(Latitude latitude, Longitude longitude)
Sets the lat/lon values to get the sample/line values.
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.
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< BundleSettings > BundleSettingsQsp
Definition for a BundleSettingsQsp, a shared pointer to a BundleSettings object.
QSharedPointer< BundleTargetBody > BundleTargetBodyQsp
Definition for BundleTargetBodyQsp, a QSharedPointer to a BundleTargetBody.
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.