Skip to content

Commit

Permalink
Simplify ensemble code
Browse files Browse the repository at this point in the history
  • Loading branch information
robbibt committed Oct 9, 2024
1 parent 609b6f3 commit 43731d9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
25 changes: 25 additions & 0 deletions docs/notebooks/Model_tides.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,31 @@
"tide_df.head()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Index([122.2186, 122.2186, 122.2186, 122.2186, 122.2186, 122.2186, 122.2186,\n",
" 122.2186, 122.2186, 122.2186,\n",
" ...\n",
" 122.2186, 122.2186, 122.2186, 122.2186, 122.2186, 122.2186, 122.2186,\n",
" 122.2186, 122.2186, 122.2186],\n",
" dtype='float64', name='x', length=721)"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"tide_df.index.get_level_values(level=\"x\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
6 changes: 3 additions & 3 deletions eo_tides/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,8 +423,8 @@ def _ensemble_model(
"""
# Extract x and y coords from dataframe
x = tide_df.index.get_level_values("x")
y = tide_df.index.get_level_values("y")
x = tide_df.index.get_level_values(level="x")
y = tide_df.index.get_level_values(level="y")

# Load model ranks points and reproject to same CRS as x and y
model_ranking_cols = [f"rank_{m}" for m in ensemble_models]
Expand Down Expand Up @@ -804,7 +804,7 @@ def model_tides(

# Optionally compute ensemble model and add to dataframe
if "ensemble" in models_requested:
ensemble_df = _ensemble_model(crs, tide_df, models_to_process, **ensemble_kwargs)
ensemble_df = _ensemble_model(tide_df, crs, models_to_process, **ensemble_kwargs)

# Update requested models with any custom ensemble models, then
# filter the dataframe to keep only models originally requested
Expand Down

0 comments on commit 43731d9

Please sign in to comment.