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

Moved test parameters into the testcase module #147

Merged
merged 2 commits into from
Nov 29, 2023
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
57 changes: 1 addition & 56 deletions oceanstream/L2_calibrated_data/noise_masks.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,61 +135,6 @@
},
}

TEST_MASK_PARAMETERS = {
"transient": {
"method": "ryan",
"params": {
"m": 5,
"n": 5,
"thr": 20,
"excludeabove": 250,
"dask_chunking": {"ping_time": 100},
"operation": "mean",
},
},
"attenuation": {
"method": "ryan",
"params": {
"r0": 180,
"r1": 280,
"n": 5,
"m": None,
"thr": -5,
"start": 0,
"offset": 0,
},
},
"impulse": {"method": "ryan", "params": {"thr": 3, "m": 3, "n": 1}},
"seabed": {
"method": "ariza",
"params": {
"r0": 10,
"r1": 1000,
"roff": 0,
"thr": -40,
"ec": 1,
"ek": (1, 3),
"dc": 10,
"dk": (3, 7),
},
},
"false_seabed": {
"method": "blackwell",
"params": {
"theta": None,
"phi": None,
"r0": 10,
"r1": 1000,
"tSv": -75,
"ttheta": 702,
"tphi": 282,
"wtheta": 28,
"wphi": 52,
},
},
}


OCEANSTREAM_NOISE_MASK_PARAMETERS = {
k: OCEANSTREAM_MASK_PARAMETERS[k] for k in ["transient", "attenuation", "impulse"]
}
Expand Down Expand Up @@ -345,7 +290,7 @@ def create_mask(source_Sv: xr.Dataset, mask_type="impulse", params=MASK_PARAMETE
return mask


def create_multiple_masks(source_Sv: xr.Dataset, params=TEST_MASK_PARAMETERS):
def create_multiple_masks(source_Sv: xr.Dataset, params=None):
"""
A function that creates multiple noise masks for a given Sv dataset

Expand Down
55 changes: 54 additions & 1 deletion tests/test_noise_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,59 @@
create_multiple_masks,
)

TEST_MASK_PARAMETERS = {
"transient": {
"method": "ryan",
"params": {
"m": 5,
"n": 5,
"thr": 20,
"excludeabove": 250,
"dask_chunking": {"ping_time": 100},
"operation": "mean",
},
},
"attenuation": {
"method": "ryan",
"params": {
"r0": 180,
"r1": 280,
"n": 5,
"m": None,
"thr": -5,
"start": 0,
"offset": 0,
},
},
"impulse": {"method": "ryan", "params": {"thr": 3, "m": 3, "n": 1}},
"seabed": {
"method": "ariza",
"params": {
"r0": 10,
"r1": 1000,
"roff": 0,
"thr": -40,
"ec": 1,
"ek": (1, 3),
"dc": 10,
"dk": (3, 7),
},
},
"false_seabed": {
"method": "blackwell",
"params": {
"theta": None,
"phi": None,
"r0": 10,
"r1": 1000,
"tSv": -75,
"ttheta": 702,
"tphi": 282,
"wtheta": 28,
"wphi": 52,
},
},
}

def test_impulse(enriched_ek60_Sv):
source_Sv = enriched_ek60_Sv
Expand Down Expand Up @@ -48,7 +101,7 @@ def test_seabed(enriched_ek60_Sv):

def test_create_masks(enriched_ek60_Sv):
enriched_Sv = enriched_ek60_Sv
Sv_mask = create_multiple_masks(enriched_Sv)
Sv_mask = create_multiple_masks(enriched_Sv, TEST_MASK_PARAMETERS)
assert Sv_mask["mask_seabed"].attrs["mask_type"] == "seabed"
assert Sv_mask["mask_impulse"].attrs["parameters"] == ["thr=3", "m=3", "n=1"]