diff --git a/CHANGELOG.md b/CHANGELOG.md index 444d4b3..1768fc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ HyBIG follows semantic versioning. All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). +## [v2.0.2] - 2024-10-15 + +### Fixed + +**DAS-2259** +- Corrects bug with RGBA input tifs. + ## [v2.0.1] - 2024-10-06 ### Changed @@ -70,7 +77,8 @@ outlined by the NASA open-source guidelines. For more information on internal releases prior to NASA open-source approval, see legacy-CHANGELOG.md. -[unreleased]:https://github.com/nasa/harmony-browse-image-generator/compare/2.0.1..HEAD +[unreleased]:https://github.com/nasa/harmony-browse-image-generator/compare/2.0.2..HEAD +[v2.0.2]:https://github.com/nasa/harmony-browse-image-generator/compare/2.0.1..2.0.2 [v2.0.1]:https://github.com/nasa/harmony-browse-image-generator/compare/2.0.0..2.0.1 [v2.0.0]:https://github.com/nasa/harmony-browse-image-generator/compare/1.2.2..2.0.0 [v1.2.2]: https://github.com/nasa/harmony-browse-image-generator/compare/1.2.1..1.2.2 diff --git a/docker/service_version.txt b/docker/service_version.txt index 38f77a6..e9307ca 100644 --- a/docker/service_version.txt +++ b/docker/service_version.txt @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/hybig/browse.py b/hybig/browse.py index c0deef7..9af788f 100644 --- a/hybig/browse.py +++ b/hybig/browse.py @@ -246,9 +246,9 @@ def convert_mulitband_to_raster(data_array: DataArray) -> ndarray: ) if image_alpha is not None: - # merge nan alpha with the image alpha prefering transparency to - # opaqueness. - alpha = np.minimum(nan_alpha, image_alpha) + # merge missing alpha with the image alpha band prefering transparency + # to opaqueness. + alpha = np.minimum(nan_alpha, image_alpha).astype(np.uint8) else: alpha = nan_alpha diff --git a/tests/unit/test_browse.py b/tests/unit/test_browse.py index aab3738..b7146a3 100644 --- a/tests/unit/test_browse.py +++ b/tests/unit/test_browse.py @@ -514,6 +514,59 @@ def test_convert_4_multiband_to_raster(self): actual_raster = convert_mulitband_to_raster(ds) assert_array_equal(expected_raster, actual_raster.data) + def test_convert_4_multiband_masked_to_raster(self): + """Input data is selected from a subset of a real OPERA RTC input data + file that has masked the alpha layer and as a result as a datatype of + float32. + + """ + ds = Mock(DataArray) + ds.rio.count = 4 + nan = np.nan + input_array = np.array( + [ + [ + [nan, nan, nan, 234.0], + [nan, nan, nan, 225.0], + [nan, nan, 255.0, 215.0], + [nan, nan, 217.0, 255.0], + ], + [ + [nan, nan, nan, 255.0], + [nan, nan, nan, 255.0], + [nan, nan, 255.0, 255.0], + [nan, nan, 255.0, 255.0], + ], + [ + [nan, nan, nan, 234.0], + [nan, nan, nan, 225.0], + [nan, nan, 255.0, 215.0], + [nan, nan, 217.0, 255.0], + ], + [ + [0.0, 0.0, 0.0, 255.0], + [0.0, 0.0, 0.0, 255.0], + [0.0, 0.0, 255.0, 255.0], + [0.0, 0.0, 255.0, 255.0], + ], + ], + dtype=np.float32, + ) + ds.to_numpy.return_value = input_array + + expected_raster = np.ma.array( + data=[ + [[0, 0, 0, 121], [0, 0, 0, 64], [0, 0, 255, 0], [0, 0, 13, 255]], + [[0, 0, 0, 255], [0, 0, 0, 255], [0, 0, 255, 255], [0, 0, 255, 255]], + [[0, 0, 0, 121], [0, 0, 0, 64], [0, 0, 255, 0], [0, 0, 13, 255]], + [[0, 0, 0, 255], [0, 0, 0, 255], [0, 0, 255, 255], [0, 0, 255, 255]], + ], + dtype=np.uint8, + ) + + actual_raster = convert_mulitband_to_raster(ds) + assert_array_equal(expected_raster.data, actual_raster.data) + def test_convert_5_multiband_to_raster(self): ds = Mock(DataArray) ds.rio.count = 5