USGS

Isis 3.0 Object Programmers' Reference

Home

NewHorizonsMvicFrameCamera.cpp
Go to the documentation of this file.
1 
22 
23 #include <QDebug>
24 
25 #include "Camera.h"
26 #include "CameraDetectorMap.h"
27 #include "CameraDistortionMap.h"
28 #include "CameraFocalPlaneMap.h"
29 #include "CameraGroundMap.h"
30 #include "CameraSkyMap.h"
31 #include "IString.h"
32 #include "iTime.h"
34 #include "NaifStatus.h"
35 
36 using namespace std;
37 
38 namespace Isis {
39 
52  NewHorizonsMvicFrameCamera::NewHorizonsMvicFrameCamera(Cube &cube) : FramingCamera(cube) {
54 
56  SetPixelPitch();
57 
58  // Get the start time from labels
59  Pvl &lab = *cube.label();
60  PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
61  m_exposure = inst["ExposureDuration"];
62  QString stime = inst["SpacecraftClockStartCount"];
63  // ** TODO ** Need an offset time added to labels at ingestion?? The 0.125 value is
64  // the value in DELTAT00.
65  double offset = 0.125;
66  m_etStart = getClockTime(stime).Et() + offset;
67  SpiceChar utc[30];
68  et2utc_c(m_etStart, "ISOC", 3, 30, utc);
69 // qDebug()<<"\n\nspacecraftClockStartCount + "<<offset<<" (offset) = "<<utc;
70 
71  // If bands have been extracted from the original image then we
72  // need to read the band bin group so we can map from the cube band
73  // number to the instrument band number. Also save times of each framelet which are stored
74  // in the BandBin group.
75  PvlGroup &bandBin = lab.findGroup("BandBin", Pvl::Traverse);
76  PvlKeyword &origBand = bandBin["OriginalBand"];
77  PvlKeyword &utcTime = bandBin["UtcTime"];
78  for(int i = 0; i < origBand.size(); i++) {
79  m_originalBand.push_back(toInt(origBand[i]));
80  m_utcTime.push_back(utcTime[i]);
81  }
82 
83  CameraDetectorMap *detectorMap = new CameraDetectorMap(this);
84  detectorMap->SetDetectorSampleSumming(1);
85  detectorMap->SetDetectorLineSumming(1);
86 
87  // Setup focal plane map. The class will read data from the instrument addendum kernel to pull
88  // out the affine transforms from detector samp,line to focal plane x,y.
89  CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
90  focalMap->SetDetectorOrigin(2500.5, 64.5);
91 
92  // Read distortion coefficients and boresight offsets from the instrument kernels. Then
93  // construct the distortion map.
94  //read the distortion coefs from the NAIF Kernels
95  QString naifXKey = "INS-98900_DISTORTION_COEF_X";
96  QString naifYKey = "INS-98900_DISTORTION_COEF_Y";
97  QString naifppKey = "INS-98900_PP_OFFSET";
98  vector<double> distCoefX;
99  vector<double> distCoefY;
100 
101  for (int i=0; i < 20; i++) {
102  distCoefX.push_back(getDouble(naifXKey,i));
103  distCoefY.push_back(getDouble(naifYKey,i));
104  }
105 
106  new NewHorizonsMvicFrameCameraDistortionMap(this, distCoefX, distCoefY);
107 
108  // Setup the ground and sky map
109  new CameraGroundMap(this);
110  new CameraSkyMap(this);
111 
112  // Internalize all the NAIF SPICE information into memory.
113  LoadCache();
115  }
116 
117 
123  void NewHorizonsMvicFrameCamera::SetBand(const int vband) {
124 
125  if(vband > (int) m_originalBand.size()) {
126  QString msg = QObject::tr("Band number out of array bounds in NewHorizonsMvicFrameCamera::SetBand legal "
127  "bands are [1-%1], input was [%2]").
128  arg(m_originalBand.size()).arg(vband);
130  }
131 
132  iTime time(m_utcTime[vband-1]);
133  double et = time.Et();
134 
135  SpiceChar utc[30];
136  et2utc_c(et, "ISOC", 3, 30, utc);
137  Camera::setTime(et);
138  pair<iTime, iTime> shuttertimes = ShutterOpenCloseTimes(et, m_exposure);
139 
140  // Set up valid band access
141  Camera::SetBand(vband);
142 
143  }
144 
145 
165  pair<iTime, iTime> NewHorizonsMvicFrameCamera::ShutterOpenCloseTimes(double time, double exposureDuration) {
166 
167  return FramingCamera::ShutterOpenCloseTimes(time, exposureDuration);
168  }
169 }
170 
171 
182  return new Isis::NewHorizonsMvicFrameCamera(cube);
183 }