Skip to content

Commit 736153f

Browse files
committed
updated remove background noise
1 parent bec1699 commit 736153f

1 file changed

Lines changed: 7 additions & 15 deletions

File tree

echopype/clean/api.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from ..commongrid.utils import _parse_x_bin
1111
from ..utils.compute import _lin2log, _log2lin
1212
from ..utils.log import _init_logger
13-
from ..utils.prov import add_processing_level, echopype_prov_attrs, insert_input_processing_level
13+
from ..utils.prov import echopype_prov_attrs
1414
from .utils import (
1515
add_remove_background_noise_attrs,
1616
downsample_upsample_along_depth,
@@ -350,7 +350,7 @@ def mask_attenuated_signal(
350350

351351

352352
def estimate_background_noise(
353-
ds_Sv: xr.Dataset, ping_num: int, range_sample_num: int, background_noise_max: str = None, range_var: str = "depth"
353+
ds_Sv: xr.Dataset, ping_num: int, range_sample_num: int, background_noise_max: str = None
354354
) -> xr.DataArray:
355355
"""
356356
Estimate background noise by computing mean calibrated power of a collection of pings.
@@ -384,8 +384,8 @@ def estimate_background_noise(
384384
background_noise_max = extract_dB(background_noise_max)
385385

386386
# Compute transmission loss
387-
spreading_loss = 20 * np.log10(ds_Sv[range_var].where(ds_Sv[range_var] >= 1, other=1))
388-
absorption_loss = 2 * ds_Sv["sound_absorption"] * ds_Sv[range_var]
387+
spreading_loss = 20 * np.log10(ds_Sv["echo_range"].where(ds_Sv["echo_range"] >= 1, other=1))
388+
absorption_loss = 2 * ds_Sv["sound_absorption"] * ds_Sv["echo_range"]
389389

390390
# Compute power binned averages
391391
power_cal = _log2lin(ds_Sv["Sv"] - spreading_loss - absorption_loss)
@@ -423,7 +423,6 @@ def estimate_background_noise(
423423
return Sv_noise
424424

425425

426-
@add_processing_level("L*B")
427426
def remove_background_noise(
428427
ds_Sv: xr.Dataset,
429428
ping_num: int,
@@ -481,21 +480,14 @@ def remove_background_noise(
481480
ds_Sv["Sv_noise"] = add_remove_background_noise_attrs(
482481
ds_Sv["Sv_noise"], "noise", ping_num, range_sample_num, SNR_threshold, background_noise_max
483482
)
484-
ds_Sv["Sv_corrected"] = corrected_Sv
485-
ds_Sv["Sv_corrected"] = add_remove_background_noise_attrs(
486-
ds_Sv["Sv_corrected"],
487-
"corrected",
488-
ping_num,
489-
range_sample_num,
490-
SNR_threshold,
491-
background_noise_max,
492-
)
483+
ds_Sv["Sv"] = corrected_Sv
484+
493485
prov_dict = echopype_prov_attrs(process_type="processing")
494486
prov_dict["processing_function"] = "clean.remove_background_noise"
495487
ds_Sv = ds_Sv.assign_attrs(prov_dict)
496488

497489
# The output `ds_Sv` is built as a copy of the input `ds_Sv`, so the step below is
498490
# not needed, strictly speaking. But doing makes the decorator function more generic
499-
ds_Sv = insert_input_processing_level(ds_Sv, input_ds=ds_Sv)
491+
# ds_Sv = insert_input_processing_level(ds_Sv, input_ds=ds_Sv)
500492

501493
return ds_Sv

0 commit comments

Comments
 (0)