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

Fix tests #125

Merged
merged 1 commit into from
Nov 8, 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
2 changes: 1 addition & 1 deletion tests/test_applying_masks_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_apply_selected_noise_masks_and_or_noise_removal(enriched_ek60_Sv):
ds_processed = apply_selected_noise_masks_and_or_noise_removal(
Sv_with_masks, process_parameters
)
assert np.nanmean(ds_processed["Sv"].values) == pytest.approx(-76.03202896956714, 0.0001)
assert np.nanmean(ds_processed["Sv"].values) == pytest.approx(-77.02628114845355, 0.0001)
with pytest.raises(ValueError, match="Unexpected mask/process"):
apply_selected_noise_masks_and_or_noise_removal(Sv_with_masks, "invalid_parameters")

Expand Down
40 changes: 3 additions & 37 deletions tests/test_nasc_computation.py
Original file line number Diff line number Diff line change
@@ -1,50 +1,16 @@
import pytest

from oceanstream.L2_calibrated_data import sv_interpolation
from oceanstream.L2_calibrated_data.noise_masks import create_default_noise_masks_oceanstream
from oceanstream.L3_regridded_data import applying_masks_handler, nasc_computation
from oceanstream.L3_regridded_data import nasc_computation


def test_compute_per_dataset_nasc(enriched_ek60_Sv):
enriched_Sv = enriched_ek60_Sv
Sv_with_masks = create_default_noise_masks_oceanstream(enriched_Sv)

process_parameters = {
"mask_transient": {
"var_name": "Sv",
},
"mask_impulse": {
"var_name": "Sv",
},
"mask_attenuation": {
"var_name": "Sv",
},
}
cleaned_ds = applying_masks_handler.apply_selected_noise_masks_and_or_noise_removal(
Sv_with_masks,
process_parameters,
)
interpolated_ds = sv_interpolation.interpolate_sv(cleaned_ds)
interpolated_ds = interpolated_ds.rename({"Sv": "Sv_denoised", "Sv_interpolated": "Sv"})
process_parameters = {
"remove_background_noise": {
"ping_num": 40,
"range_sample_num": 10,
"noise_max": -125,
"SNR_threshold": 3,
},
}
interpolated_ds = applying_masks_handler.apply_selected_noise_masks_and_or_noise_removal(
interpolated_ds, process_parameters
)

nasc_os = nasc_computation.compute_per_dataset_nasc(interpolated_ds)
nasc_os = nasc_computation.compute_per_dataset_nasc(enriched_ek60_Sv)

val = (
nasc_os["NASC_dataset"]["NASC"]
.sel(channel="GPT 18 kHz 009072058c8d 1-1 ES18-11")
.values[0][0]
)
assert val == pytest.approx(31774234.87447954, 0.0001)
assert val == pytest.approx(25554438.181145363, 0.0001)
assert nasc_os["maximum_depth"][0:3] == "199"
assert nasc_os["maximum_distance"][0:3] == "3.2"
Loading