From 43731d9799ac628b3c9523251840308baabf2177 Mon Sep 17 00:00:00 2001 From: Robbi Bishop-Taylor Date: Wed, 9 Oct 2024 04:40:59 +0000 Subject: [PATCH] Simplify ensemble code --- docs/notebooks/Model_tides.ipynb | 25 +++++++++++++++++++++++++ eo_tides/model.py | 6 +++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/docs/notebooks/Model_tides.ipynb b/docs/notebooks/Model_tides.ipynb index 410ec83..68ed328 100644 --- a/docs/notebooks/Model_tides.ipynb +++ b/docs/notebooks/Model_tides.ipynb @@ -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": {}, diff --git a/eo_tides/model.py b/eo_tides/model.py index f8df45f..7181793 100644 --- a/eo_tides/model.py +++ b/eo_tides/model.py @@ -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] @@ -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