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 
25 using namespace std;
26 namespace Isis {
35  KaguyaMiCamera::KaguyaMiCamera(Cube &cube) : LineScanCamera(cube) {
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 kernal 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 
126 extern "C" Isis::Camera *KaguyaMiCameraPlugin(Isis::Cube &cube) {
127  return new Isis::KaguyaMiCamera(cube);
128 }
Isis::LineScanCameraSkyMap
Convert between undistorted focal plane and ra/dec coordinates.
Definition: LineScanCameraSkyMap.h:34
Isis::CameraFocalPlaneMap::SetDetectorOrigin
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
Definition: CameraFocalPlaneMap.cpp:293
Isis::PvlObject::findGroup
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition: PvlObject.h:129
Isis::Spice::naifIkCode
SpiceInt naifIkCode() const
This returns the NAIF IK code to use when reading from instrument kernels.
Definition: Spice.cpp:968
Isis::iTime
Parse and return pieces of a time string.
Definition: iTime.h:65
Isis::Camera::m_instrumentNameLong
QString m_instrumentNameLong
Full instrument name.
Definition: Camera.h:496
Isis::CameraDetectorMap::SetDetectorSampleSumming
void SetDetectorSampleSumming(const double summing)
Set sample summing mode.
Definition: CameraDetectorMap.h:108
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::CameraFocalPlaneMap::SetDetectorOffset
void SetDetectorOffset(const double sampleOffset, const double lineOffset)
Set the detector offset.
Definition: CameraFocalPlaneMap.cpp:324
Isis::NaifStatus::CheckErrors
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Definition: NaifStatus.cpp:28
Isis::Camera
Definition: Camera.h:236
Isis::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
Isis::PvlObject::Traverse
@ Traverse
Search child objects.
Definition: PvlObject.h:158
Isis::Sensor::setTime
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:97
Isis::iTime::Et
double Et() const
Returns the ephemeris time (TDB) representation of the time as a double.
Definition: iTime.h:126
Isis::Camera::SetPixelPitch
void SetPixelPitch()
Reads the Pixel Pitch from the instrument kernel.
Definition: Camera.cpp:1418
Isis::PvlGroup
Contains multiple PvlContainers.
Definition: PvlGroup.h:41
Isis::KaguyaMiCameraDistortionMap
Distort/undistort focal plane coordinates.
Definition: KaguyaMiCameraDistortionMap.h:36
Isis::LineScanCamera
Generic class for Line Scan Cameras.
Definition: LineScanCamera.h:36
Isis::LineScanCameraGroundMap
Convert between undistorted focal plane and ground coordinates.
Definition: LineScanCameraGroundMap.h:49
Isis::Cube
IO Handler for Isis Cubes.
Definition: Cube.h:167
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::Camera::m_spacecraftNameLong
QString m_spacecraftNameLong
Full spacecraft name.
Definition: Camera.h:498
Isis::KaguyaMiCameraDistortionMap::SetDistortion
void SetDistortion(const int naifIkCode)
Definition: KaguyaMiCameraDistortionMap.cpp:39
Isis::CameraDetectorMap::SetStartingDetectorSample
void SetStartingDetectorSample(const double sample)
Set the starting detector sample.
Definition: CameraDetectorMap.h:79
Isis::IException::Programmer
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:146
std
Namespace for the standard library.
Isis::Camera::LoadCache
void LoadCache()
This loads the spice cache big enough for this image.
Definition: Camera.cpp:2420
Isis::Camera::m_instrumentNameShort
QString m_instrumentNameShort
Shortened instrument name.
Definition: Camera.h:497
Isis::CameraFocalPlaneMap
Convert between distorted focal plane and detector coordinates.
Definition: CameraFocalPlaneMap.h:85
Isis::Cube::label
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition: Cube.cpp:1701
Isis::Spice::getDouble
SpiceDouble getDouble(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition: Spice.cpp:1039
Isis::Camera::m_spacecraftNameShort
QString m_spacecraftNameShort
Shortened spacecraft name.
Definition: Camera.h:499
Isis::KaguyaMiCamera
Kaguya MI Camera Model.
Definition: KaguyaMiCamera.h:39
Isis::Camera::SetFocalLength
void SetFocalLength()
Reads the focal length from the instrument kernel.
Definition: Camera.cpp:1411
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::LineScanCameraDetectorMap
Convert between parent image coordinates and detector coordinates.
Definition: LineScanCameraDetectorMap.h:37