Isis 3 Programmer Reference
TgoCassisCamera.cpp
Go to the documentation of this file.
1 
22 #include "TgoCassisCamera.h"
23 
24 #include <cmath>
25 
26 #include <QByteArray>
27 #include <QString>
28 #include <QVariant>
29 
30 #include "CameraDetectorMap.h"
31 #include "CameraFocalPlaneMap.h"
32 #include "CameraGroundMap.h"
33 #include "CameraSkyMap.h"
34 #include "EndianSwapper.h"
35 #include "IException.h"
36 #include "IString.h"
37 #include "iTime.h"
38 #include "NaifStatus.h"
39 #include "TgoCassisDistortionMap.h"
40 
41 using namespace std;
42 
43 namespace Isis {
50  TgoCassisCamera::TgoCassisCamera(Cube &cube) : FramingCamera(cube) {
51 
52  m_instrumentNameLong = "Colour and Stereo Surface Imaging System";
53  m_instrumentNameShort = "CaSSIS";
54 
55  m_spacecraftNameLong = "Trace Gas Orbiter";
56  m_spacecraftNameShort = "TGO";
57 
59 
60  // CaSSIS codes
61  int cassisCode = naifIkCode();
62  QString cassis = toString(cassisCode);
63 
64  // Get all the necessary stuff from the labels
65  Pvl &lab = *cube.label();
66  const PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
67 
68  // Set up the camera characteristics
69  instrumentRotation()->SetFrame(-143420);
71  SetPixelPitch();
72 
73  // Get the Start time from the labels
74  // TODO: This is currently using UTC time. Once the timestamp is figured out,
75  // this will change to use SCLK. JAM 2017-02-06
76  QString stime = inst["SpacecraftClockStartCount"];
77  QString startT = inst["StartTime"];
78  iTime et(startT);
79 
80  // Get summing mode
81  // Summing modes are:
82  // 0 = 1x1 (No summing)
83  // 1 = 2x2
84  // 2 = 4x4
85  int sumMode = toInt(inst["SummingMode"][0]);
86  int summing = sumMode * 2;
87 
88  // Setup camera detector map
89  CameraDetectorMap *detMap = new CameraDetectorMap(this);
90  if ( summing > 0 ) {
91  detMap->SetDetectorSampleSumming(summing);
92  detMap->SetDetectorLineSumming(summing);
93  }
94 
95  // Setup focal plane map
96  CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, cassisCode);
97 
98  // Get CASSIS detector boresight
99  double bsSample = getDouble("INS" + cassis + "_BORESIGHT_SAMPLE");
100  double bsLine = getDouble("INS" + cassis + "_BORESIGHT_LINE");
101  focalMap->SetDetectorOrigin(bsSample, bsLine);
102 
103  // Setup distortion map
104  try {
105  new TgoCassisDistortionMap(this, naifIkCode());
106  }
107  catch (IException &e) {
108  // Set NULL so that cameras destructor wont seg fault trying to delete
109  SetDistortionMap(NULL, false);
110  QString msg = "Unable to Create TgoCassisDistortionMap";
111  throw IException(e, IException::Unknown, msg, _FILEINFO_);
112  }
113  // Setup the ground and sky map
114  new CameraGroundMap(this);
115  new CameraSkyMap(this);
116 
117  // Set start time to center of exposure time to ensure
118  // the proper SPICE data is cached.
119  double p_exposureDur = toDouble(inst["ExposureDuration"]);
120  iTime p_etStart = et + ( p_exposureDur / 2.0);
121 
122  setTime(p_etStart);
123  LoadCache();
125  }
126 
127 
132  }
133 
134 
155  pair <iTime, iTime> TgoCassisCamera::ShutterOpenCloseTimes(double time,
156  double exposureDuration) {
158  }
159 
160 
168  return (-143000);
169  }
170 
171 
179  return (1);
180  }
181 
182 
190  return (-143);
191  }
192 
193 
201  return (1);
202  }
203 
204 }
205 
215  return new Isis::TgoCassisCamera(cube);
216 }
TGO Cassis camera model.
void SetFocalLength()
Reads the focal length from the instrument kernel.
Definition: Camera.cpp:1430
virtual int SpkTargetId() const
SPK Target Body ID - TGO spacecraft -143.
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
virtual int CkReferenceId() const
CK Reference ID - J2000.
Isis::Camera * TgoCassisCameraPlugin(Isis::Cube &cube)
This is the function that is called in order to instantiate a TgoCassisCamera object.
QString m_instrumentNameLong
Full instrument name.
Definition: Camera.h:507
void SetDetectorSampleSumming(const double summing)
Set sample summing mode.
virtual int CkFrameId() const
CK frame ID - TGO CaSSIS instrument code (TGO_CASSIS_FSA)
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition: IString.cpp:108
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.
double toDouble(const QString &string)
Global function to convert from a string to a double.
Definition: IString.cpp:164
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.
~TgoCassisCamera()
Destroys the TgoCassisCamera object.
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
Distort/undistort focal plane coordinates.
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
virtual std::pair< iTime, iTime > ShutterOpenCloseTimes(double time, double exposureDuration)
Returns the shutter open and close times.
virtual int SpkReferenceId() const
SPK Reference ID - J2000.
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
void SetDistortionMap(CameraDistortionMap *map, bool deleteExisting=true)
Sets the Distortion Map.
Definition: Camera.cpp:2354
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
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