Isis 3 Programmer Reference
VoyagerCamera.cpp
Go to the documentation of this file.
1 
23 #include "VoyagerCamera.h"
24 
25 #include <SpiceUsr.h>
26 
27 #include <QString>
28 
29 #include "CameraDetectorMap.h"
30 #include "CameraFocalPlaneMap.h"
31 #include "CameraGroundMap.h"
32 #include "CameraSkyMap.h"
33 #include "FileName.h"
34 #include "IString.h"
35 #include "iTime.h"
36 #include "NaifStatus.h"
37 #include "ReseauDistortionMap.h"
38 #include "Spice.h"
39 
40 using namespace std;
41 
42 namespace Isis {
65  VoyagerCamera::VoyagerCamera (Cube &cube) : FramingCamera(cube) {
67 
68  // Set the pixel pitch
69  SetPixelPitch();
71  // Find out what camera is being used, and set the focal length, altinstcode,
72  // and camera
73  Pvl &lab = *cube.label();
74  PvlGroup &inst = lab.findGroup ("Instrument",Pvl::Traverse);
75  QString spacecraft = (QString)inst["SpacecraftName"];
76  QString instId = (QString)inst["InstrumentId"];
77 
78  QString reseauFileName = "";
79 
80  // These set up which kernel and other files to access,
81  if (spacecraft == "VOYAGER_1") {
82  p_ckFrameId = -31100;
83  p_spkTargetId = -31;
84  m_spacecraftNameLong = "Voyager 1";
85  m_spacecraftNameShort = "Voyager1";
86 
87  reseauFileName += "1/reseaus/vg1";
88 
89  if (instId == "NARROW_ANGLE_CAMERA") {
90  reseauFileName += "na";
91  m_instrumentNameLong = "Narrow Angle Camera";
92  m_instrumentNameShort = "NAC";
93  }
94  else if (instId == "WIDE_ANGLE_CAMERA") {
95  reseauFileName += "wa";
96  m_instrumentNameLong = "Wide Angle Camera";
97  m_instrumentNameShort = "WAC";
98  }
99  else {
100  QString msg = "File does not appear to be a Voyager image. InstrumentId ["
101  + instId + "] is invalid Voyager value.";
103  }
104  }
105  else if (spacecraft == "VOYAGER_2") {
106  p_ckFrameId = -32100;
107  p_spkTargetId = -32;
108  m_spacecraftNameLong = "Voyager 2";
109  m_spacecraftNameShort = "Voyager2";
110 
111  reseauFileName += "2/reseaus/vg2";
112 
113  if (instId == "NARROW_ANGLE_CAMERA") {
114  reseauFileName += "na";
115  m_instrumentNameLong = "Narrow Angle Camera";
116  m_instrumentNameShort = "NAC";
117  }
118  else if (instId == "WIDE_ANGLE_CAMERA") {
119  reseauFileName += "wa";
120  m_instrumentNameLong = "Wide Angle Camera";
121  m_instrumentNameShort = "WAC";
122  }
123  else {
124  QString msg = "File does not appear to be a Voyager image. InstrumentId ["
125  + instId + "] is invalid Voyager value.";
127  }
128  }
129  else {
130  QString msg = "File does not appear to be a Voyager image. SpacecraftName ["
131  + spacecraft + "] is invalid Voyager value.";
133  }
134 
135  new CameraDetectorMap(this);
136 
137  // Setup focal plane map, and detector origin
138  CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
139  focalMap->SetDetectorOrigin(500.0, 500.0);
140 
141  // Master reseau location file
142  reseauFileName = "$voyager" + reseauFileName + "MasterReseaus.pvl";
143  FileName masterReseaus(reseauFileName);
144  try {
145  new ReseauDistortionMap(this, lab, masterReseaus.expanded());
146  } catch (IException &e) {
147  e.print();
148  }
149 
150  // Setup the ground and sky map
151  new CameraGroundMap(this);
152  new CameraSkyMap(this);
153 
154  // StartTime is the most accurate time available because in voy2isis the
155  // StartTime is modified to be highly accurate.
156  // exposure duration keyword value is measured in seconds
157  double exposureDuration = inst["ExposureDuration"];
158  iTime startTime;
159  startTime.setUtc((QString)inst["StartTime"]);
160 
161  // set the start (shutter open) and end (shutter close) times for the image
162  /*****************************************************************************
163  * AS NOTED IN ISIS2 PROGRAM lev1u_vgr_routines.c:
164  * StartTime (FDS count) from the labels calculated to correspond the true spacecraft
165  * clock count for the frame. The true spacecraft clock count is readout
166  * time of the frame, which occurred 2 seconds after shutter close.
167  *****************************************************************************/
168  pair<iTime, iTime> shuttertimes = ShutterOpenCloseTimes(startTime.Et(),
170 
171  // add half the exposure duration to the start time to get the center if the image
172  iTime centerTime = shuttertimes.first.Et() + exposureDuration / 2.0;
173  setTime(centerTime);
174 
175  LoadCache();
177  }
178 
179 
202  pair<iTime, iTime> VoyagerCamera::ShutterOpenCloseTimes(double time,
203  double exposureDuration) {
204  pair<iTime, iTime> shuttertimes;
205  // To get shutter end (close) time, subtract 2 seconds from the StartTime keyword value
206  shuttertimes.second = time - 2;
207  // To get shutter start (open) time, take off the exposure duration from the end time.
208  shuttertimes.first = shuttertimes.second.Et() - exposureDuration;
209  return shuttertimes;
210  }
211 }
212 
225  return new Isis::VoyagerCamera(cube);
226 }
void SetFocalLength()
Reads the focal length from the instrument kernel.
Definition: Camera.cpp:1430
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition: PvlObject.h:141
int p_spkTargetId
Spacecraft Kernel Target ID.
File name manipulation and expansion.
Definition: FileName.h:116
Parse and return pieces of a time string.
Definition: iTime.h:78
QString m_instrumentNameLong
Full instrument name.
Definition: Camera.h:507
void SetPixelPitch()
Reads the Pixel Pitch from the instrument kernel.
Definition: Camera.cpp:1437
Namespace for the standard library.
Search child objects.
Definition: PvlObject.h:170
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
Convert between parent image coordinates and detector coordinates.
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)
Returns the shutter open and close times.
Convert between undistorted focal plane and ground coordinates.
Convert between distorted focal plane and detector coordinates.
QString m_instrumentNameShort
Shortened instrument name.
Definition: Camera.h:508
Isis::Camera * VoyagerCameraPlugin(Isis::Cube &cube)
This is the function that is called in order to instantiate a VoyagerCamera object.
Distort/undistort focal plane coordinates.
Contains multiple PvlContainers.
Definition: PvlGroup.h:57
SpiceInt naifIkCode() const
This returns the NAIF IK code to use when reading from instrument kernels.
Definition: Spice.cpp:893
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
A type of error that could only have occurred due to a mistake on the user&#39;s part (e...
Definition: IException.h:142
int p_ckFrameId
"Camera-matrix" Kernel Frame ID
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition: FileName.cpp:212
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:112
Voyager Camera Model
Definition: VoyagerCamera.h:66
Container for cube-like labels.
Definition: Pvl.h:135
void LoadCache()
This loads the spice cache big enough for this image.
Definition: Camera.cpp:2432
void print() const
Prints a string representation of this exception to stderr.
Definition: IException.cpp:461
QString m_spacecraftNameLong
Full spacecraft name.
Definition: Camera.h:509
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition: Cube.cpp:1346
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Definition: NaifStatus.cpp:43
Isis exception class.
Definition: IException.h:107
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
Convert between undistorted focal plane and ra/dec coordinates.
Definition: CameraSkyMap.h:48
QString m_spacecraftNameShort
Shortened spacecraft name.
Definition: Camera.h:510
virtual double exposureDuration() const
Return the exposure duration for the pixel that the camera is set to.
Definition: Camera.cpp:3075
Generic class for Framing Cameras.
Definition: FramingCamera.h:48
double Et() const
Returns the ephemeris time (TDB) representation of the time as a double.
Definition: iTime.h:139
IO Handler for Isis Cubes.
Definition: Cube.h:170
iTime time() const
Returns the ephemeris time in seconds which was used to obtain the spacecraft and sun positions...
Definition: Spice.cpp:809