Isis 3 Programmer Reference
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";
103  }
104  CameraDetectorMap *detectorMap = new CameraDetectorMap(this);
105  detectorMap->SetDetectorSampleSumming(1);
106  detectorMap->SetDetectorLineSumming(1);
107 
108  // Setup focal plane map. The class will read the instrument addendum kernel to pull out the affine tronsforms
109  // from detector samp,line to focal plane x,y. This is where the non-square detector size are read and utilized.
110  // The boresight position recorded in the IK is zero-based and therefore needs to be adjusted for ISIS
111  CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
112  double boresightSample = Spice::getDouble("INS" + toString(naifIkCode()) + "_CCD_CENTER",0) + 1.0;
113  double boresightLine = Spice::getDouble("INS" + toString(naifIkCode()) + "_CCD_CENTER",1) + 1.0;
114  focalMap->SetDetectorOrigin(boresightSample,boresightLine);
115 
116  // Setup distortion map. Start by reading the distortion coefficient from the instrument kernel. Then
117  // construct the distortion model. Note the distortion model code is copied from the RadialDistortionMap
118  // class and reversed. TODO: Check with Ken Edmundson to see if we can just read from IK and pass 1/K
119  // to the original RadialDistortionMap which would allow us to delete the DawnFcDistortionMap
120  double k = Spice::getDouble("INS" + toString(naifIkCode()) + "_RAD_DIST_COEFF");
121  new DawnFcDistortionMap(this,k);
122 
123  // Setup the ground and sky map
124  new CameraGroundMap(this);
125  new CameraSkyMap(this);
126 
127  // Get the timing information of the observation. Start by computing the
128  // beginning time of the exposure. This will be based off the
129  // spacecraft clock start count. There is a delay of 193 ms while the
130  // CCD is discharged or cleared. Finally the exporsure information
131  // needs to be obtained.
132  Pvl &lab = *cube.label();
133  PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
134  QString stime = inst["SpacecraftClockStartCount"];
135  double et = getClockTime(stime).Et();
136  et += 193.0 / 1000.0;
137  double exposureDuration = (double)inst["ExposureDuration"] / 1000.0;
138  pair<iTime, iTime> shuttertimes = ShutterOpenCloseTimes(et, exposureDuration);
139  iTime centerTime = et + exposureDuration / 2.0;
140  setTime(centerTime);
141 
142  // Internalize all the NAIF SPICE information into memory.
143  LoadCache();
145  }
146 
147 
169  pair<iTime, iTime> DawnFcCamera::ShutterOpenCloseTimes(double time,
170  double exposureDuration) {
172  }
173 }
174 
175 
188  return new Isis::DawnFcCamera(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.
void SetPixelPitch()
Reads the Pixel Pitch from the instrument kernel.
Definition: Camera.cpp:1437
Namespace for the standard library.
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:162
This is the camera model for the Dawn Framing Camera.
Definition: DawnFcCamera.h:58
void SetDetectorLineSumming(const double summing)
Set line summing mode.
int ParentLines() const
Returns the number of lines in the parent alphacube.
Definition: Camera.cpp:2818
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.
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
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
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
int ParentSamples() const
Returns the number of samples in the parent alphacube.
Definition: Camera.cpp:2828
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::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: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 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:963
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