Isis 3 Programmer Reference
OsirisRexOcamsCamera.cpp
1 
7 /* SPDX-License-Identifier: CC0-1.0 */
8 
9 #include "OsirisRexOcamsCamera.h"
10 
11 #include <QDebug>
12 #include <QString>
13 
14 #include "CameraDetectorMap.h"
15 #include "OsirisRexDistortionMap.h"
16 #include "CameraFocalPlaneMap.h"
17 #include "CameraGroundMap.h"
18 #include "CameraSkyMap.h"
19 #include "IString.h"
20 #include "iTime.h"
21 #include "NaifStatus.h"
22 
23 using namespace std;
24 
25 namespace Isis {
26 
33  OsirisRexOcamsCamera::OsirisRexOcamsCamera(Cube &cube) : FramingCamera(cube) {
34 
36 
37  m_spacecraftNameLong = "OSIRIS-REx";
38  m_spacecraftNameShort = "OSIRIS-REx";
39 
40  // The general IK code will be used to retrieve the transx,
41  // transy, transs and transl from the iak. The focus position specific
42  // IK code will be used to find pixel pitch and ccd center in the ik.
43  int frameCode = naifIkCode();
44 
45  if (frameCode == -64361) {
46  m_instrumentNameLong = "Mapping Camera";
47  m_instrumentNameShort = "MapCam";
48  }
49  else if (frameCode == -64362) {
50  m_instrumentNameLong = "Sampling Camera";
51  m_instrumentNameShort = "SamCam";
52  } // IK values for polycam: -64360 (general) and -64616 to -64500 (focus specific)
53  else if (frameCode == -64360) {
54  m_instrumentNameLong = "PolyMath Camera";
55  m_instrumentNameShort = "PolyCam";
56  }
57  else {
58  QString msg = "Unable to construct OSIRIS-REx camera model. "
59  "Unrecognized NaifFrameCode [" + toString(frameCode) + "].";
60  throw IException(IException::User, msg, _FILEINFO_);
61  }
62 
63  Pvl &lab = *cube.label();
64  PvlGroup inst = lab.findGroup("Instrument", Pvl::Traverse);
65 
66  QString ikCode = toString(frameCode);
67  if (inst.hasKeyword("PolyCamFocusPositionNaifId") && frameCode == -64360) {
68  if (QString::compare("NONE", inst["PolyCamFocusPositionNaifId"],
69  Qt::CaseInsensitive) != 0) {
70  ikCode = inst["PolyCamFocusPositionNaifId"][0];
71  }
72  }
73 
74  QString focalLength = "INS" + ikCode + "_FOCAL_LENGTH";
75  SetFocalLength(getDouble(focalLength));
76 
77  // The instrument kernel contains pixel pitch in microns, so convert it to mm.
78  QString pitch = "INS" + ikCode + "_PIXEL_SIZE";
79  SetPixelPitch(getDouble(pitch) / 1000.0);
80 
81  // Get the start time in et
82  // Set the observation time and exposure duration
83  QString clockCount = inst["SpacecraftClockStartCount"];
84  double startTime = getClockTime(clockCount).Et();
85  double exposureDuration = ((double) inst["ExposureDuration"]) / 1000.0;
86  pair<iTime, iTime> shuttertimes = ShutterOpenCloseTimes(startTime, exposureDuration);
87 
88  // Add half exposure duration to get time at center of image
89  iTime centerTime = shuttertimes.first.Et() + exposureDuration / 2.0;
90 
91  // Setup detector map
92  new CameraDetectorMap(this);
93 
94  // Setup focal plane map using the general IK code for the given camera
95  // Note that this is not the specific naifIkCode() value for PolyCam
96  CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, frameCode);
97 
98  // The instrument kernel contains a CCD_CENTER keyword instead of BORESIGHT_LINE
99  // and BORESIGHT_SAMPLE keywords.
100  focalMap->SetDetectorOrigin(
101  Spice::getDouble("INS" + ikCode + "_CCD_CENTER", 0) + 1.0,
102  Spice::getDouble("INS" + ikCode + "_CCD_CENTER", 1) + 1.0);
103 
104  // Setup distortion map
105  OsirisRexDistortionMap *distortionMap = new OsirisRexDistortionMap(this);
106 
107  // Different distortion model for each instrument and filter
108  PvlGroup bandBin = lab.findGroup("BandBin", Pvl::Traverse);
109  QString filterName = bandBin["FilterName"];
110  distortionMap->SetDistortion(ikCode.toInt(), filterName);
111 
112  // Setup the ground and sky map
113  new CameraGroundMap(this);
114  new CameraSkyMap(this);
115 
116  setTime(centerTime);
117  LoadCache();
119  }
120 
121 
124  }
125 
126 
135  return -64000;
136  }
137 
138 
148  return 1;
149  }
150 
151 
158  return 1;
159  }
160 
161 
184  pair<iTime, iTime> OsirisRexOcamsCamera::ShutterOpenCloseTimes(double time,
185  double exposureDuration) {
187  }
188 
189 }
190 
191 
200 extern "C" Isis::Camera *OsirisRexOcamsCameraPlugin(Isis::Cube &cube) {
201  return new Isis::OsirisRexOcamsCamera(cube);
202 }
Isis::OsirisRexDistortionMap
Distort/undistort focal plane coordinates for OSIRIS REx's cameras.
Definition: OsirisRexDistortionMap.h:30
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::OsirisRexOcamsCamera
This class models the behavior and attributes of the OSIRIS-REx Cameras: Mapping Camera,...
Definition: OsirisRexOcamsCamera.h:45
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::OsirisRexOcamsCamera::CkFrameId
virtual int CkFrameId() const
The frame ID for the spacecraft (or instrument) used by the Camera-matrix Kernel.
Definition: OsirisRexOcamsCamera.cpp:134
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::iTime
Parse and return pieces of a time string.
Definition: iTime.h:65
Isis::OsirisRexDistortionMap::SetDistortion
virtual void SetDistortion(int naifIkCode, QString filterName)
Load distortion coefficients and center-of-distortion for OCAMS.
Definition: OsirisRexDistortionMap.cpp:71
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::PvlContainer::hasKeyword
bool hasKeyword(const QString &name) const
Check to see if a keyword exists.
Definition: PvlContainer.cpp:159
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::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::OsirisRexOcamsCamera::SpkReferenceId
virtual int SpkReferenceId() const
The reference frame ID for the Spacecraft Kernel is 1, representing J2000.
Definition: OsirisRexOcamsCamera.cpp:157
Isis::OsirisRexOcamsCamera::CkReferenceId
virtual int CkReferenceId() const
The frame ID for the reference coordinate system used by the Camera-matrix Kernel.
Definition: OsirisRexOcamsCamera.cpp:147
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::OsirisRexOcamsCamera::ShutterOpenCloseTimes
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)
Returns the shutter open and close times.
Definition: OsirisRexOcamsCamera.cpp:184
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::OsirisRexOcamsCamera::~OsirisRexOcamsCamera
~OsirisRexOcamsCamera()
Destroys the MapCamera object.
Definition: OsirisRexOcamsCamera.cpp:123
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::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