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
23using namespace std;
24
25namespace Isis {
26
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) || (frameCode >= -64616 && frameCode <= -64500)) {
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
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
200extern "C" Isis::Camera *OsirisRexOcamsCameraPlugin(Isis::Cube &cube) {
201 return new Isis::OsirisRexOcamsCamera(cube);
202}
Convert between parent image coordinates and detector coordinates.
Convert between distorted focal plane and detector coordinates.
Convert between undistorted focal plane and ground coordinates.
QString m_spacecraftNameLong
Full spacecraft name.
Definition Camera.h:499
virtual double exposureDuration() const
Return the exposure duration for the pixel that the camera is set to.
Definition Camera.cpp:3093
void SetFocalLength()
Reads the focal length from the instrument kernel.
Definition Camera.cpp:1422
void SetPixelPitch()
Reads the Pixel Pitch from the instrument kernel.
Definition Camera.cpp:1429
void LoadCache()
This loads the spice cache big enough for this image.
Definition Camera.cpp:2450
QString m_instrumentNameShort
Shortened instrument name.
Definition Camera.h:498
QString m_spacecraftNameShort
Shortened spacecraft name.
Definition Camera.h:500
QString m_instrumentNameLong
Full instrument name.
Definition Camera.h:497
Convert between undistorted focal plane and ra/dec coordinates.
IO Handler for Isis Cubes.
Definition Cube.h:168
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition Cube.cpp:1707
Generic class for Framing Cameras.
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)=0
Returns the shutter open and close times.
Isis exception class.
Definition IException.h:91
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition IException.h:126
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Distort/undistort focal plane coordinates for OSIRIS REx's cameras.
This class models the behavior and attributes of the OSIRIS-REx Cameras: Mapping Camera,...
OsirisRexOcamsCamera(Cube &cube)
Constructs an OSIRIS-REx Camera Model using the image labels.
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)
Returns the shutter open and close times.
~OsirisRexOcamsCamera()
Destroys the MapCamera object.
virtual int CkFrameId() const
The frame ID for the spacecraft (or instrument) used by the Camera-matrix Kernel.
virtual int CkReferenceId() const
The frame ID for the reference coordinate system used by the Camera-matrix Kernel.
virtual int SpkReferenceId() const
The reference frame ID for the Spacecraft Kernel is 1, representing J2000.
Contains multiple PvlContainers.
Definition PvlGroup.h:41
Container for cube-like labels.
Definition Pvl.h:119
@ Traverse
Search child objects.
Definition PvlObject.h:158
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:99
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:1060
virtual iTime time() const
Returns the ephemeris time in seconds which was used to obtain the spacecraft and sun positions.
Definition Spice.cpp:891
SpiceInt naifIkCode() const
This returns the NAIF IK code to use when reading from instrument kernels.
Definition Spice.cpp:975
SpiceDouble getDouble(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition Spice.cpp:1046
Parse and return pieces of a time string.
Definition iTime.h:65
double Et() const
Returns the ephemeris time (TDB) representation of the time as a double.
Definition iTime.h:126
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition IString.cpp:211
Namespace for the standard library.