Skip to content

ensemble_tides: dedupe locations before idw(), not after - #155

Open
yurithefury wants to merge 1 commit into
GeoscienceAustralia:mainfrom
yurithefury:fix-ensemble-tides-duplicate-idw
Open

yurithefury wants to merge 1 commit into
GeoscienceAustralia:mainfrom
yurithefury:fix-ensemble-tides-duplicate-idw

Conversation

@yurithefury

@yurithefury yurithefury commented Aug 14, 2026 •

Copy link
Copy Markdown

Problem

Ran into out-of-memory (OOM) errors running ensemble tide modelling.

ensemble_tides() interpolates model rankings using tide_df's full (time, x, y, tide_model) index, so idw() gets called with each location repeated once per timestep and model, even though rankings only depend on location.

Hit this generating a DEM over a 10km AOI, 5 years of exposure() at the default 30min cadence: 64 locations turned into ~50M query rows (64 x 87,648 timesteps x 9 models), idw() tried to allocate 33.8 GiB and died.

Fix

Dedupe x/y before calling idw() instead of after (there's already a drop_duplicates() call, it just runs on the result). The join back onto tide_df a few lines down already broadcasts each location's ranking to every matching row, so this is just a perf fix. Checked original vs patched with duplicated query points, same output.

Test

Added test_ensemble_tides_deduplicates_ranking_queries, which wraps idw() to check how many points it's called with, and confirms it only gets called once per unique location. Fails on main, passes with this fix.

Ran into out-of-memory (OOM) errors during ensemble modelling. x/y
passed to idw() come straight from tide_df's full index, so each
location gets interpolated once per timestep and model instead of once.
Dedupe before calling idw(), not after. Memory now scales with unique
locations, not locations x times x models.
@yurithefury
yurithefury force-pushed the fix-ensemble-tides-duplicate-idw branch from cb1394a to 8df4d21 Compare August 14, 2026 00:28
@yurithefury
yurithefury marked this pull request as ready for review August 14, 2026 00:34

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant