Isis 3 Programmer Reference
NewHorizonsLeisaCamera.cpp
1
7/* SPDX-License-Identifier: CC0-1.0 */
8
9#include "NewHorizonsLeisaCamera.h"
10
11#include <QDebug>
12#include <QString>
13#include <QVector>
14
15#include "NaifStatus.h"
16#include "iTime.h"
17#include "LineScanCameraGroundMap.h"
18#include "LineScanCameraSkyMap.h"
19#include "CameraFocalPlaneMap.h"
20#include "LineScanCameraDetectorMap.h"
21
22using namespace std;
23
24namespace Isis {
25
40 m_instrumentNameLong = "Linear Etalon Imaging Spectral Array";
41 m_instrumentNameShort = "LEISA";
42 m_spacecraftNameLong = "New Horizons";
43 m_spacecraftNameShort = "NewHorizons";
44
45 // Override the SPICE error process for SPICE calls
47
50
51 Pvl &lab = *cube.label();
52 PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
53 QString expDuration = inst["ExposureDuration"];
54
55 QString stime = inst["SpacecraftClockStartCount"];
56 double m_etStart = getClockTime(stime).Et();
57
58 // The line rate is set to the time between each frame since we are treating LEASA as a linescan
59 double m_lineRate = expDuration.toDouble();
60
61 // The detector map tells us how to convert from image coordinates to
62 // detector coordinates. In our case, a (sample,line) to a (sample,time)
63 new LineScanCameraDetectorMap(this, m_etStart, m_lineRate);
64
65 // The focal plane map tells us how to go from detector position
66 // to focal plane x/y (distorted). That is, (sample,time) to (x,y) and back.
67 CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
68 focalMap->SetDetectorOrigin(128.5, 128.5);
69
70 // Pull out the focal plane map affine coefficients so we can use them to adjust when the band
71 // is changed. The coefficients as read from the iak are only valid for band 2. The constant
72 // terms need to be multiplied by band-1 and then put back into the focal plane map
73 m_origTransl.append(focalMap->TransL()[0]);
74 m_origTransl.append(focalMap->TransL()[1]);
75 m_origTransl.append(focalMap->TransL()[2]);
76
77 m_origTranss.append(focalMap->TransS()[0]);
78 m_origTranss.append(focalMap->TransS()[1]);
79 m_origTranss.append(focalMap->TransS()[2]);
80
81 m_origTransx.append(focalMap->TransX()[0]);
82 m_origTransx.append(focalMap->TransX()[1]);
83 m_origTransx.append(focalMap->TransX()[2]);
84
85 m_origTransy.append(focalMap->TransY()[0]);
86 m_origTransy.append(focalMap->TransY()[1]);
87 m_origTransy.append(focalMap->TransY()[2]);
88
89 // If bands have been extracted from the original image then we need to read the band bin group
90 // so we can map from the cube band number to the instrument band number
91 PvlGroup &bandBin = lab.findGroup("BandBin", Pvl::Traverse);
92 PvlKeyword &orgBand = bandBin["OriginalBand"];
93 for (int i = 0; i < orgBand.size(); i++) {
94 m_originalBand.append(toInt(orgBand[i]));
95 }
96
97 // Use the defualt no correction distortion map.
98 new CameraDistortionMap(this);
99
100 // Setup the ground and sky map
101 new LineScanCameraGroundMap(this);
102 new LineScanCameraSkyMap(this);
103
104 LoadCache();
105
106 // Check to see if there were any SPICE errors
108 }
109
110
119 void NewHorizonsLeisaCamera::SetBand(const int vband) {
120 if ( (vband < 1) || (vband > m_originalBand.size())) {
121 QString msg = QObject::tr("Band number out of array bounds in NewHorizonsLeisaCamera::SetBand "
122 "legal bands are [1-%1], input was [%2]").
123 arg(m_originalBand.size()).arg(vband);
124 throw IException(IException::Programmer, msg, _FILEINFO_);
125 }
126 int band;
127 band = m_originalBand[vband-1];
128 Camera::SetBand(vband);
129
130 // Get the affine coefficients from the focal plane map and adjust the constant terms to
131 // provide the correct Y/Line offset for this band
132 QVector<double> temp;
133
134 temp.append(m_origTransl[0] * (band - 1));
135 temp.append(m_origTransl[1]);
136 temp.append(m_origTransl[2]);
137 this->FocalPlaneMap()->SetTransL(temp);
138 temp.clear();
139
140
141 temp.append(m_origTranss[0] * (band - 1));
142 temp.append(m_origTranss[1]);
143 temp.append(m_origTranss[2]);
144 this->FocalPlaneMap()->SetTransS(temp);
145 temp.clear();
146
147 temp.append(m_origTransx[0] * (band - 1));
148 temp.append(m_origTransx[1]);
149 temp.append(m_origTransx[2]);
150 this->FocalPlaneMap()->SetTransX(temp);
151 temp.clear();
152
153 temp.append(m_origTransy[0] * (band - 1));
154 temp.append(m_origTransy[1]);
155 temp.append(m_origTransy[2]);
156 this->FocalPlaneMap()->SetTransY(temp);
157
158 }
159}
160
161
171extern "C" Isis::Camera *NewHorizonsLeisaCameraPlugin(Isis::Cube &cube) {
172 return new Isis::NewHorizonsLeisaCamera(cube);
173}
Distort/undistort focal plane coordinates.
Convert between distorted focal plane and detector coordinates.
void SetTransS(const QVector< double > transS)
Set the affine coefficients for converting destorted (x,y) to a detector Sample.
void SetTransL(const QVector< double > transL)
Set the affine coefficients for converting destorted (x,y) to a detector Line.
void SetTransX(const QVector< double > transX)
Set the affine coefficients for converting detector (sample,line) to a distorted X.
void SetTransY(const QVector< double > transY)
Set the affine coefficients for converting detector (sample,line) to a distorted Y.
QString m_spacecraftNameLong
Full spacecraft name.
Definition Camera.h:499
void SetFocalLength()
Reads the focal length from the instrument kernel.
Definition Camera.cpp:1422
void SetPixelPitch()
Reads the Pixel Pitch from the instrument kernel.
Definition Camera.cpp:1429
void LoadCache()
This loads the spice cache big enough for this image.
Definition Camera.cpp:2450
QString m_instrumentNameShort
Shortened instrument name.
Definition Camera.h:498
QString m_spacecraftNameShort
Shortened spacecraft name.
Definition Camera.h:500
CameraFocalPlaneMap * FocalPlaneMap()
Returns a pointer to the CameraFocalPlaneMap object.
Definition Camera.cpp:2866
virtual void SetBand(const int band)
Virtual method that sets the band number.
Definition Camera.cpp:2710
QString m_instrumentNameLong
Full instrument name.
Definition Camera.h:497
IO Handler for Isis Cubes.
Definition Cube.h:168
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition Cube.cpp:1707
Isis exception class.
Definition IException.h:91
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition IException.h:146
Convert between parent image coordinates and detector coordinates.
Convert between undistorted focal plane and ground coordinates.
Generic class for Line Scan Cameras.
Convert between undistorted focal plane and ra/dec coordinates.
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
This is the camera model for LEISA, New Hoirzon's infrared Spectrometer.
QVector< double > m_origTransl
The original transl affine coefficients from the iak.
NewHorizonsLeisaCamera(Cube &cube)
Create a NewHorizonsLeisaCamera object.
QVector< double > m_origTranss
The original transs affine coefficients from the iak.
void SetBand(const int vband)
Change the New Horizons camera parameters based on the band number.
QVector< int > m_originalBand
Stores the band bin OriginalBand keyword values.
QVector< double > m_origTransy
The original transy affine coefficients from the iak.
QVector< double > m_origTransx
The original transx affine coefficients from the iak.
Contains multiple PvlContainers.
Definition PvlGroup.h:41
Container for cube-like labels.
Definition Pvl.h:119
A single keyword-value pair.
Definition PvlKeyword.h:87
@ Traverse
Search child objects.
Definition PvlObject.h:158
virtual iTime getClockTime(QString clockValue, int sclkCode=-1, bool clockTicks=false)
This converts the spacecraft clock ticks value (clockValue) to an iTime.
Definition Spice.cpp:1060
SpiceInt naifIkCode() const
This returns the NAIF IK code to use when reading from instrument kernels.
Definition Spice.cpp:975
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition IString.cpp:93
Namespace for the standard library.