Isis 3 Programmer Reference
DawnFcCamera.cpp
1 
7 /* SPDX-License-Identifier: CC0-1.0 */
8 
9 #include "DawnFcCamera.h"
10 #include "DawnFcDistortionMap.h"
11 
12 #include <QString>
13 
14 #include "CameraDetectorMap.h"
15 #include "CameraFocalPlaneMap.h"
16 #include "CameraGroundMap.h"
17 #include "CameraSkyMap.h"
18 #include "IString.h"
19 #include "iTime.h"
20 #include "NaifStatus.h"
21 
22 using namespace std;
23 
24 namespace Isis {
37  DawnFcCamera::DawnFcCamera(Cube &cube) : FramingCamera(cube) {
39 
40  m_spacecraftNameLong = "Dawn";
41  m_spacecraftNameShort = "Dawn";
42 
43  int ikCode = naifIkCode();
44 
45  // http://naif.jpl.nasa.gov/pub/naif/DAWN/kernels/ik/dawn_fc_v10.ti
46  // FC1 has instrument codes -203110 to -203119 (to reference filters and radiator as well
47  if (ikCode <= -203110 && ikCode > -203120) {
48  m_instrumentNameLong = "Framing Camera 1";
49  m_instrumentNameShort = "FC1";
50  }
51  // Likewise, FC2 has instrument codes -203120 to -203129
52  else if (ikCode <= -203120 && ikCode > -203130) {
53  m_instrumentNameLong = "Framing Camera 2";
54  m_instrumentNameShort = "FC2";
55  }
56  else {
57  QString msg = "File does not appear to be a Dawn Framing Camera image. ";
58  msg += "(" + QString::number(ikCode) + " is not a Dawn FC instrument code)";
59  throw IException(IException::Programmer, msg, _FILEINFO_);
60  }
61 
62  // The focal length is dependent on wave length. The NAIF code set
63  // in the ISIS labels will read the correct focal length from the
64  // Instrument kernel (IK)
66 
67  // The pixel pitch is not square for the FC instrument. It is only
68  // slightly rectangular 14 vs 14.088 microns. ISIS only supports
69  // square CCD pixels. The impact by calling SetPixelPitch means the
70  // computation of pixel resolution (on the ground) will be slightly off.
71  // We will spread the error by setting the pixel pitch to the average of the
72  // two. The important part is the translation from detector coordinates
73  // to focal plane coordinates. Fortunately the affine transform will
74  // allow us to have different sized detector pixels. Therefore the
75  // only problem with ISIS is the pixel resolution computation. This may
76  // be something we want to refactor later in case future instrument have
77  // non-square detectors.
78  QString keyword = "INS" + toString(naifIkCode()) + "_PIXEL_SIZE";
79  double pixelPitch = (Spice::getDouble(keyword, 0) + Spice::getDouble(keyword, 1)) / 2.0;
80  pixelPitch /= 1000.0;
81  SetPixelPitch(pixelPitch);
82 
83  // We have not seen images or tested images with summing mode or
84  // starting sample/line coordinates. Because of this uncertainty we will
85  // throw an error the image size is not 1024 x 1024. If in the future we
86  // encounter such an image then inputs to the detector map will need
87  // to be given
88  if ((ParentLines() != 1024) || (ParentSamples() != 1024)) {
89  string msg = "The ISIS Dawn FC model expects the image size to be 1024x1024";
90  throw IException(IException::Programmer, msg, _FILEINFO_);
91  }
92  CameraDetectorMap *detectorMap = new CameraDetectorMap(this);
93  detectorMap->SetDetectorSampleSumming(1);
94  detectorMap->SetDetectorLineSumming(1);
95 
96  // Setup focal plane map. The class will read the instrument addendum kernel to pull out the affine tronsforms
97  // from detector samp,line to focal plane x,y. This is where the non-square detector size are read and utilized.
98  // The boresight position recorded in the IK is zero-based and therefore needs to be adjusted for ISIS
99  CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
100  double boresightSample = Spice::getDouble("INS" + toString(naifIkCode()) + "_CCD_CENTER",0) + 1.0;
101  double boresightLine = Spice::getDouble("INS" + toString(naifIkCode()) + "_CCD_CENTER",1) + 1.0;
102  focalMap->SetDetectorOrigin(boresightSample,boresightLine);
103 
104  // Setup distortion map. Start by reading the distortion coefficient from the instrument kernel. Then
105  // construct the distortion model. Note the distortion model code is copied from the RadialDistortionMap
106  // class and reversed. TODO: Check with Ken Edmundson to see if we can just read from IK and pass 1/K
107  // to the original RadialDistortionMap which would allow us to delete the DawnFcDistortionMap
108  double k = Spice::getDouble("INS" + toString(naifIkCode()) + "_RAD_DIST_COEFF");
109  new DawnFcDistortionMap(this,k);
110 
111  // Setup the ground and sky map
112  new CameraGroundMap(this);
113  new CameraSkyMap(this);
114 
115  // Get the timing information of the observation. Start by computing the
116  // beginning time of the exposure. This will be based off the
117  // spacecraft clock start count. There is a delay of 193 ms while the
118  // CCD is discharged or cleared. Finally the exporsure information
119  // needs to be obtained.
120  Pvl &lab = *cube.label();
121  PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
122  QString stime = inst["SpacecraftClockStartCount"];
123  double et = getClockTime(stime).Et();
124  et += 193.0 / 1000.0;
125  double exposureDuration = (double)inst["ExposureDuration"] / 1000.0;
126  pair<iTime, iTime> shuttertimes = ShutterOpenCloseTimes(et, exposureDuration);
127  iTime centerTime = et + exposureDuration / 2.0;
128  setTime(centerTime);
129 
130  // Internalize all the NAIF SPICE information into memory.
131  LoadCache();
133  }
134 
135 
157  pair<iTime, iTime> DawnFcCamera::ShutterOpenCloseTimes(double time,
158  double exposureDuration) {
160  }
161 }
162 
163 
175 extern "C" Isis::Camera *DawnFcCameraPlugin(Isis::Cube &cube) {
176  return new Isis::DawnFcCamera(cube);
177 }
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::DawnFcCamera::ShutterOpenCloseTimes
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)
Returns the shutter open and close times.
Definition: DawnFcCamera.cpp:157
Isis::CameraDetectorMap
Convert between parent image coordinates and detector coordinates.
Definition: CameraDetectorMap.h:47
Isis::Camera::ParentLines
int ParentLines() const
Returns the number of lines in the parent alphacube.
Definition: Camera.cpp:2806
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::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
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::DawnFcCamera
This is the camera model for the Dawn Framing Camera.
Definition: DawnFcCamera.h:47
Isis::PvlObject::Traverse
@ Traverse
Search child objects.
Definition: PvlObject.h:158
Isis::Camera::ParentSamples
int ParentSamples() const
Returns the number of samples in the parent alphacube.
Definition: Camera.cpp:2816
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::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::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::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::DawnFcDistortionMap
Definition: DawnFcDistortionMap.h:21