Isis 3 Programmer Reference
RosettaOsirisCamera.cpp
1
7/* SPDX-License-Identifier: CC0-1.0 */
8
9
10#include "RosettaOsirisCamera.h"
11
12#include <QDebug>
13#include <QFile>
14#include <QString>
15
16#include "CameraDetectorMap.h"
17#include "CameraFocalPlaneMap.h"
18#include "CameraGroundMap.h"
19#include "CameraSkyMap.h"
20#include "IString.h"
21#include "iTime.h"
22#include "FileName.h"
23#include "NaifStatus.h"
24#include "Preference.h"
25
26using namespace std;
27
28namespace Isis {
43 m_instrumentNameLong = "Optical, Spectroscopic, and Infrared Remote Imaging System";
44 m_instrumentNameShort = "OSIRIS";
45 m_spacecraftNameLong = "Rosetta";
46 m_spacecraftNameShort = "Rosetta";
47
49
50 Pvl &lab = *cube.label();
51 PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
52
53 // The Osiris focal length is fixed and is designed not to change throught the operational
54 // temperature. For OSIRIS, the focal length is in mm, so we shouldn't need the unit conversion
55
56 QString ikCode = toString(naifIkCode());
57
58 QString fl = "INS" + ikCode + "_FOCAL_LENGTH";
59 double focalLength = Spice::getDouble(fl);
60 SetFocalLength(focalLength);
61
62 // For setting the pixel pitch, the Naif keyword PIXEL_SIZE is used instead of the ISIS
63 // default of PIXEL_PITCH, so set the value directly. Needs to be converted from microns to mm.
64 QString pp = "INS" + ikCode + "_PIXEL_SIZE";
65
66 double pixelPitch = Spice::getDouble(pp);
67 pixelPitch /= 1000.0;
68 SetPixelPitch(pixelPitch);
69
70 // Setup focal plane map. The class will read data from the instrument addendum kernel to pull
71 // out the affine transforms from detector samp,line to focal plane x,y.
72 CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
73
74 CameraDetectorMap *detectorMap = new CameraDetectorMap(this);
75 detectorMap->SetStartingDetectorSample((double) inst["FirstLineSample"]);
76 // Because images are flipped on ingestion,
77 // the first line on the label is actually the last line.
78 detectorMap->SetStartingDetectorLine(2050 - cube.lineCount() - (double) inst["FirstLine"]);
79
80 //Read the pixel averaging width/height and update the detector map:
81 double pixelAveragingWidth=(double) inst["PixelAveragingWidth"];
82 double pixelAveragingHeight=(double) inst["PixelAveragingHeight"];
83 detectorMap->SetDetectorSampleSumming(pixelAveragingWidth);
84 detectorMap->SetDetectorLineSumming(pixelAveragingHeight);
85
87
88 // Setup the ground and sky map
89 new CameraGroundMap(this);
90 new CameraSkyMap(this);
91
92 // Setup clock start and stop times.
93 QString clockStartCount = inst["SpacecraftClockStartCount"];
94 double start = getClockTime(clockStartCount).Et();
95 // QString clockStopCount = inst["SpacecraftClockStopCount"];
96 // double stop = getClockTime(clockStopCount).Et();
97 double exposureTime = (double) inst["ExposureDuration"];
98
99 // Setup the distortion map
100 PvlGroup &BandBin = lab.findGroup("BandBin", Pvl::Traverse);
101 QString filterNumber = BandBin["FilterNumber"];
102 initDistortion(ikCode, distortionMap);
103 distortionMap->setPixelPitch(pixelPitch);
104
105 // The boresight position depends on the filter. They are all defined as
106 // offsets from the middle of the ccd.
107 double referenceSample = Spice::getDouble("INS" + ikCode + "_BORESIGHT",0) + 1.0;
108 double referenceLine = Spice::getDouble("INS" + ikCode + "_BORESIGHT",1) + 1.0;
109 // The offsets in the IAK are based on the S/C frame, not the camera frame
110 // For now, do not adjust based on filter. -JAM
111// referenceSample += Spice::getDouble("INS" + ikCode + "_FILTER_" + filterNumber + "_DX");
112// referenceLine += Spice::getDouble("INS" + ikCode + "_FILTER_" + filterNumber + "_DY");
113 focalMap->SetDetectorOrigin(referenceSample, referenceLine);
114 distortionMap->setBoresight(referenceSample, referenceLine);
115
116 iTime centerTime = start + (exposureTime / 2.0);
117 setTime( centerTime );
118
119 // Internalize all the NAIF SPICE information into memory.
120 LoadCache();
122
123 return;
124 }
125
126
142 /* This should not be an issue with the Osiris cameras, so this can likely be deleted.
143 It has been left here just in case something of importance in it was missed. -Sasha
144 */
145 pair<iTime, iTime> RosettaOsirisCamera::ShutterOpenCloseTimes(double time,
146 double exposureDuration) {
148 }
149
150
158 RosettaOsirisCameraDistortionMap *distortionMap) {
159
160 // Initialize matrices
163
164 // Fill matrices from the kernels
165 for (int i = 0; i < 4; i++) {
166 for (int j = 0; j < 4; j++) {
167 toUnDistX(i, j) = Spice::getDouble("INS" + ikCode + "_TO_UNDISTORTED_X", 4 * i + j);
168 toUnDistY(i, j) = Spice::getDouble("INS" + ikCode + "_TO_UNDISTORTED_Y", 4 * i + j);
169 }
170 }
171
172 // Save the matrices
173 distortionMap->setUnDistortedXMatrix(toUnDistX);
174 distortionMap->setUnDistortedYMatrix(toUnDistY);
175 }
176}
177
189extern "C" Isis::Camera *RosettaOsirisCameraPlugin(Isis::Cube &cube) {
190 return new Isis::RosettaOsirisCamera(cube);
191}
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
int lineCount() const
Definition Cube.cpp:1740
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.
static Matrix zeroMatrix(int rows, int columns)
Returns a matrix with given dimensions that is filled with zeroes.
boost::numeric::ublas::matrix< double > Matrix
Definition for an Isis::LinearAlgebra::Matrix of doubles.
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Contains multiple PvlContainers.
Definition PvlGroup.h:41
Container for cube-like labels.
Definition Pvl.h:119
@ Traverse
Search child objects.
Definition PvlObject.h:158
Distortion map for converting between undistorted focal plane and distorted focal plane coordinates f...
This is the camera model for the Osiris NAC Framing Camera.
RosettaOsirisCamera(Cube &cube)
Create a OsirisNacCamera object.
void initDistortion(QString ikCode, RosettaOsirisCameraDistortionMap *distortionMap)
Initialize the distortion map using the paramters from the NAIF SPICE kernels.
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: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
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.