USGS

Isis 3.0 Object Programmers' Reference

Home

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(),
169  exposureDuration);
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 }