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
22using namespace std;
23
24namespace Isis {
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";
50 }
51 // Likewise, FC2 has instrument codes -203120 to -203129
52 else if (ikCode <= -203120 && ikCode > -203130) {
53 m_instrumentNameLong = "Framing Camera 2";
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
175extern "C" Isis::Camera *DawnFcCameraPlugin(Isis::Cube &cube) {
176 return new Isis::DawnFcCamera(cube);
177}
Convert between parent image coordinates and detector coordinates.
Convert between distorted focal plane and detector coordinates.
Convert between undistorted focal plane and ground coordinates.
QString m_spacecraftNameLong
Full spacecraft name.
Definition Camera.h:499
virtual double exposureDuration() const
Return the exposure duration for the pixel that the camera is set to.
Definition Camera.cpp:3093
int ParentLines() const
Returns the number of lines in the parent alphacube.
Definition Camera.cpp:2836
int ParentSamples() const
Returns the number of samples in the parent alphacube.
Definition Camera.cpp:2846
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
Convert between undistorted focal plane and ra/dec coordinates.
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
This is the camera model for the Dawn Framing Camera.
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)
Returns the shutter open and close times.
DawnFcCamera(Cube &cube)
Constructs a Dawn Framing Camera object.
Generic class for Framing Cameras.
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)=0
Returns the shutter open and close times.
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
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
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:1060
virtual iTime time() const
Returns the ephemeris time in seconds which was used to obtain the spacecraft and sun positions.
Definition Spice.cpp:891
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
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.