Isis 3 Programmer Reference
NewHorizonsLorriCamera.cpp
Go to the documentation of this file.
1 
21 #include "NewHorizonsLorriCamera.h"
22 
23 #include <QString>
24 
25 #include "CameraDetectorMap.h"
26 #include "CameraDistortionMap.h"
27 #include "CameraFocalPlaneMap.h"
28 #include "CameraGroundMap.h"
29 #include "CameraSkyMap.h"
30 #include "IString.h"
31 #include "iTime.h"
32 #include "NaifStatus.h"
34 
35 using namespace std;
36 
37 namespace Isis {
52  NewHorizonsLorriCamera::NewHorizonsLorriCamera(Cube &cube) : FramingCamera(cube) {
53  m_instrumentNameLong = "Long Range Reconnaissance Imager";
54  m_instrumentNameShort = "LORRI";
55  m_spacecraftNameLong = "New Horizons";
56  m_spacecraftNameShort = "NewHorizons";
57 
59 
60  // The LORRI focal length is fixed and is designed not to change throught the operational
61  // temperature. The NAIF code, set in the ISIS labels, will be used to read a single focal
62  // length from the SPICE kernels. Version 100 of the Lorri IK uses meters for focal length,
63  // units, version 200 uses mm, and has a units keyword.
64  QString unitsKey = "INS" + toString(naifIkCode()) + "_FOCAL_LENGTH_UNITS";
65  QString focalLengthUnits = Spice::getString(unitsKey);
66  if (focalLengthUnits != "mm") {
67  QString msg = QObject::tr("SPICE keyword [%1] is expected to be mm. [%2] was found instead").
68  arg(unitsKey).arg(focalLengthUnits);
70  }
71  SetFocalLength(Spice::getDouble("INS" + toString(naifIkCode()) + "_FOCAL_LENGTH"));
72 
73  // For setting the pixel pitch, the Naif keyword PIXEL_SIZE is used instead of the ISIS
74  // default of PIXEL_PITCH, so set the value directly.
75  QString pp = "INS" + toString(naifIkCode()) + "_PIXEL_SIZE";
76  double pixelPitch = Spice::getDouble(pp);
77  pixelPitch /= 1000.0;
78  SetPixelPitch(pixelPitch);
79 
80  // Since the two summing modes are handeled via different Naif codes, force the summing modes
81  // to 1 for both the 1x1 and 4x4 modes
82  CameraDetectorMap *detectorMap = new CameraDetectorMap(this);
83  detectorMap->SetDetectorSampleSumming(1);
84  detectorMap->SetDetectorLineSumming(1);
85 
86  // Setup focal plane map. The class will read data from the instrument addendum kernel to pull
87  // out the affine transforms from detector samp,line to focal plane x,y.
88  CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
89 
90  // The boresight position recorded in the IK is zero-based and therefore needs to be adjusted
91  // for ISIS
92  double boresightSample = Spice::getDouble("INS" + toString(naifIkCode()) + "_CCD_CENTER",0) + 1.0;
93  double boresightLine = Spice::getDouble("INS" + toString(naifIkCode()) + "_CCD_CENTER",1) + 1.0;
94  focalMap->SetDetectorOrigin(boresightSample,boresightLine);
95 
96  // Setup distortion map. Start by reading the distortion coefficient from the instrument kernel.
97  // Then construct the distortion model.
98  // Uncomment the 3 lines below to use the default distortion map (i.e., no distortion)
99  // new CameraDistortionMap(this, -1);
100  // CameraDistortionMap *distortionMap = new CameraDistortionMap(this, -1);
101  // distortionMap->SetDistortion(naifIkCode());
102  // Changed the SPICE keyword names to work with LORRI IK version 200
103  QString e2("INS" + toString(naifIkCode()) + "_OOC_EM");
104  QString e5("INS" + toString(naifIkCode()) + "_OOC_EM");
105  QString e6("INS" + toString(naifIkCode()) + "_OOC_EM");
106  new NewHorizonsLorriDistortionMap(this, getDouble(e2, 0), getDouble(e5, 1),
107  getDouble(e6, 2), -1);
108 
109  // Setup the ground and sky map
110  new CameraGroundMap(this);
111  new CameraSkyMap(this);
112 
113  // The observation start time and clock count for LORRI are based on the center of the exposure.
114  Pvl &lab = *cube.label();
115  PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
116  QString clockCount = inst["SpacecraftClockStartCount"];
117  double et = getClockTime(clockCount).Et();
118  double exposureDuration = (double)inst["ExposureDuration"] / 1000.0;
119 
120  pair<iTime, iTime> startStop = ShutterOpenCloseTimes(et, exposureDuration);
121  setTime(et);
122 
123  // Internalize all the NAIF SPICE information into memory.
124  LoadCache();
126  }
127 
142  pair<iTime, iTime> NewHorizonsLorriCamera::ShutterOpenCloseTimes(double time,
143  double exposureDuration) {
145  }
146 }
147 
160  return new Isis::NewHorizonsLorriCamera(cube);
161 }
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
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.
Search child objects.
Definition: PvlObject.h:170
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.
Isis::Camera * NewHorizonsLorriCameraPlugin(Isis::Cube &cube)
This is the function that is called in order to instantiate a NewHorizonsLorriCamera object...
void SetDetectorLineSumming(const double summing)
Set line summing mode.
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)=0
Returns the shutter open and close times.
Convert between parent image coordinates and detector coordinates.
This is the camera model for the LORRI Framing Camera.
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.
QString m_instrumentNameShort
Shortened instrument name.
Definition: Camera.h:508
New Horizons LORRI Distortion Map.
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
A type of error that could only have occurred due to a mistake on the user&#39;s part (e...
Definition: IException.h:142
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
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)
Reimplemented from FrameCamera.
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
void LoadCache()
This loads the spice cache big enough for this image.
Definition: Camera.cpp:2432
QString getString(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition: Spice.cpp:1185
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
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
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
Convert between undistorted focal plane and ra/dec coordinates.
Definition: CameraSkyMap.h:48
QString m_spacecraftNameShort
Shortened spacecraft name.
Definition: Camera.h:510
virtual double exposureDuration() const
Return the exposure duration for the pixel that the camera is set to.
Definition: Camera.cpp:3075
Generic class for Framing Cameras.
Definition: FramingCamera.h:48
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
iTime time() const
Returns the ephemeris time in seconds which was used to obtain the spacecraft and sun positions...
Definition: Spice.cpp:809