Isis 3 Programmer Reference
KaguyaMiCamera.cpp
1
7/* SPDX-License-Identifier: CC0-1.0 */
8
9#include "KaguyaMiCamera.h"
10
11#include <iomanip>
12
13#include <QString>
14
15#include "CameraFocalPlaneMap.h"
16#include "IException.h"
17#include "IString.h"
18#include "iTime.h"
19#include "LineScanCameraDetectorMap.h"
20#include "LineScanCameraGroundMap.h"
21#include "LineScanCameraSkyMap.h"
22#include "KaguyaMiCameraDistortionMap.h"
23#include "NaifStatus.h"
24
25using namespace std;
26namespace Isis {
36 m_spacecraftNameLong = "Kaguya";
37 m_spacecraftNameShort = "Kaguya";
38
39 int ikCode = naifIkCode();
40
41 // https://darts.isas.jaxa.jp/pub/spice/SELENE/kernels/ik/SEL_MI_V01.TI
42 // MI-VIS instrument kernel codes -131331 through -131335
43 if (ikCode <= -131331 && ikCode >= -131335) {
44 m_instrumentNameLong = "Multi Band Imager Visible";
45 m_instrumentNameShort = "MI-VIS";
46 }
47 // MI-NIR instrument kernel codes -131341 through -131344
48 else if (ikCode <= -131341 && ikCode >= -131344) {
49 m_instrumentNameLong = "Multi Band Imager Infrared";
50 m_instrumentNameShort = "MI-NIR";
51 }
52 else {
53 QString msg = QString::number(ikCode);
54 msg += " is not a supported instrument kernel code for Kaguya.";
55 throw IException(IException::Programmer, msg, _FILEINFO_);
56 }
57
59 // Set up the camera info from ik/iak kernels
60
62 //Kaguya IK kernel uses INS-131???_PIXEL_SIZE instead of PIXEL_PITCH
63 QString ikernKey = "INS" + toString(naifIkCode()) + "_PIXEL_SIZE";
64 SetPixelPitch(getDouble(ikernKey));
65
66
67 // Get the start time from labels
68 Pvl &lab = *cube.label();
69 PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
70 QString stime = (QString)inst["StartTime"];
71 SpiceDouble etStart=0;
72
73 if(stime != "NULL") {
74 etStart = iTime(stime).Et();
75 }
76 else {
77 //TODO throw an error if "StartTime" keyword is absent
78 }
79
81
82
83 // Get other info from labels
84 double lineRate = (double) inst["CorrectedSamplingInterval"] / 1000.0;
85 setTime(etStart);
86
87 // Setup detector map
88 LineScanCameraDetectorMap *detectorMap = new LineScanCameraDetectorMap(this, etStart, lineRate);
89 detectorMap->SetDetectorSampleSumming(1.0);
90 detectorMap->SetStartingDetectorSample(1.0);
91
92 // Setup focal plane map
93 CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
94 // Retrieve boresight location from instrument kernel (IK) (addendum?)
95 ikernKey = "INS" + toString(naifIkCode()) + "_CENTER";
96 double sampleBoreSight = getDouble(ikernKey,0);
97 double lineBoreSight = getDouble(ikernKey,1)-1.0;
98
99 focalMap->SetDetectorOrigin(sampleBoreSight, lineBoreSight);
100 focalMap->SetDetectorOffset(0.0, 0.0);
101
102
104 distMap->SetDistortion(naifIkCode());
105
106 // Setup the ground and sky map
107 new LineScanCameraGroundMap(this);
108 new LineScanCameraSkyMap(this);
109
110 LoadCache();
111
113 }
114}
115
126extern "C" Isis::Camera *KaguyaMiCameraPlugin(Isis::Cube &cube) {
127 return new Isis::KaguyaMiCamera(cube);
128}
Convert between distorted focal plane and detector coordinates.
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
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
Distort/undistort focal plane coordinates.
Kaguya MI Camera Model.
KaguyaMiCamera(Cube &cube)
Constructor for the Kaguya MI Camera Model.
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.
Contains multiple PvlContainers.
Definition PvlGroup.h:41
Container for cube-like labels.
Definition Pvl.h:119
@ Traverse
Search child objects.
Definition PvlObject.h:158
void setTime(const iTime &time)
By setting the time you essential set the position of the spacecraft and body as indicated in the cla...
Definition Sensor.cpp:99
SpiceInt naifIkCode() const
This returns the NAIF IK code to use when reading from instrument kernels.
Definition Spice.cpp:975
SpiceDouble getDouble(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition Spice.cpp:1046
Parse and return pieces of a time string.
Definition iTime.h:65
double Et() const
Returns the ephemeris time (TDB) representation of the time as a double.
Definition iTime.h:126
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition IString.cpp:211
Namespace for the standard library.