Isis 3 Programmer Reference
VoyagerCamera.cpp
1 
7 /* SPDX-License-Identifier: CC0-1.0 */
8 
9 
10 #include "VoyagerCamera.h"
11 
12 #include <SpiceUsr.h>
13 
14 #include <QString>
15 
16 #include "CameraDetectorMap.h"
17 #include "CameraFocalPlaneMap.h"
18 #include "CameraGroundMap.h"
19 #include "CameraSkyMap.h"
20 #include "FileName.h"
21 #include "IString.h"
22 #include "iTime.h"
23 #include "NaifStatus.h"
24 #include "ReseauDistortionMap.h"
25 #include "Spice.h"
26 
27 using namespace std;
28 
29 namespace Isis {
52  VoyagerCamera::VoyagerCamera (Cube &cube) : FramingCamera(cube) {
54 
55  // Set the pixel pitch
56  SetPixelPitch();
58  // Find out what camera is being used, and set the focal length, altinstcode,
59  // and camera
60  Pvl &lab = *cube.label();
61  PvlGroup &inst = lab.findGroup ("Instrument",Pvl::Traverse);
62  QString spacecraft = (QString)inst["SpacecraftName"];
63  QString instId = (QString)inst["InstrumentId"];
64 
65  QString reseauFileName = "";
66 
67  // These set up which kernel and other files to access,
68  if (spacecraft == "VOYAGER_1") {
69  p_ckFrameId = -31100;
70  p_spkTargetId = -31;
71  m_spacecraftNameLong = "Voyager 1";
72  m_spacecraftNameShort = "Voyager1";
73 
74  reseauFileName += "1/reseaus/vg1";
75 
76  if (instId == "NARROW_ANGLE_CAMERA") {
77  reseauFileName += "na";
78  m_instrumentNameLong = "Narrow Angle Camera";
79  m_instrumentNameShort = "NAC";
80  }
81  else if (instId == "WIDE_ANGLE_CAMERA") {
82  reseauFileName += "wa";
83  m_instrumentNameLong = "Wide Angle Camera";
84  m_instrumentNameShort = "WAC";
85  }
86  else {
87  QString msg = "File does not appear to be a Voyager image. InstrumentId ["
88  + instId + "] is invalid Voyager value.";
89  throw IException(IException::User, msg, _FILEINFO_);
90  }
91  }
92  else if (spacecraft == "VOYAGER_2") {
93  p_ckFrameId = -32100;
94  p_spkTargetId = -32;
95  m_spacecraftNameLong = "Voyager 2";
96  m_spacecraftNameShort = "Voyager2";
97 
98  reseauFileName += "2/reseaus/vg2";
99 
100  if (instId == "NARROW_ANGLE_CAMERA") {
101  reseauFileName += "na";
102  m_instrumentNameLong = "Narrow Angle Camera";
103  m_instrumentNameShort = "NAC";
104  }
105  else if (instId == "WIDE_ANGLE_CAMERA") {
106  reseauFileName += "wa";
107  m_instrumentNameLong = "Wide Angle Camera";
108  m_instrumentNameShort = "WAC";
109  }
110  else {
111  QString msg = "File does not appear to be a Voyager image. InstrumentId ["
112  + instId + "] is invalid Voyager value.";
113  throw IException(IException::User, msg, _FILEINFO_);
114  }
115  }
116  else {
117  QString msg = "File does not appear to be a Voyager image. SpacecraftName ["
118  + spacecraft + "] is invalid Voyager value.";
119  throw IException(IException::User, msg, _FILEINFO_);
120  }
121 
122  new CameraDetectorMap(this);
123 
124  // Setup focal plane map, and detector origin
125  CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
126  focalMap->SetDetectorOrigin(500.0, 500.0);
127 
128  // Master reseau location file
129  reseauFileName = "$voyager" + reseauFileName + "MasterReseaus.pvl";
130  FileName masterReseaus(reseauFileName);
131  try {
132  new ReseauDistortionMap(this, lab, masterReseaus.expanded());
133  } catch (IException &e) {
134  e.print();
135  }
136 
137  // Setup the ground and sky map
138  new CameraGroundMap(this);
139  new CameraSkyMap(this);
140 
141  // StartTime is the most accurate time available because in voy2isis the
142  // StartTime is modified to be highly accurate.
143  // exposure duration keyword value is measured in seconds
144  double exposureDuration = inst["ExposureDuration"];
145  iTime startTime;
146  startTime.setUtc((QString)inst["StartTime"]);
147 
148  // set the start (shutter open) and end (shutter close) times for the image
149  /*****************************************************************************
150  * AS NOTED IN ISIS2 PROGRAM lev1u_vgr_routines.c:
151  * StartTime (FDS count) from the labels calculated to correspond the true spacecraft
152  * clock count for the frame. The true spacecraft clock count is readout
153  * time of the frame, which occurred 2 seconds after shutter close.
154  *****************************************************************************/
155  pair<iTime, iTime> shuttertimes = ShutterOpenCloseTimes(startTime.Et(),
157 
158  // add half the exposure duration to the start time to get the center if the image
159  iTime centerTime = shuttertimes.first.Et() + exposureDuration / 2.0;
160  setTime(centerTime);
161 
162  LoadCache();
164  }
165 
166 
189  pair<iTime, iTime> VoyagerCamera::ShutterOpenCloseTimes(double time,
190  double exposureDuration) {
191  pair<iTime, iTime> shuttertimes;
192  // To get shutter end (close) time, subtract 2 seconds from the StartTime keyword value
193  shuttertimes.second = time - 2;
194  // To get shutter start (open) time, take off the exposure duration from the end time.
195  shuttertimes.first = shuttertimes.second.Et() - exposureDuration;
196  return shuttertimes;
197  }
198 }
199 
211 extern "C" Isis::Camera *VoyagerCameraPlugin(Isis::Cube &cube) {
212  return new Isis::VoyagerCamera(cube);
213 }
Isis::CameraFocalPlaneMap::SetDetectorOrigin
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
Definition: CameraFocalPlaneMap.cpp:293
Isis::Camera::exposureDuration
virtual double exposureDuration() const
Return the exposure duration for the pixel that the camera is set to.
Definition: Camera.cpp:3063
Isis::Spice::time
iTime time() const
Returns the ephemeris time in seconds which was used to obtain the spacecraft and sun positions.
Definition: Spice.cpp:884
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::IException::print
void print() const
Prints a string representation of this exception to stderr.
Definition: IException.cpp:445
Isis::CameraDetectorMap
Convert between parent image coordinates and detector coordinates.
Definition: CameraDetectorMap.h:47
Isis::VoyagerCamera::ShutterOpenCloseTimes
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)
Returns the shutter open and close times.
Definition: VoyagerCamera.cpp:189
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::FileName
File name manipulation and expansion.
Definition: FileName.h:100
Isis::Camera::m_instrumentNameLong
QString m_instrumentNameLong
Full instrument name.
Definition: Camera.h:496
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::VoyagerCamera::p_ckFrameId
int p_ckFrameId
"Camera-matrix" Kernel Frame ID
Definition: VoyagerCamera.h:98
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::FramingCamera
Generic class for Framing Cameras.
Definition: FramingCamera.h:32
Isis::ReseauDistortionMap
Distort/undistort focal plane coordinates.
Definition: ReseauDistortionMap.h:27
Isis::CameraGroundMap
Convert between undistorted focal plane and ground coordinates.
Definition: CameraGroundMap.h:73
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::FileName::expanded
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition: FileName.cpp:196
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::VoyagerCamera::p_spkTargetId
int p_spkTargetId
Spacecraft Kernel Target ID.
Definition: VoyagerCamera.h:99
Isis::Cube
IO Handler for Isis Cubes.
Definition: Cube.h:167
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::Camera::m_spacecraftNameLong
QString m_spacecraftNameLong
Full spacecraft name.
Definition: Camera.h:498
Isis::VoyagerCamera
Voyager Camera Model.
Definition: VoyagerCamera.h:54
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::Cube::label
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition: Cube.cpp:1701
Isis::CameraSkyMap
Convert between undistorted focal plane and ra/dec coordinates.
Definition: CameraSkyMap.h:31
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::IException::User
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition: IException.h:126