Isis 3 Programmer Reference
OsirisRexOcamsCamera.cpp
Go to the documentation of this file.
1 
21 #include "OsirisRexOcamsCamera.h"
22 
23 #include <QDebug>
24 #include <QString>
25 
26 #include "CameraDetectorMap.h"
27 #include "OsirisRexDistortionMap.h"
28 #include "CameraFocalPlaneMap.h"
29 #include "CameraGroundMap.h"
30 #include "CameraSkyMap.h"
31 #include "IString.h"
32 #include "iTime.h"
33 #include "NaifStatus.h"
34 
35 using namespace std;
36 
37 namespace Isis {
38 
45  OsirisRexOcamsCamera::OsirisRexOcamsCamera(Cube &cube) : FramingCamera(cube) {
46 
48 
49  m_spacecraftNameLong = "OSIRIS-REx";
50  m_spacecraftNameShort = "OSIRIS-REx";
51 
52  // The general IK code will be used to retrieve the transx,
53  // transy, transs and transl from the iak. The focus position specific
54  // IK code will be used to find pixel pitch and ccd center in the ik.
55  int frameCode = naifIkCode();
56 
57  if (frameCode == -64361) {
58  m_instrumentNameLong = "Mapping Camera";
59  m_instrumentNameShort = "MapCam";
60  }
61  else if (frameCode == -64362) {
62  m_instrumentNameLong = "Sampling Camera";
63  m_instrumentNameShort = "SamCam";
64  } // IK values for polycam: -64360 (general) and -64616 to -64500 (focus specific)
65  else if (frameCode == -64360) {
66  m_instrumentNameLong = "PolyMath Camera";
67  m_instrumentNameShort = "PolyCam";
68  }
69  else {
70  QString msg = "Unable to construct OSIRIS-REx camera model. "
71  "Unrecognized NaifFrameCode [" + toString(frameCode) + "].";
73  }
74 
75  Pvl &lab = *cube.label();
76  PvlGroup inst = lab.findGroup("Instrument", Pvl::Traverse);
77 
78  QString ikCode = toString(frameCode);
79  if (inst.hasKeyword("PolyCamFocusPositionNaifId") && frameCode == -64360) {
80  if (QString::compare("NONE", inst["PolyCamFocusPositionNaifId"],
81  Qt::CaseInsensitive) != 0) {
82  ikCode = inst["PolyCamFocusPositionNaifId"][0];
83  }
84  }
85 
86  QString focalLength = "INS" + ikCode + "_FOCAL_LENGTH";
87  SetFocalLength(getDouble(focalLength));
88 
89  // The instrument kernel contains pixel pitch in microns, so convert it to mm.
90  QString pitch = "INS" + ikCode + "_PIXEL_SIZE";
91  SetPixelPitch(getDouble(pitch) / 1000.0);
92 
93  // Get the start time in et
94  // Set the observation time and exposure duration
95  QString clockCount = inst["SpacecraftClockStartCount"];
96  double startTime = getClockTime(clockCount).Et();
97  double exposureDuration = ((double) inst["ExposureDuration"]) / 1000.0;
98  pair<iTime, iTime> shuttertimes = ShutterOpenCloseTimes(startTime, exposureDuration);
99 
100  // Add half exposure duration to get time at center of image
101  iTime centerTime = shuttertimes.first.Et() + exposureDuration / 2.0;
102 
103  // Setup detector map
104  new CameraDetectorMap(this);
105 
106  // Setup focal plane map using the general IK code for the given camera
107  // Note that this is not the specific naifIkCode() value for PolyCam
108  CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, frameCode);
109 
110  // The instrument kernel contains a CCD_CENTER keyword instead of BORESIGHT_LINE
111  // and BORESIGHT_SAMPLE keywords.
112  focalMap->SetDetectorOrigin(
113  Spice::getDouble("INS" + ikCode + "_CCD_CENTER", 0) + 1.0,
114  Spice::getDouble("INS" + ikCode + "_CCD_CENTER", 1) + 1.0);
115 
116  // Setup distortion map
117  OsirisRexDistortionMap *distortionMap = new OsirisRexDistortionMap(this);
118 
119  // Different distortion model for each instrument and filter
120  PvlGroup bandBin = lab.findGroup("BandBin", Pvl::Traverse);
121  QString filterName = bandBin["FilterName"];
122  distortionMap->SetDistortion(ikCode.toInt(), filterName);
123 
124  // Setup the ground and sky map
125  new CameraGroundMap(this);
126  new CameraSkyMap(this);
127 
128  setTime(centerTime);
129  LoadCache();
131  }
132 
133 
136  }
137 
138 
147  return -64000;
148  }
149 
150 
160  return 1;
161  }
162 
163 
170  return 1;
171  }
172 
173 
196  pair<iTime, iTime> OsirisRexOcamsCamera::ShutterOpenCloseTimes(double time,
197  double exposureDuration) {
199  }
200 
201 }
202 
203 
213  return new Isis::OsirisRexOcamsCamera(cube);
214 }
void SetFocalLength()
Reads the focal length from the instrument kernel.
Definition: Camera.cpp:1430
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
virtual int CkFrameId() const
The frame ID for the spacecraft (or instrument) used by the Camera-matrix Kernel. ...
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition: PvlObject.h:141
This class models the behavior and attributes of the OSIRIS-REx Cameras: Mapping Camera, PolyMath Camera, and Sample Camera.
Parse and return pieces of a time string.
Definition: iTime.h:78
QString m_instrumentNameLong
Full instrument name.
Definition: Camera.h:507
virtual void SetDistortion(int naifIkCode, QString filterName)
Load distortion coefficients and center-of-distortion for OCAMS.
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.
~OsirisRexOcamsCamera()
Destroys the MapCamera object.
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.
Convert between undistorted focal plane and ground coordinates.
Distort/undistort focal plane coordinates for OSIRIS REx&#39;s cameras.
Convert between distorted focal plane and detector coordinates.
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
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 int SpkReferenceId() const
The reference frame ID for the Spacecraft Kernel is 1, representing J2000.
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
virtual int CkReferenceId() const
The frame ID for the reference coordinate system used by the Camera-matrix Kernel.
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
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)
Returns the shutter open and close times.
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
Isis::Camera * OsirisRexOcamsCameraPlugin(Isis::Cube &cube)
This is the function that is called in order to instantiate a MapCamera object.
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
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
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