diff --git a/oceanstream/L2_calibrated_data/noise_masks.py b/oceanstream/L2_calibrated_data/noise_masks.py index 4486b17..399c2d2 100644 --- a/oceanstream/L2_calibrated_data/noise_masks.py +++ b/oceanstream/L2_calibrated_data/noise_masks.py @@ -8,7 +8,6 @@ import pathlib from typing import Union -import xarray import xarray as xr from echopype.clean.api import ( get_attenuation_mask_multichannel, @@ -28,7 +27,8 @@ # "n": 5, "thr": 20, "excludeabove": 250, - "operation": "percentile15", + "dask_chunking": {"ping_time": 100}, + "operation": "mean", }, }, "attenuation": { @@ -83,7 +83,8 @@ # "n": 5, "thr": 20, "excludeabove": 250, - "operation": "percentile15", + "dask_chunking": {"ping_time": 100}, + "operation": "mean", }, }, "attenuation": { @@ -140,6 +141,7 @@ "n": 5, "thr": 20, "excludeabove": 250, + "dask_chunking": {"ping_time": 100}, "operation": "mean", }, }, @@ -307,7 +309,7 @@ def create_seabed_mask(Sv, parameters, method): return mask -def create_mask(source_Sv: xarray.Dataset, mask_type="impulse", params=MASK_PARAMETERS): +def create_mask(source_Sv: xr.Dataset, mask_type="impulse", params=MASK_PARAMETERS): """ A function that creates a single noise mask for a given dataset @@ -341,7 +343,7 @@ def create_mask(source_Sv: xarray.Dataset, mask_type="impulse", params=MASK_PARA return mask -def create_multiple_masks(source_Sv: xarray.Dataset, params=TEST_MASK_PARAMETERS): +def create_multiple_masks(source_Sv: xr.Dataset, params=TEST_MASK_PARAMETERS): """ A function that creates multiple noise masks for a given Sv dataset @@ -366,7 +368,7 @@ def create_multiple_masks(source_Sv: xarray.Dataset, params=TEST_MASK_PARAMETERS return Sv_mask -def create_noise_masks_rapidkrill(source_Sv: xarray.Dataset, params=RAPIDKRILL_MASK_PARAMETERS): +def create_noise_masks_rapidkrill(source_Sv: xr.Dataset, params=RAPIDKRILL_MASK_PARAMETERS): """ A function that creates noise masks for a given Sv dataset according to rapidkrill processing needs @@ -391,7 +393,7 @@ def create_noise_masks_rapidkrill(source_Sv: xarray.Dataset, params=RAPIDKRILL_M def create_default_noise_masks_oceanstream( - source_Sv: xarray.Dataset, params=OCEANSTREAM_MASK_PARAMETERS + source_Sv: xr.Dataset, params=OCEANSTREAM_MASK_PARAMETERS ): """ A function that creates noise masks for a given Sv dataset using default methods for oceanstream @@ -416,7 +418,7 @@ def create_default_noise_masks_oceanstream( def create_seabed_masks_oceanstream( - source_Sv: xarray.Dataset, params=OCEANSTREAM_SEABED_MASK_PARAMETERS + source_Sv: xr.Dataset, params=OCEANSTREAM_SEABED_MASK_PARAMETERS ): """ A function that creates seabed masks for a given Sv dataset using default methods for oceanstream @@ -434,9 +436,7 @@ def create_seabed_masks_oceanstream( return Sv_mask -def create_noise_masks_oceanstream( - source_Sv: xarray.Dataset, params=OCEANSTREAM_NOISE_MASK_PARAMETERS -): +def create_noise_masks_oceanstream(source_Sv: xr.Dataset, params=OCEANSTREAM_NOISE_MASK_PARAMETERS): """ A function that creates noise masks for a given Sv dataset using default methods for oceanstream diff --git a/tests/test_noise_mask.py b/tests/test_noise_mask.py index 5423d29..f20c6c1 100644 --- a/tests/test_noise_mask.py +++ b/tests/test_noise_mask.py @@ -1,4 +1,5 @@ import pytest +from oceanstream.L2_calibrated_data.noise_masks import OCEANSTREAM_MASK_PARAMETERS from oceanstream.L2_calibrated_data.noise_masks import ( create_attenuation_mask, @@ -13,22 +14,14 @@ def test_impulse(enriched_ek60_Sv): source_Sv = enriched_ek60_Sv - RYAN_DEFAULT_PARAMS = {"thr": 10, "m": 5, "n": 1} + RYAN_DEFAULT_PARAMS = OCEANSTREAM_MASK_PARAMETERS["impulse"]["params"] mask = create_impulse_mask(source_Sv, parameters=RYAN_DEFAULT_PARAMS) assert mask["channel"].shape == (3,) def test_transient(enriched_ek60_Sv): source_Sv = enriched_ek60_Sv - RYAN_DEFAULT_PARAMS = { - # "m": 5, - # "n": 20, - "m": 5, - "n": 5, - "thr": 20, - "excludeabove": 250, - "operation": "mean", - } + RYAN_DEFAULT_PARAMS = OCEANSTREAM_MASK_PARAMETERS["transient"]["params"] mask_ryan = create_transient_mask( source_Sv, parameters=RYAN_DEFAULT_PARAMS, method="ryan" ) @@ -36,23 +29,14 @@ def test_transient(enriched_ek60_Sv): def test_attenuation(enriched_ek60_Sv): - DEFAULT_RYAN_PARAMS = {"r0": 180, "r1": 280, "n": 30, "thr": -6, "start": 0} + DEFAULT_RYAN_PARAMS = OCEANSTREAM_MASK_PARAMETERS["attenuation"]["params"] source_Sv = enriched_ek60_Sv mask = create_attenuation_mask(source_Sv, parameters=DEFAULT_RYAN_PARAMS) assert mask["channel"].shape == (3,) def test_seabed(enriched_ek60_Sv): - ARIZA_DEFAULT_PARAMS = { - "r0": 10, - "r1": 1000, - "roff": 0, - "thr": -40, - "ec": 1, - "ek": (1, 3), - "dc": 10, - "dk": (3, 7), - } + ARIZA_DEFAULT_PARAMS = OCEANSTREAM_MASK_PARAMETERS["seabed"]["params"] source_Sv = enriched_ek60_Sv mask = create_seabed_mask( source_Sv, @@ -66,4 +50,5 @@ def test_create_masks(enriched_ek60_Sv): enriched_Sv = enriched_ek60_Sv Sv_mask = create_multiple_masks(enriched_Sv) assert Sv_mask["mask_seabed"].attrs["mask_type"] == "seabed" - assert Sv_mask["mask_impulse"].attrs["parameters"] == ["thr=10", "m=5", "n=1"] + assert Sv_mask["mask_impulse"].attrs["parameters"] == ["thr=3", "m=3", "n=1"] +