Isis 3 Programmer Reference
VikingCamera.cpp
1
6
7/* SPDX-License-Identifier: CC0-1.0 */
8
9
10#include "VikingCamera.h"
11
12#include <SpiceUsr.h>
13#include <SpiceZfc.h>
14#include <SpiceZmc.h>
15
16#include <QString>
17
18#include "CameraDetectorMap.h"
19#include "CameraFocalPlaneMap.h"
20#include "CameraGroundMap.h"
21#include "CameraSkyMap.h"
22#include "FileName.h"
23#include "IString.h"
24#include "iTime.h"
25#include "NaifStatus.h"
26#include "ReseauDistortionMap.h"
27
28using namespace std;
29
30namespace Isis {
47 // Set the pixel pitch
48 SetPixelPitch(1.0 / 85.0);
49
50 // Find out what camera is being used, and set the focal length, altinstcode,
51 // raster orientation, cone, crosscone, and camera
52 Pvl &lab = *cube.label();
53 PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
54 QString spacecraft = inst["SPACECRAFTNAME"];
55 QString instId = inst["INSTRUMENTID"];
56 QString cam;
57 int spn;
58 double raster, cone, crosscone;
59 int altinstcode = 0;
60 if(spacecraft == "VIKING_ORBITER_1") {
61 p_ckFrameId = -27000;
62 p_spkTargetId = -27;
63 m_spacecraftNameLong = "Viking Orbiter 1";
64 m_spacecraftNameShort = "Viking1";
65
66 spn = 1;
67 altinstcode = -27999;
68 if(instId == "VISUAL_IMAGING_SUBSYSTEM_CAMERA_A") {
69 cam = "1a";
70 SetFocalLength(474.398);
71 crosscone = -0.707350;
72 cone = -0.007580;
73 raster = 89.735690;
74 m_instrumentNameLong = "Visual Imaging Subsystem Camera A";
75 m_instrumentNameShort = "VISA";
76 }
77 else if(instId == "VISUAL_IMAGING_SUBSYSTEM_CAMERA_B") {
78 cam = "1b";
79 SetFocalLength(474.448);
80 crosscone = 0.681000;
81 cone = -0.032000;
82 raster = 90.022800;
83 m_instrumentNameLong = "Visual Imaging Subsystem Camera B";
84 m_instrumentNameShort = "VISB";
85 }
86 else {
87 QString msg = "File does not appear to be a Viking image. InstrumentId ["
88 + instId + "] is invalid Viking value.";
89 throw IException(IException::User, msg, _FILEINFO_);
90 }
91 }
92 else if(spacecraft == "VIKING_ORBITER_2") {
93 p_ckFrameId = -30000;
94 p_spkTargetId = -30;
95 m_spacecraftNameLong = "Viking Orbiter 2";
96 m_spacecraftNameShort = "Viking2";
97
98 spn = 2;
99 altinstcode = -30999;
100 if(instId == "VISUAL_IMAGING_SUBSYSTEM_CAMERA_A") {
101 cam = "2a";
102 SetFocalLength(474.610);
103 crosscone = -0.679330;
104 cone = -0.023270;
105 raster = 89.880691;
106 m_instrumentNameLong = "Visual Imaging Subsystem Camera A";
107 m_instrumentNameShort = "VISA";
108 }
109 else if(instId == "VISUAL_IMAGING_SUBSYSTEM_CAMERA_B") {
110 cam = "2b";
111 SetFocalLength(474.101);
112 crosscone = 0.663000;
113 cone = -0.044000;
114 raster = 89.663790;
115 m_instrumentNameLong = "Visual Imaging Subsystem Camera B";
116 m_instrumentNameShort = "VISB";
117 }
118 else {
119 QString msg = "File does not appear to be a Viking image. InstrumentId ["
120 + instId + "] is invalid Viking value.";
121 throw IException(IException::User, msg, _FILEINFO_);
122 }
123 }
124 else {
125 QString msg = "File does not appear to be a Viking image. SpacecraftName ["
126 + spacecraft + "] is invalid Viking value.";
127 throw IException(IException::User, msg, _FILEINFO_);
128 }
129
130 // DOCUMENTATION FROM ISIS2 lev1u_vik_vis_routines.c:
131 /*****************************************************************************
132 * Calculate the START_TIME keyword (time at middle of exposure in this case)*
133 * value from FSC to get fractional seconds (PDS START_TIME provided is only *
134 * to the nearest whole second). The algorithm below was extracted from the *
135 * NAIF document Viking Orbiter Time Tag Analysis and Restoration by Boris *
136 * Semenov and Chuck Acton. *
137 * 1. Get exposure duration from labels to center the time *
138 * 2. Get FSC from IMAGE_NUMBER on labels to use as spacecraftClock *
139 * 3. Load the appropriate FSC spacecraft clock kernel based on *
140 * the spacecraft (Viking Orbiter 1 or Viking Orbiter 2) *
141 * 4. Load a leap second kernel *
142 * 5. Convert FSC to et *
143 * 6. Add the offsets to get to midexposure *
144 * 7. Convert et to UTC calendar format and write to labels as *
145 * START_TIME *
146 *****************************************************************************/
147
148 // Get clock count and convert it to a time
149 QString spacecraftClock = inst["SpacecraftClockCount"];
150 double etClock = getClockTime(spacecraftClock, altinstcode).Et();
151
152 // exposure duration keyword value is measured in seconds
153 double exposureDuration = inst["ExposureDuration"];
154
155 // Calculate and load the euler angles
156 SpiceDouble CP[3][3];
157 eul2m_c((SpiceDouble)raster * rpd_c(), (SpiceDouble)cone * rpd_c(),
158 (SpiceDouble) - crosscone * rpd_c(), 3, 2, 1, CP);
159
160 // LoadEulerMounting(CP);
161
162 pair<iTime, iTime> shuttertimes = ShutterOpenCloseTimes(etClock, exposureDuration);
163
164 // find center shutter time
165 double centerTime = shuttertimes.first.Et() + exposureDuration / 2.0;
166 char timepds[25];
167 et2utc_c(centerTime, "ISOC", 3, 25, timepds);
168 utc2et_c(timepds, &centerTime);
169
170 // Setup detector map
171 new CameraDetectorMap(this);
172
173 // Setup focal plane map, and detector origin
174 CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
175 focalMap->SetDetectorOrigin(602.0, 528.0);
176
177 // Setup distortion map
178 QString fname = FileName("$viking" + toString(spn) + "/reseaus/vik" + cam
179 + "MasterReseaus.pvl").expanded();
180 new ReseauDistortionMap(this, lab, fname);
181
182 // Setup the ground and sky map
183 new CameraGroundMap(this);
184 new CameraSkyMap(this);
185
186 setTime(centerTime);
187 LoadCache();
189 }
190
191
212 pair<iTime, iTime> VikingCamera::ShutterOpenCloseTimes(double time,
213 double exposureDuration) {
214 pair<iTime, iTime> shuttertimes;
215 double offset1;
216 if (exposureDuration <= .420) {
217 offset1 = 7.0 / 8.0 * 4.48; //4.48 seconds = nomtick
218 }
219 else {
220 offset1 = 3.0 / 8.0 * 4.48;
221 }
222 double offset2 = 1.0 / 64.0 * 4.48;
223
224 // set private variables inherited from Spice class
225 shuttertimes.first = time + offset1 + offset2;
226 shuttertimes.second = shuttertimes.first.Et() + exposureDuration;
227 return shuttertimes;
228 }
229}
230
231
240extern "C" Isis::Camera *VikingCameraPlugin(Isis::Cube &cube) {
241 return new Isis::VikingCamera(cube);
242}
Convert between parent image coordinates and detector coordinates.
Convert between distorted focal plane and detector coordinates.
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
Convert between undistorted focal plane and ground coordinates.
QString m_spacecraftNameLong
Full spacecraft name.
Definition Camera.h:499
virtual double exposureDuration() const
Return the exposure duration for the pixel that the camera is set to.
Definition Camera.cpp:3093
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
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:1734
File name manipulation and expansion.
Definition FileName.h:100
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition FileName.cpp:196
FramingCamera(Cube &cube)
Constructs the FramingCamera object.
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.
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
Distort/undistort focal plane coordinates.
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
virtual iTime time() const
Returns the ephemeris time in seconds which was used to obtain the spacecraft and sun positions.
Definition Spice.cpp:891
SpiceInt naifIkCode() const
This returns the NAIF IK code to use when reading from instrument kernels.
Definition Spice.cpp:975
Viking Camera Model.
VikingCamera(Cube &cube)
Constructs a Viking Camera Model.
int p_ckFrameId
"Camera-matrix" Kernel Frame ID
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)
Returns the shutter open and close times.
int p_spkTargetId
Spacecraft Kernel Target ID.
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.