From cbbb64c640d9e458818e12cceb0270a959b09b11 Mon Sep 17 00:00:00 2001 From: Matt Savoie Date: Tue, 16 Apr 2024 08:19:42 -0600 Subject: [PATCH] DAS-2108: Update CHANGELOG and service version Test Cleanup, better naming. --- CHANGELOG.md | 6 ++++++ docker/service_version.txt | 2 +- harmony_browse_image_generator/browse.py | 10 +++++----- tests/unit/test_browse.py | 17 ++++------------- 4 files changed, 16 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c25eb74..5b0cf23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v1.0.2 +### 2024-04-05 + +This version of HyBIG correctly handles missing/bad input data marked by _FillValue or NoData. +Any time one of the bad values occurs in the raster the output png image will be transparent. + ## v1.0.1 ### 2024-04-05 diff --git a/docker/service_version.txt b/docker/service_version.txt index 7dea76e..6d7de6e 100644 --- a/docker/service_version.txt +++ b/docker/service_version.txt @@ -1 +1 @@ -1.0.1 +1.0.2 diff --git a/harmony_browse_image_generator/browse.py b/harmony_browse_image_generator/browse.py index f7a69bc..7760ecd 100644 --- a/harmony_browse_image_generator/browse.py +++ b/harmony_browse_image_generator/browse.py @@ -133,7 +133,7 @@ def convert_mulitband_to_raster(data_array: DataArray) -> ndarray: # Create an alpha layer where input NaN values are transparent. nan_mask = np.isnan(bands).any(axis=0) - missing_alpha = np.where(nan_mask, TRANSPARENT, OPAQUE) + nan_alpha = np.where(nan_mask, TRANSPARENT, OPAQUE) # grab any existing alpha layer bands, image_alpha = remove_alpha(bands) @@ -144,11 +144,11 @@ def convert_mulitband_to_raster(data_array: DataArray) -> ndarray: ) if image_alpha is not None: - # merge missing alpha with the image's alpha prefering transparency to - # opaqueness - alpha = np.minimum(missing_alpha, image_alpha) + # merge nan alpha with the image alpha prefering transparency to + # opaqueness. + alpha = np.minimum(nan_alpha, image_alpha) else: - alpha = missing_alpha + alpha = nan_alpha return np.concatenate((raster, alpha[None, ...]), axis=0) diff --git a/tests/unit/test_browse.py b/tests/unit/test_browse.py index 29f0101..9ba9f06 100644 --- a/tests/unit/test_browse.py +++ b/tests/unit/test_browse.py @@ -60,15 +60,6 @@ def setUpClass(cls): ] ).astype('uint16') - cls.floatdata = np.array( - [ - [100.0, 200.0, 300.0, 400.0], - [100.0, 200.0, 300.0, 400.0], - [100.0, 200.0, 300.0, 400.0], - [100.0, 200.0, 300.0, 400.0], - ] - ).astype('float64') - cls.levels = [100, 200, 300, 400] # R, G, B, A tuples @@ -312,7 +303,7 @@ def test_create_browse_imagery_with_mocks( def test_convert_singleband_to_raster_without_colortable(self): """Tests convert_gray_1band_to_raster.""" - return_data = np.copy(self.floatdata) + return_data = np.copy(self.data).astype('float64') return_data[0][1] = np.nan ds = DataArray(return_data).expand_dims('band') @@ -430,11 +421,11 @@ def test_convert_singleband_to_raster_with_colormap_and_bad_data(self): def test_convert_3_multiband_to_raster(self): - bad_data = np.copy(self.floatdata) + bad_data = np.copy(self.data).astype('float64') bad_data[1][1] = np.nan bad_data[1][2] = np.nan ds = DataArray( - np.stack([self.floatdata, bad_data, self.floatdata]), + np.stack([self.data, bad_data, self.data]), dims=('band', 'y', 'x'), ) @@ -481,7 +472,7 @@ def test_convert_4_multiband_to_raster(self): """ ds = Mock(DataArray) - bad_data = np.copy(self.floatdata) + bad_data = np.copy(self.data).astype('float64') bad_data[1, 1] = np.nan alpha = np.ones_like(self.data) * 255