Isis 3 Programmer Reference
NewHorizonsMvicFrameCamera.cpp
Go to the documentation of this file.
1 
22 
23 #include <QDebug>
24 #include <QString>
25 
26 #include "Camera.h"
27 #include "CameraDetectorMap.h"
28 #include "CameraDistortionMap.h"
29 #include "CameraFocalPlaneMap.h"
30 #include "CameraGroundMap.h"
31 #include "CameraSkyMap.h"
32 #include "IString.h"
33 #include "iTime.h"
35 #include "NaifStatus.h"
36 
37 using namespace std;
38 
39 namespace Isis {
40 
53  NewHorizonsMvicFrameCamera::NewHorizonsMvicFrameCamera(Cube &cube) : FramingCamera(cube) {
54  m_instrumentNameLong = "Multispectral Visible Imaging Framing Camera";
55  m_instrumentNameShort = "MVIC FRAMING";
56  m_spacecraftNameLong = "New Horizons";
57  m_spacecraftNameShort = "NewHorizons";
58 
60 
62  SetPixelPitch();
63 
64  // Get the start time from labels
65  Pvl &lab = *cube.label();
66  PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
67  m_exposure = inst["ExposureDuration"];
68  QString stime = inst["SpacecraftClockStartCount"];
69  // ** TODO ** Need an offset time added to labels at ingestion?? The 0.125 value is
70  // the value in DELTAT00.
71  double offset = 0.125;
72  m_etStart = getClockTime(stime).Et() + offset;
73  SpiceChar utc[30];
74  et2utc_c(m_etStart, "ISOC", 3, 30, utc);
75 // qDebug()<<"\n\nspacecraftClockStartCount + "<<offset<<" (offset) = "<<utc;
76 
77  // If bands have been extracted from the original image then we
78  // need to read the band bin group so we can map from the cube band
79  // number to the instrument band number. Also save times of each framelet which are stored
80  // in the BandBin group.
81  PvlGroup &bandBin = lab.findGroup("BandBin", Pvl::Traverse);
82  PvlKeyword &origBand = bandBin["OriginalBand"];
83  PvlKeyword &utcTime = bandBin["UtcTime"];
84  for(int i = 0; i < origBand.size(); i++) {
85  m_originalBand.push_back(toInt(origBand[i]));
86  m_utcTime.push_back(utcTime[i]);
87  }
88 
89  CameraDetectorMap *detectorMap = new CameraDetectorMap(this);
90  detectorMap->SetDetectorSampleSumming(1);
91  detectorMap->SetDetectorLineSumming(1);
92 
93  // Setup focal plane map. The class will read data from the instrument addendum kernel to pull
94  // out the affine transforms from detector samp,line to focal plane x,y.
95  CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
96  focalMap->SetDetectorOrigin(2500.5, 64.5);
97 
98  // Read distortion coefficients and boresight offsets from the instrument kernels. Then
99  // construct the distortion map.
100  //read the distortion coefs from the NAIF Kernels
101  QString naifXKey = "INS-98900_DISTORTION_COEF_X";
102  QString naifYKey = "INS-98900_DISTORTION_COEF_Y";
103  QString naifppKey = "INS-98900_PP_OFFSET";
104  vector<double> distCoefX;
105  vector<double> distCoefY;
106 
107  for (int i=0; i < 20; i++) {
108  distCoefX.push_back(getDouble(naifXKey,i));
109  distCoefY.push_back(getDouble(naifYKey,i));
110  }
111 
112  new NewHorizonsMvicFrameCameraDistortionMap(this, distCoefX, distCoefY);
113 
114  // Setup the ground and sky map
115  new CameraGroundMap(this);
116  new CameraSkyMap(this);
117 
118  // Internalize all the NAIF SPICE information into memory.
119  LoadCache();
121  }
122 
123 
129  void NewHorizonsMvicFrameCamera::SetBand(const int vband) {
130 
131  if(vband > (int) m_originalBand.size()) {
132  QString msg = QObject::tr("Band number out of array bounds in NewHorizonsMvicFrameCamera::SetBand legal "
133  "bands are [1-%1], input was [%2]").
134  arg(m_originalBand.size()).arg(vband);
136  }
137 
138  iTime time(m_utcTime[vband-1]);
139  double et = time.Et();
140 
141  SpiceChar utc[30];
142  et2utc_c(et, "ISOC", 3, 30, utc);
143  Camera::setTime(et);
144  pair<iTime, iTime> shuttertimes = ShutterOpenCloseTimes(et, m_exposure);
145 
146  // Set up valid band access
147  Camera::SetBand(vband);
148 
149  }
150 
151 
171  pair<iTime, iTime> NewHorizonsMvicFrameCamera::ShutterOpenCloseTimes(double time, double exposureDuration) {
172 
174  }
175 }
176 
177 
188  return new Isis::NewHorizonsMvicFrameCamera(cube);
189 }
void SetFocalLength()
Reads the focal length from the instrument kernel.
Definition: Camera.cpp:1430
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
Definition: PvlObject.h:141
Parse and return pieces of a time string.
Definition: iTime.h:78
QString m_instrumentNameLong
Full instrument name.
Definition: Camera.h:507
void SetDetectorSampleSumming(const double summing)
Set sample summing mode.
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition: IString.cpp:108
void SetPixelPitch()
Reads the Pixel Pitch from the instrument kernel.
Definition: Camera.cpp:1437
Namespace for the standard library.
Isis::Camera * NewHorizonsMvicFrameCameraPlugin(Isis::Cube &cube)
This is the function that is called in order to instantiate a NewHorizonsMvicFrameCamera object...
Search child objects.
Definition: PvlObject.h:170
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
void SetBand(const int vband)
Sets the band in the camera model.
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:162
void SetDetectorLineSumming(const double summing)
Set line summing mode.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)=0
Returns the shutter open and close times.
Convert between parent image coordinates and detector coordinates.
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)
The camera model is band dependent, so this method returns false.
int size() const
Returns the number of values stored in this keyword.
Definition: PvlKeyword.h:141
Convert between undistorted focal plane and ground coordinates.
Convert between distorted focal plane and detector coordinates.
QString m_instrumentNameShort
Shortened instrument name.
Definition: Camera.h:508
Distort/undistort focal plane coordinates for New Horizons/MVIC frame sensor.
Contains multiple PvlContainers.
Definition: PvlGroup.h:57
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
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
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
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:112
Container for cube-like labels.
Definition: Pvl.h:135
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
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
Convert between undistorted focal plane and ra/dec coordinates.
Definition: CameraSkyMap.h:48
QString m_spacecraftNameShort
Shortened spacecraft name.
Definition: Camera.h:510
virtual double exposureDuration() const
Return the exposure duration for the pixel that the camera is set to.
Definition: Camera.cpp:3075
Generic class for Framing Cameras.
Definition: FramingCamera.h:48
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
SpiceDouble getDouble(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition: Spice.cpp:963
This is the camera model for the New Horizons MVIC Frame mode Camera.
IO Handler for Isis Cubes.
Definition: Cube.h:170
iTime time() const
Returns the ephemeris time in seconds which was used to obtain the spacecraft and sun positions...
Definition: Spice.cpp:809