Skip to content

Commit

Permalink
DAS-2108: Update CHANGELOG and service version
Browse files Browse the repository at this point in the history
Test Cleanup, better naming.
  • Loading branch information
flamingbear committed Apr 16, 2024
1 parent a2296ce commit cbbb64c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion docker/service_version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.1
1.0.2
10 changes: 5 additions & 5 deletions harmony_browse_image_generator/browse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

Expand Down
17 changes: 4 additions & 13 deletions tests/unit/test_browse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')

Expand Down Expand Up @@ -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'),
)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cbbb64c

Please sign in to comment.