|
Isis 3 Programmer Reference
|
10 #include "CameraSkyMap.h"
22 #include "CameraDetectorMap.h"
23 #include "CameraDistortionMap.h"
24 #include "CameraFocalPlaneMap.h"
25 #include "Constants.h"
26 #include "Displacement.h"
29 #include "IException.h"
33 #include "Longitude.h"
34 #include "LinearAlgebra.h"
35 #include "NaifStatus.h"
36 #include "SpecialPixel.h"
37 #include "SurfacePoint.h"
39 #include "csm/Warning.h"
40 #include "csm/Error.h"
41 #include "csm/Plugin.h"
42 #include "csm/Ellipsoid.h"
43 #include "csm/SettableEllipsoid.h"
57 Blob state(
"CSMState",
"String");
60 QString pluginName = blobLabel.
findKeyword(
"PluginName")[0];
61 QString modelName = blobLabel.
findKeyword(
"ModelName")[0];
62 QString stateString = QString::fromUtf8(state.
getBuffer(), state.
Size());
63 init(cube, pluginName, modelName, stateString);
76 const csm::Plugin *plugin = csm::Plugin::findPlugin(pluginName.toStdString());
79 for (
const csm::Plugin *plugin: csm::Plugin::getList()) {
80 availablePlugins.append(QString::fromStdString(plugin->getPluginName()));
82 QString msg =
"Failed to find plugin [" + pluginName +
"] for image [" + cube.
fileName() +
83 "]. Check that the corresponding CSM plugin library is in the directory "
84 "specified by your IsisPreferences. Loaded plugins [" +
85 availablePlugins.join(
", ") +
"].";
88 if (!plugin->canModelBeConstructedFromState(modelName.toStdString(), stateString.toStdString())) {
89 QString msg =
"CSM state string attached to image [" + cube.
fileName() +
"] cannot "
90 "be converted to a [" + modelName +
"] using [" + pluginName +
"].";
93 m_model =
dynamic_cast<csm::RasterGM*
>(plugin->constructModelFromState(stateString.toStdString()));
96 QString msg =
"Failed to convert CSM Model to RasterGM.";
105 QString timeString = QString::fromStdString(m_model->getReferenceDateAndTime());
107 timeString.remove(
"Z");
128 csm::ImageCoord imagePt;
130 double achievedPrecision = 0;
131 csm::WarningList warnings;
132 csm::EcefLocus imageLocus;
134 imageLocus = m_model->imageToRemoteImagingLocus(imagePt,
139 catch (csm::Error &e) {
144 if (achievedPrecision > 0.001) {
147 if (!warnings.empty()) {
148 for (csm::Warning warning : warnings) {
149 if (warning.getWarning() == csm::Warning::IMAGE_COORD_OUT_OF_BOUNDS){
156 std::vector<double> obsPosition = {imageLocus.point.x / 1000.0,
157 imageLocus.point.y / 1000.0,
158 imageLocus.point.z / 1000.0};
159 std::vector<double> locusVec = {imageLocus.direction.x,
160 imageLocus.direction.y,
161 imageLocus.direction.z};
170 if(!
target()->shape()->intersectSurface(obsPosition, locusVec)) {
232 if (shape->
name() !=
"Plane") {
259 if (!surfacePt.Valid()) {
264 bool validBackProject =
true;
267 csm::ImageCoord imagePt;
268 double achievedPrecision = 0;
269 csm::WarningList warnings;
272 imagePt = m_model->groundToImage(groundPt, 0.01, &achievedPrecision, &warnings);
274 catch (csm::Error &e) {
275 validBackProject =
false;
277 if (achievedPrecision > 0.01) {
278 validBackProject =
false;
280 if (!warnings.empty()) {
281 for (csm::Warning warning : warnings) {
282 if (warning.getWarning() == csm::Warning::IMAGE_COORD_OUT_OF_BOUNDS){
283 validBackProject =
false;
291 csm::EcefLocus imageLocus = m_model->imageToRemoteImagingLocus(imagePt);
292 std::vector<double> sensorPosition = {imageLocus.point.x, imageLocus.point.y, imageLocus.point.z};
294 shape->intersectSurface(surfacePt,
298 validBackProject =
false;
302 if (validBackProject) {
303 m_lookB[0] = imageLocus.direction.x;
304 m_lookB[1] = imageLocus.direction.y;
305 m_lookB[2] = imageLocus.direction.z;
339 return sqrt(imagePartials[0]*imagePartials[0] +
340 imagePartials[2]*imagePartials[2] +
341 imagePartials[4]*imagePartials[4]);
356 return sqrt(imagePartials[1]*imagePartials[1] +
357 imagePartials[3]*imagePartials[3] +
358 imagePartials[5]*imagePartials[5]);
375 double lineRes = sqrt(imagePartials[0]*imagePartials[0] +
376 imagePartials[2]*imagePartials[2] +
377 imagePartials[4]*imagePartials[4]);
378 double sampRes = sqrt(imagePartials[1]*imagePartials[1] +
379 imagePartials[3]*imagePartials[3] +
380 imagePartials[5]*imagePartials[5]);
381 return (sampRes + lineRes) / 2.0;
490 csm::ImageCoord imagePt;
492 csm::EcefCoord sensorPosition = m_model->getSensorPosition(imagePt);
494 std::vector<double> result {
495 sensorPosition.x / 1000.0,
496 sensorPosition.y / 1000.0,
497 sensorPosition.z / 1000.0};
581 vector<double> groundPartials = m_model->computeGroundPartials(groundCoord);
587 groundMatrix(0,0) = groundPartials[0];
588 groundMatrix(0,1) = groundPartials[1];
589 groundMatrix(0,2) = groundPartials[2];
590 groundMatrix(1,0) = groundPartials[3];
591 groundMatrix(1,1) = groundPartials[4];
592 groundMatrix(1,2) = groundPartials[5];
596 vector<double> imagePartials = {imageMatrix(0,0),
602 return imagePartials;
647 vector<double> groundPartials = m_model->computeGroundPartials(groundCoord);
648 return groundPartials;
661 csm::Ellipsoid targetEllipsoid = csm::SettableEllipsoid::getEllipsoid(m_model);
690 csmPixel.line = line - 0.5;
691 csmPixel.samp = sample - 0.5;
705 line = csmPixel.line + 0.5;
706 sample = csmPixel.samp + 0.5;
721 return csm::EcefCoord(groundPt.GetX().
meters(),
723 groundPt.GetZ().
meters());
751 csm::EcefVector sunEcefVec = m_model->getIlluminationDirection(groundPt);
755 std::vector<double> sunVec = {
756 (groundPt.x - sunEcefVec.x) / 1000.0,
757 (groundPt.y - sunEcefVec.y) / 1000.0,
758 (groundPt.z - sunEcefVec.z) / 1000.0};
780 csm::EcefVector sunEcefVec = m_model->getIlluminationDirection(groundPt);
784 std::vector<double> sunVec = {
785 (groundPt.x - sunEcefVec.x) / 1000.0,
786 (groundPt.y - sunEcefVec.y) / 1000.0,
787 (groundPt.z - sunEcefVec.z) / 1000.0};
802 std::vector<double> sensorToGround = {
803 groundPoint.GetX().
kilometers() - (sensorPosition[0]),
804 groundPoint.GetY().
kilometers() - (sensorPosition[1]),
805 groundPoint.GetZ().
kilometers() - (sensorPosition[2])};
808 sensorToGround[0] * sensorToGround[0] +
809 sensorToGround[1] * sensorToGround[1] +
810 sensorToGround[2] * sensorToGround[2]);
823 sensorPosition[0] * sensorPosition[0] +
824 sensorPosition[1] * sensorPosition[1] +
825 sensorPosition[2] * sensorPosition[2]);
837 return m_model->getParameterSetIndices(paramSet);
849 std::vector<int> parameterIndices;
850 for (
int i = 0; i < m_model->getNumParameters(); i++) {
851 if (m_model->getParameterType(i) == paramType) {
852 parameterIndices.push_back(i);
855 return parameterIndices;
867 std::vector<int> parameterIndices;
869 for (
int i = 0; i < paramList.size(); i++) {
871 for (
int j = 0; j < m_model->getNumParameters(); j++) {
872 if (QString::compare(QString::fromStdString(m_model->getParameterName(j)).trimmed(),
873 paramList[i].trimmed(),
874 Qt::CaseInsensitive) == 0) {
875 parameterIndices.push_back(j);
882 failedParams.push_back(paramList[i]);
886 if (!failedParams.empty()) {
887 QString msg =
"Failed to find indices for the following parameters [" +
888 failedParams.join(
",") +
"].";
891 return parameterIndices;
902 double currentValue = m_model->getParameterValue(index);
903 m_model->setParameterValue(index, currentValue + correction);
914 return m_model->getParameterCovariance(index1, index2);
918 vector<double> CSMCamera::getSensorPartials(
int index,
SurfacePoint groundPoint) {
921 std::pair<double, double> partials = m_model->computeSensorPartials(index, groundCoord);
922 vector<double> partialsVector = {partials.first, partials.second};
924 return partialsVector;
936 return QString::fromStdString(m_model->getParameterName(index));
948 return m_model->getParameterValue(index);
960 return QString::fromStdString(m_model->getParameterUnits(index));
970 return QString::fromStdString(m_model->getModelState());
983 QString msg =
"Setting the image time is not supported for CSM camera models";
999 QString msg =
"Sub solar point is not supported for CSM camera models";
1012 QString msg =
"Pixel Field of View is not supported for CSM camera models";
1026 QString msg =
"Sun position is not supported for CSM camera models";
1040 QString msg =
"Sun position is not supported for CSM camera models";
1055 QString msg =
"Instrument position is not supported for CSM camera models";
1070 QString msg =
"Target body orientation is not supported for CSM camera models";
1085 QString msg =
"Instrument orientation is not supported for CSM camera models";
1099 QString msg =
"Solar longitude is not supported for CSM camera models";
1112 QString msg =
"Solar distance is not supported for CSM camera models";
1126 QString msg =
"Right Ascension is not supported for CSM camera models";
1140 QString msg =
"Declination is not supported for CSM camera models";
virtual void computeSolarLongitude(iTime et)
Computes the solar longitude for the given ephemeris time.
void radii(Distance r[3]) const
Returns the radii of the body in km.
@ Degrees
Degrees are generally considered more human readable, 0-360 is one circle, however most math does not...
virtual double targetCenterDistance() const
Calculates and returns the distance from the spacecraft to the target center at the currently set tim...
virtual QList< QPointF > PixelIfovOffsets()
Returns the pixel ifov offsets from center of pixel.
virtual SpicePosition * sunPosition() const
Get the SpicePosition object that contains the state information for the sun in J2000.
iTime * m_et
Ephemeris time (read NAIF documentation for a detailed description)
virtual double emissionAngle(const std::vector< double > &sB)
Computes and returns emission angle, in degrees, given the observer position.
Obtain SPICE position information for a body.
ShapeModel * shape() const
Return the shape.
virtual QString fileName() const
Returns the opened cube's filename.
virtual void clearSurfacePoint()
Clears or resets the current surface point.
virtual double ObliqueDetectorResolution()
Compute the oblique detector resolution in meters per pixel for the current set point.
SurfacePoint csmToIsisGround(const csm::EcefCoord &groundPt) const
Convert a CSM ground point into an ISIS ground point.
double getParameterCovariance(int index1, int index2)
Get the covariance between two parameters.
Contains Pvl Groups and Pvl Objects.
virtual double IncidenceAngle() const
Compute the incidence angle at the currently set ground point.
void csmToIsisPixel(csm::ImageCoord csmPixel, double &line, double &sample) const
Convert a CSM pixel coordinate to an ISIS pixel coordinate.
@ Meters
The distance is being specified in meters.
double p_childLine
Line value for child.
This class is designed to encapsulate the concept of a Latitude.
void setRadii(std::vector< Distance > radii)
Sets the radii of the body.
iTime m_refTime
CSM sensor model.
Parse and return pieces of a time string.
virtual std::vector< double > ImagePartials()
Compute the partial derivatives of the ground point with respect to the line and sample at the curren...
void read(Blob &blob, const std::vector< PvlKeyword > keywords=std::vector< PvlKeyword >()) const
This method will read data from the specified Blob object.
virtual SpiceRotation * instrumentRotation() const
Get the SpiceRotation object the contains the orientation of the sensor relative to J2000.
virtual double Sample() const
Returns the current sample number.
virtual double ObliqueSampleResolution()
Compute the oblique sample resolution in meters per pixel for the current set point.
void setHasIntersection(bool b)
Sets the flag to indicate whether this ShapeModel has an intersection.
void setSpice(Spice *spice)
Set the Spice pointer for the Target.
virtual bool SetImage(const double sample, const double line)
Set the image sample and line for the Camera Model and then compute the corresponding image time,...
QString m_instrumentNameLong
Full instrument name.
void applyParameterCorrection(int index, double correction)
Adjust the value of a parameter.
virtual double incidenceAngle(const std::vector< double > &uB)
Computes and returns incidence angle, in degrees, given the illuminator position.
double AlphaLine(double betaLine)
Returns an alpha line given a beta line.
virtual double SolarDistance() const
Computes the distance to the sun from the currently set ground point.
virtual double EmissionAngle() const
Compute the emission angle at the currently set ground point.
QString name() const
Gets the shape name.
virtual void subSpacecraftPoint(double &lat, double &lon)
Get the latitude and longitude of the sub-spacecraft point at the currently set time.
virtual double SlantDistance() const
Compute the slant distance from the sensor to the ground point at the currently set time.
Container for cube-like labels.
virtual std::vector< double > GroundPartials()
Compute the partial derivatives of the sample, line with respect to the x, y, z coordinates of the gr...
double AlphaSample(double betaSample)
Returns an alpha sample given a beta sample.
Latitude GetLatitude() const
Return the body-fixed latitude for the surface point.
virtual double PhaseAngle() const
Compute the phase angle at the currently set ground point.
SurfacePoint GetSurfacePoint() const
Returns the surface point (most efficient accessor).
virtual SpiceRotation * bodyRotation() const
Get the SpiceRotation object the contains the orientation of the target body relative to J2000.
boost::numeric::ublas::matrix< double > Matrix
Definition for an Isis::LinearAlgebra::Matrix of doubles.
virtual double LineResolution()
Compute the line resolution in meters per pixel for the current set point.
void init(Cube &cube, QString pluginName, QString modelName, QString stateString)
Init method which performs most of the setup for the CSM Camera Model inside ISIS.
Distance measurement, usually in meters.
double getParameterValue(int index)
Get the value of a parameter.
virtual double ObliqueLineResolution()
Compute the oblique line resolution in meters per pixel for the current set point.
double BetaLine(double alphaLine)
Returns a beta line given an alpha line.
This class is designed to encapsulate the concept of a Longitude.
virtual Target * target() const
Returns a pointer to the target object.
virtual double parentLine() const
Returns the currently set parent line for the camera model.
virtual void setTime(const iTime &time)
Set the time and update the sensor position and orientation.
@ Kilometers
The distance is being specified in kilometers.
Displacement is a signed length, usually in meters.
void setTarget(Pvl label)
Set the Target object for the camera model.
@ Meters
The distance is being specified in meters.
double meters() const
Get the displacement in meters.
virtual double DetectorResolution()
Compute the detector resolution in meters per pixel for the current set point.
virtual bool SetGround(Latitude latitude, Longitude longitude)
Set the latitude and longitude for the Camera Model and then compute the corresponding image time,...
virtual void subSolarPoint(double &lat, double &lon)
Returns the sub-solar latitude/longitude in universal coordinates (0-360 positive east,...
char * getBuffer()
Get the internal data buff of the Blob.
PvlObject & Label()
Accessor method that returns a PvlObject containing the Blob label.
double p_childSample
Sample value for child.
bool isValid() const
Test if this distance has been initialized or not.
virtual bool SetUniversalGround(const double latitude, const double longitude)
Set the latitude and longitude for the Camera Model and then compute the corresponding image time,...
static Matrix pseudoinverse(const Matrix &matrix)
Returns the pseudoinverse of a matrix.
virtual double parentSample() const
Returns the currently set parent sample for the camera model.
AlphaCube * p_alphaCube
A pointer to the AlphaCube.
IO Handler for Isis Cubes.
Target * m_target
Target of the observation.
QString m_spacecraftNameLong
Full spacecraft name.
virtual double Declination()
Computes the Declination of the currently set image coordinate.
Longitude GetLongitude() const
Return the body-fixed longitude for the surface point.
double BetaSample(double alphaSample)
Returns a beta sample given an alpha sample.
QString getModelState() const
Get the CSM Model state string to re-create the CSM Model.
int Size() const
Accessor method that returns the number of bytes in the blob data.
double kilometers() const
Get the displacement in kilometers.
bool p_pointComputed
Flag showing if Sample/Line has been computed.
std::vector< int > getParameterIndices(csm::param::Set paramSet) const
Get the indices of the parameters that belong to a set.
@ Programmer
This error is for when a programmer made an API call that was illegal.
QString getParameterUnits(int index)
Get the units of the parameter at a particular index.
Namespace for the standard library.
bool m_newLookB
flag to indicate we need to recompute ra/dec
Define shapes and provide utilities for Isis targets.
QString m_instrumentNameShort
Shortened instrument name.
virtual double phaseAngle(const std::vector< double > &sB, const std::vector< double > &uB)
Computes and returns phase angle, in degrees, given the positions of the observer and illuminator.
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
std::vector< double > sensorPositionBodyFixed() const
Get the position of the sensor in the body fixed coordinate system at the currently set time.
QString getParameterName(int index)
Get the name of the parameter.
csm::EcefCoord isisToCsmGround(const SurfacePoint &groundPt) const
Convert an ISIS ground point into a CSM ground point.
double degrees() const
Get the angle in units of Degrees.
virtual void instrumentBodyFixedPosition(double p[3]) const
Get the position of the sensor in the body fixed coordinate system at the currently set time.
bool hasIntersection()
Returns intersection status.
PvlKeyword & findKeyword(const QString &kname, FindOptions opts)
Finds a keyword in the current PvlObject, or deeper inside other PvlObjects and Pvlgroups within this...
virtual SpicePosition * instrumentPosition() const
Get the SpicePosition object the contains the state information for the sensor in J2000.
virtual double Line() const
Returns the current line number.
SpiceDouble m_lookB[3]
Look direction in body fixed.
QString m_spacecraftNameShort
Shortened spacecraft name.
This class is used to create and store valid Isis targets.
@ Kilometers
The distance is being specified in kilometers.
virtual double SampleResolution()
Compute the sample resolution in meters per pixel for the current set point.
virtual double RightAscension()
Computes the Right Ascension of the currently set image coordinate.
This class defines a body-fixed surface point.
This is free and unencumbered software released into the public domain.
Distance LocalRadius() const
Returns the local radius at the intersection point.
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
void isisToCsmPixel(double line, double sample, csm::ImageCoord &csmPixel) const
The reference time that all model image times are relative to.
Obtain SPICE rotation information for a body.