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 
26 using namespace std;
27 
28 namespace Isis {
42  RosettaOsirisCamera::RosettaOsirisCamera(Cube &cube) : FramingCamera(cube) {
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 
189 extern "C" Isis::Camera *RosettaOsirisCameraPlugin(Isis::Cube &cube) {
190  return new Isis::RosettaOsirisCamera(cube);
191 }
Isis::CameraFocalPlaneMap::SetDetectorOrigin
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
Definition: CameraFocalPlaneMap.cpp:293
Isis::RosettaOsirisCameraDistortionMap::setUnDistortedXMatrix
void setUnDistortedXMatrix(LinearAlgebra::Matrix xMat)
Set the matrix for converting from distorted to undistorted samples.
Definition: RosettaOsirisCameraDistortionMap.cpp:275
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::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::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::RosettaOsirisCameraDistortionMap::setBoresight
void setBoresight(double sample, double line)
Set the boresight location for converting from focal plane coordinates to pixel coordinates.
Definition: RosettaOsirisCameraDistortionMap.cpp:297
Isis::iTime
Parse and return pieces of a time string.
Definition: iTime.h:65
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::RosettaOsirisCamera::ShutterOpenCloseTimes
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)
Reimplemented from FrameCamera.
Definition: RosettaOsirisCamera.cpp:145
Isis::CameraDetectorMap::SetDetectorSampleSumming
void SetDetectorSampleSumming(const double summing)
Set sample summing mode.
Definition: CameraDetectorMap.h:108
Isis::RosettaOsirisCamera::initDistortion
void initDistortion(QString ikCode, RosettaOsirisCameraDistortionMap *distortionMap)
Initialize the distortion map using the paramters from the NAIF SPICE kernels.
Definition: RosettaOsirisCamera.cpp:157
Isis::LinearAlgebra::zeroMatrix
static Matrix zeroMatrix(int rows, int columns)
Returns a matrix with given dimensions that is filled with zeroes.
Definition: LinearAlgebra.cpp:408
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::RosettaOsirisCameraDistortionMap::setPixelPitch
void setPixelPitch(double pitch)
Set the pixel pitch for converting from focal plane coordinates to pixel coordinates.
Definition: RosettaOsirisCameraDistortionMap.cpp:309
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::LinearAlgebra::Matrix
boost::numeric::ublas::matrix< double > Matrix
Definition for an Isis::LinearAlgebra::Matrix of doubles.
Definition: LinearAlgebra.h:100
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::CameraDetectorMap::SetDetectorLineSumming
void SetDetectorLineSumming(const double summing)
Set line summing mode.
Definition: CameraDetectorMap.h:123
Isis::CameraDetectorMap::SetStartingDetectorLine
void SetStartingDetectorLine(const double line)
Set the starting detector line.
Definition: CameraDetectorMap.h:93
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::Cube::lineCount
int lineCount() const
Definition: Cube.cpp:1734
Isis::Cube
IO Handler for Isis Cubes.
Definition: Cube.h:167
Isis::Camera::m_spacecraftNameLong
QString m_spacecraftNameLong
Full spacecraft name.
Definition: Camera.h:498
Isis::CameraDetectorMap::SetStartingDetectorSample
void SetStartingDetectorSample(const double sample)
Set the starting detector sample.
Definition: CameraDetectorMap.h:79
Isis::RosettaOsirisCamera
This is the camera model for the Osiris NAC Framing Camera.
Definition: RosettaOsirisCamera.h:35
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::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::RosettaOsirisCameraDistortionMap::setUnDistortedYMatrix
void setUnDistortedYMatrix(LinearAlgebra::Matrix yMat)
Set the matrix for converting from distorted to undistorted lines.
Definition: RosettaOsirisCameraDistortionMap.cpp:285
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::RosettaOsirisCameraDistortionMap
Distortion map for converting between undistorted focal plane and distorted focal plane coordinates f...
Definition: RosettaOsirisCameraDistortionMap.h:54