Isis 3 Programmer Reference
RosettaOsirisCamera.cpp
Go to the documentation of this file.
1 
21 #include "RosettaOsirisCamera.h"
22 
23 #include <QDebug>
24 #include <QFile>
25 #include <QString>
26 
27 #include "CameraDetectorMap.h"
28 #include "CameraFocalPlaneMap.h"
29 #include "CameraGroundMap.h"
30 #include "CameraSkyMap.h"
31 #include "IString.h"
32 #include "iTime.h"
33 #include "FileName.h"
34 #include "NaifStatus.h"
35 #include "Preference.h"
36 
37 using namespace std;
38 
39 namespace Isis {
53  RosettaOsirisCamera::RosettaOsirisCamera(Cube &cube) : FramingCamera(cube) {
54  m_instrumentNameLong = "Optical, Spectroscopic, and Infrared Remote Imaging System";
55  m_instrumentNameShort = "OSIRIS";
56  m_spacecraftNameLong = "Rosetta";
57  m_spacecraftNameShort = "Rosetta";
58 
60 
61  Pvl &lab = *cube.label();
62  PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
63 
64  // The Osiris focal length is fixed and is designed not to change throught the operational
65  // temperature. For OSIRIS, the focal length is in mm, so we shouldn't need the unit conversion
66 
67  QString ikCode = toString(naifIkCode());
68 
69  QString fl = "INS" + ikCode + "_FOCAL_LENGTH";
70  double focalLength = Spice::getDouble(fl);
71  SetFocalLength(focalLength);
72 
73  // For setting the pixel pitch, the Naif keyword PIXEL_SIZE is used instead of the ISIS
74  // default of PIXEL_PITCH, so set the value directly. Needs to be converted from microns to mm.
75  QString pp = "INS" + ikCode + "_PIXEL_SIZE";
76 
77  double pixelPitch = Spice::getDouble(pp);
78  pixelPitch /= 1000.0;
79  SetPixelPitch(pixelPitch);
80 
81  // Setup focal plane map. The class will read data from the instrument addendum kernel to pull
82  // out the affine transforms from detector samp,line to focal plane x,y.
83  CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
84 
85  CameraDetectorMap *detectorMap = new CameraDetectorMap(this);
86  detectorMap->SetStartingDetectorSample((double) inst["FirstLineSample"]);
87  // Because images are flipped on ingestion,
88  // the first line on the label is actually the last line.
89  detectorMap->SetStartingDetectorLine(2050 - cube.lineCount() - (double) inst["FirstLine"]);
90 
91  //Read the pixel averaging width/height and update the detector map:
92  double pixelAveragingWidth=(double) inst["PixelAveragingWidth"];
93  double pixelAveragingHeight=(double) inst["PixelAveragingHeight"];
94  detectorMap->SetDetectorSampleSumming(pixelAveragingWidth);
95  detectorMap->SetDetectorLineSumming(pixelAveragingHeight);
96 
98 
99  // Setup the ground and sky map
100  new CameraGroundMap(this);
101  new CameraSkyMap(this);
102 
103  // Setup clock start and stop times.
104  QString clockStartCount = inst["SpacecraftClockStartCount"];
105  double start = getClockTime(clockStartCount).Et();
106  // QString clockStopCount = inst["SpacecraftClockStopCount"];
107  // double stop = getClockTime(clockStopCount).Et();
108  double exposureTime = (double) inst["ExposureDuration"];
109 
110  // Setup the distortion map
111  PvlGroup &BandBin = lab.findGroup("BandBin", Pvl::Traverse);
112  QString filterNumber = BandBin["FilterNumber"];
113  initDistortion(ikCode, distortionMap);
114  distortionMap->setPixelPitch(pixelPitch);
115 
116  // The boresight position depends on the filter. They are all defined as
117  // offsets from the middle of the ccd.
118  double referenceSample = Spice::getDouble("INS" + ikCode + "_BORESIGHT",0) + 1.0;
119  double referenceLine = Spice::getDouble("INS" + ikCode + "_BORESIGHT",1) + 1.0;
120  // The offsets in the IAK are based on the S/C frame, not the camera frame
121  // For now, do not adjust based on filter. -JAM
122 // referenceSample += Spice::getDouble("INS" + ikCode + "_FILTER_" + filterNumber + "_DX");
123 // referenceLine += Spice::getDouble("INS" + ikCode + "_FILTER_" + filterNumber + "_DY");
124  focalMap->SetDetectorOrigin(referenceSample, referenceLine);
125  distortionMap->setBoresight(referenceSample, referenceLine);
126 
127  iTime centerTime = start + (exposureTime / 2.0);
128  setTime( centerTime );
129 
130  // Internalize all the NAIF SPICE information into memory.
131  LoadCache();
133 
134  return;
135  }
136 
137 
153  /* This should not be an issue with the Osiris cameras, so this can likely be deleted.
154  It has been left here just in case something of importance in it was missed. -Sasha
155  */
156  pair<iTime, iTime> RosettaOsirisCamera::ShutterOpenCloseTimes(double time,
157  double exposureDuration) {
159  }
160 
161 
169  RosettaOsirisCameraDistortionMap *distortionMap) {
170 
171  // Initialize matrices
174 
175  // Fill matrices from the kernels
176  for (int i = 0; i < 4; i++) {
177  for (int j = 0; j < 4; j++) {
178  toUnDistX(i, j) = Spice::getDouble("INS" + ikCode + "_TO_UNDISTORTED_X", 4 * i + j);
179  toUnDistY(i, j) = Spice::getDouble("INS" + ikCode + "_TO_UNDISTORTED_Y", 4 * i + j);
180  }
181  }
182 
183  // Save the matrices
184  distortionMap->setUnDistortedXMatrix(toUnDistX);
185  distortionMap->setUnDistortedYMatrix(toUnDistY);
186  }
187 }
188 
201  return new Isis::RosettaOsirisCamera(cube);
202 }
void SetFocalLength()
Reads the focal length from the instrument kernel.
Definition: Camera.cpp:1430
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
Isis::Camera * RosettaOsirisCameraPlugin(Isis::Cube &cube)
This is the function that is called in order to instantiate an OsirisNacCamera object.
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition: PvlObject.h:141
Parse and return pieces of a time string.
Definition: iTime.h:78
This is the camera model for the Osiris NAC Framing Camera.
Distortion map for converting between undistorted focal plane and distorted focal plane coordinates f...
QString m_instrumentNameLong
Full instrument name.
Definition: Camera.h:507
void SetDetectorSampleSumming(const double summing)
Set sample summing mode.
void setUnDistortedXMatrix(LinearAlgebra::Matrix xMat)
Set the matrix for converting from distorted to undistorted samples.
void SetPixelPitch()
Reads the Pixel Pitch from the instrument kernel.
Definition: Camera.cpp:1437
Namespace for the standard library.
Search child objects.
Definition: PvlObject.h:170
boost::numeric::ublas::matrix< double > Matrix
Definition for an Isis::LinearAlgebra::Matrix of doubles.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:226
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
static Matrix zeroMatrix(int rows, int columns)
Returns a matrix with given dimensions that is filled with zeroes.
void initDistortion(QString ikCode, RosettaOsirisCameraDistortionMap *distortionMap)
Initialize the distortion map using the paramters from the NAIF SPICE kernels.
void SetDetectorLineSumming(const double summing)
Set line summing mode.
void SetStartingDetectorLine(const double line)
Set the starting detector line.
void setPixelPitch(double pitch)
Set the pixel pitch for converting from focal plane coordinates to pixel coordinates.
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)=0
Returns the shutter open and close times.
void setBoresight(double sample, double line)
Set the boresight location for converting from focal plane coordinates to pixel coordinates.
Convert between parent image coordinates and detector coordinates.
Convert between undistorted focal plane and ground coordinates.
Convert between distorted focal plane and detector coordinates.
QString m_instrumentNameShort
Shortened instrument name.
Definition: Camera.h:508
Contains multiple PvlContainers.
Definition: PvlGroup.h:57
SpiceInt naifIkCode() const
This returns the NAIF IK code to use when reading from instrument kernels.
Definition: Spice.cpp:893
iTime getClockTime(QString clockValue, int sclkCode=-1, bool clockTicks=false)
This converts the spacecraft clock ticks value (clockValue) to an iTime.
Definition: Spice.cpp:977
void setUnDistortedYMatrix(LinearAlgebra::Matrix yMat)
Set the matrix for converting from distorted to undistorted lines.
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:112
Container for cube-like labels.
Definition: Pvl.h:135
void LoadCache()
This loads the spice cache big enough for this image.
Definition: Camera.cpp:2432
QString m_spacecraftNameLong
Full spacecraft name.
Definition: Camera.h:509
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition: Cube.cpp:1346
void SetStartingDetectorSample(const double sample)
Set the starting detector sample.
int lineCount() const
Definition: Cube.cpp:1379
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Definition: NaifStatus.cpp:43
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
Convert between undistorted focal plane and ra/dec coordinates.
Definition: CameraSkyMap.h:48
QString m_spacecraftNameShort
Shortened spacecraft name.
Definition: Camera.h:510
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)
Reimplemented from FrameCamera.
virtual double exposureDuration() const
Return the exposure duration for the pixel that the camera is set to.
Definition: Camera.cpp:3075
Generic class for Framing Cameras.
Definition: FramingCamera.h:48
double Et() const
Returns the ephemeris time (TDB) representation of the time as a double.
Definition: iTime.h:139
SpiceDouble getDouble(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition: Spice.cpp:963
IO Handler for Isis Cubes.
Definition: Cube.h:170
iTime time() const
Returns the ephemeris time in seconds which was used to obtain the spacecraft and sun positions...
Definition: Spice.cpp:809