Skip to content

Commit

Permalink
Changed the shoal processing for less memory usage (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaiboldeanu authored Dec 4, 2023
1 parent a67be2c commit df9496c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
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

0 comments on commit df9496c

Please sign in to comment.