Skip to content

Commit

Permalink
Merge pull request #179 from ASFHyP3/develop
Browse files Browse the repository at this point in the history
Release v0.5.1
  • Loading branch information
forrestfwilliams authored Mar 3, 2023
2 parents af715b5 + bac35c2 commit 6313bd7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/distribute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: mamba-org/provision-with-micromamba@v15

Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
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).


## [0.5.1]

### Changed
* `asf-tools.flood_map` now produces rasters with pixel values of a positive integer where water is present and `0` where water is not present. Everywhere else is set to nodata.

## [0.5.0]

### Added
Expand Down
14 changes: 10 additions & 4 deletions src/asf_tools/flood_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ def make_flood_map(out_raster: Union[str, Path], vv_raster: Union[str, Path],

vv_array = read_as_masked_array(vv_raster)
flood_mask[vv_array.mask] = False
padding_mask = vv_array.mask
del vv_array

labeled_flood_mask, num_labels = ndimage.label(flood_mask)
Expand All @@ -212,16 +213,21 @@ def make_flood_map(out_raster: Union[str, Path], vv_raster: Union[str, Path],

flood_depth[flood_depth < 0] = 0

nodata = -1
floodmask_nodata = np.iinfo(np.uint8).max
flood_depth[padding_mask] = nodata
flood_mask[padding_mask] = floodmask_nodata

write_cog(str(out_raster).replace('.tif', f'_{estimator}_WaterDepth.tif'), flood_depth, transform=geotransform,
epsg_code=epsg, dtype=gdal.GDT_Float64, nodata_value=False)
epsg_code=epsg, dtype=gdal.GDT_Float64, nodata_value=nodata)
write_cog(str(out_raster).replace('.tif', f'_{estimator}_FloodMask.tif'), flood_mask, transform=geotransform,
epsg_code=epsg, dtype=gdal.GDT_Byte, nodata_value=False)
epsg_code=epsg, dtype=gdal.GDT_Byte, nodata_value=floodmask_nodata)

flood_mask[known_water_mask] = False
flood_depth[np.logical_not(flood_mask)] = 0

flood_depth[padding_mask] = nodata
write_cog(str(out_raster).replace('.tif', f'_{estimator}_FloodDepth.tif'), flood_depth, transform=geotransform,
epsg_code=epsg, dtype=gdal.GDT_Float64, nodata_value=False)
epsg_code=epsg, dtype=gdal.GDT_Float64, nodata_value=nodata)


def _get_cli(interface: Literal['hyp3', 'main']) -> argparse.ArgumentParser:
Expand Down

0 comments on commit 6313bd7

Please sign in to comment.