Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.

Isis 3 Programmer Reference
OsirisRexOcamsCamera.cpp
1
6
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 "CameraFocalPlaneMap.h"
16#include "CameraGroundMap.h"
17#include "CameraSkyMap.h"
18#include "IrregularBodyCameraGroundMap.h"
19#include "IString.h"
20#include "iTime.h"
21#include "NaifStatus.h"
22#include "OsirisRexDistortionMap.h"
24
25using namespace std;
26
27namespace Isis {
28
36
38
39 m_spacecraftNameLong = "OSIRIS-REx";
40 m_spacecraftNameShort = "OSIRIS-REx";
41
42 // The general IK code will be used to retrieve the transx,
43 // transy, transs and transl from the iak. The focus position specific
44 // IK code will be used to find pixel pitch and ccd center in the ik.
45 int frameCode = naifIkCode();
46
47 if (frameCode == -64361) {
48 m_instrumentNameLong = "Mapping Camera";
49 m_instrumentNameShort = "MapCam";
50 }
51 else if (frameCode == -64362) {
52 m_instrumentNameLong = "Sampling Camera";
53 m_instrumentNameShort = "SamCam";
54 } // IK values for polycam: -64360 (general) and -64616 to -64500 (focus specific)
55 else if ((frameCode == -64360) || (frameCode >= -64616 && frameCode <= -64500)) {
56 m_instrumentNameLong = "PolyMath Camera";
57 m_instrumentNameShort = "PolyCam";
58 }
59 else {
60 QString msg = "Unable to construct OSIRIS-REx camera model. "
61 "Unrecognized NaifFrameCode [" + toString(frameCode) + "].";
62 throw IException(IException::User, msg, _FILEINFO_);
63 }
64
65 Pvl &lab = *cube.label();
66 PvlGroup inst = lab.findGroup("Instrument", Pvl::Traverse);
67 QString ikCode = toString(frameCode);
68 int focusIkCode(frameCode); // Default for all other than PolyCam, too
69 // NOTE: This is likely to be use for MapCam's filter IDs that was added on or about
70 // 2019-02-20.
71 if (inst.hasKeyword("PolyCamFocusPositionNaifId")) {
72 if (QString::compare("NONE", inst["PolyCamFocusPositionNaifId"], Qt::CaseInsensitive) != 0) {
73 focusIkCode = toInt(inst["PolyCamFocusPositionNaifId"][0]);
74 }
75 }
76
77 // Different distortion model for each instrument and filter
78 PvlGroup bandBin = lab.findGroup("BandBin", Pvl::Traverse);
79 QString filterName = bandBin["FilterName"];
80
81 int distortCode = getFunctionalIkCode(frameCode, focusIkCode, filterName);
82 QString dcode(toString(distortCode));
83
84 QString focalLength = "INS" + dcode + "_FOCAL_LENGTH";
85 SetFocalLength(getDouble(focalLength));
86
87 // The instrument kernel contains pixel pitch in microns, so convert it to mm.
88 QString pitch = "INS" + dcode + "_PIXEL_SIZE";
89 SetPixelPitch(getDouble(pitch) / 1000.0);
90
91 // Get the start time in et
92 // Set the observation time and exposure duration
93 QString clockCount = inst["SpacecraftClockStartCount"];
94 double startTime = getClockTime(clockCount).Et();
95 double exposureDuration = ((double) inst["ExposureDuration"]) / 1000.0;
96 pair<iTime, iTime> shuttertimes = ShutterOpenCloseTimes(startTime, exposureDuration);
97
98 // Add half exposure duration to get time at center of image
99 iTime centerTime = shuttertimes.first.Et() + exposureDuration / 2.0;
100
101 // Setup detector map
102 new CameraDetectorMap(this);
103
104 // Setup focal plane map using the general IK code for the given camera
105 // Note that this is not the specific naifIkCode() value for PolyCam
106 CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, frameCode);
107
108 // The instrument kernel contains a CCD_CENTER keyword instead of BORESIGHT_LINE
109 // and BORESIGHT_SAMPLE keywords.
110 focalMap->SetDetectorOrigin(
111 Spice::getDouble("INS" + ikCode + "_CCD_CENTER", 0) + 1.0,
112 Spice::getDouble("INS" + ikCode + "_CCD_CENTER", 1) + 1.0);
113
114 // Setup distortion map
115 // See what type of distortion model the IAK is configured to use
116 QString dmodel;
117 try {
118 dmodel = getString("INS" + ikCode + "_DISTORTION_MODEL").toUpper();
119 } catch (IException &ie) {
120 // If not able to get the preferred model assume previous distortion
121 // model parameters are available.
122 dmodel = "OCAMS";
123 }
124
125 // Set up tangential distortion model
126 if ( "OPENCV" == dmodel) {
127 // Use OpenCV model
129 frameCode,
130 distortCode,
131 filterName);
132 double camHeadTemp(0.0);
133 QString camkey = m_instrumentNameShort + "eraHeadTemperature";
134 if ( inst.hasKeyword(camkey) ) {
135 camHeadTemp = (double) inst[camkey];
136 }
137 dmap->SetCameraTemperature(camHeadTemp);
138 }
139 else if ( "OCAMS" == dmodel ) {
140 // Original model
141 OsirisRexDistortionMap *distortionMap = new OsirisRexDistortionMap(this);
142 if ( !distortionMap->SetDistortion(distortCode, filterName) ) {
143 distortionMap->SetDistortion(frameCode, filterName);
144 }
145 }
146 else {
147 new CameraDistortionMap(this);
148 }
149
150
151 // Setup the ground and sky map
153 new CameraSkyMap(this);
154
155 setTime(centerTime);
156 LoadCache();
158 }
159
160
164
165
174 return -64000;
175 }
176
177
187 return 1;
188 }
189
190
197 return 1;
198 }
199
200
227
241 const int polyfocusCode,
242 const QString &filter) const {
243
244 if (naifIkCode == -64361) {
245 // MapCam needs to determine code based upon filter
246 QString fname = filter.toUpper();
247 // if ( "PAN30" == fname ) return ( -64363 );
248 if ( "PAN" == fname ) return ( -64364 );
249 if ( "B" == fname ) return ( -64365 );
250 if ( "V" == fname ) return ( -64366 );
251 if ( "W" == fname ) return ( -64367 );
252 if ( "X" == fname ) return ( -64368 );
253 }
254 else if (naifIkCode == -64360) {
255 // IK values for polycam: -64360 (general) and -64616 to -64500 (focus specific)
256 // PolyCam returns focus code
257 return ( polyfocusCode );
258 }
259
260 // All other conditions returns the NAIF IK code
261 return ( naifIkCode );
262 }
263
264}
265
266
275extern "C" Isis::Camera *OsirisRexOcamsCameraPlugin(Isis::Cube &cube) {
276 return new Isis::OsirisRexOcamsCamera(cube);
277}
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
Convert between parent image coordinates and detector coordinates.
Distort/undistort focal plane coordinates.
Convert between distorted focal plane and detector coordinates.
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
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:1975
FramingCamera(Cube &cube)
Constructs the FramingCamera object.
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)=0
Returns the shutter open and close times.
Convert between undistorted focal plane and ground coordinates.
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.
virtual bool SetDistortion(int naifIkCode, QString filter="UNKNOWN")
Load distortion coefficients and center-of-distortion for OCAMS.
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.
int getFunctionalIkCode(const int naifIkCode, const int polyfocusCode, const QString &filter) const
Determine best functional IK code for distortion models.
virtual int SpkReferenceId() const
The reference frame ID for the Spacecraft Kernel is 1, representing J2000.
OsirisRexOcamsOpenCVDistortionMap camera distortion model for TAGCAMS.
void SetCameraTemperature(const double temp)
Set camera head temperature for the model.
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
QString getString(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition Spice.cpp:1483
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:1270
virtual iTime time() const
Returns the ephemeris time in seconds which was used to obtain the spacecraft and sun positions.
Definition Spice.cpp:1101
SpiceInt naifIkCode() const
This returns the NAIF IK code to use when reading from instrument kernels.
Definition Spice.cpp:1185
SpiceDouble getDouble(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition Spice.cpp:1256
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(const LinearAlgebra::Vector &vector, int precision)
A global function to format LinearAlgebra::Vector as a QString with the given precision.
Namespace for the standard library.