Isis 3 Programmer Reference
LroNarrowAngleCamera.cpp
1 
7 /* SPDX-License-Identifier: CC0-1.0 */
8 
9 #include "LroNarrowAngleCamera.h"
10 
11 #include <iomanip>
12 
13 #include "CameraFocalPlaneMap.h"
14 #include "IException.h"
15 #include "IString.h"
16 #include "iTime.h"
17 #include "LineScanCameraDetectorMap.h"
18 #include "LineScanCameraGroundMap.h"
19 #include "LineScanCameraSkyMap.h"
20 #include "LroNarrowAngleDistortionMap.h"
21 #include "NaifStatus.h"
22 
23 using namespace std;
24 namespace Isis {
33  LroNarrowAngleCamera::LroNarrowAngleCamera(Cube &cube) : LineScanCamera(cube) {
34  m_spacecraftNameLong = "Lunar Reconnaissance Orbiter";
35  m_spacecraftNameShort = "LRO";
36  // NACL instrument kernel code = -85600
37  if (naifIkCode() == -85600) {
38  m_instrumentNameLong = "Narrow Angle Camera Left";
39  m_instrumentNameShort = "NACL";
40  }
41  // NACR instrument kernel code = -85610
42  else if (naifIkCode() == -85610) {
43  m_instrumentNameLong = "Narrow Angle Camera Right";
44  m_instrumentNameShort = "NACR";
45  }
46  else {
47  QString msg = "File does not appear to be a Lunar Reconnaissance Orbiter Image: ";
48  msg += QString::number(naifIkCode());
49  msg += " is not a supported instrument kernel code for Lunar Reconnaissance Orbiter.";
50  throw IException(IException::Programmer, msg, _FILEINFO_);
51  }
53 
54  // Set up the camera info from ik/iak kernels
56  SetPixelPitch();
57 
58  double constantTimeOffset = 0.0,
59  additionalPreroll = 0.0,
60  additiveLineTimeError = 0.0,
61  multiplicativeLineTimeError = 0.0;
62 
63  QString ikernKey = "INS" + toString(naifIkCode()) + "_CONSTANT_TIME_OFFSET";
64  constantTimeOffset = getDouble(ikernKey);
65 
66  ikernKey = "INS" + toString(naifIkCode()) + "_ADDITIONAL_PREROLL";
67  additionalPreroll = getDouble(ikernKey);
68 
69  ikernKey = "INS" + toString(naifIkCode()) + "_ADDITIVE_LINE_ERROR";
70  additiveLineTimeError = getDouble(ikernKey);
71 
72  ikernKey = "INS" + toString(naifIkCode()) + "_MULTIPLI_LINE_ERROR";
73  multiplicativeLineTimeError = getDouble(ikernKey);
74 
75  // Get the start time from labels
76  Pvl &lab = *cube.label();
77  PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
78  QString stime = inst["SpacecraftClockPrerollCount"];
79  SpiceDouble etStart;
80 
81  if(stime != "NULL") {
82  etStart = getClockTime(stime).Et();
83  }
84  else {
85  etStart = iTime((QString)inst["PrerollTime"]).Et();
86  }
87 
88  // Get other info from labels
89  double csum = inst["SpatialSumming"];
90  double lineRate = (double) inst["LineExposureDuration"] / 1000.0;
91  double ss = inst["SampleFirstPixel"];
92  ss += 1.0;
93 
94  lineRate *= 1.0 + multiplicativeLineTimeError;
95  lineRate += additiveLineTimeError;
96  etStart += additionalPreroll * lineRate;
97  etStart += constantTimeOffset;
98 
99  setTime(etStart);
100 
101  // Setup detector map
102  LineScanCameraDetectorMap *detectorMap = new LineScanCameraDetectorMap(this, etStart, lineRate);
103  detectorMap->SetDetectorSampleSumming(csum);
104  detectorMap->SetStartingDetectorSample(ss);
105 
106  // Setup focal plane map
107  CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
108 
109  // Retrieve boresight location from instrument kernel (IK) (addendum?)
110  ikernKey = "INS" + toString(naifIkCode()) + "_BORESIGHT_SAMPLE";
111  double sampleBoreSight = getDouble(ikernKey);
112 
113  ikernKey = "INS" + toString(naifIkCode()) + "_BORESIGHT_LINE";
114  double lineBoreSight = getDouble(ikernKey);
115 
116  focalMap->SetDetectorOrigin(sampleBoreSight, lineBoreSight);
117  focalMap->SetDetectorOffset(0.0, 0.0);
118 
119  // Setup distortion map
121  distMap->SetDistortion(naifIkCode());
122 
123  // Setup the ground and sky map
124  new LineScanCameraGroundMap(this);
125  new LineScanCameraSkyMap(this);
126 
127  LoadCache();
129  }
130 }
131 
142 extern "C" Isis::Camera *LroNarrowAngleCameraPlugin(Isis::Cube &cube) {
143  return new Isis::LroNarrowAngleCamera(cube);
144 }
Isis::LineScanCameraSkyMap
Convert between undistorted focal plane and ra/dec coordinates.
Definition: LineScanCameraSkyMap.h:34
Isis::CameraFocalPlaneMap::SetDetectorOrigin
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
Definition: CameraFocalPlaneMap.cpp:293
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::Spice::naifIkCode
SpiceInt naifIkCode() const
This returns the NAIF IK code to use when reading from instrument kernels.
Definition: Spice.cpp:968
Isis::iTime
Parse and return pieces of a time string.
Definition: iTime.h:65
Isis::LroNarrowAngleDistortionMap::SetDistortion
void SetDistortion(const int naifIkCode)
Definition: LroNarrowAngleDistortionMap.cpp:33
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::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::CameraFocalPlaneMap::SetDetectorOffset
void SetDetectorOffset(const double sampleOffset, const double lineOffset)
Set the detector offset.
Definition: CameraFocalPlaneMap.cpp:324
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::LroNarrowAngleDistortionMap
Distort/undistort focal plane coordinates.
Definition: LroNarrowAngleDistortionMap.h:42
Isis::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
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::LroNarrowAngleCamera
LRO Narrow Angle Camera Model.
Definition: LroNarrowAngleCamera.h:41
Isis::LineScanCamera
Generic class for Line Scan Cameras.
Definition: LineScanCamera.h:36
Isis::LineScanCameraGroundMap
Convert between undistorted focal plane and ground coordinates.
Definition: LineScanCameraGroundMap.h:49
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
Isis::CameraDetectorMap::SetStartingDetectorSample
void SetStartingDetectorSample(const double sample)
Set the starting detector sample.
Definition: CameraDetectorMap.h:79
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
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::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::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::LineScanCameraDetectorMap
Convert between parent image coordinates and detector coordinates.
Definition: LineScanCameraDetectorMap.h:37