Isis 3 Programmer Reference
MsiCamera.cpp
1
7/* SPDX-License-Identifier: CC0-1.0 */
8
9#include "MsiCamera.h"
10
11#include <QString>
12
13#include "CameraDetectorMap.h"
14#include "CameraFocalPlaneMap.h"
15#include "CameraGroundMap.h"
16#include "CameraSkyMap.h"
17#include "IString.h"
18#include "iTime.h"
19#include "NaifStatus.h"
20#include "Plugin.h"
21#include "RadialDistortionMap.h"
22
23using namespace std;
24namespace Isis {
41 m_instrumentNameLong = "Multi-Spectral Imager";
43 m_spacecraftNameLong = "Near Earth Asteroid Rendezvous";
44 m_spacecraftNameShort = "NEAR";
45
46 Pvl &lab = *cube.label();
51
52 // Get the start time in et
53 PvlGroup inst = lab.findGroup("Instrument", Pvl::Traverse);
54
55 // This corrects the format of the SCLK times. Updates by
56 // UA correct the time on the label in msi2isis, this is
57 // designed to be backward compatability. Note the updated
58 // version of the msi2isis ensure updates by sumspice work
59 // properly - ie., SpacecraftClockStartCount must be valid.
60 // KJB/UA 2019-08-25
61 QString stime = inst["SpacecraftClockStartCount"];
62 stime.remove('.'); // Backward compatability!!
63
64 iTime etStart = getClockTime(stime);
65 double et = etStart.Et();
66
67
68 // divide exposure duration keyword value by 1000 to convert to seconds
69 double exposureDuration = ((double) inst["ExposureDuration"]) / 1000.0;
70 pair<iTime, iTime> shuttertimes = ShutterOpenCloseTimes(et, exposureDuration);
71
72 //correct time for center of exposure duration
73 iTime centerTime = shuttertimes.first.Et() + exposureDuration / 2.0;
74
75 // Setup detector map. These images are full summing.
76 new CameraDetectorMap(this);
77
78 // Setup focal plane map
79 CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
80
81 // Make sure to grab lines and samples in the correct order.
82 double line = Spice::getDouble("INS" + toString(naifIkCode()) + "_BORESIGHT_LINE");
83 double sample = Spice::getDouble("INS" + toString(naifIkCode()) + "_BORESIGHT_SAMPLE");
84 focalMap->SetDetectorOrigin(sample, line);
85
86 // Setup distortion map
87 double k1 = Spice::getDouble("INS" + toString(naifIkCode()) + "_K1");
88 new RadialDistortionMap(this, k1, 1);
89
90 // Setup the ground and sky map
91 new CameraGroundMap(this);
92 new CameraSkyMap(this);
93 setTime(centerTime);
94 // Note: If the temperature-dependent instrument kernel is used,
95 // the following LoadCache() command should be replaced with the
96 // commented lines at the end of this file.
97 LoadCache();
99 }
100
103
129 pair<iTime, iTime> MsiCamera::ShutterOpenCloseTimes(double time,
130 double exposureDuration) {
132 }
133
142 int MsiCamera::CkFrameId() const { return -93000; }
143
152 int MsiCamera::CkReferenceId() const { return 1; }
153
162// int MsiCamera::SpkTargetId() const { return -93; }
163
171 int MsiCamera::SpkReferenceId() const { return 1; }
172}
173
182extern "C" Isis::Camera *MsiCameraPlugin(Isis::Cube &cube) {
183 return new Isis::MsiCamera(cube);
184}
185
186// Comment: 2013-03-08 Jeannie Backer - The following code will adjust the
187// camera model using the temperature dependent
188// instrument kernel. Currently, we have decided not to
189// implement this adjustment since it does not appear to
190// have been applied in ISIS2. (Code exists for this in
191// ISIS2, but without SCLK or CK, it could not have been
192// applied).
193
194// if (instrumentRotation()->IsCached()) {
195// LoadCache();
196// }
197// else {
198// double toCelcius = -273.15;
199// SpiceDouble tempCelcius = toDouble(inst["DpuDeckTemperature"][0])+toCelcius;
200// ConstSpiceChar *nearMsiTimeDependentFrame;
201// iTime originalTempDependencyDate("1999-12-20T00:00:00");
202//
203// if (centerTime.Et() <= originalTempDependencyDate.Et() ) {
204// nearMsiTimeDependentFrame = "NEAR_MSI_TEMP_DEP0000";
205// }
206// else {
207// nearMsiTimeDependentFrame = "NEAR_MSI_TEMP_DEP0001";
208// }
209//
210// // get transformation matrix based on temperature, from spacecraft to MSI
211// SpiceDouble sc2msiMatrix[3][3];
212// pxform_c("J2000", nearMsiTimeDependentFrame,tempCelcius, sc2msiMatrix);
213// NaifStatus::CheckErrors();
214// // get current TC matrix, from j2000 to spacecraft
215// vector<double> originalCJ = instrumentRotation()->TimeBasedMatrix();
216// // get new CJ matrix based on temperatureBasedRotation x originalTC
217// // now we have transformation from j2000 to msi
218// vector<double> newCJ(9);
219// mxm_c(sc2msiMatrix, (SpiceDouble( *)[3]) &originalCJ[0],
220// (SpiceDouble( *)[3]) &newCJ[0]);
221// NaifStatus::CheckErrors();
222// // mxmg_c(sc2msiMatrix, (SpiceDouble( *)[3]) &originalTC[0],
223// // 6, 6, 6, (SpiceDouble( *)[3]) &newCJ[0]);
224// // set new CJ matrix
225// instrumentRotation()->SetTimeBasedMatrix(newCJ);
226// LoadCache();
227// }
Convert between parent image coordinates and detector coordinates.
Convert between distorted focal plane and detector coordinates.
Convert between undistorted focal plane and ground coordinates.
QString m_spacecraftNameLong
Full spacecraft name.
Definition Camera.h:499
virtual double exposureDuration() const
Return the exposure duration for the pixel that the camera is set to.
Definition Camera.cpp:3093
void SetFocalLength()
Reads the focal length from the instrument kernel.
Definition Camera.cpp:1422
void SetPixelPitch()
Reads the Pixel Pitch from the instrument kernel.
Definition Camera.cpp:1429
void LoadCache()
This loads the spice cache big enough for this image.
Definition Camera.cpp:2450
QString m_instrumentNameShort
Shortened instrument name.
Definition Camera.h:498
QString m_spacecraftNameShort
Shortened spacecraft name.
Definition Camera.h:500
QString m_instrumentNameLong
Full instrument name.
Definition Camera.h:497
Convert between undistorted focal plane and ra/dec coordinates.
IO Handler for Isis Cubes.
Definition Cube.h:168
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition Cube.cpp:1707
Generic class for Framing Cameras.
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)=0
Returns the shutter open and close times.
NEAR Shoemaker MSI Camera Model.
Definition MsiCamera.h:50
virtual int SpkReferenceId() const
SPK Target ID - Target Body value for NEAR Shoemaker from spacit run on SPK.
MsiCamera(Cube &cube)
Constructs an MsiCamera object using the image labels.
Definition MsiCamera.cpp:40
virtual int CkReferenceId() const
CK Reference ID - Reference Frame value for J2000 from spacit run on CK.
~MsiCamera()
Destroys the MsiCamera object.
virtual int CkFrameId() const
CK frame ID - Instrument Code from spacit run on CK For more details, read the Camera class documenta...
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)
Returns the shutter open and close times.
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Contains multiple PvlContainers.
Definition PvlGroup.h:41
Container for cube-like labels.
Definition Pvl.h:119
@ Traverse
Search child objects.
Definition PvlObject.h:158
void setTime(const iTime &time)
By setting the time you essential set the position of the spacecraft and body as indicated in the cla...
Definition Sensor.cpp:99
virtual iTime getClockTime(QString clockValue, int sclkCode=-1, bool clockTicks=false)
This converts the spacecraft clock ticks value (clockValue) to an iTime.
Definition Spice.cpp:1060
virtual iTime time() const
Returns the ephemeris time in seconds which was used to obtain the spacecraft and sun positions.
Definition Spice.cpp:891
SpiceInt naifIkCode() const
This returns the NAIF IK code to use when reading from instrument kernels.
Definition Spice.cpp:975
SpiceDouble getDouble(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition Spice.cpp:1046
Parse and return pieces of a time string.
Definition iTime.h:65
double Et() const
Returns the ephemeris time (TDB) representation of the time as a double.
Definition iTime.h:126
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition IString.cpp:211
Namespace for the standard library.