Skip to content

Commit

Permalink
Fix notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
robbibt committed Oct 15, 2024
1 parent d02f326 commit 4bae3cb
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 85 deletions.
127 changes: 59 additions & 68 deletions docs/notebooks/Case_study_intertidal.ipynb

Large diffs are not rendered by default.

40 changes: 37 additions & 3 deletions docs/notebooks/Tide_statistics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Calculate biases for multiple satellite sensors"
"## Calculate biases for multiple satellite sensors\n",
"At our location, Sentinel-2 optical satellites are biased towards high tide observations, while Sentinel-1 radar satellites are biased towards low tide observations. \n",
"Could combining data from multiple EO sensors help us capture a more complete view of tides at this location?\n",
"\n",
"To test this theory, we can combine Sentinel-2 and Sentinel-1 data into a single `xarray.Dataset`, recording the name of each sensor using a new `satellite_name` coordinate in our data:"
]
},
{
Expand Down Expand Up @@ -379,7 +383,16 @@
"\n",
"# Combine both Sentinel-1 and Sentinel-2 data into a single dataset\n",
"ds_all = xr.concat([ds_s1, ds_s2], dim=\"time\")\n",
"print(ds_all)\n"
"print(ds_all)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can now run `tide_stats` again.\n",
"This time, we pass our satellite name coordinate to the function using the `plot_col=\"satellite_name\"` parameter.\n",
"This will plot data from each of our satellites using a different symbol."
]
},
{
Expand Down Expand Up @@ -429,6 +442,27 @@
" directory=\"../../tests/data/tide_models\",\n",
")\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We can see that at this location, combining Sentinel-2 and Sentinel-1 data greatly improves our biases: our satellite data now covers ~85% of the modelled astronomical tide range, and only fails to observe 10% of the highest tides and 6% of the lowest tides!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Next steps\n",
"\n",
"We have explored calculating tide statistics and biases in EO data. Now we can learn how to validate modelled tides against [measured tide gauge data](../Validating_tides) to ensure the tides we are modelling are accurate."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
}
],
"metadata": {
Expand All @@ -447,7 +481,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.0"
"version": "3.12.1"
}
},
"nbformat": 4,
Expand Down
15 changes: 2 additions & 13 deletions docs/notebooks/Validating_tides.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,6 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/workspaces/eo-tides/.venv/lib/python3.12/site-packages/geopandas/array.py:403: UserWarning: Geometry is in a geographic CRS. Results from 'sjoin_nearest' are likely incorrect. Use 'GeoSeries.to_crs()' to re-project geometries to a projected CRS before this operation.\n",
"\n",
" warnings.warn(\n",
"/workspaces/eo-tides/eo_tides/validation.py:157: FutureWarning: Support for nested sequences for 'parse_dates' in pd.read_csv is deprecated. Combine the desired columns with pd.to_datetime after parsing instead.\n",
" pd.read_csv(\n"
]
Expand Down Expand Up @@ -194,19 +191,11 @@
"joined_df.plot.scatter(x=\"sea_level\", y=\"tide_height\")\n",
"eval_metrics(x=joined_df.sea_level, y=joined_df.tide_height)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9427ee6f-0db7-47a5-86e1-1617f9372c6c",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": ".venv",
"language": "python",
"name": "python3"
},
Expand All @@ -220,7 +209,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.1"
"version": "3.12.0"
}
},
"nbformat": 4,
Expand Down
4 changes: 3 additions & 1 deletion eo_tides/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ def load_gauge_gesla(

# If x and y are single numbers, select nearest row
elif isinstance(x, Number) & isinstance(y, Number):
site_code = _nearest_row(metadata_gdf, x, y, max_distance).site_code
with warnings.catch_warnings():
warnings.simplefilter("ignore")
site_code = _nearest_row(metadata_gdf, x, y, max_distance).site_code

# Raise exception if no valid tide gauges are found
if site_code.isnull().all():
Expand Down

0 comments on commit 4bae3cb

Please sign in to comment.