Isis 3 Programmer Reference
ThemisVisCamera.cpp
Go to the documentation of this file.
1 
20 #include "ThemisVisCamera.h"
21 
22 #include <iomanip>
23 
24 #include <QDebug>
25 #include <QString>
26 
27 #include "CameraFocalPlaneMap.h"
28 #include "CameraSkyMap.h"
29 #include "iTime.h"
30 #include "NaifStatus.h"
33 #include "ThemisVisDistortionMap.h"
34 
35 
36 using namespace std;
37 
38 namespace Isis {
39 
50  ThemisVisCamera::ThemisVisCamera(Cube &cube) : PushFrameCamera(cube) {
51  m_instrumentNameLong = "Thermal Emission Imaging System Visual";
52  m_instrumentNameShort = "Themis-VIS";
53  m_spacecraftNameLong = "Mars Odyssey";
54  m_spacecraftNameShort = "Odyssey";
55 
57  // Set up the camera characteristics
58  // LoadFrameMounting("M01_SPACECRAFT","M01_THEMIS_VIS");
59  // Changed Focal Length from 203.9 (millimeters????) to 202.059, per request from
60  // Christopher Edwards (Christopher.Edwards@asu.edu) at ASU, on 2/18/11.
61  SetFocalLength(202.059);
62  SetPixelPitch(0.009);
63 
64  Pvl &lab = *cube.label();
65  PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
66 
67  // make sure it is a themis vis image
68  if(inst["InstrumentId"][0] != "THEMIS_VIS") {
69  QString msg = "Unable to create Themis VIS camera model from an image with InstrumentId ["
70  + inst["InstrumentId"][0] + "].";
72  }
73 
74  // Get necessary variables
75  p_exposureDur = inst["ExposureDuration"];
76  p_interframeDelay = inst["InterframeDelay"];
77  int sumMode = inst["SpatialSumming"];
78 
79  // Get the start and end time
80  double et;
81  QString stime = inst["SpacecraftClockCount"];
82  et = getClockTime(stime).Et();
83 
84  double offset = inst["SpacecraftClockOffset"];
85  p_etStart = et + offset - ((p_exposureDur / 1000.0) / 2.0);
86  p_nframes = inst["NumFramelets"];
87 
88  // Get the keywords from labels
89  PvlGroup &bandBin = lab.findGroup("BandBin", Pvl::Traverse);
90 
91  PvlKeyword &filterNumbers = bandBin["FilterNumber"];
92  for (int i = 0; i < filterNumbers.size(); i++) {
93  p_filterNumber.append(toInt(filterNumbers[i]));
94  }
95 
96 
97  // Setup detector map
98  double frameRate = p_interframeDelay;
99  //int frameletHeight = 192;
100  int frameletHeight = (int) (ParentLines() / ((double) p_nframes / (double) sumMode)); // = 192
102  new PushFrameCameraDetectorMap(this, p_etStart, frameRate, frameletHeight);
103  dmap->SetDetectorSampleSumming(sumMode);
104  dmap->SetDetectorLineSumming(sumMode);
105  dmap->SetFrameletOrderReversed(false, p_nframes); // these framelets are in time ascending order
106  //(i.e. the order is not reversed)
107  // dmap->SetFrameletsGeometricallyFlipped(true); this is not set... looks like it defaults to true???
108  // We do not want to set the exposure duration in the detector map, let it default to 0.0...
109 
110  // Setup focal plane map
111  CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
112  focalMap->SetDetectorOrigin(512.5, 512.5);
113 
114  // Setup distortion map
115  new ThemisVisDistortionMap(this);
116 
117  // Setup the ground and sky map
118  bool evenFramelets = (inst["Framelets"][0] == "Even");
119  new PushFrameCameraGroundMap(this, evenFramelets);
120  new CameraSkyMap(this);
121 
122  LoadCache();
124  }
125 
126 
128  }
129 
130 
131 
137  void ThemisVisCamera::SetBand(const int vband) {
138  Camera::SetBand(vband);
139 
140  // Set the et
141  double et = p_etStart + BandEphemerisTimeOffset(vband);
142  setTime(et);
144  dmap->SetStartTime(et);
145  }
146 
147 
148 
158  // Lookup the time band corresponding to this ISIS cube band
159  // number based on the FilterNumber keyword in the BandBin group.
160  // Filter numbers indicate the physical location of the band in
161  // the detector array. They are numbered by ascending times.
162  // (filter number = time band)
163  int timeBand = p_filterNumber[vband - 1];
164 
165  if (HasReferenceBand()) {
166  // If there is a reference band, the data has all been aligned in the band dimension
167 
168  // VIS BandNumbers (including the reference band) are numbered by ascending filter
169  // wavelength. Convert the wavelength band to a time band (filter number).
170  int wavelengthToTimeBand[] = { 2, 5, 3, 4, 1 };
171  timeBand = wavelengthToTimeBand[ReferenceBand() - 1];
172  }
173 
174  // Compute the time offset for this detector line.
175  // Subtract 1 from the time band then multiply by the interframe delay then
176  // subtract half the exposure duration, in seconds.
177  //
178  // Subtracting 1 from the time band number calculates the appropriate
179  // number of interframe delay multiples for this filter number (recall this
180  // corresponds to a location on the ccd)
181  p_bandTimeOffset = ((timeBand - 1) * p_interframeDelay) - ((p_exposureDur / 1000.0) / 2.0);
182 
183  // Set the detector first line for this band on the ccd.
184  // The VIS band first row values are 1-based detector row numbers
185  // used for the beginning (bottom) of the 192-row framelet for the various bands.
186  // These row values correspond directly to the filter numbers (time bands) {1, 2, 3, 4, 5}.
187  // Obtained from the NAIF instrument kernel.
188  // Note that row 1 is the first detector row to see an area of the ground.
189  int visBandFirstRow[] = { 4, 203, 404, 612, 814 };
191  dmap->SetBandFirstDetectorLine(visBandFirstRow[timeBand - 1]);
192 
193  return p_bandTimeOffset;
194  }
195 
196 
197 
205  return false;
206  }
207 
208 
209 
217  return -53000;
218  }
219 
220 
221 
229  return 16;
230  }
231 
232 
233 
241  return 1;
242  }
243 }
244 
245 
246 // Plugin
258  return new Isis::ThemisVisCamera(cube);
259 }
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
bool IsBandIndependent()
The camera model is band dependent (i.e.
void SetFrameletOrderReversed(bool frameletOrderReversed, int nframelets)
Changes the direction of the framelets.
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition: PvlObject.h:141
int p_nframes
Number of frames in whole image.
QString m_instrumentNameLong
Full instrument name.
Definition: Camera.h:507
void SetDetectorSampleSumming(const double summing)
Set sample summing mode.
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition: IString.cpp:108
double p_exposureDur
Exposure Duration value from labels.
void SetPixelPitch()
Reads the Pixel Pitch from the instrument kernel.
Definition: Camera.cpp:1437
~ThemisVisCamera()
Destroys the Themis Vis Camera object.
Namespace for the standard library.
QList< int > p_filterNumber
List of filter number values from the Instrument BandBin group that correspond to each band in the cu...
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
Convert between undistorted focal plane and ground coordinates.
Search child objects.
Definition: PvlObject.h:170
virtual int CkFrameId() const
CK frame ID - - Instrument Code from spacit run on CK.
virtual int CkReferenceId() const
CK Reference ID - MARSIAU.
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
PushFrameCameraDetectorMap * DetectorMap()
Returns a pointer to the PushFrameCameraDetectorMap object.
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
Distort/undistort focal plane coordinates.
bool HasReferenceBand() const
Checks to see if the Camera object has a reference band.
Definition: Camera.cpp:2682
Generic class for Push Frame Cameras.
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_bandTimeOffset
Offset iTime for Band.
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.
Isis::Camera * ThemisVisCameraPlugin(Isis::Cube &cube)
This is the function that is called in order to instantiate a ThemisVisCamera object.
double p_etStart
Ephemeris Start iTime.
double p_interframeDelay
Interframe Delay value from labels.
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 SetBand(const int band)
Sets the band in the camera model.
void LoadCache()
This loads the spice cache big enough for this image.
Definition: Camera.cpp:2432
virtual int SpkReferenceId() const
SPK Reference ID - J2000.
double BandEphemerisTimeOffset(int vband)
Calculates time offset for the given cube band number.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
QString m_spacecraftNameLong
Full spacecraft name.
Definition: Camera.h:509
void SetStartTime(const double etStart)
Reset the starting ephemeris time.
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
THEMIS VIS Camera Model.
Isis exception class.
Definition: IException.h:107
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
int ReferenceBand() const
Returns the reference band.
Definition: Camera.cpp:2671
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
IO Handler for Isis Cubes.
Definition: Cube.h:170