Isis 3.0 Programmer Reference
Back | Home
DawnFcCamera.cpp
Go to the documentation of this file.
1 
21 #include "DawnFcCamera.h"
22 #include "DawnFcDistortionMap.h"
23 
24 #include <QString>
25 
26 #include "CameraDetectorMap.h"
27 #include "CameraFocalPlaneMap.h"
28 #include "CameraGroundMap.h"
29 #include "CameraSkyMap.h"
30 #include "IString.h"
31 #include "iTime.h"
32 #include "NaifStatus.h"
33 
34 using namespace std;
35 
36 namespace Isis {
49  DawnFcCamera::DawnFcCamera(Cube &cube) : FramingCamera(cube) {
51 
52  m_spacecraftNameLong = "Dawn";
53  m_spacecraftNameShort = "Dawn";
54 
55  int ikCode = naifIkCode();
56 
57  // http://naif.jpl.nasa.gov/pub/naif/DAWN/kernels/ik/dawn_fc_v10.ti
58  // FC1 has instrument codes -203110 to -203119 (to reference filters and radiator as well
59  if (ikCode <= -203110 && ikCode > -203120) {
60  m_instrumentNameLong = "Framing Camera 1";
61  m_instrumentNameShort = "FC1";
62  }
63  // Likewise, FC2 has instrument codes -203120 to -203129
64  else if (ikCode <= -203120 && ikCode > -203130) {
65  m_instrumentNameLong = "Framing Camera 2";
66  m_instrumentNameShort = "FC2";
67  }
68  else {
69  QString msg = "File does not appear to be a Dawn Framing Camera image. ";
70  msg += "(" + QString::number(ikCode) + " is not a Dawn FC instrument code)";
72  }
73 
74  // The focal length is dependent on wave length. The NAIF code set
75  // in the ISIS labels will read the correct focal length from the
76  // Instrument kernel (IK)
78 
79  // The pixel pitch is not square for the FC instrument. It is only
80  // slightly rectangular 14 vs 14.088 microns. ISIS only supports
81  // square CCD pixels. The impact by calling SetPixelPitch means the
82  // computation of pixel resolution (on the ground) will be slightly off.
83  // We will spread the error by setting the pixel pitch to the average of the
84  // two. The important part is the translation from detector coordinates
85  // to focal plane coordinates. Fortunately the affine transform will
86  // allow us to have different sized detector pixels. Therefore the
87  // only problem with ISIS is the pixel resolution computation. This may
88  // be something we want to refactor later in case future instrument have
89  // non-square detectors.
90  QString keyword = "INS" + toString(naifIkCode()) + "_PIXEL_SIZE";
91  double pixelPitch = (Spice::getDouble(keyword, 0) + Spice::getDouble(keyword, 1)) / 2.0;
92  pixelPitch /= 1000.0;
93  SetPixelPitch(pixelPitch);
94 
95  // We have not seen images or tested images with summing mode or
96  // starting sample/line coordinates. Because of this uncertainty we will
97  // throw an error the image size is not 1024 x 1024. If in the future we
98  // encounter such an image then inputs to the detector map will need
99  // to be given
100  if ((ParentLines() != 1024) || (ParentSamples() != 1024)) {
101  string msg = "The ISIS Dawn FC model expects the image size to be 1024x1024";
102  msg += "Please contact Jeff Anderson (janderson@usgs.gov) with the Dawn FC PDS filename for further testing.";
104  }
105  CameraDetectorMap *detectorMap = new CameraDetectorMap(this);
106  detectorMap->SetDetectorSampleSumming(1);
107  detectorMap->SetDetectorLineSumming(1);
108 
109  // Setup focal plane map. The class will read the instrument addendum kernel to pull out the affine tronsforms
110  // from detector samp,line to focal plane x,y. This is where the non-square detector size are read and utilized.
111  // The boresight position recorded in the IK is zero-based and therefore needs to be adjusted for ISIS
112  CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
113  double boresightSample = Spice::getDouble("INS" + toString(naifIkCode()) + "_CCD_CENTER",0) + 1.0;
114  double boresightLine = Spice::getDouble("INS" + toString(naifIkCode()) + "_CCD_CENTER",1) + 1.0;
115  focalMap->SetDetectorOrigin(boresightSample,boresightLine);
116 
117  // Setup distortion map. Start by reading the distortion coefficient from the instrument kernel. Then
118  // construct the distortion model. Note the distortion model code is copied from the RadialDistortionMap
119  // class and reversed. TODO: Check with Ken Edmundson to see if we can just read from IK and pass 1/K
120  // to the original RadialDistortionMap which would allow us to delete the DawnFcDistortionMap
121  double k = Spice::getDouble("INS" + toString(naifIkCode()) + "_RAD_DIST_COEFF");
122  new DawnFcDistortionMap(this,k);
123 
124  // Setup the ground and sky map
125  new CameraGroundMap(this);
126  new CameraSkyMap(this);
127 
128  // Get the timing information of the observation. Start by computing the
129  // beginning time of the exposure. This will be based off the
130  // spacecraft clock start count. There is a delay of 193 ms while the
131  // CCD is discharged or cleared. Finally the exporsure information
132  // needs to be obtained.
133  Pvl &lab = *cube.label();
134  PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
135  QString stime = inst["SpacecraftClockStartCount"];
136  double et = getClockTime(stime).Et();
137  et += 193.0 / 1000.0;
138  double exposureDuration = (double)inst["ExposureDuration"] / 1000.0;
139  pair<iTime, iTime> shuttertimes = ShutterOpenCloseTimes(et, exposureDuration);
140  iTime centerTime = et + exposureDuration / 2.0;
141  setTime(centerTime);
142 
143  // Internalize all the NAIF SPICE information into memory.
144  LoadCache();
146  }
147 
148 
170  pair<iTime, iTime> DawnFcCamera::ShutterOpenCloseTimes(double time,
171  double exposureDuration) {
172  return FramingCamera::ShutterOpenCloseTimes(time, exposureDuration);
173  }
174 }
175 
176 
189  return new Isis::DawnFcCamera(cube);
190 }
void SetFocalLength()
Reads the focal length from the instrument kernel.
Definition: Camera.cpp:1485
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:74
QString m_instrumentNameLong
Full instrument name.
Definition: Camera.h:494
void SetDetectorSampleSumming(const double summing)
Set sample summing mode.
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition: Cube.cpp:1298
void SetPixelPitch()
Reads the Pixel Pitch from the instrument kernel.
Definition: Camera.cpp:1492
Search child objects.
Definition: PvlObject.h:170
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:226
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:154
double Et() const
Returns the ephemeris time (TDB) representation of the time as a double.
Definition: iTime.h:135
This is the camera model for the Dawn Framing Camera.
Definition: DawnFcCamera.h:58
void SetDetectorLineSumming(const double summing)
Set line summing mode.
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)=0
Returns the shutter open and close times.
virtual double exposureDuration() const
Return the exposure duration for the pixel that the camera is set to.
Definition: Camera.cpp:3113
Convert between parent image coordinates and detector coordinates.
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:495
Contains multiple PvlContainers.
Definition: PvlGroup.h:57
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:38
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:2489
QString m_spacecraftNameLong
Full spacecraft name.
Definition: Camera.h:496
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Definition: NaifStatus.cpp:43
Isis::Camera * DawnFcCameraPlugin(Isis::Cube &cube)
This is the function that is called in order to instantiate a DawnFcCamera object.
Isis exception class.
Definition: IException.h:99
SpiceInt naifIkCode() const
This returns the NAIF IK code to use when reading from instrument kernels.
Definition: Spice.cpp:888
iTime getClockTime(QString clockValue, int sclkCode=-1)
This converts the spacecraft clock ticks value (clockValue) to an iTime.
Definition: Spice.cpp:969
Convert between undistorted focal plane and ra/dec coordinates.
Definition: CameraSkyMap.h:47
QString m_spacecraftNameShort
Shortened spacecraft name.
Definition: Camera.h:497
int ParentLines() const
Returns the number of lines in the parent alphacube.
Definition: Camera.cpp:2866
int ParentSamples() const
Returns the number of samples in the parent alphacube.
Definition: Camera.cpp:2876
Generic class for Framing Cameras.
Definition: FramingCamera.h:48
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)
Returns the shutter open and close times.
SpiceDouble getDouble(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition: Spice.cpp:958
IO Handler for Isis Cubes.
Definition: Cube.h:158

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:17:24