Skip to content

Commit

Permalink
fix from Raluca's PR for KeyError: mask_attenuation; #160 - fix one e…
Browse files Browse the repository at this point in the history
…rror; fix one typo; fix FutureWarning for DataArray.dims -> DataArray.sizes; fixed downloading of files over FTP only when those files are missing; fix warning: PytestUnknownMarkWarning.
  • Loading branch information
oanabotezat committed Jan 31, 2024
1 parent 1aff48b commit 6b57884
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
4 changes: 3 additions & 1 deletion oceanstream/denoise/apply_masks.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,6 @@ def apply_seabed_mask(ds: xr.Dataset, config) -> xr.Dataset:

ds_processed = apply_selected_masks(ds, params)

return ds_processed
return ds_processed

return ds
4 changes: 2 additions & 2 deletions oceanstream/denoise/background_noise_remover.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Functions:
- `apply_remove_background_noise`:
Main function that applies the `remove_noise` function from echopype to an Sv dataset.
Main function that applies the `remove_noise` function from echopype to a Sv dataset.
Computes default parameters based on dataset characteristics when not provided.
The dataset initially passed to the function, processed in the following manner:
`Sv_corrected` and `Sv_noise` variables are generated by the echopype `remove_noise` function.
Expand Down Expand Up @@ -76,7 +76,7 @@ def apply_remove_background_noise(
# Compute range_sample_num if not provided
if range_sample_num is None:
range_sample_nums = []
for ch in range(ds_Sv.dims["channel"]):
for ch in range(ds_Sv.sizes["channel"]):
mean_diff = np.nanmean(np.diff(ds_Sv["echo_range"].isel(channel=ch).values[0, :]))
if np.isnan(mean_diff):
raise ValueError(
Expand Down
6 changes: 5 additions & 1 deletion oceanstream/settings/defaults.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
"m": null,
"thr": -5,
"start": 0,
"offset": 0
"offset": 0,
"dask_chunking": {
"ping_time": 100,
"range_sample": 100
}
}
},
"transient": {
Expand Down
12 changes: 9 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,15 @@ def denoise_dataset(dataset):
@pytest.fixture(scope="session")
def ftp_data():
test_data_folder = Path(TEST_DATA_FOLDER) / "ek60"
# with FTP(FTP_MAIN) as ftp:
# ftp.login()
# download_ftp_directory(ftp, FTP_PARTIAL_PATH, test_data_folder)

# if there is data in here skip downloading...
must_download = not os.path.exists(test_data_folder) or not os.listdir(test_data_folder)

if must_download:
with FTP(FTP_MAIN) as ftp:
ftp.login()
download_ftp_directory(ftp, FTP_PARTIAL_PATH, test_data_folder)

yield str(test_data_folder)
# Optional: Cleanup after tests are done
# shutil.rmtree(TEST_DATA_FOLDER)
Expand Down
3 changes: 3 additions & 0 deletions tests/pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[pytest]
markers =
ignore: marks a test as ignored.

0 comments on commit 6b57884

Please sign in to comment.