Skip to content

Commit e3afbb3

Browse files
gshiromaGitHub Enterprise
authored andcommitted
Set ENU as the default coordinates for cubes LOS and along-track unit vectors (#772)
* add new parameter to set the EPSG for LOS and along-track unit vectors at C++ level * updating python bindings after adding new parameter to set the EPSG for LOS and along-track unit vectors * update python unitest * update C++ unitest * Update interface with functions that create metadata data cubes with the new parameter to set the EPSG for LOS and along-track unit vectors * add message to unitest to inform which EPSG is being processed * move new parameter to the end for backwards compatibility * move definition of projection for LOS and along-track unit vectors outside the writeVectorDerivedCubes() function to improve efficiency * set default epsg_los_and_along_track_vectors to zero in the header; update docstrings
1 parent c2d3fe3 commit e3afbb3

File tree

6 files changed

+86
-41
lines changed

6 files changed

+86
-41
lines changed

cxx/isce3/geometry/metadataCubes.cpp

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static inline void writeVectorDerivedCubes(const int array_pos_i,
6464
const isce3::core::Vec3& target_llh,
6565
const isce3::core::Vec3& target_proj, const isce3::core::Orbit& orbit,
6666
const isce3::core::Ellipsoid& ellipsoid,
67-
const isce3::core::ProjectionBase* proj,
67+
const isce3::core::ProjectionBase* proj_los_and_along_track_vectors,
6868
isce3::io::Raster* incidence_angle_raster,
6969
isce3::core::Matrix<float>& incidence_angle_array,
7070
isce3::io::Raster* los_unit_vector_x_raster,
@@ -132,8 +132,8 @@ static inline void writeVectorDerivedCubes(const int array_pos_i,
132132
}
133133

134134

135-
// If lat/lon, compute vectors in ENU coordinates around target
136-
if (proj->code() == 4326) {
135+
// If null, compute vectors in ENU coordinates around target
136+
if (proj_los_and_along_track_vectors == nullptr) {
137137

138138
// LOS unit vector X (ENU)
139139
if (los_unit_vector_x_raster != nullptr) {
@@ -173,7 +173,7 @@ static inline void writeVectorDerivedCubes(const int array_pos_i,
173173
const isce3::core::Vec3 target_to_sat_next_llh =
174174
ellipsoid.xyzToLonLat(target_to_sat_next_xyz);
175175
isce3::core::Vec3 target_to_sat_next_proj =
176-
proj->forward(target_to_sat_next_llh);
176+
proj_los_and_along_track_vectors->forward(target_to_sat_next_llh);
177177
const isce3::core::Vec3 look_vector_proj =
178178
(target_to_sat_next_proj - target_proj).normalized();
179179

@@ -233,11 +233,13 @@ static inline void writeVectorDerivedCubes(const int array_pos_i,
233233
// Compute velocity vector (proj)
234234
const isce3::core::Vec3 sat_next_llh =
235235
ellipsoid.xyzToLonLat(sat_next_xyz);
236-
const isce3::core::Vec3 sat_next_proj = proj->forward(sat_next_llh);
236+
const isce3::core::Vec3 sat_next_proj =
237+
proj_los_and_along_track_vectors->forward(sat_next_llh);
237238

238239
const isce3::core::Vec3 sat_previous_llh =
239240
ellipsoid.xyzToLonLat(sat_xyz_previous);
240-
const isce3::core::Vec3 sat_previous_proj = proj->forward(sat_previous_llh);
241+
const isce3::core::Vec3 sat_previous_proj =
242+
proj_los_and_along_track_vectors->forward(sat_previous_llh);
241243

242244
const isce3::core::Vec3 along_track_unit_vector =
243245
(sat_next_proj - sat_previous_proj).normalized();
@@ -262,6 +264,7 @@ void makeRadarGridCubes(const isce3::product::RadarGridParameters& radar_grid,
262264
const isce3::core::Orbit& orbit,
263265
const isce3::core::LUT2d<double>& native_doppler,
264266
const isce3::core::LUT2d<double>& grid_doppler,
267+
const int epsg_los_and_along_track_vectors,
265268
isce3::io::Raster* slant_range_raster,
266269
isce3::io::Raster* azimuth_time_raster,
267270
isce3::io::Raster* incidence_angle_raster,
@@ -286,6 +289,12 @@ void makeRadarGridCubes(const isce3::product::RadarGridParameters& radar_grid,
286289
for (int height_count = 0; height_count < heights.size(); ++height_count) {
287290

288291
auto proj = isce3::core::makeProjection(geogrid.epsg());
292+
std::unique_ptr<ProjectionBase>
293+
proj_los_and_along_track_vectors =
294+
(epsg_los_and_along_track_vectors == 0 or
295+
epsg_los_and_along_track_vectors == 4326) ?
296+
nullptr :
297+
isce3::core::makeProjection(epsg_los_and_along_track_vectors);
289298

290299
const isce3::core::Ellipsoid& ellipsoid = proj->ellipsoid();
291300

@@ -377,10 +386,10 @@ void makeRadarGridCubes(const isce3::product::RadarGridParameters& radar_grid,
377386

378387
isce3::geometry::writeVectorDerivedCubes(
379388
i, j, native_azimuth_time, target_llh, target_proj,
380-
orbit, ellipsoid, proj.get(), incidence_angle_raster,
381-
incidence_angle_array, los_unit_vector_x_raster,
382-
los_unit_vector_x_array, los_unit_vector_y_raster,
383-
los_unit_vector_y_array,
389+
orbit, ellipsoid, proj_los_and_along_track_vectors.get(),
390+
incidence_angle_raster, incidence_angle_array,
391+
los_unit_vector_x_raster, los_unit_vector_x_array,
392+
los_unit_vector_y_raster, los_unit_vector_y_array,
384393
along_track_unit_vector_x_raster,
385394
along_track_unit_vector_x_array,
386395
along_track_unit_vector_y_raster,
@@ -448,6 +457,7 @@ void makeGeolocationGridCubes(
448457
const std::vector<double>& heights, const isce3::core::Orbit& orbit,
449458
const isce3::core::LUT2d<double>& native_doppler,
450459
const isce3::core::LUT2d<double>& grid_doppler, const int epsg,
460+
const int epsg_los_and_along_track_vectors,
451461
isce3::io::Raster* coordinate_x_raster,
452462
isce3::io::Raster* coordinate_y_raster,
453463
isce3::io::Raster* incidence_angle_raster,
@@ -471,9 +481,15 @@ void makeGeolocationGridCubes(
471481
for (int height_count = 0; height_count < heights.size(); ++height_count) {
472482

473483
auto proj = isce3::core::makeProjection(epsg);
474-
475484
const isce3::core::Ellipsoid& ellipsoid = proj->ellipsoid();
476485

486+
std::unique_ptr<ProjectionBase>
487+
proj_los_and_along_track_vectors =
488+
(epsg_los_and_along_track_vectors == 0 or
489+
epsg_los_and_along_track_vectors == 4326) ?
490+
nullptr :
491+
isce3::core::makeProjection(epsg_los_and_along_track_vectors);
492+
477493
auto coordinate_x_array =
478494
getNanArrayRadarGrid<double>(coordinate_x_raster, radar_grid);
479495
auto coordinate_y_array =
@@ -561,7 +577,7 @@ void makeGeolocationGridCubes(
561577

562578
writeVectorDerivedCubes(
563579
i, j, native_azimuth_time, target_llh, target_proj,
564-
orbit, ellipsoid, proj.get(),
580+
orbit, ellipsoid, proj_los_and_along_track_vectors.get(),
565581
incidence_angle_raster, incidence_angle_array,
566582
los_unit_vector_x_raster, los_unit_vector_x_array,
567583
los_unit_vector_y_raster, los_unit_vector_y_array,

cxx/isce3/geometry/metadataCubes.h

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ namespace isce3 { namespace geometry {
1919
* projection system
2020
* @param[in] orbit Reference orbit
2121
* @param[in] ellipsoid Reference ellipsoid
22-
* @param[in] proj Output projection
22+
* @param[in] proj_los_and_along_track_vectors ProjectionBase object for
23+
* representing LOS and along-track unit vectors
2324
* @param[out] incidence_angle_raster Incidence angle cube raster
2425
* @param[out] incidence_angle_array Incidence angle cube array
2526
* @param[out] los_unit_vector_x_raster LOS (target-to-sensor) unit
@@ -42,7 +43,7 @@ static inline void writeVectorDerivedCubes(
4243
const double native_azimuth_time, const isce3::core::Vec3& target_llh,
4344
const isce3::core::Vec3& target_proj, const isce3::core::Orbit& orbit,
4445
const isce3::core::Ellipsoid& ellipsoid,
45-
const isce3::core::ProjectionBase* proj,
46+
const isce3::core::ProjectionBase* proj_los_and_along_track_vectors,
4647
isce3::io::Raster* incidence_angle_raster,
4748
isce3::core::Matrix<float>& incidence_angle_array,
4849
isce3::io::Raster* los_unit_vector_x_raster,
@@ -78,16 +79,19 @@ static inline void writeVectorDerivedCubes(
7879
* high-resolution maps of the corresponding radar geometry variable.
7980
*
8081
* The line-of-sight (LOS) and along-track unit vectors are referenced to
81-
* the projection defined by the geogrid EPSG code. In case the EPSG code
82-
* is equal to 4326, ENU coordinates wrt targets are used instead.
82+
* the projection defined by the epsg_los_and_along_track_vectors code.
83+
* In the case of ENU, i.e. epsg_los_and_along_track_vectors equals to 0
84+
* or 4326, ENU coordinates are computed wrt targets.
8385
*
8486
* @param[in] radar_grid Radar grid
8587
* @param[in] geogrid Geogrid to be
8688
* used as reference for output cubes
8789
* @param[in] heights Cube heights [m]
8890
* @param[in] orbit Reference orbit
8991
* @param[in] native_doppler Native image Doppler
90-
* @param[in] grid_doppler Grid Doppler.
92+
* @param[in] grid_doppler Grid Doppler
93+
* @param[in] epsg_los_and_along_track_vectors EPSG code for LOS and
94+
* along-track unit vectors (0 or 4326 for ENU coordinates)
9195
* @param[out] slant_range_raster Slant-range (in meters)
9296
* cube raster
9397
* @param[out] azimuth_time_raster Azimuth time (in seconds)
@@ -115,6 +119,7 @@ void makeRadarGridCubes(
115119
const std::vector<double>& heights, const isce3::core::Orbit& orbit,
116120
const isce3::core::LUT2d<double>& native_doppler,
117121
const isce3::core::LUT2d<double>& grid_doppler,
122+
const int epsg_los_and_along_track_vectors = 0,
118123
isce3::io::Raster* slant_range_raster = nullptr,
119124
isce3::io::Raster* azimuth_time_raster = nullptr,
120125
isce3::io::Raster* incidence_angle_raster = nullptr,
@@ -147,15 +152,18 @@ void makeRadarGridCubes(
147152
* high-resolution maps of the corresponding radar geometry variable.
148153
*
149154
* The line-of-sight (LOS) and along-track unit vectors are referenced to
150-
* the projection defined by the EPSG code. In case the EPSG code
151-
* is equal to 4326, ENU coordinates wrt targets are used instead.
155+
* the projection defined by the epsg_los_and_along_track_vectors code.
156+
* In the case of ENU, i.e. epsg_los_and_along_track_vectors equals to 0
157+
* or 4326, ENU coordinates are computed wrt targets.
152158
*
153159
* @param[in] radar_grid Cube radar grid
154160
* @param[in] heights Cube heights
155161
* @param[in] orbit Orbit
156162
* @param[in] native_doppler Native image Doppler
157163
* @param[in] grid_doppler Grid Doppler.
158164
* @param[in] epsg Output geolocation EPSG
165+
* @param[in] epsg_los_and_along_track_vectors EPSG code for LOS and
166+
* along-track unit vectors (0 or 4326 for ENU coordinates)
159167
* @param[out] coordinate_x_raster Geolocation coordinate X raster
160168
* @param[out] coordinate_y_raster Geolocation coordinage Y raster
161169
* @param[out] incidence_angle_raster Incidence angle (in degrees wrt
@@ -180,7 +188,7 @@ void makeGeolocationGridCubes(
180188
const std::vector<double>& heights, const isce3::core::Orbit& orbit,
181189
const isce3::core::LUT2d<double>& native_doppler,
182190
const isce3::core::LUT2d<double>& grid_doppler,
183-
const int epsg,
191+
const int epsg, const int epsg_los_and_along_track_vectors = 0,
184192
isce3::io::Raster* coordinate_x_raster = nullptr,
185193
isce3::io::Raster* coordinate_y_raster = nullptr,
186194
isce3::io::Raster* incidence_angle_raster = nullptr,

python/extensions/pybind_isce3/geometry/metadataCubes.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ void addbinding_metadata_cubes(py::module & m)
1414
m.def("make_radar_grid_cubes", &isce3::geometry::makeRadarGridCubes,
1515
py::arg("radar_grid"), py::arg("geogrid"), py::arg("heights"),
1616
py::arg("orbit"), py::arg("native_doppler"), py::arg("grid_doppler"),
17+
py::arg("epsg_los_and_along_track_vectors") = 0,
1718
py::arg("slant_range_raster") = nullptr,
1819
py::arg("azimuth_time_raster") = nullptr,
1920
py::arg("incidence_angle_raster") = nullptr,
@@ -45,8 +46,9 @@ void addbinding_metadata_cubes(py::module & m)
4546
high-resolution maps of the corresponding radar geometry variable.
4647
4748
The line-of-sight (LOS) and along-track unit vectors are referenced to
48-
the projection defined by the geogrid EPSG code. In case the EPSG code
49-
is equal to 4326, ENU coordinates wrt targets are used instead.
49+
the projection defined by the epsg_los_and_along_track_vectors code.
50+
In the case of ENU, i.e. epsg_los_and_along_track_vectors equals to 0
51+
or 4326, ENU coordinates are computed wrt targets.
5052
5153
Parameters
5254
----------
@@ -62,6 +64,9 @@ void addbinding_metadata_cubes(py::module & m)
6264
Native image Doppler
6365
grid_doppler : isce3.core.LUT2d
6466
Grid Doppler
67+
epsg_los_and_along_track_vectors : int, optional
68+
EPSG code for LOS and along-track unit vectors
69+
(0 or 4326 for ENU coordinates)
6570
slant_range_raster : isce3.io.Raster, optional
6671
Slant-range (in meters) cube raster
6772
azimuth_time_raster : isce3.io.Raster, optional
@@ -95,6 +100,7 @@ void addbinding_metadata_cubes(py::module & m)
95100
py::arg("native_doppler"),
96101
py::arg("grid_doppler"),
97102
py::arg("epsg"),
103+
py::arg("epsg_los_and_along_track_vectors") = 0,
98104
py::arg("coordinate_x_raster") = nullptr,
99105
py::arg("coordinate_y_raster") = nullptr,
100106
py::arg("incidence_angle_raster") = nullptr,
@@ -127,8 +133,9 @@ void addbinding_metadata_cubes(py::module & m)
127133
high-resolution maps of the corresponding radar geometry variable.
128134
129135
The line-of-sight (LOS) and along-track unit vectors are referenced to
130-
the projection defined by the EPSG code. In case the EPSG code
131-
is equal to 4326, ENU coordinates wrt targets are used instead.
136+
the projection defined by the epsg_los_and_along_track_vectors code.
137+
In the case of ENU, i.e. epsg_los_and_along_track_vectors equals to 0
138+
or 4326, ENU coordinates are computed wrt targets.
132139
133140
Parameters
134141
----------
@@ -144,6 +151,9 @@ void addbinding_metadata_cubes(py::module & m)
144151
Grid Doppler
145152
epsg : int
146153
Output geolocation EPSG
154+
epsg_los_and_along_track_vectors : int, optional
155+
EPSG code for LOS and along-track unit vectors
156+
(0 or 4326 for ENU coordinates)
147157
coordinate_x_raster : isce3.io.Raster, optional
148158
Geolocation coordinate X raster
149159
coordinate_y_raster : isce3.io.Raster, optional

python/packages/pybind_nisar/workflows/h5_prep.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,11 +1092,12 @@ def set_get_geo_info(hdf5_obj, root_ds, geo_grid, z_vect=None, flag_cube=False):
10921092
return yds, xds
10931093

10941094

1095-
def add_radar_grid_cubes_to_hdf5(hdf5_obj, cube_group_name, geogrid, heights,
1096-
radar_grid,
1097-
orbit, native_doppler, grid_doppler,
1095+
def add_radar_grid_cubes_to_hdf5(hdf5_obj, cube_group_name, geogrid,
1096+
heights, radar_grid, orbit,
1097+
native_doppler, grid_doppler,
10981098
threshold_geo2rdr=1e-8,
1099-
numiter_geo2rdr=100, delta_range=1e-8):
1099+
numiter_geo2rdr=100, delta_range=1e-8,
1100+
epsg_los_and_along_track_vectors=0):
11001101
if cube_group_name not in hdf5_obj:
11011102
cube_group = hdf5_obj.create_group(cube_group_name)
11021103
else:
@@ -1105,8 +1106,7 @@ def add_radar_grid_cubes_to_hdf5(hdf5_obj, cube_group_name, geogrid, heights,
11051106
cube_shape = [len(heights), geogrid.length, geogrid.width]
11061107

11071108
zds, yds, xds = set_get_geo_info(hdf5_obj, cube_group_name, geogrid,
1108-
z_vect=heights,
1109-
flag_cube=True)
1109+
z_vect=heights, flag_cube=True)
11101110

11111111
# seconds since ref epoch
11121112
ref_epoch = radar_grid.ref_epoch
@@ -1168,6 +1168,7 @@ def add_radar_grid_cubes_to_hdf5(hdf5_obj, cube_group_name, geogrid, heights,
11681168
orbit,
11691169
native_doppler,
11701170
grid_doppler,
1171+
epsg_los_and_along_track_vectors,
11711172
slant_range_raster,
11721173
azimuth_time_raster,
11731174
incidence_angle_raster,
@@ -1231,10 +1232,11 @@ def _get_raster_from_hdf5_ds(group, ds_name, dtype, shape,
12311232

12321233

12331234
def add_geolocation_grid_cubes_to_hdf5(hdf5_obj, cube_group_name, radar_grid,
1234-
heights,
1235-
orbit, native_doppler, grid_doppler,
1236-
epsg, threshold_geo2rdr=1e-8,
1237-
numiter_geo2rdr=100, delta_range=1e-8):
1235+
heights, orbit, native_doppler,
1236+
grid_doppler, epsg,
1237+
threshold_geo2rdr=1e-8,
1238+
numiter_geo2rdr=100, delta_range=1e-8,
1239+
epsg_los_and_along_track_vectors=0):
12381240
if cube_group_name not in hdf5_obj:
12391241
cube_group = hdf5_obj.create_group(cube_group_name)
12401242
else:
@@ -1307,6 +1309,7 @@ def add_geolocation_grid_cubes_to_hdf5(hdf5_obj, cube_group_name, radar_grid,
13071309
native_doppler,
13081310
grid_doppler,
13091311
epsg,
1312+
epsg_los_and_along_track_vectors,
13101313
coordinate_x_raster,
13111314
coordinate_y_raster,
13121315
incidence_angle_raster,

tests/cxx/isce3/geometry/metadata_cubes/metadata_cubes.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,14 @@ TEST(radarGridCubeTest, testRadarGridCube)
454454
isce3::product::GeoGridParameters geogrid(x0, y0, dx, dy, width, length,
455455
epsg);
456456

457+
const int epsg_los_and_along_track_vectors = epsg;
458+
457459
// Make cubes
460+
std::cout << "calling makeRadarGridCubes() with geogrid EPSG:"
461+
<< epsg << std::endl;
458462
isce3::geometry::makeRadarGridCubes(
459-
radar_grid, geogrid, heights, orbit, zero_doppler, zero_doppler,
463+
radar_grid, geogrid, heights, orbit, zero_doppler,
464+
zero_doppler, epsg_los_and_along_track_vectors,
460465
&slant_range_raster, &azimuth_time_raster,
461466
&incidence_angle_raster, &los_unit_vector_x_raster,
462467
&los_unit_vector_y_raster, &along_track_unit_vector_x_raster,
@@ -698,6 +703,7 @@ TEST(metadataCubesTest, testMetadataCubes) {
698703
int numiter_geo2rdr = 25;
699704
double delta_range = 1e-6;
700705
int epsg = 4326;
706+
int epsg_los_and_along_track_vectors = epsg;
701707

702708
std::vector<double> heights = {0.0, 1000.0};
703709

@@ -730,7 +736,8 @@ TEST(metadataCubesTest, testMetadataCubes) {
730736
// Make cubes
731737
isce3::geometry::makeGeolocationGridCubes(
732738
radar_grid, heights, orbit, zero_doppler, zero_doppler, epsg,
733-
&coordinate_x_raster, &coordinate_y_raster, &incidence_angle_raster,
739+
epsg_los_and_along_track_vectors, &coordinate_x_raster,
740+
&coordinate_y_raster, &incidence_angle_raster,
734741
&los_unit_vector_x_raster, &los_unit_vector_y_raster,
735742
&along_track_unit_vector_x_raster, &along_track_unit_vector_y_raster,
736743
&elevation_angle_raster, threshold_geo2rdr, numiter_geo2rdr,

0 commit comments

Comments
 (0)