Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.

Isis 3 Programmer Reference
CrismCamera.cpp
1
6
7/* SPDX-License-Identifier: CC0-1.0 */
8
9#include "CrismCamera.h"
10
11#include <fstream>
12#include <iostream>
13#include <iomanip>
14
15#include <QString>
16
17//#include "CrismCameraGroundMap.h"
18//#include "CrismDistortionMap.h"
19#include "CameraFocalPlaneMap.h"
20#include "LineScanCameraDetectorMap.h"
21#include "LineScanCameraGroundMap.h"
22#include "LineScanCameraSkyMap.h"
23#include "Constants.h"
24#include "FileName.h"
25#include "IException.h"
26#include "IString.h"
27#include "iTime.h"
28#include "NaifStatus.h"
29#include "SpecialPixel.h"
30
31using namespace std;
32
33namespace Isis {
43 CrismCamera::CrismCamera(Cube &cube) : LineScanCamera(cube), m_lineRates(),
44 m_isBandDependent(true) {
45 m_instrumentNameLong = "Compact Reconnaissance Imaging Spectrometer for Mars";
46 m_instrumentNameShort = "CRISM";
47 m_spacecraftNameLong = "Mars Reconnaissance Orbiter";
50
51 Pvl &lab = *cube.label();
52
53 PvlGroup inst = lab.findGroup("Instrument", Pvl::Traverse);
54
55 // SensorId = S (VNIR), = L (IR) = J (JOINT)
56 QString sensor = (QString) inst ["SensorId"];
57
58 // Prepare instrument code
59 QString ikCode(toString(naifIkCode()));
60
61 // Set Frame mounting. Same for both (VNIR, IR) detectors
64
65 // Get the start and end time in et
66 double etStart = getEtTime((QString) inst ["SpacecraftClockStartCount"]);
67 double etStop = getEtTime((QString) inst ["SpacecraftClockStopCount"]);
68
69
70 // Compute the exposure time of the first line and the line rate. This
71 // algorithm is taken from the CRISM instrument kernel, mro_crism_v10.ti,
72 // at the time of development.
73// double framesPerSec = (double) inst["FrameRate"];
74 int exposure = (int) inst["ExposureParameter"];
75
76 // calculate seconds for a full frame
77// double frame_time = 1.0 / framesPerSec;
78
79 // calculate seconds per pixel clock
80// double pixel_clock_time = frame_time / 83333.0;
81
82 // This is what John Hayes does in the DPU (Data Processing Unit), to write
83 // register to FPU (Focal Plane Unit) specifying how long NOT to integrate,
84 // in pixel clocks [0..83333]
85 int reg = ((480 - exposure) * 83333) / 480;
86
87 // Actual integration starts 3 line-times later, rounded up to next line
88 // time
89 int start_clocks = reg + (3 * 166);
90 if (start_clocks % 166) start_clocks += 166 - (start_clocks % 166);
91
92 // integration continues 4 line-times after de-assertion
93// int stop_clocks = 83333 + (4 * 166);
94
95// double start_time = start_clocks * pixel_clock_time;
96// double stop_time = stop_clocks * pixel_clock_time;
97
98 // Start of first line exposure time. This is the start time of the
99 // frame time plus the itegration delay start time - constant for all
100 // frames
101// double obsStartTime(etStart+start_time);
102// double obsStopTime(obsStartTime+(stop_time*ParentLines())-start_time);
103// double obsEndTime(obsStartTime+(frame_time*(ParentLines()))-start_time);
104
105 double frameStartTime(etStart);
106// double frameStopTime(frameStartTime+(stop_time*(ParentLines())));
107// double frameEndTime(frameStartTime+(frame_time*(ParentLines())));
108
109// double lineTime((etStop-etStart+frame_time)/(ParentLines()));
110
111
112 // Compute the sclk and UTC of the specifed line for cropping purposes
113#if 0
114 iTime myLineStartTime(etStart + ((25.0 - 1.0) * frame_time));
115// cout << "\nLine 25 Start Times...\n";
116 SpiceChar sclk[80];
117 (void) sce2s_c(naifSclkCode(), myLineStartTime.Et(), sizeof(sclk), sclk);
118// cout << "UTC@Line 25: " << myLineStartTime.UTC() << "\n";
119// cout << "SCLK@Line 25: " << sclk << "\n";
120
121#endif
122 // Setup detector map
123#if 1
124 double jaTime = (etStop-etStart)/ParentLines();
125 new LineScanCameraDetectorMap(this, frameStartTime, jaTime);
126// new LineScanCameraDetectorMap(this, frameStartTime, frame_time);
127#else
128 // Have to use variable line scan detector mapping due to how line scans
129 // are performed. This is currently segfaulting...
130
131 double stime(obsStartTime);
132 double scanTime(stop_time-start_time);
133 m_lineRates.clear();
134 for (int i = 0 ; i < ParentLines() ; i++) {
135 m_lineRates.push_back(LineRateChange(i+1, stime, scanTime));
136 stime += frame_time;
137 }
138 m_lineRates.push_back(LineRateChange(ParentLines()+1,stime-start_time,start_time));
139 double endTime(stime-frame_time+scanTime);
140 new VariableLineScanCameraDetectorMap(this, m_lineRates);
141#endif
142
143 int binning = inst["PixelAveragingWidth"];
145 DetectorMap()->SetDetectorLineSumming(1.0); // Line dimension never binned
146
147 // Setup focal plane map
149
150 // lines and samples added to the pvl in the order you
151 // call getDouble()
152 double bLine = getDouble("INS"+ikCode+"_BORESIGHT_LINE");
153 double bSample = getDouble("INS"+ikCode+"_BORESIGHT_SAMPLE");
154
155 fmap->SetDetectorOrigin(bSample, bLine);
156 fmap->SetDetectorOffset(0.0, 0.0);
157
158 // Setup distortion map
159 //new CrismDistortionMap(this);
160 new CameraDistortionMap(this);
161
162
163 // Setup the ground and sky map
164 new LineScanCameraGroundMap(this);
165// new CrismCameraGroundMap(this);
166 new LineScanCameraSkyMap(this);
167
168 setTime(iTime(frameStartTime));
169 double tol = 0.0; //PixelResolution();
170 if(tol < 0.) {
171 // Alternative calculation of .01*ground resolution of a pixel
172 tol = PixelPitch() * SpacecraftAltitude() / FocalLength() / 1000. / 100.;
173 }
174
175// cout << "\nCreateCache(" << frameStartTime << ", " << frameEndTime << ")...\n";
176#if 0
177// cout << "CacheSize: " << CacheSize(obsStartTime, obsStopTime) << "\n";
178 createCache(obsStartTime, obsStopTime, ParentLines(), tol);
179
180#else
181// cout << "LoadCache()...\n";
182 LoadCache();
183#endif
184// cout << "Done.\n";
186 return;
187 }
188
189 void CrismCamera::SetBand (const int physicalBand) {
190 return;
191 }
192
194 return (m_isBandDependent);
195 }
196
197
198 double CrismCamera::getEtTime(const QString &sclk) {
199 return (getClockTime(sclk, -74999).Et());
200 }
201}
202
203
204// Plugin
213extern "C" Isis::Camera *CrismCameraPlugin(Isis::Cube &cube) {
214 return new Isis::CrismCamera(cube);
215}
void SetDetectorLineSumming(const double summing)
Set line summing mode.
void SetDetectorSampleSumming(const double summing)
Set sample summing mode.
Distort/undistort focal plane coordinates.
Convert between distorted focal plane and detector coordinates.
void SetDetectorOffset(const double sampleOffset, const double lineOffset)
Set the detector offset.
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
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
double PixelPitch() const
Returns the pixel pitch.
Definition Camera.cpp:2772
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
double FocalLength() const
Returns the focal length.
Definition Camera.cpp:2762
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
QString m_instrumentNameLong
Full instrument name.
Definition Camera.h:497
MRO CRISM camera model.
Definition CrismCamera.h:45
CrismCamera(Cube &cube)
Constructor for the MRO CRISM Camera Model.
bool IsBandIndependent()
This is a band-dependant instrument.
void SetBand(const int physicalBand)
Virtual method that sets the band number.
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:1734
Container class for storing timing information for a section of an image.
Convert between parent image coordinates and detector coordinates.
Convert between undistorted focal plane and ground coordinates.
LineScanCamera(Isis::Cube &cube)
Constructs the LineScanCamera object.
LineScanCameraDetectorMap * DetectorMap()
Returns a pointer to the LineScanCameraDetectorMap object.
Convert between undistorted focal plane and ra/dec coordinates.
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Contains multiple PvlContainers.
Definition PvlGroup.h:41
Container for cube-like labels.
Definition Pvl.h:119
@ Traverse
Search child objects.
Definition PvlObject.h:158
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition PvlObject.h:129
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
double SpacecraftAltitude()
Returns the distance from the spacecraft to the subspacecraft point in km.
Definition Sensor.cpp:703
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
virtual void createCache(iTime startTime, iTime endTime, const int size, double tol)
This method creates an internal cache of spacecraft and sun positions over a specified time range.
Definition Spice.cpp:649
SpiceInt naifIkCode() const
This returns the NAIF IK code to use when reading from instrument kernels.
Definition Spice.cpp:975
SpiceInt naifSclkCode() const
This returns the NAIF SCLK code to use when reading from instrument kernels.
Definition Spice.cpp:985
SpiceDouble getDouble(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition Spice.cpp:1046
Convert between parent image coordinates and detector coordinates.
Parse and return pieces of a time string.
Definition iTime.h:65
double Et() const
Returns the ephemeris time (TDB) representation of the time as a double.
Definition iTime.h:126
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition IString.cpp:211
Namespace for the standard library.