Isis 3 Programmer Reference
NewHorizonsLeisaCamera.cpp
Go to the documentation of this file.
1 
21 #include "NewHorizonsLeisaCamera.h"
22 
23 #include <QDebug>
24 #include <QString>
25 #include <QVector>
26 
27 #include "NaifStatus.h"
28 #include "iTime.h"
30 #include "LineScanCameraSkyMap.h"
31 #include "CameraFocalPlaneMap.h"
33 
34 using namespace std;
35 
36 namespace Isis {
37 
51  NewHorizonsLeisaCamera::NewHorizonsLeisaCamera(Cube &cube) : LineScanCamera(cube) {
52  m_instrumentNameLong = "Linear Etalon Imaging Spectral Array";
53  m_instrumentNameShort = "LEISA";
54  m_spacecraftNameLong = "New Horizons";
55  m_spacecraftNameShort = "NewHorizons";
56 
57  // Override the SPICE error process for SPICE calls
59 
61  SetPixelPitch();
62 
63  Pvl &lab = *cube.label();
64  PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
65  QString expDuration = inst["ExposureDuration"];
66 
67  QString stime = inst["SpacecraftClockStartCount"];
68  double m_etStart = getClockTime(stime).Et();
69 
70  // The line rate is set to the time between each frame since we are treating LEASA as a linescan
71  double m_lineRate = expDuration.toDouble();
72 
73  // The detector map tells us how to convert from image coordinates to
74  // detector coordinates. In our case, a (sample,line) to a (sample,time)
75  new LineScanCameraDetectorMap(this, m_etStart, m_lineRate);
76 
77  // The focal plane map tells us how to go from detector position
78  // to focal plane x/y (distorted). That is, (sample,time) to (x,y) and back.
79  CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
80  focalMap->SetDetectorOrigin(128.5, 128.5);
81 
82  // Pull out the focal plane map affine coefficients so we can use them to adjust when the band
83  // is changed. The coefficients as read from the iak are only valid for band 2. The constant
84  // terms need to be multiplied by band-1 and then put back into the focal plane map
85  m_origTransl.append(focalMap->TransL()[0]);
86  m_origTransl.append(focalMap->TransL()[1]);
87  m_origTransl.append(focalMap->TransL()[2]);
88 
89  m_origTranss.append(focalMap->TransS()[0]);
90  m_origTranss.append(focalMap->TransS()[1]);
91  m_origTranss.append(focalMap->TransS()[2]);
92 
93  m_origTransx.append(focalMap->TransX()[0]);
94  m_origTransx.append(focalMap->TransX()[1]);
95  m_origTransx.append(focalMap->TransX()[2]);
96 
97  m_origTransy.append(focalMap->TransY()[0]);
98  m_origTransy.append(focalMap->TransY()[1]);
99  m_origTransy.append(focalMap->TransY()[2]);
100 
101  // If bands have been extracted from the original image then we need to read the band bin group
102  // so we can map from the cube band number to the instrument band number
103  PvlGroup &bandBin = lab.findGroup("BandBin", Pvl::Traverse);
104  PvlKeyword &orgBand = bandBin["OriginalBand"];
105  for (int i = 0; i < orgBand.size(); i++) {
106  m_originalBand.append(toInt(orgBand[i]));
107  }
108 
109  // Use the defualt no correction distortion map.
110  new CameraDistortionMap(this);
111 
112  // Setup the ground and sky map
113  new LineScanCameraGroundMap(this);
114  new LineScanCameraSkyMap(this);
115 
116  LoadCache();
117 
118  // Check to see if there were any SPICE errors
120  }
121 
122 
131  void NewHorizonsLeisaCamera::SetBand(const int vband) {
132  if ( (vband < 1) || (vband > m_originalBand.size())) {
133  QString msg = QObject::tr("Band number out of array bounds in NewHorizonsLeisaCamera::SetBand "
134  "legal bands are [1-%1], input was [%2]").
135  arg(m_originalBand.size()).arg(vband);
137  }
138  int band;
139  band = m_originalBand[vband-1];
140  Camera::SetBand(vband);
141 
142  // Get the affine coefficients from the focal plane map and adjust the constant terms to
143  // provide the correct Y/Line offset for this band
144  QVector<double> temp;
145 
146  temp.append(m_origTransl[0] * (band - 1));
147  temp.append(m_origTransl[1]);
148  temp.append(m_origTransl[2]);
149  this->FocalPlaneMap()->SetTransL(temp);
150  temp.clear();
151 
152 
153  temp.append(m_origTranss[0] * (band - 1));
154  temp.append(m_origTranss[1]);
155  temp.append(m_origTranss[2]);
156  this->FocalPlaneMap()->SetTransS(temp);
157  temp.clear();
158 
159  temp.append(m_origTransx[0] * (band - 1));
160  temp.append(m_origTransx[1]);
161  temp.append(m_origTransx[2]);
162  this->FocalPlaneMap()->SetTransX(temp);
163  temp.clear();
164 
165  temp.append(m_origTransy[0] * (band - 1));
166  temp.append(m_origTransy[1]);
167  temp.append(m_origTransy[2]);
168  this->FocalPlaneMap()->SetTransY(temp);
169 
170  }
171 }
172 
173 
184  return new Isis::NewHorizonsLeisaCamera(cube);
185 }
186 
Isis::Camera * NewHorizonsLeisaCameraPlugin(Isis::Cube &cube)
This is the function that is called in order to instantiate a NewHorizonsLeisaCamera object...
void SetFocalLength()
Reads the focal length from the instrument kernel.
Definition: Camera.cpp:1430
const double * TransX() const
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition: PvlObject.h:141
void SetTransY(const QVector< double > transY)
Set the affine coefficients for converting detector (sample,line) to a distorted Y.
void SetBand(const int vband)
Change the New Horizons camera parameters based on the band number.
QVector< double > m_origTransy
The original transy affine coefficients from the iak.
QString m_instrumentNameLong
Full instrument name.
Definition: Camera.h:507
void SetTransL(const QVector< double > transL)
Set the affine coefficients for converting destorted (x,y) to a detector Line.
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition: IString.cpp:108
QVector< double > m_origTranss
The original transs affine coefficients from the iak.
void SetPixelPitch()
Reads the Pixel Pitch from the instrument kernel.
Definition: Camera.cpp:1437
Namespace for the standard library.
Generic class for Line Scan Cameras.
Search child objects.
Definition: PvlObject.h:170
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:162
const double * TransS() const
Convert between undistorted focal plane and ground coordinates.
int size() const
Returns the number of values stored in this keyword.
Definition: PvlKeyword.h:141
Convert between distorted focal plane and detector coordinates.
void SetTransX(const QVector< double > transX)
Set the affine coefficients for converting detector (sample,line) to a distorted X.
QString m_instrumentNameShort
Shortened instrument name.
Definition: Camera.h:508
This is the camera model for LEISA, New Hoirzon&#39;s infrared Spectrometer.
Contains multiple PvlContainers.
Definition: PvlGroup.h:57
QVector< double > m_origTransl
The original transl affine coefficients from the iak.
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
void SetTransS(const QVector< double > transS)
Set the affine coefficients for converting destorted (x,y) to a detector Sample.
A single keyword-value pair.
Definition: PvlKeyword.h:98
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
Distort/undistort focal plane coordinates.
Container for cube-like labels.
Definition: Pvl.h:135
CameraFocalPlaneMap * FocalPlaneMap()
Returns a pointer to the CameraFocalPlaneMap object.
Definition: Camera.cpp:2848
const double * TransL() const
Convert between undistorted focal plane and ra/dec coordinates.
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
QVector< int > m_originalBand
Stores the band bin OriginalBand keyword values.
QVector< double > m_origTransx
The original transx affine coefficients from the iak.
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
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
QString m_spacecraftNameShort
Shortened spacecraft name.
Definition: Camera.h:510
const double * TransY() const
Convert between parent image coordinates and detector coordinates.
double Et() const
Returns the ephemeris time (TDB) representation of the time as a double.
Definition: iTime.h:139
virtual void SetBand(const int band)
Virtual method that sets the band number.
Definition: Camera.cpp:2692
IO Handler for Isis Cubes.
Definition: Cube.h:170