Isis 3 Programmer Reference
MiniRF.cpp
1
7/* SPDX-License-Identifier: CC0-1.0 */
8
9#include "MiniRF.h"
10
11#include <QString>
12
13#include "IString.h"
14#include "iTime.h"
15#include "IException.h"
16#include "RadarPulseMap.h"
17#include "RadarGroundRangeMap.h"
18#include "RadarSlantRangeMap.h"
19#include "RadarGroundMap.h"
20#include "RadarSkyMap.h"
21
22using namespace std;
23
24namespace Isis {
40
41 // LRO MiniRF naif instrument code = -85700
42 if (naifIkCode() == -85700) {
43 m_instrumentNameLong = "Miniature Radio Frequency";
44 m_instrumentNameShort = "Mini-RF";
45 m_spacecraftNameLong = "Lunar Reconnaissance Orbiter";
47 }
48 // Chandrayaan Mini-SAR instrument code = -86001
49 else if (naifIkCode() == -86001) {
50 m_instrumentNameLong = "Miniature Synthetic Aperture Radar";
51 m_instrumentNameShort = "Mini-SAR";
52 m_spacecraftNameLong = "Chandrayaan 1";
53 m_spacecraftNameShort = "Chan1";
54 }
55 else {
56 QString msg = "Cube does not appear to be a mini RF image";
57 throw IException(IException::Programmer, msg, _FILEINFO_);
58 }
59
60 // Get the ground range resolution (ScaledPixelHeight and ScaledPixelWidth
61 // are expected to be equal - mrf2isis checks for this)
62 Pvl &lab = *cube.label();
63 Isis::PvlGroup &inst = lab.findGroup("Instrument", Isis::Pvl::Traverse);
64 double groundRangeResolution = inst["ScaledPixelHeight"]; // meters
65
66 // Synthesize the pixel pitch to the ground range resolution
67 SetPixelPitch(groundRangeResolution); // meters/pix
68
69 // Focal length should always be slant range to the current ground
70 // point. This will be set each time the slant range is calculated.
71 // For now, set the focal length to 1.0.
72 SetFocalLength(1.0);
73
74 // Get the start time from labels (the SpacecraftClockStartCount is set to
75 // is set to UNK in the PDS labels, so StartTime is used instead)
76 SpiceDouble etStart = iTime((QString)inst["StartTime"]).Et();
77
78 // The line rate is in units of seconds in the PDS label. The exposure
79 // is the sum of the burst and the delay for the return. The movement of the
80 // spacecraft is negligible compared to the speed of light, so we are assuming
81 // the spacecraft hasn't moved between the burst and the return.
82 double lineRate = (double) inst["LineExposureDuration"];
83
84 // Get the incidence angle at the center of the image
85 double incidenceAngle = (double) inst["IncidenceAngle"];
86 incidenceAngle = incidenceAngle * Isis::PI / 180.0;
87
88 // Get the azimuth resolution at the center of the image
89 double azimuthResolution = (double) inst["AzimuthResolution"]; // label units are meters
90 azimuthResolution = azimuthResolution / 1000.0; // change to km
91
92 // Get the range resolution at the center of the image
93 double rangeResolution = (double) inst["RangeResolution"]; // label units are meters
94
95 // Get the wavelength or frequency of the instrument. This does not
96 // exist in the PDS labels, so it will need to be hardcoded until the
97 // PDS labels are updated. Right now, the mrf2isis program is putting
98 // a frequency value in the labels based on the instrument mode id.
99 double frequency = (double) inst["Frequency"]; // units are htz
100 double waveLength = clight_c() / frequency; // units are km/sec/htz
101
102 // Setup map from image(sample,line) to radar(sample,time)
103 new RadarPulseMap(this, etStart, lineRate);
104
105 // Setup map from radar(sample,time) to radar(groundrange,time)
106 Radar::LookDirection ldir = Radar::Right;
107 if((QString)inst["LookDirection"] == "LEFT") {
108 ldir = Radar::Left;
109 }
110 RadarGroundRangeMap::setTransform(naifIkCode(), groundRangeResolution,
111 this->Samples(), ldir);
112 new RadarGroundRangeMap(this, naifIkCode());
113
114 // Calculate weighting for focal plane coordinates. This is done
115 // because the focal plane coordinates (slant range and Doppler
116 // shift) do not have the same units of measurement and cannot
117 // be used by jigsaw as is. The weighting factors convert the
118 // focal plane coordinates into comparitive values. The weighting
119 // factor for the Doppler shift requires spacecraft pointing and
120 // velocity at the center of the image, so it is calculated
121 // after Spice gets loaded.
122 double range_sigma = rangeResolution * sin(incidenceAngle) * 100; // scaled meters
123 double etMid = etStart + 0.5 * (this->ParentLines() + 1) * lineRate;
124
125 // Setup the map from Radar(groundRange,t) to Radar(slantRange,t)
126 RadarSlantRangeMap *slantRangeMap = new RadarSlantRangeMap(this,
127 groundRangeResolution);
128 slantRangeMap->SetCoefficients(inst["RangeCoefficientSet"]);
129
130 // Setup the ground and sky map
131 RadarGroundMap *groundMap = new RadarGroundMap(this, ldir, waveLength);
132 groundMap->SetRangeSigma(range_sigma);
133 new RadarSkyMap(this);
134
135 // Set the time range to cover the cube
136 // Must be done last as the naif kernels will be unloaded
137 double etEnd = etStart + this->ParentLines() * lineRate + lineRate;
138 etStart = etStart - lineRate;
139 double tol = PixelResolution() / 100.;
140
141 if(tol < 0.) {
142 // Alternative calculation of .01*ground resolution of a pixel
143 setTime(etMid);
144 tol = PixelPitch() * SpacecraftAltitude() / FocalLength() / 100.;
145 }
146 Spice::createCache(etStart, etEnd, this->ParentLines() + 1, tol);
147 setTime(etMid);
148 SpiceRotation *bodyFrame = this->bodyRotation();
149 SpicePosition *spaceCraft = this->instrumentPosition();
150
151 SpiceDouble Ssc[6];
152 // Load the state into Ssc
153 vequ_c((SpiceDouble *) & (spaceCraft->Coordinate()[0]), Ssc);
154 vequ_c((SpiceDouble *) & (spaceCraft->Velocity()[0]), Ssc + 3);
155 // Create the J2000 to body-fixed state transformation matrix BJ
156 SpiceDouble BJ[6][6];
157 rav2xf_c(&(bodyFrame->Matrix()[0]), (SpiceDouble *) & (bodyFrame->AngularVelocity()[0]), BJ);
158 // Rotate the spacecraft state from J2000 to body-fixed
159 mxvg_c(BJ, Ssc, 6, 6, Ssc);
160 // Extract the body-fixed position and velocity
161 double Vsc[3];
162 double Xsc[3];
163 vequ_c(Ssc, Xsc);
164 vequ_c(Ssc + 3, Vsc);
165
167 this->radii(radii);
168 double R = radii[0].kilometers();
169 double height = sqrt(Xsc[0] * Xsc[0] + Xsc[1] * Xsc[1] + Xsc[2] * Xsc[2]) - R;
170 double speed = vnorm_c(Vsc);
171 double dopplerSigma = 2.0 * speed * azimuthResolution / (waveLength *
172 height / cos(incidenceAngle)) * 100.;
173 groundMap->SetDopplerSigma(dopplerSigma);
174 slantRangeMap->SetWeightFactors(range_sigma, dopplerSigma);
175 }
176
183 int MiniRF::CkFrameId() const {
184 std::string msg = "Cannot generate CK for MiniRF";
185 throw IException(IException::User, msg, _FILEINFO_);
186 }
187
195 std::string msg = "Cannot generate CK for MiniRF";
196 throw IException(IException::User, msg, _FILEINFO_);
197 }
198}
199
210extern "C" Isis::Camera *MiniRFPlugin(Isis::Cube &cube) {
211 return new Isis::MiniRF(cube);
212}
QString m_spacecraftNameLong
Full spacecraft name.
Definition Camera.h:499
int ParentLines() const
Returns the number of lines in the parent alphacube.
Definition Camera.cpp:2836
double PixelPitch() const
Returns the pixel pitch.
Definition Camera.cpp:2772
friend class RadarGroundMap
A friend class to calculate focal length.
Definition Camera.h:492
virtual double PixelResolution()
Returns the pixel resolution at the current position in meters/pixel.
Definition Camera.cpp:681
void SetFocalLength()
Reads the focal length from the instrument kernel.
Definition Camera.cpp:1422
void SetPixelPitch()
Reads the Pixel Pitch from the instrument kernel.
Definition Camera.cpp:1429
double FocalLength() const
Returns the focal length.
Definition Camera.cpp:2762
QString m_instrumentNameShort
Shortened instrument name.
Definition Camera.h:498
friend class RadarSlantRangeMap
A friend class to calculate focal length.
Definition Camera.h:493
QString m_spacecraftNameShort
Shortened spacecraft name.
Definition Camera.h:500
int Samples() const
Returns the number of samples in the image.
Definition Camera.cpp:2806
QString m_instrumentNameLong
Full instrument name.
Definition Camera.h:497
IO Handler for Isis Cubes.
Definition Cube.h:168
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition Cube.cpp:1707
Distance measurement, usually in meters.
Definition Distance.h:34
Isis exception class.
Definition IException.h:91
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition IException.h:126
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition IException.h:146
LRO Mini-RF SAR and Chandrayaan 1 Mini-RF SAR.
Definition MiniRF.h:56
virtual int CkReferenceId() const
CK Reference ID.
Definition MiniRF.cpp:194
virtual int CkFrameId() const
CK frame ID.
Definition MiniRF.cpp:183
MiniRF(Cube &cube)
Initialize the Mini-RF SAR radar model for LRO and Chandrayaan 1.
Definition MiniRF.cpp:39
Contains multiple PvlContainers.
Definition PvlGroup.h:41
Container for cube-like labels.
Definition Pvl.h:119
@ Traverse
Search child objects.
Definition PvlObject.h:158
Generic class for Radar Cameras.
Definition RadarCamera.h:31
Convert between undistorted focal plane coordinate (slant range) and ground coordinates.
void SetDopplerSigma(double dopplerSigma)
Set the doppler sigma.
void SetRangeSigma(double rangeSigma)
Set the range sigma.
Construct a mapping between image sample and Radar ground range.
Convert between alpha image coordinates and radar sample, time coordinates.
Convert between slantrange/groundrange and ra/dec coordinates.
Definition RadarSkyMap.h:31
Convert between radar ground range and slant range.
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:99
double SpacecraftAltitude()
Returns the distance from the spacecraft to the subspacecraft point in km.
Definition Sensor.cpp:703
virtual SpiceRotation * bodyRotation() const
Accessor method for the body rotation.
Definition Spice.cpp:1623
virtual 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:649
void radii(Distance r[3]) const
Returns the radii of the body in km.
Definition Spice.cpp:937
virtual SpicePosition * instrumentPosition() const
Accessor method for the instrument position.
Definition Spice.cpp:1612
SpiceInt naifIkCode() const
This returns the NAIF IK code to use when reading from instrument kernels.
Definition Spice.cpp:975
Obtain SPICE position information for a body.
Obtain SPICE rotation information for a body.
Parse and return pieces of a time string.
Definition iTime.h:65
double Et() const
Returns the ephemeris time (TDB) representation of the time as a double.
Definition iTime.h:126
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
const double PI
The mathematical constant PI.
Definition Constants.h:40
Namespace for the standard library.