Isis 3 Programmer Reference
MiniRF.cpp
Go to the documentation of this file.
1 
22 #include "MiniRF.h"
23 
24 #include <QString>
25 
26 #include "IString.h"
27 #include "iTime.h"
28 #include "IException.h"
29 #include "RadarPulseMap.h"
30 #include "RadarGroundRangeMap.h"
31 #include "RadarSlantRangeMap.h"
32 #include "RadarGroundMap.h"
33 #include "RadarSkyMap.h"
34 
35 using namespace std;
36 
37 namespace Isis {
52  MiniRF::MiniRF(Isis::Cube &cube) : Isis::RadarCamera(cube) {
53 
54  // LRO MiniRF naif instrument code = -85700
55  if (naifIkCode() == -85700) {
56  m_instrumentNameLong = "Miniature Radio Frequency";
57  m_instrumentNameShort = "Mini-RF";
58  m_spacecraftNameLong = "Lunar Reconnaissance Orbiter";
59  m_spacecraftNameShort = "LRO";
60  }
61  // Chandrayaan Mini-SAR instrument code = -86001
62  else if (naifIkCode() == -86001) {
63  m_instrumentNameLong = "Miniature Synthetic Aperture Radar";
64  m_instrumentNameShort = "Mini-SAR";
65  m_spacecraftNameLong = "Chandrayaan 1";
66  m_spacecraftNameShort = "Chan1";
67  }
68  else {
69  QString msg = "Cube does not appear to be a mini RF image";
71  }
72 
73  // Get the ground range resolution (ScaledPixelHeight and ScaledPixelWidth
74  // are expected to be equal - mrf2isis checks for this)
75  Pvl &lab = *cube.label();
76  Isis::PvlGroup &inst = lab.findGroup("Instrument", Isis::Pvl::Traverse);
77  double groundRangeResolution = inst["ScaledPixelHeight"]; // meters
78 
79  // Synthesize the pixel pitch to the ground range resolution
80  SetPixelPitch(groundRangeResolution); // meters/pix
81 
82  // Focal length should always be slant range to the current ground
83  // point. This will be set each time the slant range is calculated.
84  // For now, set the focal length to 1.0.
85  SetFocalLength(1.0);
86 
87  // Get the start time from labels (the SpacecraftClockStartCount is set to
88  // is set to UNK in the PDS labels, so StartTime is used instead)
89  SpiceDouble etStart = iTime((QString)inst["StartTime"]).Et();
90 
91  // The line rate is in units of seconds in the PDS label. The exposure
92  // is the sum of the burst and the delay for the return. The movement of the
93  // spacecraft is negligible compared to the speed of light, so we are assuming
94  // the spacecraft hasn't moved between the burst and the return.
95  double lineRate = (double) inst["LineExposureDuration"];
96 
97  // Get the incidence angle at the center of the image
98  double incidenceAngle = (double) inst["IncidenceAngle"];
99  incidenceAngle = incidenceAngle * Isis::PI / 180.0;
100 
101  // Get the azimuth resolution at the center of the image
102  double azimuthResolution = (double) inst["AzimuthResolution"]; // label units are meters
103  azimuthResolution = azimuthResolution / 1000.0; // change to km
104 
105  // Get the range resolution at the center of the image
106  double rangeResolution = (double) inst["RangeResolution"]; // label units are meters
107 
108  // Get the wavelength or frequency of the instrument. This does not
109  // exist in the PDS labels, so it will need to be hardcoded until the
110  // PDS labels are updated. Right now, the mrf2isis program is putting
111  // a frequency value in the labels based on the instrument mode id.
112  double frequency = (double) inst["Frequency"]; // units are htz
113  double waveLength = clight_c() / frequency; // units are km/sec/htz
114 
115  // Setup map from image(sample,line) to radar(sample,time)
116  new RadarPulseMap(this, etStart, lineRate);
117 
118  // Setup map from radar(sample,time) to radar(groundrange,time)
119  Radar::LookDirection ldir = Radar::Right;
120  if((QString)inst["LookDirection"] == "LEFT") {
121  ldir = Radar::Left;
122  }
123  RadarGroundRangeMap::setTransform(naifIkCode(), groundRangeResolution,
124  this->Samples(), ldir);
125  new RadarGroundRangeMap(this, naifIkCode());
126 
127  // Calculate weighting for focal plane coordinates. This is done
128  // because the focal plane coordinates (slant range and Doppler
129  // shift) do not have the same units of measurement and cannot
130  // be used by jigsaw as is. The weighting factors convert the
131  // focal plane coordinates into comparitive values. The weighting
132  // factor for the Doppler shift requires spacecraft pointing and
133  // velocity at the center of the image, so it is calculated
134  // after Spice gets loaded.
135  double range_sigma = rangeResolution * sin(incidenceAngle) * 100; // scaled meters
136  double etMid = etStart + 0.5 * (this->ParentLines() + 1) * lineRate;
137 
138  // Setup the map from Radar(groundRange,t) to Radar(slantRange,t)
139  RadarSlantRangeMap *slantRangeMap = new RadarSlantRangeMap(this,
140  groundRangeResolution);
141  slantRangeMap->SetCoefficients(inst["RangeCoefficientSet"]);
142 
143  // Setup the ground and sky map
144  RadarGroundMap *groundMap = new RadarGroundMap(this, ldir, waveLength);
145  groundMap->SetRangeSigma(range_sigma);
146  new RadarSkyMap(this);
147 
148  // Set the time range to cover the cube
149  // Must be done last as the naif kernels will be unloaded
150  double etEnd = etStart + this->ParentLines() * lineRate + lineRate;
151  etStart = etStart - lineRate;
152  double tol = PixelResolution() / 100.;
153 
154  if(tol < 0.) {
155  // Alternative calculation of .01*ground resolution of a pixel
156  setTime(etMid);
157  tol = PixelPitch() * SpacecraftAltitude() / FocalLength() / 100.;
158  }
159  Spice::createCache(etStart, etEnd, this->ParentLines() + 1, tol);
160  setTime(etMid);
161  SpiceRotation *bodyFrame = this->bodyRotation();
162  SpicePosition *spaceCraft = this->instrumentPosition();
163 
164  SpiceDouble Ssc[6];
165  // Load the state into Ssc
166  vequ_c((SpiceDouble *) & (spaceCraft->Coordinate()[0]), Ssc);
167  vequ_c((SpiceDouble *) & (spaceCraft->Velocity()[0]), Ssc + 3);
168  // Create the J2000 to body-fixed state transformation matrix BJ
169  SpiceDouble BJ[6][6];
170  rav2xf_c(&(bodyFrame->Matrix()[0]), (SpiceDouble *) & (bodyFrame->AngularVelocity()[0]), BJ);
171  // Rotate the spacecraft state from J2000 to body-fixed
172  mxvg_c(BJ, Ssc, 6, 6, Ssc);
173  // Extract the body-fixed position and velocity
174  double Vsc[3];
175  double Xsc[3];
176  vequ_c(Ssc, Xsc);
177  vequ_c(Ssc + 3, Vsc);
178 
180  this->radii(radii);
181  double R = radii[0].kilometers();
182  double height = sqrt(Xsc[0] * Xsc[0] + Xsc[1] * Xsc[1] + Xsc[2] * Xsc[2]) - R;
183  double speed = vnorm_c(Vsc);
184  double dopplerSigma = 2.0 * speed * azimuthResolution / (waveLength *
185  height / cos(incidenceAngle)) * 100.;
186  groundMap->SetDopplerSigma(dopplerSigma);
187  slantRangeMap->SetWeightFactors(range_sigma, dopplerSigma);
188  }
189 
196  int MiniRF::CkFrameId() const {
197  std::string msg = "Cannot generate CK for MiniRF";
199  }
200 
207  int MiniRF::CkReferenceId() const {
208  std::string msg = "Cannot generate CK for MiniRF";
210  }
211 }
212 
224  return new Isis::MiniRF(cube);
225 }
SpicePosition * instrumentPosition() const
Accessor method for the instrument position.
Definition: Spice.cpp:1467
void SetWeightFactors(double range_sigma, double doppler_sigma)
Set the weight factors for slant range and Doppler shift.
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
LRO Mini-RF SAR and Chandrayaan 1 Mini-RF SAR.
Definition: MiniRF.h:68
std::vector< double > Matrix()
Return the full rotation TJ as a matrix.
Parse and return pieces of a time string.
Definition: iTime.h:78
const double PI
The mathematical constant PI.
Definition: Constants.h:56
friend class RadarGroundMap
A friend class to calculate focal length.
Definition: Camera.h:502
Convert between alpha image coordinates and radar sample, time coordinates.
Definition: RadarPulseMap.h:51
QString m_instrumentNameLong
Full instrument name.
Definition: Camera.h:507
SpiceRotation * bodyRotation() const
Accessor method for the body rotation.
Definition: Spice.cpp:1478
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
std::vector< double > AngularVelocity()
Accessor method to get the angular velocity.
void SetDopplerSigma(double dopplerSigma)
Set the doppler sigma.
virtual int CkReferenceId() const
CK Reference ID.
Definition: MiniRF.cpp:207
void createCache(iTime startTime, iTime endTime, const int size, double tol)
This method creates an internal cache of spacecraft and sun positions over a specified time range...
Definition: Spice.cpp:574
void SetRangeSigma(double rangeSigma)
Set the range sigma.
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:162
Distance measurement, usually in meters.
Definition: Distance.h:47
friend class RadarSlantRangeMap
A friend class to calculate focal length.
Definition: Camera.h:503
int ParentLines() const
Returns the number of lines in the parent alphacube.
Definition: Camera.cpp:2818
virtual int CkFrameId() const
CK frame ID.
Definition: MiniRF.cpp:196
Convert between undistorted focal plane coordinate (slant range) and ground coordinates.
Construct a mapping between image sample and Radar ground range.
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 could only have occurred due to a mistake on the user&#39;s part (e...
Definition: IException.h:142
const std::vector< double > & Coordinate()
Return the current J2000 position.
double FocalLength() const
Returns the focal length.
Definition: Camera.cpp:2744
double PixelPitch() const
Returns the pixel pitch.
Definition: Camera.cpp:2754
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
Obtain SPICE rotation information for a body.
Container for cube-like labels.
Definition: Pvl.h:135
Isis::Camera * MiniRFPlugin(Isis::Cube &cube)
This is the function that is called in order to instantiate a MiniRF object.
Definition: MiniRF.cpp:223
double SpacecraftAltitude()
Returns the distance from the spacecraft to the subspacecraft point in km.
Definition: Sensor.cpp:712
void SetCoefficients(PvlKeyword &keyword)
Load the ground range/slant range coefficients from the RangeCoefficientSet keyword.
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
Convert between slantrange/groundrange and ra/dec coordinates.
Definition: RadarSkyMap.h:48
int Samples() const
Returns the number of samples in the image.
Definition: Camera.cpp:2788
Convert between radar ground range and slant range.
double PixelResolution()
Returns the pixel resolution at the current position in meters/pixel.
Definition: Camera.cpp:689
Isis exception class.
Definition: IException.h:107
Obtain SPICE position information for a body.
const std::vector< double > & Velocity()
Return the current J2000 velocity.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
QString m_spacecraftNameShort
Shortened spacecraft name.
Definition: Camera.h:510
Generic class for Radar Cameras.
Definition: RadarCamera.h:47
void radii(Distance r[3]) const
Returns the radii of the body in km.
Definition: Spice.cpp:855
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