Isis 3 Programmer Reference
MarciCamera.cpp
1 
7 /* SPDX-License-Identifier: CC0-1.0 */
8 
9 #include <iomanip>
10 
11 #include "MarciCamera.h"
12 #include "MarciDistortionMap.h"
13 
14 #include <QString>
15 
16 #include "CameraFocalPlaneMap.h"
17 #include "CameraSkyMap.h"
18 #include "IException.h"
19 #include "iTime.h"
20 #include "NaifStatus.h"
21 #include "PushFrameCameraDetectorMap.h"
22 #include "PushFrameCameraGroundMap.h"
23 
24 using namespace std;
25 namespace Isis {
26 
37  MarciCamera::MarciCamera(Cube &cube) : PushFrameCamera(cube) {
38  m_instrumentNameLong = "Mars Color Imager";
39  m_instrumentNameShort = "MARCI";
40  m_spacecraftNameLong = "Mars Reconnaissance Orbiter";
41  m_spacecraftNameShort = "MRO";
42 
44  Pvl &lab = *cube.label();
45  PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
46  // make sure it is a marci image
47  if(inst["InstrumentId"][0] != "Marci") {
48  string msg = "The image does not appear to be a Marci Image";
49  throw IException(IException::User, msg, _FILEINFO_);
50  }
51 
52  // Set up the camera characteristics
54 
55  QString pixelPitchKey = "INS" + toString(naifIkCode()) + "_PIXEL_SIZE";
56  SetPixelPitch(getDouble(pixelPitchKey));
57 
58  // Get necessary variables
59  p_exposureDur = inst["ExposureDuration"];
60  p_interframeDelay = inst["InterframeDelay"];
61  int sumMode = inst["SummingMode"];
62 
63  // Get the start and end time
64  double et;
65  QString stime = inst["SpacecraftClockCount"];
66  et = getClockTime(stime).Et();
67  p_etStart = et - ((p_exposureDur / 1000.0) / 2.0);
68  p_nframelets = (int) (ParentLines() / sumMode);
69 
70  // These numbers came from "MARCI_CTX_Cal_Report_v1.5.pdf" page 7 (Bandpasses & downlinked detector rows)
71  map<QString, int> filterToDetectorOffset;
72  filterToDetectorOffset.insert(pair<QString, int>("BLUE", 709));
73  filterToDetectorOffset.insert(pair<QString, int>("GREEN", 734));
74  filterToDetectorOffset.insert(pair<QString, int>("ORANGE", 760));
75  filterToDetectorOffset.insert(pair<QString, int>("RED", 786));
76  filterToDetectorOffset.insert(pair<QString, int>("NIR", 811));
77  filterToDetectorOffset.insert(pair<QString, int>("LONG_UV", 266));
78  filterToDetectorOffset.insert(pair<QString, int>("SHORT_UV", 293));
79 
80  map<QString, int> filterToFilterNumbers;
81  filterToFilterNumbers.insert(pair<QString, int>("BLUE", 0));
82  filterToFilterNumbers.insert(pair<QString, int>("GREEN", 1));
83  filterToFilterNumbers.insert(pair<QString, int>("ORANGE", 2));
84  filterToFilterNumbers.insert(pair<QString, int>("RED", 3));
85  filterToFilterNumbers.insert(pair<QString, int>("NIR", 4));
86  filterToFilterNumbers.insert(pair<QString, int>("LONG_UV", 5));
87  filterToFilterNumbers.insert(pair<QString, int>("SHORT_UV", 6));
88 
89  int frameletOffsetFactor = inst["ColorOffset"];
90 
91  if((int)inst["DataFlipped"] != 0) frameletOffsetFactor *= -1;
92  map<QString, int> filterToFrameletOffset;
93  filterToFrameletOffset.insert(pair<QString, int>("NIR", 0 * frameletOffsetFactor));
94  filterToFrameletOffset.insert(pair<QString, int>("RED", 1 * frameletOffsetFactor));
95  filterToFrameletOffset.insert(pair<QString, int>("ORANGE", 2 * frameletOffsetFactor));
96  filterToFrameletOffset.insert(pair<QString, int>("GREEN", 3 * frameletOffsetFactor));
97  filterToFrameletOffset.insert(pair<QString, int>("BLUE", 4 * frameletOffsetFactor));
98  filterToFrameletOffset.insert(pair<QString, int>("LONG_UV", 5 * frameletOffsetFactor));
99  filterToFrameletOffset.insert(pair<QString, int>("SHORT_UV", 6 * frameletOffsetFactor));
100 
101  // Get the keywords from labels
102  const PvlGroup &bandBin = lab.findGroup("BandBin", Pvl::Traverse);
103  const PvlKeyword &filtNames = bandBin["FilterName"];
104 
105  for(int i = 0; i < filtNames.size(); i++) {
106  if(filterToDetectorOffset.find(filtNames[i]) == filterToDetectorOffset.end()) {
107  QString msg = "Unrecognized filter name [" + filtNames[i] + "]";
108  throw IException(IException::Programmer, msg, _FILEINFO_);
109  }
110 
111  p_detectorStartLines.push_back(filterToDetectorOffset.find(filtNames[i])->second);
112  p_filterNumbers.push_back(filterToFilterNumbers.find(filtNames[i])->second);
113  p_frameletOffsets.push_back(filterToFrameletOffset.find(filtNames[i])->second);
114  }
115 
116  // Setup detector map
117  double frameletRate = p_interframeDelay;
119  new PushFrameCameraDetectorMap(this, p_etStart, frameletRate, 16);
120  dmap->SetDetectorSampleSumming(sumMode);
121  dmap->SetDetectorLineSumming(sumMode);
123 
124  int numFramelets = ParentLines() / (16 / sumMode);
125  bool flippedFramelets = (int)inst["DataFlipped"] != 0;
126  dmap->SetFrameletOrderReversed(flippedFramelets, numFramelets);
127 
128  // Setup focal plane map
129  new CameraFocalPlaneMap(this, -74400);
130 
131  if ((int) naifIkCode() == -74410) {
132  // The line detector origin is in the middle of the orange framelet
133  FocalPlaneMap()->SetDetectorOrigin(512.5, 760.0 + 8.5);
134  }
135  else if ((int) naifIkCode() == -74420) {
136  FocalPlaneMap()->SetDetectorOrigin(512.5, 288.5);
137  }
138  else {
139  string msg = "Unrecognized NaifIkCode [" + IString((int) naifIkCode()) + "]";
140  throw IException(IException::Programmer, msg, _FILEINFO_);
141  }
142 
143  // Setup distortion map
144  new MarciDistortionMap(this, naifIkCode());
145 
146  // Setup the ground and sky map
147  bool evenFramelets = (inst["Framelets"][0] == "Even");
148  new PushFrameCameraGroundMap(this, evenFramelets);
149  new CameraSkyMap(this);
150  LoadCache();
152 
153  if(sumMode == 1) {
154  SetGeometricTilingHint(16, 4);
155  }
156  else if(sumMode == 2) {
158  }
159  else if(sumMode == 4) {
161  }
162  else {
164  }
165  }
166 
167 
168 
171  }
172 
173 
174 
180  void MarciCamera::SetBand(const int vband) {
181  Camera::SetBand(vband);
182 
184  dmap->SetBandFirstDetectorLine(p_detectorStartLines[vband-1]);
185  dmap->SetFrameletOffset(p_frameletOffsets[vband-1]);
186 
188  distmap->SetFilter(p_filterNumbers[vband-1]);
189  }
190 
191 
192 
199  return false;
200  }
201 
202 
203 
211  return (-74000);
212  }
213 
214 
215 
223  return (-74900);
224  }
225 
226 
227 
235  return (1);
236  }
237 }
238 
239 
249 extern "C" Isis::Camera *MarciCameraPlugin(Isis::Cube &cube) {
250  return new Isis::MarciCamera(cube);
251 }
Isis::Camera::SetBand
virtual void SetBand(const int band)
Virtual method that sets the band number.
Definition: Camera.cpp:2680
Isis::MarciCamera::~MarciCamera
~MarciCamera()
Destroys the Themis Vis Camera object.
Definition: MarciCamera.cpp:170
Isis::MarciCamera::CkReferenceId
virtual int CkReferenceId() const
CK Reference ID - MRO_MME_OF_DATE.
Definition: MarciCamera.cpp:222
Isis::CameraFocalPlaneMap::SetDetectorOrigin
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
Definition: CameraFocalPlaneMap.cpp:293
Isis::PushFrameCameraDetectorMap::SetFrameletOffset
void SetFrameletOffset(int frameletOffset)
Reset the frame offset.
Definition: PushFrameCameraDetectorMap.cpp:270
Isis::Camera::SetGeometricTilingHint
void SetGeometricTilingHint(int startSize=128, int endSize=8)
This method sets the best geometric tiling size for projecting from this camera model.
Definition: Camera.cpp:2554
Isis::MarciCamera::p_etStart
double p_etStart
Ephemeris Start iTime.
Definition: MarciCamera.h:69
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::MarciCamera::SetBand
void SetBand(const int band)
Sets the band in the camera model.
Definition: MarciCamera.cpp:180
Isis::Camera::ParentLines
int ParentLines() const
Returns the number of lines in the parent alphacube.
Definition: Camera.cpp:2806
Isis::PvlKeyword
A single keyword-value pair.
Definition: PvlKeyword.h:82
Isis::Spice::naifIkCode
SpiceInt naifIkCode() const
This returns the NAIF IK code to use when reading from instrument kernels.
Definition: Spice.cpp:968
Isis::PushFrameCameraDetectorMap::SetFrameletOrderReversed
void SetFrameletOrderReversed(bool frameletOrderReversed, int nframelets)
Changes the direction of the framelets.
Definition: PushFrameCameraDetectorMap.cpp:340
Isis::PushFrameCameraDetectorMap::SetFrameletsGeometricallyFlipped
void SetFrameletsGeometricallyFlipped(bool frameletsFlipped)
Mirrors the each framelet in the file.
Definition: PushFrameCameraDetectorMap.cpp:359
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::CameraDetectorMap::SetDetectorSampleSumming
void SetDetectorSampleSumming(const double summing)
Set sample summing mode.
Definition: CameraDetectorMap.h:108
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::Camera::DistortionMap
CameraDistortionMap * DistortionMap()
Returns a pointer to the CameraDistortionMap object.
Definition: Camera.cpp:2826
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::MarciCamera::SpkReferenceId
virtual int SpkReferenceId() const
SPK Reference ID - J2000.
Definition: MarciCamera.cpp:234
Isis::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
Isis::MarciCamera
Marci Camera Model.
Definition: MarciCamera.h:51
Isis::CameraDetectorMap::SetDetectorLineSumming
void SetDetectorLineSumming(const double summing)
Set line summing mode.
Definition: CameraDetectorMap.h:123
Isis::PvlObject::Traverse
@ Traverse
Search child objects.
Definition: PvlObject.h:158
Isis::PushFrameCamera::DetectorMap
PushFrameCameraDetectorMap * DetectorMap()
Returns a pointer to the PushFrameCameraDetectorMap object.
Definition: PushFrameCamera.h:62
Isis::MarciDistortionMap
Distort/undistort focal plane coordinates.
Definition: MarciDistortionMap.h:34
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::MarciCamera::CkFrameId
virtual int CkFrameId() const
CK frame ID - - Instrument Code from spacit run on CK.
Definition: MarciCamera.cpp:210
Isis::PushFrameCamera
Generic class for Push Frame Cameras.
Definition: PushFrameCamera.h:35
Isis::Cube
IO Handler for Isis Cubes.
Definition: Cube.h:167
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::Camera::m_spacecraftNameLong
QString m_spacecraftNameLong
Full spacecraft name.
Definition: Camera.h:498
Isis::MarciCamera::IsBandIndependent
bool IsBandIndependent()
The camera model is band dependent, so this method returns false.
Definition: MarciCamera.cpp:198
Isis::Camera::FocalPlaneMap
CameraFocalPlaneMap * FocalPlaneMap()
Returns a pointer to the CameraFocalPlaneMap object.
Definition: Camera.cpp:2836
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
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::MarciCamera::p_exposureDur
double p_exposureDur
Exposure Duration value from labels.
Definition: MarciCamera.h:71
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::PushFrameCameraDetectorMap::SetBandFirstDetectorLine
void SetBandFirstDetectorLine(int firstLine)
Change the starting line in the detector based on band.
Definition: PushFrameCameraDetectorMap.cpp:308
Isis::PvlKeyword::size
int size() const
Returns the number of values stored in this keyword.
Definition: PvlKeyword.h:125
Isis::MarciCamera::p_nframelets
int p_nframelets
Number of framelets in whole image.
Definition: MarciCamera.h:73
Isis::IString
Adds specific functionality to C++ strings.
Definition: IString.h:165
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::PushFrameCameraGroundMap
Convert between undistorted focal plane and ground coordinates.
Definition: PushFrameCameraGroundMap.h:34
Isis::Camera::m_spacecraftNameShort
QString m_spacecraftNameShort
Shortened spacecraft name.
Definition: Camera.h:499
Isis::MarciCamera::p_interframeDelay
double p_interframeDelay
Interframe Delay value from labels.
Definition: MarciCamera.h:72
Isis::PushFrameCameraDetectorMap
Convert between parent image coordinates and detector coordinates.
Definition: PushFrameCameraDetectorMap.h:45
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::IException::User
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition: IException.h:126