|
10 | 10 | from ..commongrid.utils import _parse_x_bin |
11 | 11 | from ..utils.compute import _lin2log, _log2lin |
12 | 12 | 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 |
14 | 14 | from .utils import ( |
15 | 15 | add_remove_background_noise_attrs, |
16 | 16 | downsample_upsample_along_depth, |
@@ -350,7 +350,7 @@ def mask_attenuated_signal( |
350 | 350 |
|
351 | 351 |
|
352 | 352 | 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 |
354 | 354 | ) -> xr.DataArray: |
355 | 355 | """ |
356 | 356 | Estimate background noise by computing mean calibrated power of a collection of pings. |
@@ -384,8 +384,8 @@ def estimate_background_noise( |
384 | 384 | background_noise_max = extract_dB(background_noise_max) |
385 | 385 |
|
386 | 386 | # 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"] |
389 | 389 |
|
390 | 390 | # Compute power binned averages |
391 | 391 | power_cal = _log2lin(ds_Sv["Sv"] - spreading_loss - absorption_loss) |
@@ -423,7 +423,6 @@ def estimate_background_noise( |
423 | 423 | return Sv_noise |
424 | 424 |
|
425 | 425 |
|
426 | | -@add_processing_level("L*B") |
427 | 426 | def remove_background_noise( |
428 | 427 | ds_Sv: xr.Dataset, |
429 | 428 | ping_num: int, |
@@ -481,21 +480,14 @@ def remove_background_noise( |
481 | 480 | ds_Sv["Sv_noise"] = add_remove_background_noise_attrs( |
482 | 481 | ds_Sv["Sv_noise"], "noise", ping_num, range_sample_num, SNR_threshold, background_noise_max |
483 | 482 | ) |
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 | + |
493 | 485 | prov_dict = echopype_prov_attrs(process_type="processing") |
494 | 486 | prov_dict["processing_function"] = "clean.remove_background_noise" |
495 | 487 | ds_Sv = ds_Sv.assign_attrs(prov_dict) |
496 | 488 |
|
497 | 489 | # The output `ds_Sv` is built as a copy of the input `ds_Sv`, so the step below is |
498 | 490 | # 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) |
500 | 492 |
|
501 | 493 | return ds_Sv |
0 commit comments