Isis 3 Programmer Reference
NewHorizonsMvicFrameCamera.cpp
1 
7 /* SPDX-License-Identifier: CC0-1.0 */
8 
9 #include "NewHorizonsMvicFrameCamera.h"
10 
11 #include <QDebug>
12 #include <QString>
13 
14 #include "Camera.h"
15 #include "CameraDetectorMap.h"
16 #include "CameraDistortionMap.h"
17 #include "CameraFocalPlaneMap.h"
18 #include "CameraGroundMap.h"
19 #include "CameraSkyMap.h"
20 #include "IString.h"
21 #include "iTime.h"
22 #include "NewHorizonsMvicFrameCameraDistortionMap.h"
23 #include "NaifStatus.h"
24 
25 using namespace std;
26 
27 namespace Isis {
28 
41  NewHorizonsMvicFrameCamera::NewHorizonsMvicFrameCamera(Cube &cube) : FramingCamera(cube) {
42  m_instrumentNameLong = "Multispectral Visible Imaging Framing Camera";
43  m_instrumentNameShort = "MVIC FRAMING";
44  m_spacecraftNameLong = "New Horizons";
45  m_spacecraftNameShort = "NewHorizons";
46 
48 
50  SetPixelPitch();
51 
52  // Get the start time from labels
53  Pvl &lab = *cube.label();
54  PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
55  m_exposure = inst["ExposureDuration"];
56  QString stime = inst["SpacecraftClockStartCount"];
57  // ** TODO ** Need an offset time added to labels at ingestion?? The 0.125 value is
58  // the value in DELTAT00.
59  double offset = 0.125;
60  m_etStart = getClockTime(stime).Et() + offset;
61  SpiceChar utc[30];
62  et2utc_c(m_etStart, "ISOC", 3, 30, utc);
63 // qDebug()<<"\n\nspacecraftClockStartCount + "<<offset<<" (offset) = "<<utc;
64 
65  // If bands have been extracted from the original image then we
66  // need to read the band bin group so we can map from the cube band
67  // number to the instrument band number. Also save times of each framelet which are stored
68  // in the BandBin group.
69  PvlGroup &bandBin = lab.findGroup("BandBin", Pvl::Traverse);
70  PvlKeyword &origBand = bandBin["OriginalBand"];
71  PvlKeyword &utcTime = bandBin["UtcTime"];
72  for(int i = 0; i < origBand.size(); i++) {
73  m_originalBand.push_back(toInt(origBand[i]));
74  m_utcTime.push_back(utcTime[i]);
75  }
76 
77  CameraDetectorMap *detectorMap = new CameraDetectorMap(this);
78  detectorMap->SetDetectorSampleSumming(1);
79  detectorMap->SetDetectorLineSumming(1);
80 
81  // Setup focal plane map. The class will read data from the instrument addendum kernel to pull
82  // out the affine transforms from detector samp,line to focal plane x,y.
83  CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
84  focalMap->SetDetectorOrigin(2500.5, 64.5);
85 
86  // Read distortion coefficients and boresight offsets from the instrument kernels. Then
87  // construct the distortion map.
88  //read the distortion coefs from the NAIF Kernels
89  QString naifXKey = "INS-98900_DISTORTION_COEF_X";
90  QString naifYKey = "INS-98900_DISTORTION_COEF_Y";
91  QString naifppKey = "INS-98900_PP_OFFSET";
92  vector<double> distCoefX;
93  vector<double> distCoefY;
94 
95  for (int i=0; i < 20; i++) {
96  distCoefX.push_back(getDouble(naifXKey,i));
97  distCoefY.push_back(getDouble(naifYKey,i));
98  }
99 
100  new NewHorizonsMvicFrameCameraDistortionMap(this, distCoefX, distCoefY);
101 
102  // Setup the ground and sky map
103  new CameraGroundMap(this);
104  new CameraSkyMap(this);
105 
106  // Internalize all the NAIF SPICE information into memory.
107  LoadCache();
109  }
110 
111 
117  void NewHorizonsMvicFrameCamera::SetBand(const int vband) {
118 
119  if(vband > (int) m_originalBand.size()) {
120  QString msg = QObject::tr("Band number out of array bounds in NewHorizonsMvicFrameCamera::SetBand legal "
121  "bands are [1-%1], input was [%2]").
122  arg(m_originalBand.size()).arg(vband);
123  throw IException(IException::Programmer, msg, _FILEINFO_);
124  }
125 
126  iTime time(m_utcTime[vband-1]);
127  double et = time.Et();
128 
129  SpiceChar utc[30];
130  et2utc_c(et, "ISOC", 3, 30, utc);
131  Camera::setTime(et);
132  pair<iTime, iTime> shuttertimes = ShutterOpenCloseTimes(et, m_exposure);
133 
134  // Set up valid band access
135  Camera::SetBand(vband);
136 
137  }
138 
139 
159  pair<iTime, iTime> NewHorizonsMvicFrameCamera::ShutterOpenCloseTimes(double time, double exposureDuration) {
160 
162  }
163 }
164 
165 
175 extern "C" Isis::Camera *NewHorizonsMvicFrameCameraPlugin(Isis::Cube &cube) {
176  return new Isis::NewHorizonsMvicFrameCamera(cube);
177 }
Isis::Camera::SetBand
virtual void SetBand(const int band)
Virtual method that sets the band number.
Definition: Camera.cpp:2680
Isis::CameraFocalPlaneMap::SetDetectorOrigin
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
Definition: CameraFocalPlaneMap.cpp:293
Isis::Camera::exposureDuration
virtual double exposureDuration() const
Return the exposure duration for the pixel that the camera is set to.
Definition: Camera.cpp:3063
Isis::Spice::time
iTime time() const
Returns the ephemeris time in seconds which was used to obtain the spacecraft and sun positions.
Definition: Spice.cpp:884
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::NewHorizonsMvicFrameCamera
This is the camera model for the New Horizons MVIC Frame mode Camera.
Definition: NewHorizonsMvicFrameCamera.h:33
Isis::CameraDetectorMap
Convert between parent image coordinates and detector coordinates.
Definition: CameraDetectorMap.h:47
Isis::PvlKeyword
A single keyword-value pair.
Definition: PvlKeyword.h:82
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::Spice::getClockTime
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:1053
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::FramingCamera::ShutterOpenCloseTimes
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)=0
Returns the shutter open and close times.
Definition: FramingCamera.cpp:42
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::FramingCamera
Generic class for Framing Cameras.
Definition: FramingCamera.h:32
Isis::CameraGroundMap
Convert between undistorted focal plane and ground coordinates.
Definition: CameraGroundMap.h:73
Isis::CameraDetectorMap::SetDetectorLineSumming
void SetDetectorLineSumming(const double summing)
Set line summing mode.
Definition: CameraDetectorMap.h:123
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::toInt
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition: IString.cpp:93
Isis::NewHorizonsMvicFrameCameraDistortionMap
Distort/undistort focal plane coordinates for New Horizons/MVIC frame sensor.
Definition: NewHorizonsMvicFrameCameraDistortionMap.h:34
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::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::CameraSkyMap
Convert between undistorted focal plane and ra/dec coordinates.
Definition: CameraSkyMap.h:31
Isis::PvlKeyword::size
int size() const
Returns the number of values stored in this keyword.
Definition: PvlKeyword.h:125
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::NewHorizonsMvicFrameCamera::SetBand
void SetBand(const int vband)
Sets the band in the camera model.
Definition: NewHorizonsMvicFrameCamera.cpp:117
Isis::Camera::m_spacecraftNameShort
QString m_spacecraftNameShort
Shortened spacecraft name.
Definition: Camera.h:499
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::NewHorizonsMvicFrameCamera::ShutterOpenCloseTimes
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)
Returns the shutter open and close times.
Definition: NewHorizonsMvicFrameCamera.cpp:159