Skip to content

Commit c0b776d

Browse files
authored
DAS-2259 fix opera rtc browse images. (#34)
1 parent 117b878 commit c0b776d

File tree

4 files changed

+66
-5
lines changed

4 files changed

+66
-5
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ HyBIG follows semantic versioning. All notable changes to this project will be
44
documented in this file. The format is based on [Keep a
55
Changelog](http://keepachangelog.com/en/1.0.0/).
66

7+
## [v2.0.2] - 2024-10-15
8+
9+
### Fixed
10+
11+
**DAS-2259**
12+
- Corrects bug with RGBA input tifs.
13+
714
## [v2.0.1] - 2024-10-06
815

916
### Changed
@@ -70,7 +77,8 @@ outlined by the NASA open-source guidelines.
7077
For more information on internal releases prior to NASA open-source approval,
7178
see legacy-CHANGELOG.md.
7279

73-
[unreleased]:https://github.com/nasa/harmony-browse-image-generator/compare/2.0.1..HEAD
80+
[unreleased]:https://github.com/nasa/harmony-browse-image-generator/compare/2.0.2..HEAD
81+
[v2.0.2]:https://github.com/nasa/harmony-browse-image-generator/compare/2.0.1..2.0.2
7482
[v2.0.1]:https://github.com/nasa/harmony-browse-image-generator/compare/2.0.0..2.0.1
7583
[v2.0.0]:https://github.com/nasa/harmony-browse-image-generator/compare/1.2.2..2.0.0
7684
[v1.2.2]: https://github.com/nasa/harmony-browse-image-generator/compare/1.2.1..1.2.2

docker/service_version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.0.1
1+
2.0.2

hybig/browse.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,9 @@ def convert_mulitband_to_raster(data_array: DataArray) -> ndarray:
246246
)
247247

248248
if image_alpha is not None:
249-
# merge nan alpha with the image alpha prefering transparency to
250-
# opaqueness.
251-
alpha = np.minimum(nan_alpha, image_alpha)
249+
# merge missing alpha with the image alpha band prefering transparency
250+
# to opaqueness.
251+
alpha = np.minimum(nan_alpha, image_alpha).astype(np.uint8)
252252
else:
253253
alpha = nan_alpha
254254

tests/unit/test_browse.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,59 @@ def test_convert_4_multiband_to_raster(self):
514514
actual_raster = convert_mulitband_to_raster(ds)
515515
assert_array_equal(expected_raster, actual_raster.data)
516516

517+
def test_convert_4_multiband_masked_to_raster(self):
518+
"""Input data is selected from a subset of a real OPERA RTC input data
519+
file that has masked the alpha layer and as a result as a datatype of
520+
float32.
521+
522+
"""
523+
ds = Mock(DataArray)
524+
ds.rio.count = 4
525+
nan = np.nan
526+
input_array = np.array(
527+
[
528+
[
529+
[nan, nan, nan, 234.0],
530+
[nan, nan, nan, 225.0],
531+
[nan, nan, 255.0, 215.0],
532+
[nan, nan, 217.0, 255.0],
533+
],
534+
[
535+
[nan, nan, nan, 255.0],
536+
[nan, nan, nan, 255.0],
537+
[nan, nan, 255.0, 255.0],
538+
[nan, nan, 255.0, 255.0],
539+
],
540+
[
541+
[nan, nan, nan, 234.0],
542+
[nan, nan, nan, 225.0],
543+
[nan, nan, 255.0, 215.0],
544+
[nan, nan, 217.0, 255.0],
545+
],
546+
[
547+
[0.0, 0.0, 0.0, 255.0],
548+
[0.0, 0.0, 0.0, 255.0],
549+
[0.0, 0.0, 255.0, 255.0],
550+
[0.0, 0.0, 255.0, 255.0],
551+
],
552+
],
553+
dtype=np.float32,
554+
)
555+
ds.to_numpy.return_value = input_array
556+
557+
expected_raster = np.ma.array(
558+
data=[
559+
[[0, 0, 0, 121], [0, 0, 0, 64], [0, 0, 255, 0], [0, 0, 13, 255]],
560+
[[0, 0, 0, 255], [0, 0, 0, 255], [0, 0, 255, 255], [0, 0, 255, 255]],
561+
[[0, 0, 0, 121], [0, 0, 0, 64], [0, 0, 255, 0], [0, 0, 13, 255]],
562+
[[0, 0, 0, 255], [0, 0, 0, 255], [0, 0, 255, 255], [0, 0, 255, 255]],
563+
],
564+
dtype=np.uint8,
565+
)
566+
567+
actual_raster = convert_mulitband_to_raster(ds)
568+
assert_array_equal(expected_raster.data, actual_raster.data)
569+
517570
def test_convert_5_multiband_to_raster(self):
518571
ds = Mock(DataArray)
519572
ds.rio.count = 5

0 commit comments

Comments
 (0)