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 
23 using namespace std;
24 
25 namespace Isis {
40  NewHorizonsLorriCamera::NewHorizonsLorriCamera(Cube &cube) : FramingCamera(cube) {
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 
147 extern "C" Isis::Camera *NewHorizonsLorriCameraPlugin(Isis::Cube &cube) {
148  return new Isis::NewHorizonsLorriCamera(cube);
149 }
Isis::CameraFocalPlaneMap::SetDetectorOrigin
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
Definition: CameraFocalPlaneMap.cpp:293
Isis::Camera::exposureDuration
virtual double exposureDuration() const
Return the exposure duration for the pixel that the camera is set to.
Definition: Camera.cpp:3063
Isis::Spice::time
iTime time() const
Returns the ephemeris time in seconds which was used to obtain the spacecraft and sun positions.
Definition: Spice.cpp:884
Isis::PvlObject::findGroup
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition: PvlObject.h:129
Isis::CameraDetectorMap
Convert between parent image coordinates and detector coordinates.
Definition: CameraDetectorMap.h:47
Isis::Spice::naifIkCode
SpiceInt naifIkCode() const
This returns the NAIF IK code to use when reading from instrument kernels.
Definition: Spice.cpp:968
Isis::Spice::getString
QString getString(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition: Spice.cpp:1261
Isis::Camera::m_instrumentNameLong
QString m_instrumentNameLong
Full instrument name.
Definition: Camera.h:496
Isis::Spice::getClockTime
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:1053
Isis::CameraDetectorMap::SetDetectorSampleSumming
void SetDetectorSampleSumming(const double summing)
Set sample summing mode.
Definition: CameraDetectorMap.h:108
Isis::NewHorizonsLorriCamera
This is the camera model for the LORRI Framing Camera.
Definition: NewHorizonsLorriCamera.h:37
Isis::NewHorizonsLorriDistortionMap
New Horizons LORRI Distortion Map.
Definition: NewHorizonsLorriDistortionMap.h:30
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::FramingCamera::ShutterOpenCloseTimes
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)=0
Returns the shutter open and close times.
Definition: FramingCamera.cpp:42
Isis::NaifStatus::CheckErrors
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Definition: NaifStatus.cpp:28
Isis::Camera
Definition: Camera.h:236
Isis::FramingCamera
Generic class for Framing Cameras.
Definition: FramingCamera.h:32
Isis::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
Isis::CameraGroundMap
Convert between undistorted focal plane and ground coordinates.
Definition: CameraGroundMap.h:73
Isis::CameraDetectorMap::SetDetectorLineSumming
void SetDetectorLineSumming(const double summing)
Set line summing mode.
Definition: CameraDetectorMap.h:123
Isis::PvlObject::Traverse
@ Traverse
Search child objects.
Definition: PvlObject.h:158
Isis::Sensor::setTime
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:97
Isis::iTime::Et
double Et() const
Returns the ephemeris time (TDB) representation of the time as a double.
Definition: iTime.h:126
Isis::Camera::SetPixelPitch
void SetPixelPitch()
Reads the Pixel Pitch from the instrument kernel.
Definition: Camera.cpp:1418
Isis::PvlGroup
Contains multiple PvlContainers.
Definition: PvlGroup.h:41
Isis::Cube
IO Handler for Isis Cubes.
Definition: Cube.h:167
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::Camera::m_spacecraftNameLong
QString m_spacecraftNameLong
Full spacecraft name.
Definition: Camera.h:498
std
Namespace for the standard library.
Isis::Camera::LoadCache
void LoadCache()
This loads the spice cache big enough for this image.
Definition: Camera.cpp:2420
Isis::Camera::m_instrumentNameShort
QString m_instrumentNameShort
Shortened instrument name.
Definition: Camera.h:497
Isis::CameraFocalPlaneMap
Convert between distorted focal plane and detector coordinates.
Definition: CameraFocalPlaneMap.h:85
Isis::Cube::label
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition: Cube.cpp:1701
Isis::CameraSkyMap
Convert between undistorted focal plane and ra/dec coordinates.
Definition: CameraSkyMap.h:31
Isis::Spice::getDouble
SpiceDouble getDouble(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition: Spice.cpp:1039
Isis::Camera::m_spacecraftNameShort
QString m_spacecraftNameShort
Shortened spacecraft name.
Definition: Camera.h:499
Isis::NewHorizonsLorriCamera::ShutterOpenCloseTimes
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)
Reimplemented from FrameCamera.
Definition: NewHorizonsLorriCamera.cpp:130
Isis::Camera::SetFocalLength
void SetFocalLength()
Reads the focal length from the instrument kernel.
Definition: Camera.cpp:1411
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::IException::User
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition: IException.h:126