Isis 3 Programmer Reference
IssNACamera.cpp
Go to the documentation of this file.
1 
20 // $Id: IssNACamera.cpp,v 1.6 2009/08/31 15:12:29 slambright Exp $
21 #include "IssNACamera.h"
22 
23 #include <QString>
24 
25 #include "CameraDetectorMap.h"
26 #include "CameraFocalPlaneMap.h"
27 #include "CameraGroundMap.h"
28 #include "CameraSkyMap.h"
29 #include "IString.h"
30 #include "iTime.h"
31 #include "NaifStatus.h"
32 #include "RadialDistortionMap.h"
33 #include "iTime.h"
34 
35 using namespace std;
36 namespace Isis {
46  IssNACamera::IssNACamera(Cube &cube) : FramingCamera(cube) {
47  m_instrumentNameLong = "Imaging Science Subsystem Narrow Angle";
48  m_instrumentNameShort = "ISSNA";
49  m_spacecraftNameLong = "Cassini Huygens";
50  m_spacecraftNameShort = "Cassini";
51 
52  Pvl &lab = *cube.label();
53 
54  // Get the filter wheels positions dependent focal length.
55  // If we can not get the focal length for this specific filter wheel combination then
56  // use the default.
57  double focalLength = 0.0;
58  try {
59  PvlGroup bandBin = lab.findGroup("BandBin", Pvl::Traverse);
60  QString key = QString("INS%1_%2_FOCAL_LENGTH").
61  arg(naifIkCode()).arg(bandBin["FilterName"][0]);
62  key = key.replace("/", "_");
63  focalLength = getDouble(key);
64  }
65  catch (IException &firstException) {
66  try {
67  QString key = "INS-82360_DEFAULT_FOCAL_LENGTH";
68  focalLength = getDouble(key);
69  }
70  catch (IException &secondException) {
71  PvlGroup bandBin = lab.findGroup("BandBin", Pvl::Traverse);
73  QString("Unable to find a focal length for the requested Cassini ISS NA "
74  "filter combination [%1] or the default focal length")
75  .arg(bandBin["FilterName"][0]),
76  _FILEINFO_);
77  finalError.append(firstException);
78  finalError.append(secondException);
79  throw finalError;
80  }
81  }
82 
84 
85  SetFocalLength(focalLength);
86  SetPixelPitch();
87  instrumentRotation()->SetFrame(Spice::getInteger("INS_" + toString(naifIkCode()) + "_FRAME_ID"));
88 
89  // Get the start time in et
90  PvlGroup inst = lab.findGroup("Instrument", Pvl::Traverse);
91 
92  double et = iTime((QString)inst["StartTime"]).Et();
93 
94  // divide exposure duration keyword value by 1000 to convert to seconds
95  double exposureDuration = ((double) inst["ExposureDuration"]) / 1000.0;
96  pair<iTime, iTime> shuttertimes = ShutterOpenCloseTimes(et, exposureDuration);
97 
98  //correct time for center of exposure duration
99  iTime centerTime = shuttertimes.first.Et() + exposureDuration / 2.0;
100 
101  // Setup detector map
102  int summingMode = inst["SummingMode"];
103  CameraDetectorMap *detectorMap = new CameraDetectorMap(this);
104  detectorMap->SetDetectorLineSumming(summingMode);
105  detectorMap->SetDetectorSampleSumming(summingMode);
106 
107  // Setup focal plane map
108  CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
109 
110  focalMap->SetDetectorOrigin(Spice::getDouble("INS" + toString(naifIkCode()) + "_BORESIGHT_SAMPLE"),
111  Spice::getDouble("INS" + toString(naifIkCode()) + "_BORESIGHT_LINE"));
112 
113  // Setup distortion map
114  double k1 = Spice::getDouble("INS" + toString(naifIkCode()) + "_K1");
115  new RadialDistortionMap(this, k1);
116 
117  // Setup the ground and sky map
118  new CameraGroundMap(this);
119  new CameraSkyMap(this);
120 
121  setTime(centerTime);
122  LoadCache();
124  }
125 
149  pair<iTime, iTime> IssNACamera::ShutterOpenCloseTimes(double time,
150  double exposureDuration) {
152  }
153 }
154 
155 
168  return new Isis::IssNACamera(cube);
169 }
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
Cassini ISS Narrow Angle Camera Model.
Definition: IssNACamera.h:72
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)
Returns the shutter open and close times.
Isis::Camera * IssNACameraPlugin(Isis::Cube &cube)
This is the function that is called in order to instantiate a IssNACamera object. ...
Parse and return pieces of a time string.
Definition: iTime.h:78
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
SpiceInt getInteger(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition: Spice.cpp:949
QString m_instrumentNameLong
Full instrument name.
Definition: Camera.h:507
void SetDetectorSampleSumming(const double summing)
Set sample summing mode.
void append(const IException &exceptionSource)
Appends the given exception (and its list of previous exceptions) to this exception&#39;s causational exc...
Definition: IException.cpp:425
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
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.
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.
Convert between parent image coordinates and detector coordinates.
void SetFrame(int frameCode)
Change the frame to the given frame code.
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
A type of error that cannot be classified as any of the other error types.
Definition: IException.h:134
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
SpiceRotation * instrumentRotation() const
Accessor method for the instrument rotation.
Definition: Spice.cpp:1489
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
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