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
25using namespace std;
26
27namespace Isis {
28
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
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
246extern "C" Isis::Camera *ThemisVisCameraPlugin(Isis::Cube &cube) {
247 return new Isis::ThemisVisCamera(cube);
248}
Convert between distorted focal plane and detector coordinates.
QString m_spacecraftNameLong
Full spacecraft name.
Definition Camera.h:499
int ParentLines() const
Returns the number of lines in the parent alphacube.
Definition Camera.cpp:2836
int ReferenceBand() const
Returns the reference band.
Definition Camera.cpp:2689
void SetFocalLength()
Reads the focal length from the instrument kernel.
Definition Camera.cpp:1422
void SetPixelPitch()
Reads the Pixel Pitch from the instrument kernel.
Definition Camera.cpp:1429
void LoadCache()
This loads the spice cache big enough for this image.
Definition Camera.cpp:2450
QString m_instrumentNameShort
Shortened instrument name.
Definition Camera.h:498
QString m_spacecraftNameShort
Shortened spacecraft name.
Definition Camera.h:500
bool HasReferenceBand() const
Checks to see if the Camera object has a reference band.
Definition Camera.cpp:2700
virtual void SetBand(const int band)
Virtual method that sets the band number.
Definition Camera.cpp:2710
QString m_instrumentNameLong
Full instrument name.
Definition Camera.h:497
Convert between undistorted focal plane and ra/dec coordinates.
IO Handler for Isis Cubes.
Definition Cube.h:168
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition Cube.cpp:1707
Isis exception class.
Definition IException.h:91
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition IException.h:126
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Convert between parent image coordinates and detector coordinates.
void SetBandFirstDetectorLine(int firstLine)
Change the starting line in the detector based on band.
void SetStartTime(const double etStart)
Reset the starting ephemeris time.
Convert between undistorted focal plane and ground coordinates.
Generic class for Push Frame Cameras.
PushFrameCameraDetectorMap * DetectorMap()
Returns a pointer to the PushFrameCameraDetectorMap object.
Contains multiple PvlContainers.
Definition PvlGroup.h:41
Container for cube-like labels.
Definition Pvl.h:119
A single keyword-value pair.
Definition PvlKeyword.h:87
@ Traverse
Search child objects.
Definition PvlObject.h:158
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:99
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:1060
SpiceInt naifIkCode() const
This returns the NAIF IK code to use when reading from instrument kernels.
Definition Spice.cpp:975
THEMIS VIS Camera Model.
bool IsBandIndependent()
The camera model is band dependent (i.e.
int p_nframes
Number of frames in whole image.
double p_etStart
Ephemeris Start iTime.
virtual int SpkReferenceId() const
SPK Reference ID - J2000.
double BandEphemerisTimeOffset(int vband)
Calculates time offset for the given cube band number.
~ThemisVisCamera()
Destroys the Themis Vis Camera object.
void SetBand(const int band)
Sets the band in the camera model.
virtual int CkFrameId() const
CK frame ID - - Instrument Code from spacit run on CK.
double p_bandTimeOffset
Offset iTime for Band.
virtual int CkReferenceId() const
CK Reference ID - MARSIAU.
double p_interframeDelay
Interframe Delay value from labels.
ThemisVisCamera(Cube &cube)
Constructor for the Themis Vis Camera Model.
QList< int > p_filterNumber
List of filter number values from the Instrument BandBin group that correspond to each band in the cu...
double p_exposureDur
Exposure Duration value from labels.
Distort/undistort focal plane coordinates.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition IString.cpp:93
Namespace for the standard library.