Loading [MathJax]/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
CrismCamera.cpp
1 
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 
31 using namespace std;
32 
33 namespace 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";
48  m_spacecraftNameShort = "MRO";
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
63  SetPixelPitch();
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
213 extern "C" Isis::Camera *CrismCameraPlugin(Isis::Cube &cube) {
214  return new Isis::CrismCamera(cube);
215 }
Isis::LineScanCameraSkyMap
Convert between undistorted focal plane and ra/dec coordinates.
Definition: LineScanCameraSkyMap.h:34
Isis::CameraFocalPlaneMap::SetDetectorOrigin
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
Definition: CameraFocalPlaneMap.cpp:293
Isis::CrismCamera::SetBand
void SetBand(const int physicalBand)
Virtual method that sets the band number.
Definition: CrismCamera.cpp:189
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::Sensor::SpacecraftAltitude
double SpacecraftAltitude()
Returns the distance from the spacecraft to the subspacecraft point in km.
Definition: Sensor.cpp:701
Isis::Camera::ParentLines
int ParentLines() const
Returns the number of lines in the parent alphacube.
Definition: Camera.cpp:2806
Isis::Spice::naifIkCode
SpiceInt naifIkCode() const
This returns the NAIF IK code to use when reading from instrument kernels.
Definition: Spice.cpp:968
Isis::iTime
Parse and return pieces of a time string.
Definition: iTime.h:65
Isis::CrismCamera::IsBandIndependent
bool IsBandIndependent()
This is a band-dependant instrument.
Definition: CrismCamera.cpp:193
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::CameraFocalPlaneMap::SetDetectorOffset
void SetDetectorOffset(const double sampleOffset, const double lineOffset)
Set the detector offset.
Definition: CameraFocalPlaneMap.cpp:324
Isis::Spice::createCache
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
Isis::VariableLineScanCameraDetectorMap
Convert between parent image coordinates and detector coordinates.
Definition: VariableLineScanCameraDetectorMap.h:49
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::CrismCamera
MRO CRISM camera model.
Definition: CrismCamera.h:45
Isis::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
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::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::LineScanCamera
Generic class for Line Scan Cameras.
Definition: LineScanCamera.h:36
Isis::LineScanCameraGroundMap
Convert between undistorted focal plane and ground coordinates.
Definition: LineScanCameraGroundMap.h:49
Isis::CameraDistortionMap
Distort/undistort focal plane coordinates.
Definition: CameraDistortionMap.h:41
Isis::Cube
IO Handler for Isis Cubes.
Definition: Cube.h:167
Isis::Camera::m_spacecraftNameLong
QString m_spacecraftNameLong
Full spacecraft name.
Definition: Camera.h:498
Isis::Spice::naifSclkCode
SpiceInt naifSclkCode() const
This returns the NAIF SCLK code to use when reading from instrument kernels.
Definition: Spice.cpp:978
Isis::Camera::FocalLength
double FocalLength() const
Returns the focal length.
Definition: Camera.cpp:2732
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::Camera::PixelPitch
double PixelPitch() const
Returns the pixel pitch.
Definition: Camera.cpp:2742
Isis::Cube::label
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition: Cube.cpp:1701
Isis::Spice::getDouble
SpiceDouble getDouble(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition: Spice.cpp:1039
Isis::LineScanCamera::DetectorMap
LineScanCameraDetectorMap * DetectorMap()
Returns a pointer to the LineScanCameraDetectorMap object.
Definition: LineScanCamera.h:72
Isis::Camera::m_spacecraftNameShort
QString m_spacecraftNameShort
Shortened spacecraft name.
Definition: Camera.h:499
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::LineScanCameraDetectorMap
Convert between parent image coordinates and detector coordinates.
Definition: LineScanCameraDetectorMap.h:37
Isis::LineRateChange
Container class for storing timing information for a section of an image.
Definition: VariableLineScanCameraDetectorMap.h:83

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the USGS Astrogeology Discussion Board
To report a bug, or suggest a feature go to: ISIS Github
File Modified: 07/13/2023 15:16:20