Skip to content

Commit

Permalink
fix assignment of the GeoTIFF metadata to the correct (burst) output …
Browse files Browse the repository at this point in the history
…file list
  • Loading branch information
gshiroma committed Sep 11, 2023
1 parent de74769 commit f339550
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
22 changes: 13 additions & 9 deletions src/rtc/rtc_s1.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,8 @@ def run_parallel(cfg: RunConfig, logfile_path, flag_logger_full_format):
logger.info(f'Processing burst: {burst_id} ({burst_index+1}/'
f'{n_bursts})')

burst_output_file_list = []

pol_list = list(burst_pol_dict.keys())
burst = burst_pol_dict[pol_list[0]]
geogrid = cfg.geogrids[burst_id]
Expand Down Expand Up @@ -683,7 +685,7 @@ def run_parallel(cfg: RunConfig, logfile_path, flag_logger_full_format):
if flag_bursts_secondary_files_are_temporary:
temp_files_list.append(nlooks_file)
else:
output_file_list.append(nlooks_file)
burst_output_file_list.append(nlooks_file)
else:
nlooks_file = None

Expand All @@ -700,7 +702,7 @@ def run_parallel(cfg: RunConfig, logfile_path, flag_logger_full_format):
if flag_bursts_secondary_files_are_temporary:
temp_files_list.append(rtc_anf_file)
else:
output_file_list.append(rtc_anf_file)
burst_output_file_list.append(rtc_anf_file)

else:
rtc_anf_file = None
Expand All @@ -720,7 +722,7 @@ def run_parallel(cfg: RunConfig, logfile_path, flag_logger_full_format):
if flag_bursts_secondary_files_are_temporary:
temp_files_list.append(rtc_anf_gamma0_to_sigma0_file)
else:
output_file_list.append(rtc_anf_gamma0_to_sigma0_file)
burst_output_file_list.append(rtc_anf_gamma0_to_sigma0_file)

else:
rtc_anf_gamma0_to_sigma0_file = None
Expand All @@ -746,7 +748,7 @@ def run_parallel(cfg: RunConfig, logfile_path, flag_logger_full_format):
temp_files_list.append(layover_shadow_mask_file)
layover_shadow_mask_file = None
else:
output_file_list.append(layover_shadow_mask_file)
burst_output_file_list.append(layover_shadow_mask_file)
logger.info(f'file saved: {layover_shadow_mask_file}')

# Take the layover shadow mask from HDF5 file if not exists
Expand Down Expand Up @@ -796,7 +798,7 @@ def run_parallel(cfg: RunConfig, logfile_path, flag_logger_full_format):
temp_files_list.append(geo_burst_vrt_filename)

if not flag_bursts_files_are_temporary:
output_file_list += output_burst_imagery_list
burst_output_file_list += output_burst_imagery_list
else:
temp_files_list += output_burst_imagery_list

Expand Down Expand Up @@ -834,14 +836,14 @@ def run_parallel(cfg: RunConfig, logfile_path, flag_logger_full_format):
if flag_bursts_secondary_files_are_temporary:
temp_files_list.append(current_file)
else:
output_file_list.append(current_file)
burst_output_file_list.append(current_file)

# Browse image (burst) using static layers
if (flag_save_browse and
product_type == STATIC_LAYERS_PRODUCT_TYPE):
browse_image_filename = \
os.path.join(output_dir_bursts, f'{burst_product_id}.png')
output_file_list.append(browse_image_filename)
burst_output_file_list.append(browse_image_filename)

# Create burst HDF5
if (save_hdf5_metadata and save_bursts):
Expand All @@ -850,7 +852,7 @@ def run_parallel(cfg: RunConfig, logfile_path, flag_logger_full_format):
output_hdf5_file_burst = os.path.join(
hdf5_file_output_dir,
f'{burst_product_id}.{hdf5_file_extension}')
output_file_list.append(output_hdf5_file_burst)
burst_output_file_list.append(output_hdf5_file_burst)

# Create mosaic HDF5
if (save_hdf5_metadata and save_mosaics
Expand All @@ -864,7 +866,7 @@ def run_parallel(cfg: RunConfig, logfile_path, flag_logger_full_format):
product_type != STATIC_LAYERS_PRODUCT_TYPE):
browse_image_filename = \
os.path.join(output_dir_bursts, f'{burst_product_id}.png')
output_file_list.append(browse_image_filename)
burst_output_file_list.append(browse_image_filename)

# Save mosaic metadata for later use
if (save_mosaics and burst_index == 0):
Expand All @@ -875,6 +877,8 @@ def run_parallel(cfg: RunConfig, logfile_path, flag_logger_full_format):
all_metadata_dict_to_geotiff_metadata_dict(
mosaic_metadata_dict)

output_file_list += burst_output_file_list

t_burst_end = time.time()
logger.info(
f'elapsed time (burst): {t_burst_end - t_burst_start}')
Expand Down
24 changes: 14 additions & 10 deletions src/rtc/rtc_s1_single_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,8 @@ def run_single_job(cfg: RunConfig):
logger.info(f'Processing burst: {burst_id} ({burst_index+1}/'
f'{n_bursts})')

burst_output_file_list = []

geogrid = cfg.geogrids[burst_id]
pol_list = list(burst_pol_dict.keys())
burst = burst_pol_dict[pol_list[0]]
Expand Down Expand Up @@ -1586,7 +1588,7 @@ def run_single_job(cfg: RunConfig):
if flag_bursts_secondary_files_are_temporary:
temp_files_list.append(nlooks_file)
else:
output_file_list.append(nlooks_file)
burst_output_file_list.append(nlooks_file)
else:
nlooks_file = None

Expand All @@ -1598,7 +1600,7 @@ def run_single_job(cfg: RunConfig):
if flag_bursts_secondary_files_are_temporary:
temp_files_list.append(rtc_anf_file)
else:
output_file_list.append(rtc_anf_file)
burst_output_file_list.append(rtc_anf_file)

else:
rtc_anf_file = None
Expand All @@ -1612,7 +1614,7 @@ def run_single_job(cfg: RunConfig):
if flag_bursts_secondary_files_are_temporary:
temp_files_list.append(rtc_anf_gamma0_to_sigma0_file)
else:
output_file_list.append(rtc_anf_gamma0_to_sigma0_file)
burst_output_file_list.append(rtc_anf_gamma0_to_sigma0_file)

else:
rtc_anf_gamma0_to_sigma0_file = None
Expand Down Expand Up @@ -1715,7 +1717,7 @@ def run_single_job(cfg: RunConfig):
if flag_layover_shadow_mask_is_temporary:
temp_files_list.append(layover_shadow_mask_file)
else:
output_file_list.append(layover_shadow_mask_file)
burst_output_file_list.append(layover_shadow_mask_file)
logger.info(f'file saved: {layover_shadow_mask_file}')
if save_mask:
output_metadata_dict[LAYER_NAME_LAYOVER_SHADOW_MASK][1].append(
Expand Down Expand Up @@ -1858,7 +1860,7 @@ def run_single_job(cfg: RunConfig):
output_burst_imagery_list,
output_raster_format, logger)

output_file_list += output_burst_imagery_list
burst_output_file_list += output_burst_imagery_list

if save_nlooks:
if flag_process:
Expand Down Expand Up @@ -1913,7 +1915,7 @@ def run_single_job(cfg: RunConfig):
# files are temporary
temp_files_list += radar_grid_file_dict_filenames
else:
output_file_list += radar_grid_file_dict_filenames
burst_output_file_list += radar_grid_file_dict_filenames

# Save browse image (burst) using static layers
if (flag_save_browse and
Expand All @@ -1925,7 +1927,7 @@ def run_single_job(cfg: RunConfig):
browse_image_burst_height,
browse_image_burst_width, temp_files_list,
burst_scratch_path, logger)
output_file_list.append(browse_image_filename)
burst_output_file_list.append(browse_image_filename)

# Create burst HDF5
if (flag_process and save_hdf5_metadata and save_bursts):
Expand All @@ -1943,7 +1945,7 @@ def run_single_job(cfg: RunConfig):
layover_shadow_mask_file, radar_grid_file_dict,
save_imagery=save_imagery_as_hdf5,
save_secondary_layers=save_secondary_layers_as_hdf5)
output_file_list.append(output_hdf5_file_burst)
burst_output_file_list.append(output_hdf5_file_burst)

# Save browse image (burst)
if (flag_process and flag_save_browse and
Expand All @@ -1955,7 +1957,7 @@ def run_single_job(cfg: RunConfig):
pol_list, browse_image_burst_height,
browse_image_burst_width, temp_files_list,
burst_scratch_path, logger)
output_file_list.append(browse_image_filename)
burst_output_file_list.append(browse_image_filename)

# Append metadata to burst GeoTIFFs
if (flag_process and (not flag_bursts_files_are_temporary or
Expand All @@ -1965,7 +1967,7 @@ def run_single_job(cfg: RunConfig):
is_mosaic=False)
geotiff_metadata_dict = all_metadata_dict_to_geotiff_metadata_dict(
metadata_dict)
for current_file in output_file_list:
for current_file in burst_output_file_list:
if not current_file.endswith('.tif'):
continue
append_metadata_to_geotiff_file(current_file,
Expand All @@ -1988,6 +1990,8 @@ def run_single_job(cfg: RunConfig):
all_metadata_dict_to_geotiff_metadata_dict(
mosaic_metadata_dict)

output_file_list += burst_output_file_list

t_burst_end = time.time()
logger.info(
f'elapsed time (burst): {t_burst_end - t_burst_start}')
Expand Down

0 comments on commit f339550

Please sign in to comment.