Isis 3 Programmer Reference
VikingCamera.cpp
Go to the documentation of this file.
1 
23 #include "VikingCamera.h"
24 
25 #include <SpiceUsr.h>
26 #include <SpiceZfc.h>
27 #include <SpiceZmc.h>
28 
29 #include <QString>
30 
31 #include "CameraDetectorMap.h"
32 #include "CameraFocalPlaneMap.h"
33 #include "CameraGroundMap.h"
34 #include "CameraSkyMap.h"
35 #include "FileName.h"
36 #include "IString.h"
37 #include "iTime.h"
38 #include "NaifStatus.h"
39 #include "ReseauDistortionMap.h"
40 
41 using namespace std;
42 
43 namespace Isis {
58  VikingCamera::VikingCamera(Cube &cube) : FramingCamera(cube) {
60  // Set the pixel pitch
61  SetPixelPitch(1.0 / 85.0);
62 
63  // Find out what camera is being used, and set the focal length, altinstcode,
64  // raster orientation, cone, crosscone, and camera
65  Pvl &lab = *cube.label();
66  PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
67  QString spacecraft = inst["SPACECRAFTNAME"];
68  QString instId = inst["INSTRUMENTID"];
69  QString cam;
70  int spn;
71  double raster, cone, crosscone;
72  int altinstcode = 0;
73  if(spacecraft == "VIKING_ORBITER_1") {
74  p_ckFrameId = -27000;
75  p_spkTargetId = -27;
76  m_spacecraftNameLong = "Viking Orbiter 1";
77  m_spacecraftNameShort = "Viking1";
78 
79  spn = 1;
80  altinstcode = -27999;
81  if(instId == "VISUAL_IMAGING_SUBSYSTEM_CAMERA_A") {
82  cam = "1a";
83  SetFocalLength(474.398);
84  crosscone = -0.707350;
85  cone = -0.007580;
86  raster = 89.735690;
87  m_instrumentNameLong = "Visual Imaging Subsystem Camera A";
88  m_instrumentNameShort = "VISA";
89  }
90  else if(instId == "VISUAL_IMAGING_SUBSYSTEM_CAMERA_B") {
91  cam = "1b";
92  SetFocalLength(474.448);
93  crosscone = 0.681000;
94  cone = -0.032000;
95  raster = 90.022800;
96  m_instrumentNameLong = "Visual Imaging Subsystem Camera B";
97  m_instrumentNameShort = "VISB";
98  }
99  else {
100  QString msg = "File does not appear to be a Viking image. InstrumentId ["
101  + instId + "] is invalid Viking value.";
103  }
104  }
105  else if(spacecraft == "VIKING_ORBITER_2") {
106  p_ckFrameId = -30000;
107  p_spkTargetId = -30;
108  m_spacecraftNameLong = "Viking Orbiter 2";
109  m_spacecraftNameShort = "Viking2";
110 
111  spn = 2;
112  altinstcode = -30999;
113  if(instId == "VISUAL_IMAGING_SUBSYSTEM_CAMERA_A") {
114  cam = "2a";
115  SetFocalLength(474.610);
116  crosscone = -0.679330;
117  cone = -0.023270;
118  raster = 89.880691;
119  m_instrumentNameLong = "Visual Imaging Subsystem Camera A";
120  m_instrumentNameShort = "VISA";
121  }
122  else if(instId == "VISUAL_IMAGING_SUBSYSTEM_CAMERA_B") {
123  cam = "2b";
124  SetFocalLength(474.101);
125  crosscone = 0.663000;
126  cone = -0.044000;
127  raster = 89.663790;
128  m_instrumentNameLong = "Visual Imaging Subsystem Camera B";
129  m_instrumentNameShort = "VISB";
130  }
131  else {
132  QString msg = "File does not appear to be a Viking image. InstrumentId ["
133  + instId + "] is invalid Viking value.";
135  }
136  }
137  else {
138  QString msg = "File does not appear to be a Viking image. SpacecraftName ["
139  + spacecraft + "] is invalid Viking value.";
141  }
142 
143  // DOCUMENTATION FROM ISIS2 lev1u_vik_vis_routines.c:
144  /*****************************************************************************
145  * Calculate the START_TIME keyword (time at middle of exposure in this case)*
146  * value from FSC to get fractional seconds (PDS START_TIME provided is only *
147  * to the nearest whole second). The algorithm below was extracted from the *
148  * NAIF document Viking Orbiter Time Tag Analysis and Restoration by Boris *
149  * Semenov and Chuck Acton. *
150  * 1. Get exposure duration from labels to center the time *
151  * 2. Get FSC from IMAGE_NUMBER on labels to use as spacecraftClock *
152  * 3. Load the appropriate FSC spacecraft clock kernel based on *
153  * the spacecraft (Viking Orbiter 1 or Viking Orbiter 2) *
154  * 4. Load a leap second kernel *
155  * 5. Convert FSC to et *
156  * 6. Add the offsets to get to midexposure *
157  * 7. Convert et to UTC calendar format and write to labels as *
158  * START_TIME *
159  *****************************************************************************/
160 
161  // Get clock count and convert it to a time
162  QString spacecraftClock = inst["SpacecraftClockCount"];
163  double etClock = getClockTime(spacecraftClock, altinstcode).Et();
164 
165  // exposure duration keyword value is measured in seconds
166  double exposureDuration = inst["ExposureDuration"];
167 
168  // Calculate and load the euler angles
169  SpiceDouble CP[3][3];
170  eul2m_c((SpiceDouble)raster * rpd_c(), (SpiceDouble)cone * rpd_c(),
171  (SpiceDouble) - crosscone * rpd_c(), 3, 2, 1, CP);
172 
173  // LoadEulerMounting(CP);
174 
175  pair<iTime, iTime> shuttertimes = ShutterOpenCloseTimes(etClock, exposureDuration);
176 
177  // find center shutter time
178  double centerTime = shuttertimes.first.Et() + exposureDuration / 2.0;
179  char timepds[25];
180  et2utc_c(centerTime, "ISOC", 3, 25, timepds);
181  utc2et_c(timepds, &centerTime);
182 
183  // Setup detector map
184  new CameraDetectorMap(this);
185 
186  // Setup focal plane map, and detector origin
187  CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
188  focalMap->SetDetectorOrigin(602.0, 528.0);
189 
190  // Setup distortion map
191  QString fname = FileName("$viking" + toString(spn) + "/reseaus/vik" + cam
192  + "MasterReseaus.pvl").expanded();
193  new ReseauDistortionMap(this, lab, fname);
194 
195  // Setup the ground and sky map
196  new CameraGroundMap(this);
197  new CameraSkyMap(this);
198 
199  setTime(centerTime);
200  LoadCache();
202  }
203 
204 
225  pair<iTime, iTime> VikingCamera::ShutterOpenCloseTimes(double time,
226  double exposureDuration) {
227  pair<iTime, iTime> shuttertimes;
228  double offset1;
229  if (exposureDuration <= .420) {
230  offset1 = 7.0 / 8.0 * 4.48; //4.48 seconds = nomtick
231  }
232  else {
233  offset1 = 3.0 / 8.0 * 4.48;
234  }
235  double offset2 = 1.0 / 64.0 * 4.48;
236 
237  // set private variables inherited from Spice class
238  shuttertimes.first = time + offset1 + offset2;
239  shuttertimes.second = shuttertimes.first.Et() + exposureDuration;
240  return shuttertimes;
241  }
242 }
243 
244 
254  return new Isis::VikingCamera(cube);
255 }
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
File name manipulation and expansion.
Definition: FileName.h:116
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
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:226
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
int p_spkTargetId
Spacecraft Kernel Target ID.
Definition: VikingCamera.h:122
Convert between parent image coordinates and detector coordinates.
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
Distort/undistort focal plane coordinates.
Contains multiple PvlContainers.
Definition: PvlGroup.h:57
int p_ckFrameId
"Camera-matrix" Kernel Frame ID
Definition: VikingCamera.h:121
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
iTime getClockTime(QString clockValue, int sclkCode=-1, bool clockTicks=false)
This converts the spacecraft clock ticks value (clockValue) to an iTime.
Definition: Spice.cpp:977
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
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
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
Isis::Camera * VikingCameraPlugin(Isis::Cube &cube)
This is the function that is called in order to instantiate a VikingCamera object.
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 std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)
Returns the shutter open and close times.
virtual double exposureDuration() const
Return the exposure duration for the pixel that the camera is set to.
Definition: Camera.cpp:3075
Viking Camera Model.
Definition: VikingCamera.h:71
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