Skip to content

Commit 83de041

Browse files
gshiromaGitHub Enterprise
authored andcommitted
Update metadata cubes: elevation angle and LOS unit vector (#711)
* change direction of the LOS vector and update unitest * update calculation of elevation angle from geocentric to geodedic * compute LOS unit vector around target * update evaluation of LOS unit vector around target and update sat_position_error_threshold
1 parent 02be345 commit 83de041

File tree

2 files changed

+39
-30
lines changed

2 files changed

+39
-30
lines changed

cxx/isce3/geometry/metadataCubes.cpp

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,21 @@ static inline void writeVectorDerivedCubes(const int array_pos_i,
105105

106106
// Compute elevation angle calculated in ECEF (geocentric)
107107
if (elevation_angle_raster != nullptr) {
108-
const double cos_elevation =
109-
sat_xyz.dot(look_vector_xyz) / sat_xyz.norm();
108+
109+
// Get platform position in llh (sat_llh)
110+
const isce3::core::Vec3 sat_llh = ellipsoid.xyzToLonLat(sat_xyz);
111+
112+
// Get target-to-sat vector in ENU around the platform
113+
const isce3::core::Mat3 xyz2enu_sat =
114+
isce3::core::Mat3::xyzToEnu(sat_llh[1], sat_llh[0]);
115+
const isce3::core::Vec3 look_vector_enu_sat =
116+
xyz2enu_sat.dot(look_vector_xyz).normalized();
117+
const double cos_elevation = look_vector_enu_sat[2];
110118
elevation_angle_array(i, j) = std::acos(cos_elevation) * 180.0 / M_PI;
119+
111120
}
112121

113-
// Get target-to-sat vector in ENU (local)
122+
// Get target-to-sat vector in ENU around the target
114123
const isce3::core::Mat3 xyz2enu =
115124
isce3::core::Mat3::xyzToEnu(target_llh[1], target_llh[0]);
116125
const isce3::core::Vec3 look_vector_enu =
@@ -158,16 +167,15 @@ static inline void writeVectorDerivedCubes(const int array_pos_i,
158167

159168
} else {
160169

161-
/*
162-
Get platform position in llh (sat_llh) and in output proj
163-
coordinates (sat_proj)
164-
*/
165-
const isce3::core::Vec3 sat_llh = ellipsoid.xyzToLonLat(sat_xyz);
166-
isce3::core::Vec3 sat_proj = proj->forward(sat_llh);
167-
168-
// Compute target-to-sat vector (proj)
170+
// Compute target-to-sat vector (proj) around the target
171+
const isce3::core::Vec3 target_to_sat_next_xyz =
172+
target_xyz + look_vector_xyz;
173+
const isce3::core::Vec3 target_to_sat_next_llh =
174+
ellipsoid.xyzToLonLat(target_to_sat_next_xyz);
175+
isce3::core::Vec3 target_to_sat_next_proj =
176+
proj->forward(target_to_sat_next_llh);
169177
const isce3::core::Vec3 look_vector_proj =
170-
(sat_proj - target_proj).normalized();
178+
(target_to_sat_next_proj - target_proj).normalized();
171179

172180
// LOS unit vector X (proj)
173181
if (los_unit_vector_x_raster != nullptr) {

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

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ void _check_vectors(const isce3::product::GeoGridParameters& geogrid,
7171
if (geogrid.epsg() == 4326) {
7272
slant_range_error_threshold = 1e-16;
7373
incidence_angle_error_threshold = 1e-5;
74-
sat_position_error_threshold = 1e-7;
74+
sat_position_error_threshold = 1e-3;
7575
vel_unit_error_threshold = 1e-3;
7676
} else {
7777
slant_range_error_threshold = 1e-16;
7878
incidence_angle_error_threshold = 1e-5;
79-
sat_position_error_threshold = 1e-5;
79+
sat_position_error_threshold = 1e-3;
8080
vel_unit_error_threshold = 1e-3;
8181
}
8282

@@ -144,33 +144,34 @@ void _check_vectors(const isce3::product::GeoGridParameters& geogrid,
144144
std::pow(los_unit_test[1], 2)));
145145

146146
// 3. Estimate platform position
147-
isce3::core::Vec3 sat_xyz_test, sat_llh_test;
147+
isce3::core::Vec3 sat_xyz_test, sat_llh_test, los_xyz_test;
148148
if (proj->code() == 4326) {
149149
// For epsg == 4326, vectors are given in ENU
150-
const isce3::core::Vec3 los_xyz_test =
150+
los_xyz_test =
151151
enu2xyz.dot(los_unit_test).normalized();
152152
sat_xyz_test = target_xyz + slant_range_test * los_xyz_test;
153153

154154
} else {
155-
const isce3::core::Vec3 look_vector_test =
156-
slant_range_test * los_unit_test;
157-
const isce3::core::Vec3 sat_proj_test =
158-
target_proj + look_vector_test;
159-
sat_llh_test = proj->inverse(sat_proj_test);
160-
sat_xyz_test = ellipsoid.lonLatToXyz(sat_llh_test);
155+
const isce3::core::Vec3 target_to_sat_next_proj =
156+
target_proj + los_unit_test;
157+
const isce3::core::Vec3 target_to_sat_next_llh =
158+
proj->inverse(target_to_sat_next_proj);
159+
const isce3::core::Vec3 target_to_sat_next_xyz =
160+
ellipsoid.lonLatToXyz(target_to_sat_next_llh);
161+
los_xyz_test =
162+
(target_to_sat_next_xyz - target_xyz).normalized();
163+
sat_xyz_test = target_xyz + slant_range_test * los_xyz_test;
161164
}
162165

163-
/* 3. Evaluate platform position from LOS vector and slant-range
166+
/*
167+
3. Evaluate platform position from LOS vector and slant-range
164168
distance extracted from metadata cubes (errors are multiplied).
165-
Absolute values are large, therefore they are normalized
166-
for comparison */
167-
double error_norm = std::sqrt(std::pow(sat_xyz_test.norm(), 2) +
168-
std::pow(sat_xyz.norm(), 2));
169-
ASSERT_NEAR(sat_xyz_test[0] / error_norm, sat_xyz[0] / error_norm,
169+
*/
170+
ASSERT_NEAR(sat_xyz_test[0], sat_xyz[0],
170171
sat_position_error_threshold);
171-
ASSERT_NEAR(sat_xyz_test[1] / error_norm, sat_xyz[1] / error_norm,
172+
ASSERT_NEAR(sat_xyz_test[1], sat_xyz[1],
172173
sat_position_error_threshold);
173-
ASSERT_NEAR(sat_xyz_test[2] / error_norm, sat_xyz[2] / error_norm,
174+
ASSERT_NEAR(sat_xyz_test[2], sat_xyz[2],
174175
sat_position_error_threshold);
175176

176177
// 4. Estimate velocity from cube along-track vector

0 commit comments

Comments
 (0)