Skip to content

Commit fdcb149

Browse files
gshiromaGitHub Enterprise
authored andcommitted
Add option to save the interpolated DEM within the GCOV product (#738)
* add option to save interpolated DEM within the GCOV product * use same geogrid as GCOV imagery if geocoding algorithm is interpolation (rather than area projection) * fix import of h5_prep * fix import of h5_prep (2) * fix output DEM geogrid for geocoding with AP
1 parent 391ed01 commit fdcb149

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

python/packages/pybind_nisar/workflows/gcov.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from pybind_nisar.workflows.h5_prep import add_radar_grid_cubes_to_hdf5
2020
from pybind_nisar.workflows.yaml_argparse import YamlArgparse
2121
from pybind_nisar.workflows.gcov_runconfig import GCOVRunConfig
22+
from pybind_nisar.workflows.h5_prep import set_get_geo_info
2223

2324
def run(cfg):
2425
'''
@@ -51,6 +52,7 @@ def run(cfg):
5152
flag_upsample_radar_grid = geocode_dict['upsample_radargrid']
5253
flag_save_nlooks = geocode_dict['save_nlooks']
5354
flag_save_rtc = geocode_dict['save_rtc']
55+
flag_save_dem = geocode_dict['save_dem']
5456

5557
# unpack RTC run parameters
5658
rtc_dict = cfg['processing']['rtc']
@@ -202,6 +204,25 @@ def run(cfg):
202204
temp_rtc = None
203205
out_geo_rtc_obj = None
204206

207+
if flag_save_dem:
208+
temp_interpolated_dem = tempfile.NamedTemporaryFile(
209+
dir=scratch_path, suffix='.tif')
210+
if (output_mode ==
211+
isce3.geocode.GeocodeOutputMode.AREA_PROJECTION):
212+
interpolated_dem_width = geogrid.width + 1
213+
interpolated_dem_length = geogrid.length + 1
214+
else:
215+
interpolated_dem_width = geogrid.width
216+
interpolated_dem_length = geogrid.length
217+
out_geo_dem_obj = isce3.io.Raster(
218+
temp_interpolated_dem.name,
219+
interpolated_dem_width,
220+
interpolated_dem_length, 1,
221+
gdal.GDT_Float32, "GTiff")
222+
else:
223+
temp_interpolated_dem = None
224+
out_geo_dem_obj = None
225+
205226
# geocode rasters
206227
geo.geocode(radar_grid=radar_grid,
207228
input_raster=input_raster_obj,
@@ -223,6 +244,7 @@ def run(cfg):
223244
out_off_diag_terms=out_off_diag_terms_obj,
224245
out_geo_nlooks=out_geo_nlooks_obj,
225246
out_geo_rtc=out_geo_rtc_obj,
247+
out_geo_dem=out_geo_dem_obj,
226248
input_rtc=None,
227249
output_rtc=None,
228250
memory_mode=memory_mode)
@@ -235,6 +257,9 @@ def run(cfg):
235257
if flag_save_rtc:
236258
del out_geo_rtc_obj
237259

260+
if flag_save_dem:
261+
del out_geo_dem_obj
262+
238263
if flag_fullcovariance:
239264
# out_off_diag_terms_obj.close_dataset()
240265
del out_off_diag_terms_obj
@@ -284,6 +309,35 @@ def run(cfg):
284309
units = '',
285310
valid_min = 0)
286311

312+
# save interpolated DEM
313+
if flag_save_dem:
314+
315+
'''
316+
The DEM is interpolated over the geogrid pixels vertices
317+
rather than the pixels centers.
318+
'''
319+
if (output_mode ==
320+
isce3.geocode.GeocodeOutputMode.AREA_PROJECTION):
321+
dem_geogrid = isce3.product.GeoGridParameters(
322+
start_x=geogrid.start_x - geogrid.spacing_x / 2,
323+
start_y=geogrid.start_y - geogrid.spacing_y / 2,
324+
spacing_x=geogrid.spacing_x,
325+
spacing_y=geogrid.spacing_y,
326+
width=int(geogrid.width) + 1,
327+
length=int(geogrid.length) + 1,
328+
epsg=geogrid.epsg)
329+
yds_dem, xds_dem = \
330+
set_get_geo_info(hdf5_obj, root_ds, dem_geogrid)
331+
else:
332+
yds_dem = yds
333+
xds_dem = xds
334+
335+
_save_hdf5_dataset(temp_interpolated_dem.name, hdf5_obj,
336+
root_ds, yds_dem, xds_dem,
337+
'interpolatedDem',
338+
long_name='Interpolated DEM',
339+
units='')
340+
287341
# save GCOV off-diagonal elements
288342
if flag_fullcovariance:
289343
off_diag_terms_list = []

share/nisar/defaults/gcov.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ runconfig:
116116
# Save the RTC area factor used to compute GCOV
117117
save_rtc: True
118118

119+
# Save interpolated DEM used to compute GCOV
120+
save_dem: False
121+
119122
# OPTIONAL - Absolute radiometric correction
120123
abs_rad_cal: 1
121124

share/nisar/schemas/gcov.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ runconfig:
9494

9595
# Save the RTC area factor used to compute GCOV
9696
save_rtc: bool(required=False)
97-
97+
98+
# Save interpolated DEM used to compute GCOV
99+
save_dem: bool(required=False)
100+
98101
# Absolute radiometric correction factor
99102
abs_rad_cal: num(required=False)
100103

0 commit comments

Comments
 (0)