USGS

Isis 3.0 Object Programmers' Reference

Home

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