Isis 3 Programmer Reference
HiriseCamera.cpp
Go to the documentation of this file.
1 
23 #include "HiriseCamera.h"
24 
25 #include <string>
26 #include <iomanip>
27 
28 #include <QString>
29 
30 #include "CameraDistortionMap.h"
31 #include "CameraFocalPlaneMap.h"
32 #include "iTime.h"
35 #include "LineScanCameraSkyMap.h"
36 #include "NaifStatus.h"
37 
38 using namespace std;
39 namespace Isis {
47  HiriseCamera::HiriseCamera(Cube &cube) : LineScanCamera(cube) {
48  m_instrumentNameLong = "High Resolution Imaging Science Experiment";
49  m_instrumentNameShort = "HiRISE";
50  m_spacecraftNameLong = "Mars Reconnaissance Orbiter";
51  m_spacecraftNameShort = "MRO";
52 
54  // Setup camera characteristics from instrument and frame kernel
56  SetPixelPitch();
57  //LoadFrameMounting("MRO_SPACECRAFT", "MRO_HIRISE_OPTICAL_AXIS");
58  instrumentRotation()->SetFrame(-74690);
59 
60  // Get required keywords from instrument group
61  Pvl &lab = *cube.label();
62  PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
63  int tdiMode = inst["Tdi"];
64  double binMode = inst["Summing"];
65  int chan = inst["ChannelNumber"];
66  int cpmm = inst["CpmmNumber"];
67  double deltaLineTimerCount = inst["DeltaLineTimerCount"];
68  QString stime = inst["SpacecraftClockStartCount"];
69 
70  // Convert CPMM number to CCD number
71  static int cpmm2ccd[] = {0, 1, 2, 3, 12, 4, 10, 11, 5, 13, 6, 7, 8, 9};
72  int ccd = cpmm2ccd[cpmm];
73 
74  // Compute the line rate, convert to seconds, and multiply by the
75  // downtrack summing
76  double unBinnedRate = (74.0 + (deltaLineTimerCount / 16.0)) / 1000000.0;
77  double lineRate = unBinnedRate * binMode;
78 
79  // Convert the spacecraft clock count to ephemeris time
80  SpiceDouble et;
81  // The -74999 is the code to select the transformation from
82  // high-precision MRO SCLK to ET
83  et = getClockTime(stime, -74999).Et();
84 
85  // Adjust the start time so that it is the effective time for
86  // the first line in the image file. Note that on 2006-03-29, this
87  // time is now subtracted as opposed to adding it. The computed start
88  // time in the EDR is at the first serial line.
89  et -= unBinnedRate * (((double) tdiMode / 2.0) - 0.5);
90  // Effective observation
91  // time for all the TDI lines used for the
92  // first line before doing binning
93  et += unBinnedRate * (((double) binMode / 2.0) - 0.5);
94  // Effective observation time of the first line
95  // in the image file, which is possibly binned
96 
97  // Compute effective line number within the CCD (in pixels) for the
98  // given TDI mode.
99  // This is the "centered" 0-based line number, where line 0 is the
100  // center of the detector array and line numbers decrease going
101  // towards the serial readout. Line number +64 sees a spot
102  // on the ground before line number 0 or -64.
103  double ccdLine_c = -64.0 + ((double) tdiMode / 2.0);
104 
105  // Setup detector map for transform of image pixels to detector position
106  // CameraDetectorMap *detectorMap =
107  // new LineScanCameraDetectorMap(this,et,lineRate);
108  LineScanCameraDetectorMap *detectorMap =
109  new LineScanCameraDetectorMap(this, et, lineRate);
110  detectorMap->SetDetectorSampleSumming(binMode);
111  detectorMap->SetDetectorLineSumming(binMode);
112  if(chan == 0) {
113  detectorMap->SetStartingDetectorSample(1025.0);
114  }
115 
116  // Setup focal plane map for transform of detector position to
117  // focal plane x/y. This will read the appropriate CCD
118  // transformation coefficients from the instrument kernel
119  CameraFocalPlaneMap *focalMap =
120  new CameraFocalPlaneMap(this, -74600 - ccd);
121  focalMap->SetDetectorOrigin(1024.5, 0.0);
122  focalMap->SetDetectorOffset(0.0, ccdLine_c);
123 
124  // Setup distortion map. This will read the optical distortion
125  // coefficients from the instrument kernel
126  CameraDistortionMap *distortionMap = new CameraDistortionMap(this);
127  distortionMap->SetDistortion(naifIkCode());
128 
129  // Setup the ground and sky map to transform undistorted focal
130  // plane x/y to lat/lon or ra/dec respectively.
131  new LineScanCameraGroundMap(this);
132  new LineScanCameraSkyMap(this);
133 
134  LoadCache();
136  }
137 
140 }
141 
142 
154  return new Isis::HiriseCamera(cube);
155 }
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
void SetDetectorOffset(const double sampleOffset, const double lineOffset)
Set the detector offset.
Hirise Camera Model.
Definition: HiriseCamera.h:60
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.
Generic class for Line Scan Cameras.
Search child objects.
Definition: PvlObject.h:170
virtual void SetDistortion(int naifIkCode)
Load distortion coefficients.
void SetDetectorOrigin(const double sample, const double line)
Set the detector origin.
void SetDetectorLineSumming(const double summing)
Set line summing mode.
Convert between undistorted focal plane and ground coordinates.
void SetFrame(int frameCode)
Change the frame to the given frame code.
Convert between distorted focal plane and detector coordinates.
QString m_instrumentNameShort
Shortened instrument name.
Definition: Camera.h:508
~HiriseCamera()
Destroys the HiriseCamera object.
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
Isis::Camera * HiriseCameraPlugin(Isis::Cube &cube)
This is the function that is called in order to instantiate a HiriseCamera object.
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
Distort/undistort focal plane coordinates.
Container for cube-like labels.
Definition: Pvl.h:135
Convert between undistorted focal plane and ra/dec coordinates.
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
void SetStartingDetectorSample(const double sample)
Set the starting detector sample.
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Definition: NaifStatus.cpp:43
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
SpiceRotation * instrumentRotation() const
Accessor method for the instrument rotation.
Definition: Spice.cpp:1489
QString m_spacecraftNameShort
Shortened spacecraft name.
Definition: Camera.h:510
Convert between parent image coordinates and detector coordinates.
double Et() const
Returns the ephemeris time (TDB) representation of the time as a double.
Definition: iTime.h:139
IO Handler for Isis Cubes.
Definition: Cube.h:170