diff --git a/python/packages/nisar/static/water_mask.py b/python/packages/nisar/static/water_mask.py index 5fbb42e63..6de9e40fa 100644 --- a/python/packages/nisar/static/water_mask.py +++ b/python/packages/nisar/static/water_mask.py @@ -19,8 +19,8 @@ def binarize_nisar_water_mask(water_distance: ArrayLike) -> np.ndarray: ---------- water_distance : array_like The input water distance map, in the format specified by the NISAR Water Mask - Product Specification\ [1]_. A value of 0 indicates a water pixel. A value of - 255 represents a no-data (invalid) pixel. Values in 1-200 represent non-water + Product Specification\ [1]_. A value of 0 indicates a not-water pixel. A value + of 255 represents a no-data (invalid) pixel. Values in 1-200 represent water pixels. Returns @@ -37,7 +37,7 @@ def binarize_nisar_water_mask(water_distance: ArrayLike) -> np.ndarray: # Compute a binary mask where the value 1 represents (ocean or inland) water pixels # and the value 0 represents non-water pixels. - water = water_distance == 0 + water = (water_distance >= 1) & (water_distance <= 200) # Get a binary mask of invalid pixels (i.e. pixels whose value is equal to the fill # value of 255). @@ -102,8 +102,8 @@ def binarize_and_reproject_water_mask( water_distance_raster_file : path-like The file path or name of the input water distance map file. It must be a GDAL-compatible raster file in the format specified by the NISAR Water Mask - Product Specification\ [1]_. A value of 0 indicates a water pixel. A value of - 255 represents a no-data (invalid) pixel. Values in 1-200 represent non-water + Product Specification\ [1]_. A value of 0 indicates a not-water pixel. A value + of 255 represents a no-data (invalid) pixel. Values in 1-200 represent water pixels. geo_grid : isce3.product.GeoGridParameters The output geocoded coordinate grid to re-project the water mask onto. diff --git a/share/nisar/defaults/static.yaml b/share/nisar/defaults/static.yaml index 6d61d965a..9eaade8ec 100644 --- a/share/nisar/defaults/static.yaml +++ b/share/nisar/defaults/static.yaml @@ -12,7 +12,9 @@ runconfig: # [REQUIRED] File path or URL of the input water mask raster file. # Must be an existing file in a GDAL-compatible raster format that spans the # region of interest and conforms to the NISAR Water Mask Product Specification - # (JPL D-107710). + # (JPL D-107710), where a value of 0 indicates a not-water pixel, a value + # of 255 represents a no-data (invalid) pixel, and values in 1-200 represent + # water pixels. water_mask_raster_file: # [REQUIRED] Path to the input orbit ephemeris XML file. # Must be an existing XML file conforming to the NISAR Orbit Ephemeris Product diff --git a/tests/python/packages/nisar/static/water_mask.py b/tests/python/packages/nisar/static/water_mask.py index 117d1a744..642d822ed 100644 --- a/tests/python/packages/nisar/static/water_mask.py +++ b/tests/python/packages/nisar/static/water_mask.py @@ -9,14 +9,14 @@ def test_binarize_nisar_water_mask(): - # Create three arrays of water pixels (filled with zeros), non-water pixels (filled + # Create three arrays of non-water pixels (filled with zeros), water pixels (filled # with values in range [1, 200]), and invalid pixels (filled with 255). - water = np.zeros((20, 10), dtype=np.uint8) - nonwater = np.arange(1, 201, dtype=np.uint8).reshape(20, 10) + nonwater = np.zeros((20, 10), dtype=np.uint8) + water = np.arange(1, 201, dtype=np.uint8).reshape(20, 10) invalid = np.full((20, 10), fill_value=255, dtype=np.uint8) # Concatenate the three arrays into a single 20x30 array. - water_distance = np.concatenate([water, nonwater, invalid], axis=1) + water_distance = np.concatenate([nonwater, water, invalid], axis=1) # Convert the water distance map into a binary water mask water_mask = binarize_nisar_water_mask(water_distance) @@ -25,8 +25,8 @@ def test_binarize_nisar_water_mask(): assert water_mask.dtype == np.uint8 # Check the mask values. - np.testing.assert_equal(water_mask[:, :10], 1) - np.testing.assert_equal(water_mask[:, 10:20], 0) + np.testing.assert_equal(water_mask[:, :10], 0) + np.testing.assert_equal(water_mask[:, 10:20], 1) np.testing.assert_equal(water_mask[:, 20:], 255)