Include headers
In general, one only needs to include the following headerfiles.
#include "isce3/core/Orbit.h"
If one is looking to use this with other features from ISCE, you might need additional appropriate header files.
Orbit
isce3::core::Orbit is at the heart of all geometric manipulation in ISCE. This is just a time-tagged collection of state vectors. In this example, we will just walk through an example of constructing an Orbit object with a list of time-tagged position and velocity state vectors.
#include <sstream>
#include <fstream>
#include <iostream>
int main(int argc, char *argv[])
{
std::ifstream ifid("input_orbit.txt");
std::string line;
while(std::getline(ifid, line))
{
std::stringstream stream;
std::string aztime;
stream << line;
std::cout << line << "\n";
stream >> aztime >> pos[0] >> pos[1] >> pos[2] >> vel[0] >> vel[1] >> vel[2];
sv.datetime = aztime;
sv.position = pos;
sv.velocity = vel;
orbit.stateVectors.push_back(sv);
}
ifid.close();
orbit.reformatOrbit( orbit.stateVectors[0].date());
orbit.printOrbit();
return 0;
}
The "input_orbit.txt" file looks like
2016-04-08T09:13:13.000000 -3752316.976337 4925051.878499 3417259.473609 3505.330104 -1842.136554 6482.122476
2016-04-08T09:13:23.000000 -3717067.52658 4906329.056304 3481886.455117 3544.479224 -1902.402281 6443.152265
...
In the above example, we used a 7-column text file with datetime in ISO-8601 format, ECEF position (m) and ECEF velocity (m/s). Similar readers can be easily written to parse state vector information in other formats like HDF5, XML etc.
Forward mapping - determining bounding boxes
In this example, we will demonstrate the forward mapping algorithm by using it to determine approximate bounding boxes on the ground. See geometry overview for details on the implemented algorithm.
#include "isce3/core/LookSide.h"
#include <sstream>
#include <fstream>
#include <iostream>
int main(int argc, char *argv[])
{
...
std::vector<isce3::core::DateTime> timetags;
std::vector<double> ranges;
ranges.push_back(800000.);
ranges.push_back(950000.);
std::vector<double> zrange;
zrange.push_back(-100.);
zrange.push_back(2000.);
double wvl = 0.06;
std::vector<double> lats;
std::vector<double> lons;
for (int tt=0; tt<timetags.size(); tt++)
{
double tintp = timetags[tt].secondsSinceEpoch(orbit.refEpoch);
for(int rr=0; rr<ranges.size(); rr++)
{
double rng = ranges[rr];
for(int zz=0; zz<zrange.size(); zz++)
{
rng,
0.,
orbit,
ellipse,
constDEM,
llh,
wvl,
side,
5.0e-2,
2,
0,
isce3::core::Hermite);
lons.push_back(llh[0] * 180.0/M_PI);
lats.push_back(llh[1] * 180.0/M_PI);
}
}
}
auto lonresult = std::minmax_element(lons.begin(), lons.end());
std::cout << "Lon limits (deg): " << lons[lonresult.first - lons.begin()] << " "
<< lons[lonresult.second - lons.begin()] << "\n";
auto latresult = std::minmax_element(lats.begin(), lats.end());
std::cout << "Lat limits (deg): " << lats[latresult.first - lats.begin()] << " "
<< lats[latresult.second - lats.begin()] << "\n";
return 0;
}
Inverse mapping - locating corner reflectors
In this example, we will demonstrate the inverse mapping algorithm by using it to determine the location of a known target in a radar image.
#include "isce3/core/LookSide.h"
#include <sstream>
#include <fstream>
#include <iostream>
int main(int argc, char *argv[])
{
...
std::vector<isce3::core::cartesian_t> targets;
double wvl = 0.06;
isce3::product::ImageMode mode;
std::array<size_t,2> dims{{1500,1000}};
mode.dataDimensions(dims);
mode.prf(1000.);
mode.rangeBandwidth(20.0e6);
mode.wavelength(0.06);
mode.startingRange(8.0e5);
mode.rangePixelSpacing(10.);
mode.numberAzimuthLooks(10);
mode.numberRangeLooks(10);
mode.startAzTime(t0);
mode.endAzTime(t1);
dop.setCoeff(0,0,0.);
for (int tt=0; tt<targets.size(); tt++)
{
double rng;
double aztime;
llh[0] = targets[tt][0] * M_PI / 180.0;
llh[1] = targets[tt][1] * M_PI / 180.0;
llh[2] = targets[tt][2];
ellipse,
orbit,
dop,
mode,
aztime,
rng,
side,
1.0e-8,
51,
1.0e-8);
std::cout << "Target at: " << targets[tt][0] << " " << targets[tt][1] << " " << targets[tt][2] << "\n";
std::cout << "Estimated line number: " << (aztime - mode.startAzTime().secondsSinceEpoch(orbit.refEpoch)) * mode.prf() / mode.numberAzimuthLooks() << "\n";
std::cout << "Estimated pixel number: " << (rng - mode.startingRange())/mode.rangePixelSpacing() / mode.numberRangeLooks() << "\n\n";
}
return 0;
}