Isis 3 Programmer Reference
ThemisVisCamera.cpp
1 
7 /* SPDX-License-Identifier: CC0-1.0 */
8 
9 #include "ThemisVisCamera.h"
10 
11 #include <iomanip>
12 
13 #include <QDebug>
14 #include <QString>
15 
16 #include "CameraFocalPlaneMap.h"
17 #include "CameraSkyMap.h"
18 #include "iTime.h"
19 #include "NaifStatus.h"
20 #include "PushFrameCameraDetectorMap.h"
21 #include "PushFrameCameraGroundMap.h"
22 #include "ThemisVisDistortionMap.h"
23 
24 
25 using namespace std;
26 
27 namespace Isis {
28 
39  ThemisVisCamera::ThemisVisCamera(Cube &cube) : PushFrameCamera(cube) {
40  m_instrumentNameLong = "Thermal Emission Imaging System Visual";
41  m_instrumentNameShort = "Themis-VIS";
42  m_spacecraftNameLong = "Mars Odyssey";
43  m_spacecraftNameShort = "Odyssey";
44 
46  // Set up the camera characteristics
47  // LoadFrameMounting("M01_SPACECRAFT","M01_THEMIS_VIS");
48  // Changed Focal Length from 203.9 (millimeters????) to 202.059, per request from
49  // Christopher Edwards (Christopher.Edwards@asu.edu) at ASU, on 2/18/11.
50  SetFocalLength(202.059);
51  SetPixelPitch(0.009);
52 
53  Pvl &lab = *cube.label();
54  PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
55 
56  // make sure it is a themis vis image
57  if(inst["InstrumentId"][0] != "THEMIS_VIS") {
58  QString msg = "Unable to create Themis VIS camera model from an image with InstrumentId ["
59  + inst["InstrumentId"][0] + "].";
60  throw IException(IException::User, msg, _FILEINFO_);
61  }
62 
63  // Get necessary variables
64  p_exposureDur = inst["ExposureDuration"];
65  p_interframeDelay = inst["InterframeDelay"];
66  int sumMode = inst["SpatialSumming"];
67 
68  // Get the start and end time
69  double et;
70  QString stime = inst["SpacecraftClockCount"];
71  et = getClockTime(stime).Et();
72 
73  double offset = inst["SpacecraftClockOffset"];
74  p_etStart = et + offset - ((p_exposureDur / 1000.0) / 2.0);
75  p_nframes = inst["NumFramelets"];
76 
77  // Get the keywords from labels
78  PvlGroup &bandBin = lab.findGroup("BandBin", Pvl::Traverse);
79 
80  PvlKeyword &filterNumbers = bandBin["FilterNumber"];
81  for (int i = 0; i < filterNumbers.size(); i++) {
82  p_filterNumber.append(toInt(filterNumbers[i]));
83  }
84 
85 
86  // Setup detector map
87  double frameRate = p_interframeDelay;
88  //int frameletHeight = 192;
89  int frameletHeight = (int) (ParentLines() / ((double) p_nframes / (double) sumMode)); // = 192
91  new PushFrameCameraDetectorMap(this, p_etStart, frameRate, frameletHeight);
92  dmap->SetDetectorSampleSumming(sumMode);
93  dmap->SetDetectorLineSumming(sumMode);
94  dmap->SetFrameletOrderReversed(false, p_nframes); // these framelets are in time ascending order
95  //(i.e. the order is not reversed)
96  // dmap->SetFrameletsGeometricallyFlipped(true); this is not set... looks like it defaults to true???
97  // We do not want to set the exposure duration in the detector map, let it default to 0.0...
98 
99  // Setup focal plane map
100  CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
101  focalMap->SetDetectorOrigin(512.5, 512.5);
102 
103  // Setup distortion map
104  new ThemisVisDistortionMap(this);
105 
106  // Setup the ground and sky map
107  bool evenFramelets = (inst["Framelets"][0] == "Even");
108  new PushFrameCameraGroundMap(this, evenFramelets);
109  new CameraSkyMap(this);
110 
111  LoadCache();
113  }
114 
115 
117  }
118 
119 
120 
126  void ThemisVisCamera::SetBand(const int vband) {
127  Camera::SetBand(vband);
128 
129  // Set the et
130  double et = p_etStart + BandEphemerisTimeOffset(vband);
131  setTime(et);
133  dmap->SetStartTime(et);
134  }
135 
136 
137 
147  // Lookup the time band corresponding to this ISIS cube band
148  // number based on the FilterNumber keyword in the BandBin group.
149  // Filter numbers indicate the physical location of the band in
150  // the detector array. They are numbered by ascending times.
151  // (filter number = time band)
152  int timeBand = p_filterNumber[vband - 1];
153 
154  if (HasReferenceBand()) {
155  // If there is a reference band, the data has all been aligned in the band dimension
156 
157  // VIS BandNumbers (including the reference band) are numbered by ascending filter
158  // wavelength. Convert the wavelength band to a time band (filter number).
159  int wavelengthToTimeBand[] = { 2, 5, 3, 4, 1 };
160  timeBand = wavelengthToTimeBand[ReferenceBand() - 1];
161  }
162 
163  // Compute the time offset for this detector line.
164  // Subtract 1 from the time band then multiply by the interframe delay then
165  // subtract half the exposure duration, in seconds.
166  //
167  // Subtracting 1 from the time band number calculates the appropriate
168  // number of interframe delay multiples for this filter number (recall this
169  // corresponds to a location on the ccd)
170  p_bandTimeOffset = ((timeBand - 1) * p_interframeDelay) - ((p_exposureDur / 1000.0) / 2.0);
171 
172  // Set the detector first line for this band on the ccd.
173  // The VIS band first row values are 1-based detector row numbers
174  // used for the beginning (bottom) of the 192-row framelet for the various bands.
175  // These row values correspond directly to the filter numbers (time bands) {1, 2, 3, 4, 5}.
176  // Obtained from the NAIF instrument kernel.
177  // Note that row 1 is the first detector row to see an area of the ground.
178  int visBandFirstRow[] = { 4, 203, 404, 612, 814 };
180  dmap->SetBandFirstDetectorLine(visBandFirstRow[timeBand - 1]);
181 
182  return p_bandTimeOffset;
183  }
184 
185 
186 
194  return false;
195  }
196 
197 
198 
206  return -53000;
207  }
208 
209 
210 
218  return 16;
219  }
220 
221 
222 
230  return 1;
231  }
232 }
233 
234 
235 // Plugin
246 extern "C" Isis::Camera *ThemisVisCameraPlugin(Isis::Cube &cube) {
247  return new Isis::ThemisVisCamera(cube);
248 }
Isis::Camera::SetBand
virtual void SetBand(const int band)
Virtual method that sets the band number.
Definition: Camera.cpp:2680
Isis::CameraFocalPlaneMap::SetDetectorOrigin
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
Definition: CameraFocalPlaneMap.cpp:293
Isis::ThemisVisCamera::p_bandTimeOffset
double p_bandTimeOffset
Offset iTime for Band.
Definition: ThemisVisCamera.h:93
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::ThemisVisCamera::~ThemisVisCamera
~ThemisVisCamera()
Destroys the Themis Vis Camera object.
Definition: ThemisVisCamera.cpp:116
Isis::ThemisVisCamera::IsBandIndependent
bool IsBandIndependent()
The camera model is band dependent (i.e.
Definition: ThemisVisCamera.cpp:193
Isis::ThemisVisCamera::BandEphemerisTimeOffset
double BandEphemerisTimeOffset(int vband)
Calculates time offset for the given cube band number.
Definition: ThemisVisCamera.cpp:146
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::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::ThemisVisCamera::p_exposureDur
double p_exposureDur
Exposure Duration value from labels.
Definition: ThemisVisCamera.h:94
Isis::Camera::HasReferenceBand
bool HasReferenceBand() const
Checks to see if the Camera object has a reference band.
Definition: Camera.cpp:2670
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::ThemisVisCamera::p_filterNumber
QList< int > p_filterNumber
List of filter number values from the Instrument BandBin group that correspond to each band in the cu...
Definition: ThemisVisCamera.h:97
Isis::ThemisVisDistortionMap
Distort/undistort focal plane coordinates.
Definition: ThemisVisDistortionMap.h:37
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::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::ThemisVisCamera
THEMIS VIS Camera Model.
Definition: ThemisVisCamera.h:73
Isis::ThemisVisCamera::SpkReferenceId
virtual int SpkReferenceId() const
SPK Reference ID - J2000.
Definition: ThemisVisCamera.cpp:229
Isis::toInt
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition: IString.cpp:93
Isis::PushFrameCamera
Generic class for Push Frame Cameras.
Definition: PushFrameCamera.h:35
Isis::ThemisVisCamera::p_nframes
int p_nframes
Number of frames in whole image.
Definition: ThemisVisCamera.h:96
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::ThemisVisCamera::SetBand
void SetBand(const int band)
Sets the band in the camera model.
Definition: ThemisVisCamera.cpp:126
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::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::PushFrameCameraDetectorMap::SetStartTime
void SetStartTime(const double etStart)
Reset the starting ephemeris time.
Definition: PushFrameCameraDetectorMap.cpp:215
Isis::ThemisVisCamera::CkReferenceId
virtual int CkReferenceId() const
CK Reference ID - MARSIAU.
Definition: ThemisVisCamera.cpp:217
Isis::Camera::ReferenceBand
int ReferenceBand() const
Returns the reference band.
Definition: Camera.cpp:2659
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::PushFrameCameraDetectorMap
Convert between parent image coordinates and detector coordinates.
Definition: PushFrameCameraDetectorMap.h:45
Isis::ThemisVisCamera::CkFrameId
virtual int CkFrameId() const
CK frame ID - - Instrument Code from spacit run on CK.
Definition: ThemisVisCamera.cpp:205
Isis::ThemisVisCamera::p_etStart
double p_etStart
Ephemeris Start iTime.
Definition: ThemisVisCamera.h:92
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
Isis::ThemisVisCamera::p_interframeDelay
double p_interframeDelay
Interframe Delay value from labels.
Definition: ThemisVisCamera.h:95