Skip to content

Commit

Permalink
Merge pull request #438 from ASFHyP3/develop
Browse files Browse the repository at this point in the history
Release v6.0.0
  • Loading branch information
asjohnston-asf authored Feb 4, 2023
2 parents df32dec + cce72c4 commit 205e264
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 97 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [PEP 440](https://www.python.org/dev/peps/pep-0440/)
and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [6.0.0]

### Removed
- Surface water extent map processing of RTC products, which is now entirely contained in
[asf-tools](https://github.com/ASFHyP3/asf-tools/) and its associated docker container image. This includes removing:
- `water_map` entrypoint to create a water map product
- `asf_tools` environment from the hyp3-gamma docker container image

## [5.7.5]

### Added
Expand Down
11 changes: 0 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
## ASF TOOLS
ARG ASF_TOOLS_IMAGE='ghcr.io/asfhyp3/asf-tools'
ARG ASF_TOOLS_TAG=0.4.4

FROM ${ASF_TOOLS_IMAGE}:${ASF_TOOLS_TAG} as asf-tools

FROM ubuntu:22.04

# For opencontainers label definitions, see:
Expand Down Expand Up @@ -75,10 +69,5 @@ ENV HDF5_DISABLE_VERSION_CHECK=1

WORKDIR /home/conda/

COPY --from=asf-tools --chown=${CONDA_GID}:${CONDA_UID} /opt/conda /opt/conda
COPY --from=asf-tools --chown=${CONDA_GID}:${CONDA_UID} /home/conda/.profile /home/conda/

ENV PATH=$PATH:/opt/conda/bin

ENTRYPOINT ["/usr/local/bin/hyp3_gamma"]
CMD ["-h"]
86 changes: 1 addition & 85 deletions hyp3_gamma/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from shutil import make_archive

from hyp3lib.aws import upload_file_to_s3
from hyp3lib.execute import execute
from hyp3lib.fetch import write_credentials_to_netrc_file
from hyp3lib.image import create_thumbnail
from hyp3lib.util import string_is_true
Expand All @@ -23,7 +22,7 @@
def main():
parser = ArgumentParser(prefix_chars='+', formatter_class=ArgumentDefaultsHelpFormatter)
parser.add_argument(
'++process', choices=['rtc', 'insar', 'water_map'], default='rtc',
'++process', choices=['rtc', 'insar'], default='rtc',
help='Select the HyP3 entrypoint version to use'
)
parser.add_argument('++omp-num-threads', type=int, help='The number of OpenMP threads to use for parallel regions')
Expand Down Expand Up @@ -176,88 +175,5 @@ def insar():
upload_file_to_s3(product_file, args.bucket, args.bucket_prefix)


def water_map():
parser = ArgumentParser()
parser.add_argument('--username')
parser.add_argument('--password')
parser.add_argument('--bucket')
parser.add_argument('--bucket-prefix', default='')

parser.add_argument('--resolution', type=float, choices=[10.0, 30.0], default=30.0)
parser.add_argument('--speckle-filter', type=string_is_true, default=False)
parser.add_argument('--max-vv-threshold', type=float, default=-17.)
parser.add_argument('--max-vh-threshold', type=float, default=-24.)
parser.add_argument('--hand-threshold', type=float, default=15.)
parser.add_argument('--hand-fraction', type=float, default=0.8)
parser.add_argument('--membership-threshold', type=float, default=0.45)
parser.add_argument('granule')

parser.add_argument('--include-flood-depth', type=string_is_true, default=False)
parser.add_argument('--estimator', type=str, default='iterative', choices=['iterative', 'logstat', 'nmad', 'numpy'])
parser.add_argument('--water-level-sigma', type=float, default=3.)
parser.add_argument('--known-water-threshold', type=float, default=30.)
parser.add_argument('--iterative-min', type=int, default=0)
parser.add_argument('--iterative-max', type=int, default=15)

args = parser.parse_args()

username, password = check_earthdata_credentials(args.username, args.password)

logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s',
datefmt='%m/%d/%Y %I:%M:%S %p', level=logging.INFO)

write_credentials_to_netrc_file(username, password)

safe_dir = util.get_granule(args.granule)

product_name = rtc_sentinel_gamma(
safe_dir=safe_dir,
resolution=args.resolution,
scale='power',
radiometry='gamma0',
speckle_filter=args.speckle_filter,
dem_matching=False,
include_dem=True,
include_inc_map=False,
include_scattering_area=False,
include_rgb=True,
dem_name='copernicus',
)
execute(f'conda run -n asf-tools water_map {product_name}/{product_name}_WM.tif '
f'{product_name}/{product_name}_VV.tif {product_name}/{product_name}_VH.tif '
f'--max-vv-threshold {args.max_vv_threshold} --max-vh-threshold {args.max_vh_threshold} '
f'--hand-threshold {args.hand_threshold} --hand-fraction {args.hand_fraction} '
f'--membership-threshold {args.membership_threshold}', uselogging=True)

files_to_remove = [
Path(product_name) / f'{product_name}_WM_VV_initial.tif',
Path(product_name) / f'{product_name}_WM_VH_initial.tif',
Path(product_name) / f'{product_name}_WM_VV_fuzzy.tif',
Path(product_name) / f'{product_name}_WM_VH_fuzzy.tif',
]
for file_to_remove in files_to_remove:
file_to_remove.unlink()

if args.include_flood_depth:
execute(f'conda run -n asf-tools flood_map {product_name}/{product_name}_FM.tif '
f'{product_name}/{product_name}_VV.tif {product_name}/{product_name}_WM.tif '
f'{product_name}/{product_name}_WM_HAND.tif --estimator {args.estimator} '
f'--water-level-sigma {args.water_level_sigma} --known-water-threshold {args.known_water_threshold} '
f'--iterative-bounds {args.iterative_min} {args.iterative_max}',
uselogging=True)

output_zip = make_archive(base_name=product_name, format='zip', base_dir=product_name)

if args.bucket:
product_dir = Path(product_name)
for browse in product_dir.glob('*.png'):
create_thumbnail(browse, output_dir=product_dir)

upload_file_to_s3(Path(output_zip), args.bucket, args.bucket_prefix)

for product_file in product_dir.iterdir():
upload_file_to_s3(product_file, args.bucket, args.bucket_prefix)


if __name__ == '__main__':
main()
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
'ifm_sentinel.py = hyp3_gamma.insar.ifm_sentinel:main',
'interf_pwr_s1_lt_tops_proc.py = hyp3_gamma.insar.interf_pwr_s1_lt_tops_proc:main',
'unwrapping_geocoding.py = hyp3_gamma.insar.unwrapping_geocoding:main',
'water_map = hyp3_gamma.__main__:water_map',
]
},

Expand Down

0 comments on commit 205e264

Please sign in to comment.