USGS

Isis 3.0 Object Programmers' Reference

Home

ThemisVisCamera.cpp
Go to the documentation of this file.
1 
20 #include "ThemisVisCamera.h"
21 
22 #include <iomanip>
23 
24 #include <QDebug>
25 #include <QString>
26 
27 #include "CameraFocalPlaneMap.h"
28 #include "CameraSkyMap.h"
29 #include "iTime.h"
30 #include "NaifStatus.h"
33 #include "ThemisVisDistortionMap.h"
34 
35 
36 using namespace std;
37 
38 namespace Isis {
39 
50  ThemisVisCamera::ThemisVisCamera(Cube &cube) : PushFrameCamera(cube) {
52  // Set up the camera characteristics
53  // LoadFrameMounting("M01_SPACECRAFT","M01_THEMIS_VIS");
54  // Changed Focal Length from 203.9 (millimeters????) to 202.059, per request from
55  // Christopher Edwards (Christopher.Edwards@asu.edu) at ASU, on 2/18/11.
56  SetFocalLength(202.059);
57  SetPixelPitch(0.009);
58 
59  Pvl &lab = *cube.label();
60  PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
61 
62  // make sure it is a themis vis image
63  if(inst["InstrumentId"][0] != "THEMIS_VIS") {
64  QString msg = "Unable to create Themis VIS camera model from an image with InstrumentId ["
65  + inst["InstrumentId"][0] + "].";
67  }
68 
69  // Get necessary variables
70  p_exposureDur = inst["ExposureDuration"];
71  p_interframeDelay = inst["InterframeDelay"];
72  int sumMode = inst["SpatialSumming"];
73 
74  // Get the start and end time
75  double et;
76  QString stime = inst["SpacecraftClockCount"];
77  et = getClockTime(stime).Et();
78 
79  double offset = inst["SpacecraftClockOffset"];
80  p_etStart = et + offset - ((p_exposureDur / 1000.0) / 2.0);
81  p_nframes = inst["NumFramelets"];
82 
83  // Get the keywords from labels
84  PvlGroup &bandBin = lab.findGroup("BandBin", Pvl::Traverse);
85 
86  PvlKeyword &filterNumbers = bandBin["FilterNumber"];
87  for (int i = 0; i < filterNumbers.size(); i++) {
88  p_filterNumber.append(toInt(filterNumbers[i]));
89  }
90 
91 
92  // Setup detector map
93  double frameRate = p_interframeDelay;
94  //int frameletHeight = 192;
95  int frameletHeight = (int) (ParentLines() / ((double) p_nframes / (double) sumMode)); // = 192
97  new PushFrameCameraDetectorMap(this, p_etStart, frameRate, frameletHeight);
98  dmap->SetDetectorSampleSumming(sumMode);
99  dmap->SetDetectorLineSumming(sumMode);
100  dmap->SetFrameletOrderReversed(false, p_nframes); // these framelets are in time ascending order
101  //(i.e. the order is not reversed)
102  // dmap->SetFrameletsGeometricallyFlipped(true); this is not set... looks like it defaults to true???
103  // We do not want to set the exposure duration in the detector map, let it default to 0.0...
104 
105  // Setup focal plane map
106  CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, naifIkCode());
107  focalMap->SetDetectorOrigin(512.5, 512.5);
108 
109  // Setup distortion map
110  new ThemisVisDistortionMap(this);
111 
112  // Setup the ground and sky map
113  bool evenFramelets = (inst["Framelets"][0] == "Even");
114  new PushFrameCameraGroundMap(this, evenFramelets);
115  new CameraSkyMap(this);
116 
117  LoadCache();
119  }
120 
121 
122 
124  }
125 
126 
127 
133  void ThemisVisCamera::SetBand(const int vband) {
134  Camera::SetBand(vband);
135 
136  // Set the et
137  double et = p_etStart + BandEphemerisTimeOffset(vband);
138  setTime(et);
140  dmap->SetStartTime(et);
141  }
142 
143 
144 
154  // Lookup the time band corresponding to this ISIS cube band
155  // number based on the FilterNumber keyword in the BandBin group.
156  // Filter numbers indicate the physical location of the band in
157  // the detector array. They are numbered by ascending times.
158  // (filter number = time band)
159  int timeBand = p_filterNumber[vband - 1];
160 
161  if (HasReferenceBand()) {
162  // If there is a reference band, the data has all been aligned in the band dimension
163 
164  // VIS BandNumbers (including the reference band) are numbered by ascending filter
165  // wavelength. Convert the wavelength band to a time band (filter number).
166  int wavelengthToTimeBand[] = { 2, 5, 3, 4, 1 };
167  timeBand = wavelengthToTimeBand[ReferenceBand() - 1];
168  }
169 
170  // Compute the time offset for this detector line.
171  // Subtract 1 from the time band then multiply by the interframe delay then
172  // subtract half the exposure duration, in seconds.
173  //
174  // Subtracting 1 from the time band number calculates the appropriate
175  // number of interframe delay multiples for this filter number (recall this
176  // corresponds to a location on the ccd)
177  p_bandTimeOffset = ((timeBand - 1) * p_interframeDelay) - ((p_exposureDur / 1000.0) / 2.0);
178 
179  // Set the detector first line for this band on the ccd.
180  // The VIS band first row values are 1-based detector row numbers
181  // used for the beginning (bottom) of the 192-row framelet for the various bands.
182  // These row values correspond directly to the filter numbers (time bands) {1, 2, 3, 4, 5}.
183  // Obtained from the NAIF instrument kernel.
184  // Note that row 1 is the first detector row to see an area of the ground.
185  int visBandFirstRow[] = { 4, 203, 404, 612, 814 };
187  dmap->SetBandFirstDetectorLine(visBandFirstRow[timeBand - 1]);
188 
189  return p_bandTimeOffset;
190  }
191 
192 
193 
201  return false;
202  }
203 
204 
205 
213  return -53000;
214  }
215 
216 
217 
225  return 16;
226  }
227 
228 
229 
237  return 1;
238  }
239 }
240 
241 
242 // Plugin
254  return new Isis::ThemisVisCamera(cube);
255 }