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

Changed the shoal processing for less memory usage #149

Merged
merged 1 commit into from
Dec 4, 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
8 changes: 5 additions & 3 deletions oceanstream/L3_regridded_data/shoal_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def split_shoal_mask(Sv: xr.Dataset):
coords=all_shoals.coords,
)
shoal.attrs["label"] = i
shoals.append(shoal)
shoal_dict = process_single_shoal(Sv, shoal)
shoals.append(shoal_dict)
return shoals


Expand Down Expand Up @@ -198,8 +199,9 @@ def process_shoals(Sv: xr.Dataset):
"nasc": None,
}
return [return_dict]
masks = split_shoal_mask(Sv)
dicts = [process_single_shoal(Sv, mask) for mask in masks]
# masks = split_shoal_mask(Sv)
# dicts = [process_single_shoal(Sv, mask) for mask in masks]
dicts = split_shoal_mask(Sv)
results = [item for sublist in dicts for item in sublist]
results = [r for r in results if r is not None]
return results
Expand Down
12 changes: 6 additions & 6 deletions tests/test_shoal_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ def test_split_shoal(ek_60_Sv_denoised):
expected_results = [(13671, 6101109), (13465, 6101315), (30, 6114750)]
shoal_dataset = prep_dataset(ek_60_Sv_denoised)
res = split_shoal_mask(shoal_dataset)
res_tfc = [tfc(r) for r in res]
assert res_tfc == expected_results
assert len(res) == len(expected_results)

# @pytest.mark.ignore
def test_single_shoal(ek_60_Sv_denoised):
shoal_dataset = prep_dataset(ek_60_Sv_denoised)
mask = split_shoal_mask(shoal_dataset)[0]
res = process_single_shoal(shoal_dataset, mask)
#mask = split_shoal_mask(shoal_dataset)[0]
res = split_shoal_mask(shoal_dataset)

assert len(res) == 3
assert len(res[0]) == 24
assert res[0]["area"] == 6017
assert len(res[0]) == 3
assert res[0][0]["area"] == 6017

# @pytest.mark.ignore
def test_shoals(ek_60_Sv_denoised):
Expand Down
Loading