Skip to content

Commit bc35b0f

Browse files
authored
Merge branch 'main' into fix_layover_shadow_mask_antimeridian
2 parents 5f21d52 + 3e270f8 commit bc35b0f

16 files changed

+715
-70
lines changed

Docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM oraclelinux:8
22

33
LABEL author="OPERA ADT" \
44
description="RTC cal/val release R4" \
5-
version="1.0.3-final"
5+
version="1.0.4-final"
66

77
RUN yum -y update &&\
88
yum -y install curl &&\

Docker/requirements.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
python>=3.9,<3.10
1+
python
22
cmake>=3.18
33
eigen>=3.3
44
fftw>=3.3
@@ -16,9 +16,12 @@ pyre>=1.11.2
1616
pytest
1717
cython
1818
ruamel.yaml
19-
scipy!=1.10.0
19+
scipy
2020
setuptools
2121
shapely
2222
yamale
2323
backoff
24-
isce3==0.15.0
24+
isce3
25+
libnetcdf
26+
libgdal-hdf5
27+
libgdal-netcdf

build_docker_image.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
REPO=opera
44
IMAGE=rtc
5-
TAG=final_1.0.3
5+
TAG=final_1.0.4
66

77
echo "IMAGE is $REPO/$IMAGE:$TAG"
88

src/rtc/defaults/rtc_s1.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,6 @@ runconfig:
197197
# OPTIONAL - Choices: "single_block", "geogrid", "geogrid_and_radargrid", and "auto" (default)
198198
memory_mode:
199199

200-
# OPTIONAL - Processing upsampling factor applied to input geogrid
201-
geogrid_upsampling: 1
202-
203200
# Save the incidence angle
204201
save_incidence_angle: False
205202

src/rtc/defaults/rtc_s1_static.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,6 @@ runconfig:
198198
# OPTIONAL - Choices: "single_block", "geogrid", "geogrid_and_radargrid", and "auto" (default)
199199
memory_mode:
200200

201-
# OPTIONAL - Processing upsampling factor applied to input geogrid
202-
geogrid_upsampling: 1
203-
204201
# Save the incidence angle
205202
save_incidence_angle: True
206203

src/rtc/h5_prep.py

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929

3030
LAYER_NAME_VV = 'VV'
3131
LAYER_NAME_VH = 'VH'
32+
LAYER_NAME_HH = 'HH'
33+
LAYER_NAME_HV = 'HV'
3234
LAYER_NAME_LAYOVER_SHADOW_MASK = 'mask'
3335
LAYER_NAME_RTC_ANF_GAMMA0_TO_BETA0 = 'rtc_anf_gamma0_to_beta0'
3436
LAYER_NAME_RTC_ANF_GAMMA0_TO_SIGMA0 = 'rtc_anf_gamma0_to_sigma0'
@@ -46,6 +48,8 @@
4648
layer_hdf5_dict = {
4749
LAYER_NAME_VV: 'VV',
4850
LAYER_NAME_VH: 'VH',
51+
LAYER_NAME_HH: 'HH',
52+
LAYER_NAME_HV: 'HV',
4953
LAYER_NAME_LAYOVER_SHADOW_MASK: 'mask',
5054
LAYER_NAME_RTC_ANF_GAMMA0_TO_BETA0:
5155
'rtcAreaNormalizationFactorGamma0ToBeta0',
@@ -68,6 +72,8 @@
6872
layer_names_dict = {
6973
LAYER_NAME_VV: 'RTC-S1 VV Backscatter',
7074
LAYER_NAME_VH: 'RTC-S1 VH Backscatter',
75+
LAYER_NAME_HH: 'RTC-S1 HH Backscatter',
76+
LAYER_NAME_HV: 'RTC-S1 HV Backscatter',
7177
LAYER_NAME_LAYOVER_SHADOW_MASK: 'Mask Layer',
7278
LAYER_NAME_RTC_ANF_GAMMA0_TO_BETA0: ('RTC Area Normalization Factor'
7379
' Gamma0 to Beta0'),
@@ -96,6 +102,10 @@
96102
' coefficient normalized to gamma0'),
97103
LAYER_NAME_VH: ('Radiometric terrain corrected Sentinel-1 VH backscatter'
98104
' coefficient normalized to gamma0'),
105+
LAYER_NAME_HH: ('Radiometric terrain corrected Sentinel-1 HH backscatter'
106+
' coefficient normalized to gamma0'),
107+
LAYER_NAME_HV: ('Radiometric terrain corrected Sentinel-1 HV backscatter'
108+
' coefficient normalized to gamma0'),
99109
LAYER_NAME_LAYOVER_SHADOW_MASK: ('Mask Layer. Values: 0: not'
100110
' masked; 1: shadow; 2: layover;'
101111
' 3: layover and shadow;'
@@ -310,8 +320,27 @@ def create_hdf5_file(product_id, output_hdf5_file, orbit, burst, cfg,
310320

311321

312322
def save_orbit(orbit, orbit_group, orbit_file_path):
313-
return
323+
# ensure that the orbit reference epoch has not fractional part
324+
# otherwise, trancate it to seconds precision
325+
orbit_reference_epoch = orbit.reference_epoch
326+
if orbit_reference_epoch.frac != 0:
327+
logger.warning('the orbit reference epoch is not an'
328+
' integer number. Truncating it'
329+
' to seconds precision and'
330+
' updating the orbit ephemeris'
331+
' accordingly.')
332+
333+
epoch = isce3.core.DateTime(orbit_reference_epoch.year,
334+
orbit_reference_epoch.month,
335+
orbit_reference_epoch.day,
336+
orbit_reference_epoch.hour,
337+
orbit_reference_epoch.minute,
338+
orbit_reference_epoch.second)
339+
340+
orbit.update_reference_epoch(epoch)
341+
314342
orbit.save_to_h5(orbit_group)
343+
315344
# Add description attributes.
316345
orbit_group["time"].attrs["description"] = np.bytes_(
317346
"Time vector record. This"
@@ -350,8 +379,11 @@ def save_orbit(orbit, orbit_group, orbit_file_path):
350379
orbit_type_list.append(orbit_type_individual)
351380
orbit_type = '; '.join(orbit_type_list)
352381

353-
d = orbit_group.require_dataset("orbitType", (), "S64",
354-
data=np.bytes_(orbit_type))
382+
if 'orbitType' in orbit_group:
383+
del orbit_group['orbitType']
384+
d = orbit_group.create_dataset("orbitType",
385+
data=np.bytes_(orbit_type))
386+
355387
d.attrs["description"] = np.bytes_(
356388
"Type of orbit file used in processing")
357389

@@ -1332,7 +1364,11 @@ def save_hdf5_dataset(ds_filename, h5py_obj, root_path,
13321364
logger.warning(f'WARNING Cannot open raster file: {ds_filename}')
13331365
return
13341366

1335-
ds_name = layer_hdf5_dict[layer_name]
1367+
if isinstance(layer_name, str):
1368+
ds_name = layer_hdf5_dict[layer_name]
1369+
else:
1370+
ds_name = [layer_hdf5_dict[l] for l in layer_name]
1371+
13361372
if long_name is not None:
13371373
description = long_name
13381374
else:
@@ -1387,6 +1423,8 @@ def save_hdf5_dataset(ds_filename, h5py_obj, root_path,
13871423
dset.attrs.create('_FillValue', data=np.nan + 1j * np.nan)
13881424
elif 'float' in gdal.GetDataTypeName(raster.datatype()).lower():
13891425
dset.attrs.create('_FillValue', data=np.nan)
1426+
elif 'byte' in gdal.GetDataTypeName(raster.datatype()).lower():
1427+
dset.attrs.create('_FillValue', data=255)
13901428

13911429
if stats_vector is not None:
13921430
stats_obj = stats_vector[band]

src/rtc/rtc_s1.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -769,22 +769,21 @@ def run_parallel(cfg: RunConfig, logfile_path, flag_logger_full_format):
769769

770770
if flag_layover_shadow_mask_is_temporary:
771771
temp_files_list.append(layover_shadow_mask_file)
772-
layover_shadow_mask_file = None
773772
else:
774773
burst_output_file_list.append(layover_shadow_mask_file)
775774
logger.info(f'file saved: {layover_shadow_mask_file}')
776775

777-
# Take the layover shadow mask from HDF5 file if not exists
778-
if save_secondary_layers_as_hdf5:
779-
layover_shadow_mask_file = (
780-
f'NETCDF:{burst_hdf5_in_output}:'
781-
f'{DATA_BASE_GROUP}/'
782-
f'{layer_hdf5_dict[LAYER_NAME_LAYOVER_SHADOW_MASK]}')
783-
784-
if save_mask:
785-
output_metadata_dict[
786-
LAYER_NAME_LAYOVER_SHADOW_MASK][1].append(
787-
layover_shadow_mask_file)
776+
# Take the layover shadow mask from HDF5 file if not exists
777+
if save_secondary_layers_as_hdf5:
778+
layover_shadow_mask_file = (
779+
f'NETCDF:{burst_hdf5_in_output}:'
780+
f'{DATA_BASE_GROUP}/'
781+
f'{layer_hdf5_dict[LAYER_NAME_LAYOVER_SHADOW_MASK]}')
782+
783+
if save_mask:
784+
output_metadata_dict[
785+
LAYER_NAME_LAYOVER_SHADOW_MASK][1].append(
786+
layover_shadow_mask_file)
788787

789788
if not save_mask:
790789
layover_shadow_mask_file = None

src/rtc/rtc_s1_single_job.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,6 @@ def run_single_job(cfg: RunConfig):
12151215
cfg.groups.processing.correction_lut_range_spacing_in_meters
12161216

12171217
memory_mode = geocode_namespace.memory_mode
1218-
geogrid_upsampling = geocode_namespace.geogrid_upsampling
12191218
shadow_dilation_size = geocode_namespace.shadow_dilation_size
12201219
abs_cal_factor = geocode_namespace.abs_rad_cal
12211220
clip_max = geocode_namespace.clip_max
@@ -1324,7 +1323,7 @@ def run_single_job(cfg: RunConfig):
13241323

13251324
logger.info('Save layers:')
13261325
logger.info(f' {layer_names_dict[LAYER_NAME_LAYOVER_SHADOW_MASK]}:'
1327-
f' {save_rtc_anf}')
1326+
f' {save_mask}')
13281327
logger.info(f' RTC area normalization factor: {save_rtc_anf}')
13291328
logger.info(f' RTC area normalization factor Gamma0 to Beta0:'
13301329
f' {save_rtc_anf_gamma0_to_sigma0}')
@@ -1720,9 +1719,10 @@ def run_single_job(cfg: RunConfig):
17201719
else:
17211720
burst_output_file_list.append(layover_shadow_mask_file)
17221721
logger.info(f'file saved: {layover_shadow_mask_file}')
1723-
if save_mask:
1724-
output_metadata_dict[LAYER_NAME_LAYOVER_SHADOW_MASK][1].append(
1725-
layover_shadow_mask_file)
1722+
1723+
if save_mask:
1724+
output_metadata_dict[LAYER_NAME_LAYOVER_SHADOW_MASK][1].append(
1725+
layover_shadow_mask_file)
17261726

17271727
if not save_mask:
17281728
layover_shadow_mask_file = None
@@ -1804,6 +1804,8 @@ def run_single_job(cfg: RunConfig):
18041804
geo_obj.geogrid(geogrid.start_x, geogrid.start_y,
18051805
geogrid.spacing_x, geogrid.spacing_y,
18061806
geogrid.width, geogrid.length, geogrid.epsg)
1807+
1808+
geogrid_upsampling = 1
18071809

18081810
geo_obj.geocode(radar_grid=radar_grid,
18091811
input_raster=rdr_burst_raster,
@@ -1849,8 +1851,7 @@ def run_single_job(cfg: RunConfig):
18491851
if product_type != STATIC_LAYERS_PRODUCT_TYPE:
18501852
output_imagery_list.append(geo_burst_filename)
18511853

1852-
if (flag_process and save_mask and
1853-
not save_secondary_layers_as_hdf5):
1854+
if flag_process and save_mask:
18541855
set_mask_fill_value_and_ctable(layover_shadow_mask_file,
18551856
geo_burst_filename)
18561857

src/rtc/runconfig.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ def load_parameters(cfg):
3939
if geocode_namespace.clip_min is None:
4040
geocode_namespace.clip_min = np.nan
4141

42-
if geocode_namespace.geogrid_upsampling is None:
43-
geocode_namespace.geogrid_upsampling = 1.0
44-
4542
if geocode_namespace.memory_mode == 'single_block':
4643
geocode_namespace.memory_mode = \
4744
isce3.core.GeocodeMemoryMode.SingleBlock

src/rtc/schemas/rtc_s1.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,6 @@ geocoding_options:
223223
# Memory mode
224224
memory_mode: enum('auto', 'single_block', 'geogrid', 'geogrid_and_radargrid', required=False)
225225

226-
# Processing upsampling factor on top of the input geogrid
227-
geogrid_upsampling: int(required=False)
228-
229226
# Save the incidence angle
230227
save_incidence_angle: bool(required=False)
231228

0 commit comments

Comments
 (0)