Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/transient attenuation mask type #93

Merged
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
4 changes: 3 additions & 1 deletion echopype/clean/signal_attenuation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import warnings

import numpy as np
import xarray as xr
from skimage.measure import label
Expand Down Expand Up @@ -65,9 +67,9 @@ def _ryan(source_Sv: xr.DataArray, desired_channel: str, parameters=DEFAULT_RYAN

# return empty mask if searching range is outside the echosounder range
if (r0 > r[-1]) or (r1 < r[0]):
warnings.warn("Searching range is outside the echosounder range. Returning empty mask.")
mask = np.zeros_like(Sv, dtype=bool)
mask_ = np.zeros_like(Sv, dtype=bool)
return mask, mask_

# turn layer boundaries into arrays with length = Sv.shape[1]
r0 = np.ones(Sv.shape[1]) * r0
Expand Down
14 changes: 13 additions & 1 deletion echopype/clean/transient_noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"Mihai Boldeanu", # adapted the mask transient noise algorithms to echopype
]

import warnings

import numpy as np
import xarray as xr
Expand Down Expand Up @@ -189,9 +190,20 @@ def _fielding(

# return empty mask if searching range is outside the echosounder range
if (r0 > r[-1]) or (r1 < r[0]):
# Raise a warning to inform the user
warnings.warn(
"The searching range is outside the echosounder range. "
"A default mask with all False values is returned, "
"which won't mask any data points in the dataset."
)
mask = np.zeros_like(Sv, dtype=bool)
mask_ = np.zeros_like(Sv, dtype=bool)
return mask, mask_
combined_mask = mask
return xr.DataArray(
combined_mask,
dims=("ping_time", "range_sample"),
coords={"ping_time": source_Sv.ping_time, "range_sample": source_Sv.range_sample},
)

# get upper and lower range indexes
up = np.argmin(abs(r - r0))
Expand Down