USGS

Isis 3.0 Object Programmers' Reference

Home

NewHorizonsLeisaCamera.cpp
Go to the documentation of this file.
1 
21 #include <QDebug>
22 #include <QVector>
23 
24 #include "NewHorizonsLeisaCamera.h"
25 #include "NaifStatus.h"
26 #include "iTime.h"
28 #include "LineScanCameraSkyMap.h"
29 #include "CameraFocalPlaneMap.h"
31 
32 using namespace std;
33 
34 namespace Isis {
35 
49  NewHorizonsLeisaCamera::NewHorizonsLeisaCamera(Cube &cube) : LineScanCamera(cube) {
50 
51  // Override the SPICE error process for SPICE calls
53 
55  SetPixelPitch();
56 
57  Pvl &lab = *cube.label();
58  PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
59  QString expDuration = inst["ExposureDuration"];
60 
61  QString stime = inst["SpacecraftClockStartCount"];
62  double m_etStart = getClockTime(stime).Et();
63 
64  // The line rate is set to the time between each frame since we are treating LEASA as a linescan
65  double m_lineRate = expDuration.toDouble();
66 
67  // The detector map tells us how to convert from image coordinates to
68  // detector coordinates. In our case, a (sample,line) to a (sample,time)
69  new LineScanCameraDetectorMap(this, m_etStart, m_lineRate);
70 
71  // The focal plane map tells us how to go from detector position
72  // to focal plane x/y (distorted). That is, (sample,time) to (x,y) and back.
73  CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
74  focalMap->SetDetectorOrigin(128.5, 128.5);
75 
76  // Pull out the focal plane map affine coefficients so we can use them to adjust when the band
77  // is changed. The coefficients as read from the iak are only valid for band 2. The constant
78  // terms need to be multiplied by band-1 and then put back into the focal plane map
79  m_origTransl.append(focalMap->TransL()[0]);
80  m_origTransl.append(focalMap->TransL()[1]);
81  m_origTransl.append(focalMap->TransL()[2]);
82 
83  m_origTranss.append(focalMap->TransS()[0]);
84  m_origTranss.append(focalMap->TransS()[1]);
85  m_origTranss.append(focalMap->TransS()[2]);
86 
87  m_origTransx.append(focalMap->TransX()[0]);
88  m_origTransx.append(focalMap->TransX()[1]);
89  m_origTransx.append(focalMap->TransX()[2]);
90 
91  m_origTransy.append(focalMap->TransY()[0]);
92  m_origTransy.append(focalMap->TransY()[1]);
93  m_origTransy.append(focalMap->TransY()[2]);
94 
95  // If bands have been extracted from the original image then we need to read the band bin group
96  // so we can map from the cube band number to the instrument band number
97  PvlGroup &bandBin = lab.findGroup("BandBin", Pvl::Traverse);
98  PvlKeyword &orgBand = bandBin["OriginalBand"];
99  for (int i = 0; i < orgBand.size(); i++) {
100  m_originalBand.append(toInt(orgBand[i]));
101  }
102 
103  // Use the defualt no correction distortion map.
104  new CameraDistortionMap(this);
105 
106  // Setup the ground and sky map
107  new LineScanCameraGroundMap(this);
108  new LineScanCameraSkyMap(this);
109 
110  LoadCache();
111 
112  // Check to see if there were any SPICE errors
114  }
115 
116 
124  void NewHorizonsLeisaCamera::SetBand(const int vband) {
125 
126  // Lookup the original band from the band bin group.
127  if (vband > (int) m_originalBand.size()) {
128  QString msg = QObject::tr("Band number out of array bounds in NewHorizonsLeisaCamera::SetBand legal "
129  "bands are [1-%1], input was [%2]").
130  arg(m_originalBand.size()).arg(vband);
132  }
133  int band;
134  band = m_originalBand[vband-1];
135 
136  // Get the affine coefficients from the focal plane map and adjust the constant terms to
137  // provide the correct Y/Line offset for this band
138  QVector<double> temp;
139 
140  temp.append(m_origTransl[0] * (band - 1));
141  temp.append(m_origTransl[1]);
142  temp.append(m_origTransl[2]);
143  this->FocalPlaneMap()->SetTransL(temp);
144  temp.clear();
145 
146 
147  temp.append(m_origTranss[0] * (band - 1));
148  temp.append(m_origTranss[1]);
149  temp.append(m_origTranss[2]);
150  this->FocalPlaneMap()->SetTransS(temp);
151  temp.clear();
152 
153  temp.append(m_origTransx[0] * (band - 1));
154  temp.append(m_origTransx[1]);
155  temp.append(m_origTransx[2]);
156  this->FocalPlaneMap()->SetTransX(temp);
157  temp.clear();
158 
159  temp.append(m_origTransy[0] * (band - 1));
160  temp.append(m_origTransy[1]);
161  temp.append(m_origTransy[2]);
162  this->FocalPlaneMap()->SetTransY(temp);
163 
164  }
165 }
166 
167 
178  return new Isis::NewHorizonsLeisaCamera(cube);
179 }
180