Skip to content

Commit

Permalink
Merge pull request #82 from gshiroma/rtc_update_2024
Browse files Browse the repository at this point in the history
Changes for v1.0.2
  • Loading branch information
gshiroma authored Mar 11, 2024
2 parents 70d4216 + bf50e62 commit ebb175f
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 9 deletions.
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: check-added-large-files
2 changes: 1 addition & 1 deletion Docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM oraclelinux:8

LABEL author="OPERA ADT" \
description="RTC cal/val release R4" \
version="1.0.1-final"
version="1.0.2-final"

RUN yum -y update &&\
yum -y install curl &&\
Expand Down
2 changes: 1 addition & 1 deletion Docker/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ dependencies:
- pyre>=1.11.2

- scipy!=1.10.0
- isce3>=0.15.0
- isce3==0.15.0
# Workaround for the issue with `libabseil` (09/11/2023)
- libabseil=20230125.3
2 changes: 1 addition & 1 deletion Docker/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ setuptools
shapely
yamale
backoff
isce3>=0.14.0
isce3==0.15.0
2 changes: 1 addition & 1 deletion build_docker_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

REPO=opera
IMAGE=rtc
TAG=final_1.0.1
TAG=final_1.0.2

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

Expand Down
10 changes: 9 additions & 1 deletion src/rtc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,15 @@ def save_as_cog(filename, scratch_dir='.', logger=None,
logger = logging.getLogger('rtc_s1')

logger.info(' COG step 1: add overviews')
gdal_ds = gdal.Open(filename, gdal.GA_Update)

# open GeoTIFF file in update mode
try:
gdal_ds = gdal.Open(filename, gdal.GA_Update)
except RuntimeError:
# fix for GDAL >= 3.8
gdal_ds = gdal.OpenEx(filename, gdal.GA_Update,
open_options=["IGNORE_COG_LAYOUT_BREAK=YES"])

gdal_dtype = gdal_ds.GetRasterBand(1).DataType
dtype_name = gdal.GetDataTypeName(gdal_dtype).lower()

Expand Down
15 changes: 15 additions & 0 deletions src/rtc/h5_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,13 @@ def get_metadata_dict(product_id: str,
# If the DEM description is not provided, use DEM source
dem_file_description = os.path.basename(cfg_in.dem)

# reformat burst ID to URL data access format used by ASF
# (e.g., from "t018_038602_iw2" to "T018-038602-iw2")
burst_id_asf = str(burst_in.burst_id).upper().replace('_', '-')

# create substring "{end_date}"
end_date_str = burst_in.sensing_stop.strftime('%Y-%m-%d')

# source data access (URL or DOI)
source_data_access = cfg_in.groups.input_file_group.source_data_access
if not source_data_access:
Expand All @@ -424,12 +431,20 @@ def get_metadata_dict(product_id: str,
product_data_access = cfg_in.groups.product_group.product_data_access
if not product_data_access:
product_data_access = '(NOT PROVIDED)'
else:
# replace "{burst_id}"" and "{end_date}" substrings
product_data_access = product_data_access.format(
burst_id=burst_id_asf, end_date=end_date_str)

# static layers data access (URL or DOI)
static_layers_data_access = \
cfg_in.groups.product_group.static_layers_data_access
if not static_layers_data_access:
static_layers_data_access = '(NOT PROVIDED)'
else:
# replace "{burst_id}"" and "{end_date}" substrings
static_layers_data_access = static_layers_data_access.format(
burst_id=burst_id_asf, end_date=end_date_str)

# platform ID
if burst_in.platform_id == 'S1A':
Expand Down
4 changes: 2 additions & 2 deletions src/rtc/mosaic_geobursts.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,13 +623,13 @@ def mosaic_single_output_file(list_rtc_images, list_nlooks, mosaic_filename,

for i_band in range(num_bands):
gdal_band = raster_out.GetRasterBand(i_band+1)
gdal_band.WriteArray(arr_numerator[i_band])
gdal_band.SetDescription(description_list[i_band])
if ctable is not None:
gdal_band.SetRasterColorTable(ctable)
gdal_band.SetRasterColorInterpretation(gdal.GCI_PaletteIndex)
if no_data_value is not None:
gdal_band.SetNoDataValue(no_data_value)
gdal_band.WriteArray(arr_numerator[i_band])

band_ds = None
reference_raster = None
Expand Down Expand Up @@ -710,12 +710,12 @@ def mosaic_multiple_output_files(

# for i_band in range(num_bands):
band_out = raster_out.GetRasterBand(1)
band_out.WriteArray(arr_numerator[i_band])
if ctable is not None:
band_out.SetRasterColorTable(ctable)
band_out.SetRasterColorInterpretation(gdal.GCI_PaletteIndex)
if no_data_value is not None:
band_out.SetNoDataValue(no_data_value)
band_out.WriteArray(arr_numerator[i_band])

band_ds = None
reference_raster = None
2 changes: 1 addition & 1 deletion src/rtc/rtc_s1_single_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,13 +822,13 @@ def set_mask_fill_value_and_ctable(mask_file, reference_file):
mask_gdal_band = mask_gdal_ds.GetRasterBand(1)
mask_array = mask_gdal_band.ReadAsArray()
mask_array[(np.isnan(ref_array)) & (mask_array == 0)] = 255
mask_gdal_band.WriteArray(mask_array)
mask_gdal_band.SetNoDataValue(255)

mask_ctable.SetColorEntry(255, (0, 0, 0, 0))
mask_gdal_band.SetRasterColorTable(mask_ctable)
mask_gdal_band.SetRasterColorInterpretation(
gdal.GCI_PaletteIndex)
mask_gdal_band.WriteArray(mask_array)

del mask_gdal_band
del mask_gdal_ds
Expand Down
2 changes: 1 addition & 1 deletion src/rtc/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION='1.0.1'
VERSION='1.0.2'

0 comments on commit ebb175f

Please sign in to comment.