Isis 3 Programmer Reference
LroNarrowAngleCamera.cpp
Go to the documentation of this file.
1 
20 #include "LroNarrowAngleCamera.h"
21 
22 #include <iomanip>
23 
24 #include "CameraFocalPlaneMap.h"
25 #include "IException.h"
26 #include "IString.h"
27 #include "iTime.h"
30 #include "LineScanCameraSkyMap.h"
32 #include "NaifStatus.h"
33 
34 using namespace std;
35 namespace Isis {
44  LroNarrowAngleCamera::LroNarrowAngleCamera(Cube &cube) : LineScanCamera(cube) {
45  m_spacecraftNameLong = "Lunar Reconnaissance Orbiter";
46  m_spacecraftNameShort = "LRO";
47  // NACL instrument kernel code = -85600
48  if (naifIkCode() == -85600) {
49  m_instrumentNameLong = "Narrow Angle Camera Left";
50  m_instrumentNameShort = "NACL";
51  }
52  // NACR instrument kernel code = -85610
53  else if (naifIkCode() == -85610) {
54  m_instrumentNameLong = "Narrow Angle Camera Right";
55  m_instrumentNameShort = "NACR";
56  }
57  else {
58  QString msg = "File does not appear to be a Lunar Reconnaissance Orbiter Image: ";
59  msg += QString::number(naifIkCode());
60  msg += " is not a supported instrument kernel code for Lunar Reconnaissance Orbiter.";
62  }
64 
65  // Set up the camera info from ik/iak kernels
67  SetPixelPitch();
68 
69  double constantTimeOffset = 0.0,
70  additionalPreroll = 0.0,
71  additiveLineTimeError = 0.0,
72  multiplicativeLineTimeError = 0.0;
73 
74  QString ikernKey = "INS" + toString(naifIkCode()) + "_CONSTANT_TIME_OFFSET";
75  constantTimeOffset = getDouble(ikernKey);
76 
77  ikernKey = "INS" + toString(naifIkCode()) + "_ADDITIONAL_PREROLL";
78  additionalPreroll = getDouble(ikernKey);
79 
80  ikernKey = "INS" + toString(naifIkCode()) + "_ADDITIVE_LINE_ERROR";
81  additiveLineTimeError = getDouble(ikernKey);
82 
83  ikernKey = "INS" + toString(naifIkCode()) + "_MULTIPLI_LINE_ERROR";
84  multiplicativeLineTimeError = getDouble(ikernKey);
85 
86  // Get the start time from labels
87  Pvl &lab = *cube.label();
88  PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
89  QString stime = inst["SpacecraftClockPrerollCount"];
90  SpiceDouble etStart;
91 
92  if(stime != "NULL") {
93  etStart = getClockTime(stime).Et();
94  }
95  else {
96  etStart = iTime((QString)inst["PrerollTime"]).Et();
97  }
98 
99  // Get other info from labels
100  double csum = inst["SpatialSumming"];
101  double lineRate = (double) inst["LineExposureDuration"] / 1000.0;
102  double ss = inst["SampleFirstPixel"];
103  ss += 1.0;
104 
105  lineRate *= 1.0 + multiplicativeLineTimeError;
106  lineRate += additiveLineTimeError;
107  etStart += additionalPreroll * lineRate;
108  etStart += constantTimeOffset;
109 
110  setTime(etStart);
111 
112  // Setup detector map
113  LineScanCameraDetectorMap *detectorMap = new LineScanCameraDetectorMap(this, etStart, lineRate);
114  detectorMap->SetDetectorSampleSumming(csum);
115  detectorMap->SetStartingDetectorSample(ss);
116 
117  // Setup focal plane map
118  CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
119 
120  // Retrieve boresight location from instrument kernel (IK) (addendum?)
121  ikernKey = "INS" + toString(naifIkCode()) + "_BORESIGHT_SAMPLE";
122  double sampleBoreSight = getDouble(ikernKey);
123 
124  ikernKey = "INS" + toString(naifIkCode()) + "_BORESIGHT_LINE";
125  double lineBoreSight = getDouble(ikernKey);
126 
127  focalMap->SetDetectorOrigin(sampleBoreSight, lineBoreSight);
128  focalMap->SetDetectorOffset(0.0, 0.0);
129 
130  // Setup distortion map
132  distMap->SetDistortion(naifIkCode());
133 
134  // Setup the ground and sky map
135  new LineScanCameraGroundMap(this);
136  new LineScanCameraSkyMap(this);
137 
138  LoadCache();
140  }
141 }
142 
154  return new Isis::LroNarrowAngleCamera(cube);
155 }
void SetFocalLength()
Reads the focal length from the instrument kernel.
Definition: Camera.cpp:1430
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition: PvlObject.h:141
void SetDetectorOffset(const double sampleOffset, const double lineOffset)
Set the detector offset.
Parse and return pieces of a time string.
Definition: iTime.h:78
Distort/undistort focal plane coordinates.
QString m_instrumentNameLong
Full instrument name.
Definition: Camera.h:507
void SetDetectorSampleSumming(const double summing)
Set sample summing mode.
void SetPixelPitch()
Reads the Pixel Pitch from the instrument kernel.
Definition: Camera.cpp:1437
Namespace for the standard library.
Generic class for Line Scan Cameras.
Search child objects.
Definition: PvlObject.h:170
Isis::Camera * LroNarrowAngleCameraPlugin(Isis::Cube &cube)
This is the function that is called in order to instantiate a LroNarrowAngle object.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:226
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:162
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
Convert between undistorted focal plane and ground coordinates.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
Convert between distorted focal plane and detector coordinates.
LRO Narrow Angle Camera Model.
QString m_instrumentNameShort
Shortened instrument name.
Definition: Camera.h:508
Contains multiple PvlContainers.
Definition: PvlGroup.h:57
SpiceInt naifIkCode() const
This returns the NAIF IK code to use when reading from instrument kernels.
Definition: Spice.cpp:893
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
iTime getClockTime(QString clockValue, int sclkCode=-1, bool clockTicks=false)
This converts the spacecraft clock ticks value (clockValue) to an iTime.
Definition: Spice.cpp:977
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:112
Container for cube-like labels.
Definition: Pvl.h:135
Convert between undistorted focal plane and ra/dec coordinates.
void LoadCache()
This loads the spice cache big enough for this image.
Definition: Camera.cpp:2432
QString m_spacecraftNameLong
Full spacecraft name.
Definition: Camera.h:509
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition: Cube.cpp:1346
void SetStartingDetectorSample(const double sample)
Set the starting detector sample.
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Definition: NaifStatus.cpp:43
Isis exception class.
Definition: IException.h:107
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
QString m_spacecraftNameShort
Shortened spacecraft name.
Definition: Camera.h:510
Convert between parent image coordinates and detector coordinates.
double Et() const
Returns the ephemeris time (TDB) representation of the time as a double.
Definition: iTime.h:139
SpiceDouble getDouble(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition: Spice.cpp:963
IO Handler for Isis Cubes.
Definition: Cube.h:170