USGS

Isis 3.0 Object Programmers' Reference

Home

IssNACamera.cpp
Go to the documentation of this file.
1 
20 // $Id: IssNACamera.cpp,v 1.6 2009/08/31 15:12:29 slambright Exp $
21 #include "IssNACamera.h"
22 
23 #include "CameraDetectorMap.h"
24 #include "CameraFocalPlaneMap.h"
25 #include "CameraGroundMap.h"
26 #include "CameraSkyMap.h"
27 #include "IString.h"
28 #include "iTime.h"
29 #include "NaifStatus.h"
30 #include "RadialDistortionMap.h"
31 #include "iTime.h"
32 
33 using namespace std;
34 namespace Isis {
44  IssNACamera::IssNACamera(Cube &cube) : FramingCamera(cube) {
45  Pvl &lab = *cube.label();
46 
47  // Get the filter wheels positions dependent focal length.
48  // If we can not get the focal length for this specific filter wheel combination then
49  // use the default.
50  double focalLength = 0.0;
51  try {
52  PvlGroup bandBin = lab.findGroup("BandBin", Pvl::Traverse);
53  QString key = QString("INS%1_%2_FOCAL_LENGTH").
54  arg(naifIkCode()).arg(bandBin["FilterName"][0]);
55  key = key.replace("/", "_");
56  focalLength = getDouble(key);
57  }
58  catch (IException &firstException) {
59  try {
60  QString key = "INS-82360_DEFAULT_FOCAL_LENGTH";
61  focalLength = getDouble(key);
62  }
63  catch (IException &secondException) {
64  PvlGroup bandBin = lab.findGroup("BandBin", Pvl::Traverse);
66  QString("Unable to find a focal length for the requested Cassini ISS NA "
67  "filter combination [%1] or the default focal length")
68  .arg(bandBin["FilterName"][0]),
69  _FILEINFO_);
70  finalError.append(firstException);
71  finalError.append(secondException);
72  throw finalError;
73  }
74  }
75 
77 
78  SetFocalLength(focalLength);
79  SetPixelPitch();
80  instrumentRotation()->SetFrame(Spice::getInteger("INS_" + toString(naifIkCode()) + "_FRAME_ID"));
81 
82  // Get the start time in et
83  PvlGroup inst = lab.findGroup("Instrument", Pvl::Traverse);
84 
85  double et = iTime((QString)inst["StartTime"]).Et();
86 
87  // divide exposure duration keyword value by 1000 to convert to seconds
88  double exposureDuration = ((double) inst["ExposureDuration"]) / 1000.0;
89  pair<iTime, iTime> shuttertimes = ShutterOpenCloseTimes(et, exposureDuration);
90 
91  //correct time for center of exposure duration
92  iTime centerTime = shuttertimes.first.Et() + exposureDuration / 2.0;
93 
94  // Setup detector map
95  int summingMode = inst["SummingMode"];
96  CameraDetectorMap *detectorMap = new CameraDetectorMap(this);
97  detectorMap->SetDetectorLineSumming(summingMode);
98  detectorMap->SetDetectorSampleSumming(summingMode);
99 
100  // Setup focal plane map
101  CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
102 
103  focalMap->SetDetectorOrigin(Spice::getDouble("INS" + toString(naifIkCode()) + "_BORESIGHT_SAMPLE"),
104  Spice::getDouble("INS" + toString(naifIkCode()) + "_BORESIGHT_LINE"));
105 
106  // Setup distortion map
107  double k1 = Spice::getDouble("INS" + toString(naifIkCode()) + "_K1");
108  new RadialDistortionMap(this, k1);
109 
110  // Setup the ground and sky map
111  new CameraGroundMap(this);
112  new CameraSkyMap(this);
113 
114  setTime(centerTime);
115  LoadCache();
117  }
118 
142  pair<iTime, iTime> IssNACamera::ShutterOpenCloseTimes(double time,
143  double exposureDuration) {
144  return FramingCamera::ShutterOpenCloseTimes(time, exposureDuration);
145  }
146 }
147 
160  return new Isis::IssNACamera(cube);
161 }