Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions python/packages/nisar/static/water_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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).
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion share/nisar/defaults/static.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions tests/python/packages/nisar/static/water_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)


Expand Down
Loading