Isis 3 Programmer Reference
VimsCamera.cpp
1
7/* SPDX-License-Identifier: CC0-1.0 */
8
9#include "VimsCamera.h"
10#include "VimsGroundMap.h"
11#include "VimsSkyMap.h"
12
13#include <fstream>
14#include <iostream>
15#include <iomanip>
16
17#include <QDebug>
18#include <QList>
19#include <QPointF>
20#include <QString>
21
22#include "CameraDetectorMap.h"
23#include "CameraDistortionMap.h"
24#include "CameraFocalPlaneMap.h"
25#include "Constants.h"
26#include "FileName.h"
27#include "IException.h"
28#include "IString.h"
29#include "iTime.h"
30#include "NaifStatus.h"
31#include "SpecialPixel.h"
32
33using namespace std;
34
35namespace Isis {
54 m_instrumentNameLong = "Visible and Infrared Mapping Spectrometer";
55 m_instrumentNameShort = "VIMS";
56 m_spacecraftNameLong = "Cassini Huygens";
57 m_spacecraftNameShort = "Cassini";
58
60
61 Pvl &lab = *cube.label();
62 PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
63 QString channel = (QString) inst ["Channel"];
64
65 // Vims pixel pitch is not always square, but ISISdoes not have the ability to store
66 // more than a single value for pixel pitch. Member variables for pixelPitch x and y
67 // were created for proper calculation of ifov.
68 if (channel == "VIS") {
69 //LoadFrameMounting ("CASSINI_SC_COORD","CASSINI_VIMS_V");
70
71 SetFocalLength(143.0);
72 if (QString((QString)inst["SamplingMode"]).toUpper() == "NORMAL") {
73 SetPixelPitch(3 * .024);
74 // Should this .506? According to 2002 paper ground calibration shows .506 +/- .003 mrad
75 m_pixelPitchX = 0.024 * 3;
76 m_pixelPitchY = 0.024 * 3;
77 }
78 else if (QString((QString)inst["SamplingMode"]).toUpper() == "HI-RES") {
79 SetPixelPitch(.024);
80 m_pixelPitchX = 0.024;
81 m_pixelPitchY = 0.024;
82 }
83 else if (QString((QString)inst["SamplingMode"]).toUpper() == "UNDER") {
84 QString msg = "Isis cannot process images with a SamplingMode = \"UNDER\" (or NYQUIST)";
85 throw IException(IException::Programmer, msg, _FILEINFO_);
86 }
87 else {
88 QString msg = "Unknown SamplingMode [" + (QString) inst["SamplingMode"] + "]";
89 throw IException(IException::Programmer, msg, _FILEINFO_);
90 }
91 }
92 else if (channel == "IR") {
93 //LoadFrameMounting ("CASSINI_SC_COORD","CASSINI_VIMS_IR");
94
95 SetFocalLength(426.0);
96 SetPixelPitch(.2);
97 if (QString((QString)inst["SamplingMode"]).toUpper() == "NORMAL") {
98 m_pixelPitchX = 0.2;
99 m_pixelPitchY = 0.2;
100 }
101 else if (QString((QString)inst["SamplingMode"]).toUpper() == "HI-RES") {
102 m_pixelPitchX = 0.103;
103 m_pixelPitchY = 0.2;
104 }
105 else if (QString((QString)inst["SamplingMode"]).toUpper() == "UNDER") {
106 QString msg = "Isis cannot process images with a SamplingMode = \"UNDER\" (or NYQUIST)";
107 throw IException(IException::Programmer, msg, _FILEINFO_);
108 }
109 else {
110 QString msg = "Unknown SamplingMode [" + (QString) inst["SamplingMode"] + "]";
111 throw IException(IException::Programmer, msg, _FILEINFO_);
112 }
113 }
114
115 // Get the start time in et
116 QString stime = inst ["NativeStartTime"][0];
117 QString intTime = stime.split(".").first();
118 stime = stime.split(".").last();
119
120 double etStart = getClockTime(intTime).Et();
121
122 // Add 2 seconds to either side of time range because the time are for IR
123 // channel, the VIS may actually start integrating before NATIVE_START_TIME.
124 // This insures the cache is large enough.
125 etStart += toDouble(stime) / 15959.0 - 2.;
126
127 // Get the end time in et
128 QString etime = (QString) inst ["NativeStopTime"];
129 intTime = etime.split(".").first();
130 etime = etime.split(".").last();
131
132 double etStop = getClockTime(intTime).Et();
133
134 // Add 2 seconds to either side of time range because the time are for IR
135 // channel, the VIS may actually start integrating before NATIVE_START_TIME.
136 // This insures the cache is large enough.
137 etStop += toDouble(stime) / 15959.0 + 2.;
138
139 // Setup detector map
140 new CameraDetectorMap(this);
141
142 // Setup focal plane map
143 new CameraFocalPlaneMap(this, naifIkCode());
144
145 // Setup distortion map
146 new CameraDistortionMap(this);
147
148 // Setup the ground and sky map
149 new VimsGroundMap(this, lab);
150 new VimsSkyMap(this, lab);
151
152 ((VimsGroundMap *)GroundMap())->Init(lab);
153 ((VimsSkyMap *)SkyMap())->Init(lab);
154
155 LoadCache();
156
157 IgnoreProjection(true);
158 SetImage(1, 1);
159 IgnoreProjection(false);
161 return;
162 }
163
164
174
175 QList<QPointF> offsets;
176
177 // Create 100 pts on each edge of pixel
178 int npts = 100;
179
180 // Top edge of pixel
181 for (double x = -m_pixelPitchX / 2.0; x <= m_pixelPitchX / 2.0; x += m_pixelPitchX / (npts-1)) {
182 offsets.append(QPointF(x, -m_pixelPitchY / 2.0));
183 }
184 // Right edge of pixel
185 for (double y = -m_pixelPitchY / 2.0; y <= m_pixelPitchY / 2.0; y += m_pixelPitchY / (npts-1)) {
186 offsets.append(QPointF(m_pixelPitchX / 2.0, y));
187 }
188 // Bottom edge of pixel
189 for (double x = m_pixelPitchX / 2.0; x >= -m_pixelPitchX / 2.0; x -= m_pixelPitchX / (npts-1)) {
190 offsets.append(QPointF(x, m_pixelPitchY / 2.0));
191 }
192 // Left edge of pixel
193 for (double y = m_pixelPitchY / 2.0; y >= -m_pixelPitchY / 2.0; y -= m_pixelPitchY / (npts-1)) {
194 offsets.append(QPointF(-m_pixelPitchX / 2.0, y));
195 }
196
197 return offsets;
198 }
199}
200
201// Plugin
212extern "C" Isis::Camera *VimsCameraPlugin(Isis::Cube &cube) {
213 return new Isis::VimsCamera(cube);
214}
Convert between parent image coordinates and detector coordinates.
Distort/undistort focal plane coordinates.
Convert between distorted focal plane and detector coordinates.
QString m_spacecraftNameLong
Full spacecraft name.
Definition Camera.h:499
void IgnoreProjection(bool ignore)
Set whether or not the camera should ignore the Projection.
Definition Camera.cpp:2955
CameraSkyMap * SkyMap()
Returns a pointer to the CameraSkyMap object.
Definition Camera.cpp:2896
virtual bool SetImage(const double sample, const double line)
Sets the sample/line values of the image to get the lat/lon values.
Definition Camera.cpp:156
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
CameraGroundMap * GroundMap()
Returns a pointer to the CameraGroundMap object.
Definition Camera.cpp:2886
QString m_instrumentNameLong
Full instrument name.
Definition Camera.h:497
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
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition IException.h:146
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
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
Cassini Vims camera model.
Definition VimsCamera.h:80
VimsCamera(Cube &cube)
Constructor for the Cassini Vims Camera Model.
virtual QList< QPointF > PixelIfovOffsets()
Returns the pixel ifov offsets from center of pixel.
Convert between undistorted focal plane and ground coordinates.
Convert between undistorted focal plane and ground coordinates.
Definition VimsSkyMap.h:46
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
double toDouble(const QString &string)
Global function to convert from a string to a double.
Definition IString.cpp:149
Namespace for the standard library.