Isis 3 Programmer Reference
NewHorizonsLorriCamera.cpp
1
7/* SPDX-License-Identifier: CC0-1.0 */
8
9#include "NewHorizonsLorriCamera.h"
10
11#include <QString>
12
13#include "CameraDetectorMap.h"
14#include "CameraDistortionMap.h"
15#include "CameraFocalPlaneMap.h"
16#include "CameraGroundMap.h"
17#include "CameraSkyMap.h"
18#include "IString.h"
19#include "iTime.h"
20#include "NaifStatus.h"
21#include "NewHorizonsLorriDistortionMap.h"
22
23using namespace std;
24
25namespace Isis {
41 m_instrumentNameLong = "Long Range Reconnaissance Imager";
42 m_instrumentNameShort = "LORRI";
43 m_spacecraftNameLong = "New Horizons";
44 m_spacecraftNameShort = "NewHorizons";
45
47
48 // The LORRI focal length is fixed and is designed not to change throught the operational
49 // temperature. The NAIF code, set in the ISIS labels, will be used to read a single focal
50 // length from the SPICE kernels. Version 100 of the Lorri IK uses meters for focal length,
51 // units, version 200 uses mm, and has a units keyword.
52 QString unitsKey = "INS" + toString(naifIkCode()) + "_FOCAL_LENGTH_UNITS";
53 QString focalLengthUnits = Spice::getString(unitsKey);
54 if (focalLengthUnits != "mm") {
55 QString msg = QObject::tr("SPICE keyword [%1] is expected to be mm. [%2] was found instead").
56 arg(unitsKey).arg(focalLengthUnits);
57 throw IException(IException::User, msg, _FILEINFO_);
58 }
59 SetFocalLength(Spice::getDouble("INS" + toString(naifIkCode()) + "_FOCAL_LENGTH"));
60
61 // For setting the pixel pitch, the Naif keyword PIXEL_SIZE is used instead of the ISIS
62 // default of PIXEL_PITCH, so set the value directly.
63 QString pp = "INS" + toString(naifIkCode()) + "_PIXEL_SIZE";
64 double pixelPitch = Spice::getDouble(pp);
65 pixelPitch /= 1000.0;
66 SetPixelPitch(pixelPitch);
67
68 // Since the two summing modes are handeled via different Naif codes, force the summing modes
69 // to 1 for both the 1x1 and 4x4 modes
70 CameraDetectorMap *detectorMap = new CameraDetectorMap(this);
71 detectorMap->SetDetectorSampleSumming(1);
72 detectorMap->SetDetectorLineSumming(1);
73
74 // Setup focal plane map. The class will read data from the instrument addendum kernel to pull
75 // out the affine transforms from detector samp,line to focal plane x,y.
76 CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
77
78 // The boresight position recorded in the IK is zero-based and therefore needs to be adjusted
79 // for ISIS
80 double boresightSample = Spice::getDouble("INS" + toString(naifIkCode()) + "_CCD_CENTER",0) + 1.0;
81 double boresightLine = Spice::getDouble("INS" + toString(naifIkCode()) + "_CCD_CENTER",1) + 1.0;
82 focalMap->SetDetectorOrigin(boresightSample,boresightLine);
83
84 // Setup distortion map. Start by reading the distortion coefficient from the instrument kernel.
85 // Then construct the distortion model.
86 // Uncomment the 3 lines below to use the default distortion map (i.e., no distortion)
87 // new CameraDistortionMap(this, -1);
88 // CameraDistortionMap *distortionMap = new CameraDistortionMap(this, -1);
89 // distortionMap->SetDistortion(naifIkCode());
90 // Changed the SPICE keyword names to work with LORRI IK version 200
91 QString e2("INS" + toString(naifIkCode()) + "_OOC_EM");
92 QString e5("INS" + toString(naifIkCode()) + "_OOC_EM");
93 QString e6("INS" + toString(naifIkCode()) + "_OOC_EM");
94 new NewHorizonsLorriDistortionMap(this, getDouble(e2, 0), getDouble(e5, 1),
95 getDouble(e6, 2), -1);
96
97 // Setup the ground and sky map
98 new CameraGroundMap(this);
99 new CameraSkyMap(this);
100
101 // The observation start time and clock count for LORRI are based on the center of the exposure.
102 Pvl &lab = *cube.label();
103 PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
104 QString clockCount = inst["SpacecraftClockStartCount"];
105 double et = getClockTime(clockCount).Et();
106 double exposureDuration = (double)inst["ExposureDuration"] / 1000.0;
107
108 pair<iTime, iTime> startStop = ShutterOpenCloseTimes(et, exposureDuration);
109 setTime(et);
110
111 // Internalize all the NAIF SPICE information into memory.
112 LoadCache();
114 }
115
130 pair<iTime, iTime> NewHorizonsLorriCamera::ShutterOpenCloseTimes(double time,
131 double exposureDuration) {
133 }
134}
135
147extern "C" Isis::Camera *NewHorizonsLorriCameraPlugin(Isis::Cube &cube) {
148 return new Isis::NewHorizonsLorriCamera(cube);
149}
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.
Isis exception class.
Definition IException.h:91
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition IException.h:126
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
This is the camera model for the LORRI Framing Camera.
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)
Reimplemented from FrameCamera.
NewHorizonsLorriCamera(Cube &cube)
Create a NewHorizonsLorriCamer object.
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
QString getString(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition Spice.cpp:1273
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
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.