Isis 3 Programmer Reference
MarciCamera.cpp
Go to the documentation of this file.
1 
20 #include <iomanip>
21 
22 #include "MarciCamera.h"
23 #include "MarciDistortionMap.h"
24 
25 #include <QString>
26 
27 #include "CameraFocalPlaneMap.h"
28 #include "CameraSkyMap.h"
29 #include "IException.h"
30 #include "iTime.h"
31 #include "NaifStatus.h"
34 
35 using namespace std;
36 namespace Isis {
37 
48  MarciCamera::MarciCamera(Cube &cube) : PushFrameCamera(cube) {
49  m_instrumentNameLong = "Mars Color Imager";
50  m_instrumentNameShort = "MARCI";
51  m_spacecraftNameLong = "Mars Reconnaissance Orbiter";
52  m_spacecraftNameShort = "MRO";
53 
55  Pvl &lab = *cube.label();
56  PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
57  // make sure it is a marci image
58  if(inst["InstrumentId"][0] != "Marci") {
59  string msg = "The image does not appear to be a Marci Image";
61  }
62 
63  // Set up the camera characteristics
65 
66  QString pixelPitchKey = "INS" + toString(naifIkCode()) + "_PIXEL_SIZE";
67  SetPixelPitch(getDouble(pixelPitchKey));
68 
69  // Get necessary variables
70  p_exposureDur = inst["ExposureDuration"];
71  p_interframeDelay = inst["InterframeDelay"];
72  int sumMode = inst["SummingMode"];
73 
74  // Get the start and end time
75  double et;
76  QString stime = inst["SpacecraftClockCount"];
77  et = getClockTime(stime).Et();
78  p_etStart = et - ((p_exposureDur / 1000.0) / 2.0);
79  p_nframelets = (int) (ParentLines() / sumMode);
80 
81  // These numbers came from "MARCI_CTX_Cal_Report_v1.5.pdf" page 7 (Bandpasses & downlinked detector rows)
82  map<QString, int> filterToDetectorOffset;
83  filterToDetectorOffset.insert(pair<QString, int>("BLUE", 709));
84  filterToDetectorOffset.insert(pair<QString, int>("GREEN", 734));
85  filterToDetectorOffset.insert(pair<QString, int>("ORANGE", 760));
86  filterToDetectorOffset.insert(pair<QString, int>("RED", 786));
87  filterToDetectorOffset.insert(pair<QString, int>("NIR", 811));
88  filterToDetectorOffset.insert(pair<QString, int>("LONG_UV", 266));
89  filterToDetectorOffset.insert(pair<QString, int>("SHORT_UV", 293));
90 
91  map<QString, int> filterToFilterNumbers;
92  filterToFilterNumbers.insert(pair<QString, int>("BLUE", 0));
93  filterToFilterNumbers.insert(pair<QString, int>("GREEN", 1));
94  filterToFilterNumbers.insert(pair<QString, int>("ORANGE", 2));
95  filterToFilterNumbers.insert(pair<QString, int>("RED", 3));
96  filterToFilterNumbers.insert(pair<QString, int>("NIR", 4));
97  filterToFilterNumbers.insert(pair<QString, int>("LONG_UV", 5));
98  filterToFilterNumbers.insert(pair<QString, int>("SHORT_UV", 6));
99 
100  int frameletOffsetFactor = inst["ColorOffset"];
101 
102  if((int)inst["DataFlipped"] != 0) frameletOffsetFactor *= -1;
103  map<QString, int> filterToFrameletOffset;
104  filterToFrameletOffset.insert(pair<QString, int>("NIR", 0 * frameletOffsetFactor));
105  filterToFrameletOffset.insert(pair<QString, int>("RED", 1 * frameletOffsetFactor));
106  filterToFrameletOffset.insert(pair<QString, int>("ORANGE", 2 * frameletOffsetFactor));
107  filterToFrameletOffset.insert(pair<QString, int>("GREEN", 3 * frameletOffsetFactor));
108  filterToFrameletOffset.insert(pair<QString, int>("BLUE", 4 * frameletOffsetFactor));
109  filterToFrameletOffset.insert(pair<QString, int>("LONG_UV", 5 * frameletOffsetFactor));
110  filterToFrameletOffset.insert(pair<QString, int>("SHORT_UV", 6 * frameletOffsetFactor));
111 
112  // Get the keywords from labels
113  const PvlGroup &bandBin = lab.findGroup("BandBin", Pvl::Traverse);
114  const PvlKeyword &filtNames = bandBin["FilterName"];
115 
116  for(int i = 0; i < filtNames.size(); i++) {
117  if(filterToDetectorOffset.find(filtNames[i]) == filterToDetectorOffset.end()) {
118  QString msg = "Unrecognized filter name [" + filtNames[i] + "]";
120  }
121 
122  p_detectorStartLines.push_back(filterToDetectorOffset.find(filtNames[i])->second);
123  p_filterNumbers.push_back(filterToFilterNumbers.find(filtNames[i])->second);
124  p_frameletOffsets.push_back(filterToFrameletOffset.find(filtNames[i])->second);
125  }
126 
127  // Setup detector map
128  double frameletRate = p_interframeDelay;
130  new PushFrameCameraDetectorMap(this, p_etStart, frameletRate, 16);
131  dmap->SetDetectorSampleSumming(sumMode);
132  dmap->SetDetectorLineSumming(sumMode);
134 
135  int numFramelets = ParentLines() / (16 / sumMode);
136  bool flippedFramelets = (int)inst["DataFlipped"] != 0;
137  dmap->SetFrameletOrderReversed(flippedFramelets, numFramelets);
138 
139  // Setup focal plane map
140  new CameraFocalPlaneMap(this, -74400);
141 
142  if ((int) naifIkCode() == -74410) {
143  // The line detector origin is in the middle of the orange framelet
144  FocalPlaneMap()->SetDetectorOrigin(512.5, 760.0 + 8.5);
145  }
146  else if ((int) naifIkCode() == -74420) {
147  FocalPlaneMap()->SetDetectorOrigin(512.5, 288.5);
148  }
149  else {
150  string msg = "Unrecognized NaifIkCode [" + IString((int) naifIkCode()) + "]";
152  }
153 
154  // Setup distortion map
155  new MarciDistortionMap(this, naifIkCode());
156 
157  // Setup the ground and sky map
158  bool evenFramelets = (inst["Framelets"][0] == "Even");
159  new PushFrameCameraGroundMap(this, evenFramelets);
160  new CameraSkyMap(this);
161  LoadCache();
163 
164  if(sumMode == 1) {
165  SetGeometricTilingHint(16, 4);
166  }
167  else if(sumMode == 2) {
169  }
170  else if(sumMode == 4) {
172  }
173  else {
175  }
176  }
177 
178 
179 
182  }
183 
184 
185 
191  void MarciCamera::SetBand(const int vband) {
192  Camera::SetBand(vband);
193 
195  dmap->SetBandFirstDetectorLine(p_detectorStartLines[vband-1]);
196  dmap->SetFrameletOffset(p_frameletOffsets[vband-1]);
197 
199  distmap->SetFilter(p_filterNumbers[vband-1]);
200  }
201 
202 
203 
210  return false;
211  }
212 
213 
214 
222  return (-74000);
223  }
224 
225 
226 
234  return (-74900);
235  }
236 
237 
238 
246  return (1);
247  }
248 }
249 
250 
261  return new Isis::MarciCamera(cube);
262 }
void SetBandFirstDetectorLine(int firstLine)
Change the starting line in the detector based on band.
void SetFocalLength()
Reads the focal length from the instrument kernel.
Definition: Camera.cpp:1430
void SetFrameletOrderReversed(bool frameletOrderReversed, int nframelets)
Changes the direction of the framelets.
void SetBand(const int band)
Sets the band in the camera model.
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition: PvlObject.h:141
Distort/undistort focal plane coordinates.
CameraDistortionMap * DistortionMap()
Returns a pointer to the CameraDistortionMap object.
Definition: Camera.cpp:2838
void SetFrameletOffset(int frameletOffset)
Reset the frame offset.
QString m_instrumentNameLong
Full instrument name.
Definition: Camera.h:507
Isis::Camera * MarciCameraPlugin(Isis::Cube &cube)
This is the function that is called in order to instantiate a MarciCamera object. ...
double p_etStart
Ephemeris Start iTime.
Definition: MarciCamera.h:81
void SetDetectorSampleSumming(const double summing)
Set sample summing mode.
void SetPixelPitch()
Reads the Pixel Pitch from the instrument kernel.
Definition: Camera.cpp:1437
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
void SetFrameletsGeometricallyFlipped(bool frameletsFlipped)
Mirrors the each framelet in the file.
Namespace for the standard library.
Convert between undistorted focal plane and ground coordinates.
Search child objects.
Definition: PvlObject.h:170
double p_interframeDelay
Interframe Delay value from labels.
Definition: MarciCamera.h:84
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.
PushFrameCameraDetectorMap * DetectorMap()
Returns a pointer to the PushFrameCameraDetectorMap object.
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:162
void SetDetectorLineSumming(const double summing)
Set line summing mode.
int ParentLines() const
Returns the number of lines in the parent alphacube.
Definition: Camera.cpp:2818
virtual int CkFrameId() const
CK frame ID - - Instrument Code from spacit run on CK.
virtual int SpkReferenceId() const
SPK Reference ID - J2000.
Generic class for Push Frame Cameras.
Marci Camera Model.
Definition: MarciCamera.h:63
bool IsBandIndependent()
The camera model is band dependent, so this method returns false.
int size() const
Returns the number of values stored in this keyword.
Definition: PvlKeyword.h:141
Convert between distorted focal plane and detector coordinates.
double p_exposureDur
Exposure Duration value from labels.
Definition: MarciCamera.h:83
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
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
A type of error that could only have occurred due to a mistake on the user&#39;s part (e...
Definition: IException.h:142
A single keyword-value pair.
Definition: PvlKeyword.h:98
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
Convert between parent image coordinates and detector coordinates.
Container for cube-like labels.
Definition: Pvl.h:135
virtual int CkReferenceId() const
CK Reference ID - MRO_MME_OF_DATE.
CameraFocalPlaneMap * FocalPlaneMap()
Returns a pointer to the CameraFocalPlaneMap object.
Definition: Camera.cpp:2848
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
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Definition: NaifStatus.cpp:43
Isis exception class.
Definition: IException.h:107
Adds specific functionality to C++ strings.
Definition: IString.h:181
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
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:2566
~MarciCamera()
Destroys the Themis Vis Camera object.
int p_nframelets
Number of framelets in whole image.
Definition: MarciCamera.h:85
double Et() const
Returns the ephemeris time (TDB) representation of the time as a double.
Definition: iTime.h:139
virtual void SetBand(const int band)
Virtual method that sets the band number.
Definition: Camera.cpp:2692
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