USGS

Isis 3.0 Object Programmers' Reference

Home

VimsCamera.cpp
Go to the documentation of this file.
1 
21 #include "VimsCamera.h"
22 #include "VimsGroundMap.h"
23 #include "VimsSkyMap.h"
24 
25 #include <fstream>
26 #include <iostream>
27 #include <iomanip>
28 
29 #include <QDebug>
30 #include <QList>
31 #include <QPointF>
32 
33 #include "CameraDetectorMap.h"
34 #include "CameraDistortionMap.h"
35 #include "CameraFocalPlaneMap.h"
36 #include "Constants.h"
37 #include "FileName.h"
38 #include "IException.h"
39 #include "IString.h"
40 #include "iTime.h"
41 #include "NaifStatus.h"
42 #include "SpecialPixel.h"
43 
44 using namespace std;
45 
46 namespace Isis {
61  VimsCamera::VimsCamera(Cube &cube) : Camera(cube) {
63 
64  Pvl &lab = *cube.label();
65  PvlGroup &inst = lab.findGroup("Instrument", Pvl::Traverse);
66  QString channel = (QString) inst ["Channel"];
67 
68  // Vims pixel pitch is not always square, but Isis does not have the ability to store
69  // more than a single value for pixel pitch. Member variables for pixelPitch x and y
70  // were created for proper calculation of ifov.
71  if (channel == "VIS") {
72  //LoadFrameMounting ("CASSINI_SC_COORD","CASSINI_VIMS_V");
73 
74  SetFocalLength(143.0);
75  if (QString((QString)inst["SamplingMode"]).toUpper() == "NORMAL") {
76  SetPixelPitch(3 * .024);
77  // Should this .506? According to 2002 paper ground calibration shows .506 +/- .003 mrad
78  m_pixelPitchX = 0.024 * 3;
79  m_pixelPitchY = 0.024 * 3;
80  }
81  else if (QString((QString)inst["SamplingMode"]).toUpper() == "HI-RES") {
82  SetPixelPitch(.024);
83  m_pixelPitchX = 0.024;
84  m_pixelPitchY = 0.024;
85  }
86  else if (QString((QString)inst["SamplingMode"]).toUpper() == "UNDER") {
87  QString msg = "Isis cannot process images with a SamplingMode = \"UNDER\" (or NYQUIST)";
89  }
90  else {
91  QString msg = "Unknown SamplingMode [" + (QString) inst["SamplingMode"] + "]";
93  }
94  }
95  else if (channel == "IR") {
96  //LoadFrameMounting ("CASSINI_SC_COORD","CASSINI_VIMS_IR");
97 
98  SetFocalLength(426.0);
99  SetPixelPitch(.2);
100  if (QString((QString)inst["SamplingMode"]).toUpper() == "NORMAL") {
101  m_pixelPitchX = 0.2;
102  m_pixelPitchY = 0.2;
103  }
104  else if (QString((QString)inst["SamplingMode"]).toUpper() == "HI-RES") {
105  m_pixelPitchX = 0.103;
106  m_pixelPitchY = 0.2;
107  }
108  else if (QString((QString)inst["SamplingMode"]).toUpper() == "UNDER") {
109  QString msg = "Isis cannot process images with a SamplingMode = \"UNDER\" (or NYQUIST)";
111  }
112  else {
113  QString msg = "Unknown SamplingMode [" + (QString) inst["SamplingMode"] + "]";
115  }
116  }
117 
118  // Get the start time in et
119  QString stime = inst ["NativeStartTime"][0];
120  QString intTime = stime.split(".").first();
121  stime = stime.split(".").last();
122 
123  double etStart = getClockTime(intTime).Et();
124 
125  // Add 2 seconds to either side of time range because the time are for IR
126  // channel, the VIS may actually start integrating before NATIVE_START_TIME.
127  // This insures the cache is large enough.
128  etStart += toDouble(stime) / 15959.0 - 2.;
129 
130  // Get the end time in et
131  QString etime = (QString) inst ["NativeStopTime"];
132  intTime = etime.split(".").first();
133  etime = etime.split(".").last();
134 
135  double etStop = getClockTime(intTime).Et();
136 
137  // Add 2 seconds to either side of time range because the time are for IR
138  // channel, the VIS may actually start integrating before NATIVE_START_TIME.
139  // This insures the cache is large enough.
140  etStop += toDouble(stime) / 15959.0 + 2.;
141 
142  // Setup detector map
143  new CameraDetectorMap(this);
144 
145  // Setup focal plane map
146  new CameraFocalPlaneMap(this, naifIkCode());
147 
148  // Setup distortion map
149  new CameraDistortionMap(this);
150 
151  // Setup the ground and sky map
152  new VimsGroundMap(this, lab);
153  new VimsSkyMap(this, lab);
154 
155  ((VimsGroundMap *)GroundMap())->Init(lab);
156  ((VimsSkyMap *)SkyMap())->Init(lab);
157 
158  double tol = PixelResolution();
159 
160  if (tol < 0.) {
161  // Alternative calculation of .01*ground resolution of a pixel
162  tol = PixelPitch() * SpacecraftAltitude() / FocalLength() / 1000. / 100.;
163  }
164 
165  if (channel == "VIS") createCache(etStart, etStop, 64 * 64, tol);
166  if (channel == "IR") createCache(etStart, etStop, 64 * 64, tol);
167 
168  // Call SetImage so that the et is reset to beginning of image w/o
169  // padding.
170  IgnoreProjection(true);
171  SetImage(1, 1);
172  IgnoreProjection(false);
174  return;
175  }
176 
177 
187 
188  QList<QPointF> offsets;
189 
190  // Create 100 pts on each edge of pixel
191  int npts = 100;
192 
193  // Top edge of pixel
194  for (double x = -m_pixelPitchX / 2.0; x <= m_pixelPitchX / 2.0; x += m_pixelPitchX / (npts-1)) {
195  offsets.append(QPointF(x, -m_pixelPitchY / 2.0));
196  }
197  // Right edge of pixel
198  for (double y = -m_pixelPitchY / 2.0; y <= m_pixelPitchY / 2.0; y += m_pixelPitchY / (npts-1)) {
199  offsets.append(QPointF(m_pixelPitchX / 2.0, y));
200  }
201  // Bottom edge of pixel
202  for (double x = m_pixelPitchX / 2.0; x >= -m_pixelPitchX / 2.0; x -= m_pixelPitchX / (npts-1)) {
203  offsets.append(QPointF(x, m_pixelPitchY / 2.0));
204  }
205  // Left edge of pixel
206  for (double y = m_pixelPitchY / 2.0; y >= -m_pixelPitchY / 2.0; y -= m_pixelPitchY / (npts-1)) {
207  offsets.append(QPointF(-m_pixelPitchX / 2.0, y));
208  }
209 
210  return offsets;
211  }
212 }
213 
214 // Plugin
226  return new Isis::VimsCamera(cube);
227 }
228