Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added TELEMAC Notebook and files #93

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ repos:
rev: "v4.6.0"
hooks:
- id: "check-added-large-files"
args: ["--maxkb=20000"]
- id: "check-ast"
- id: "check-byte-order-marker"
- id: "check-docstring-first"
Expand Down
134 changes: 134 additions & 0 deletions notebooks/TELEMAC.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# ensure that the Selafin engine is available\n",
"%pip install xarray-selafin"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# main imports\n",
"import holoviews as hv\n",
"hv.extension(\"bokeh\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import thalassa\n",
"from thalassa import api"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"malpasset = api.open_dataset('../tests/data/r2d_malpasset-char_p2.slf', source_crs = None) # default EPSG is 4326\n",
"malpasset"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The `Malpasset` mesh is not georeferentiated in a known local coordinate system\n",
"\n",
"We'll avoid activating the default EPSG (4326) in order to be able to view it. \n",
"\n",
"by imposing `source_crs = None`, we disable: \n",
" * reprojection done on the mesh (Thalassa reprojects automatically to Mercator to superpose meshes with WMS tiles) \n",
" * the tiling visualization"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# The trimesh is the most basic object. This is what you need to create all the others graphs\n",
"# It is on this object that you specify the timestamp and/or the layer.\n",
"trimesh = api.create_trimesh(malpasset.isel(time=0), variable='H')\n",
"\n",
"# The nodes of the mesh (without triangles, just the points!)\n",
"nodes = api.get_nodes(trimesh)\n",
"\n",
"# The wireframe is the representation of the mesh\n",
"wireframe = api.get_wireframe(trimesh)\n",
"\n",
"# The raster object is the basic Map that visualizes the variable. \n",
"# You can specify things like the colorbar limits and/or the extents\n",
"#raster = api.get_raster(trimesh, clim_min=0, clim_max=15)\n",
"raster = api.get_raster(trimesh).opts(cmap = 'rainbow')\n",
"\n",
"(raster * wireframe).opts(width=900, height=600)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To show another example using a known CRS, here is the `Manche` mesh from the TOMAWAC examples:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"manche = api.open_dataset('../tests/data/r2d.V1P3.slf') # use the default EPSG (4326)\n",
"manche"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"thalassa.plot(\n",
" manche.isel(time = -1), \n",
" variable='HAUTEUR_HM0', \n",
" show_mesh = True, \n",
" cmap = 'rainbow'\n",
").opts(width=900, height = 900)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
81 changes: 71 additions & 10 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ xarray = {version = "*", extras = ["io", "accel"]}
covdefaults = "*"
ipykernel = "*"
ipython = "*"
jupyter-bokeh = "*"
mypy = ">=1"
nbmake = "*"
pandas-stubs = "*"
Expand Down
8 changes: 6 additions & 2 deletions requirements/requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ executing==2.0.1 ; python_version >= "3.9" and python_version < "4.0"
fasteners==0.19 ; python_version >= "3.9" and python_version < "4.0" and sys_platform != "emscripten"
fastjsonschema==2.19.1 ; python_version >= "3.9" and python_version < "4.0"
fiona==1.9.6 ; python_version >= "3.9" and python_version < "4.0"
flox==0.9.7 ; python_version >= "3.9" and python_version < "4.0"
flox==0.9.8 ; python_version >= "3.9" and python_version < "4.0"
fonttools==4.52.4 ; python_version >= "3.9" and python_version < "4.0"
fsspec==2024.5.0 ; python_version >= "3.9" and python_version < "4.0"
future==1.0.0 ; python_version >= "3.9" and python_version < "4.0"
Expand All @@ -56,12 +56,15 @@ importlib-resources==6.4.0 ; python_version >= "3.9" and python_version < "3.10"
iniconfig==2.0.0 ; python_version >= "3.9" and python_version < "4.0"
ipykernel==6.29.4 ; python_version >= "3.9" and python_version < "4.0"
ipython==8.18.1 ; python_version >= "3.9" and python_version < "4.0"
ipywidgets==8.1.3 ; python_version >= "3.9" and python_version < "4.0"
jedi==0.19.1 ; python_version >= "3.9" and python_version < "4.0"
jinja2==3.1.4 ; python_version >= "3.9" and python_version < "4.0"
jsonschema-specifications==2023.12.1 ; python_version >= "3.9" and python_version < "4.0"
jsonschema==4.22.0 ; python_version >= "3.9" and python_version < "4.0"
jupyter-bokeh==4.0.4 ; python_version >= "3.9" and python_version < "4.0"
jupyter-client==8.6.2 ; python_version >= "3.9" and python_version < "4.0"
jupyter-core==5.7.2 ; python_version >= "3.9" and python_version < "4.0"
jupyterlab-widgets==3.0.11 ; python_version >= "3.9" and python_version < "4.0"
kiwisolver==1.4.5 ; python_version >= "3.9" and python_version < "4.0"
linkify-it-py==2.0.3 ; python_version >= "3.9" and python_version < "4.0"
llvmlite==0.42.0 ; python_version >= "3.9" and python_version < "4.0"
Expand Down Expand Up @@ -138,7 +141,7 @@ pyyaml==6.0.1 ; python_version >= "3.9" and python_version < "4.0"
pyzmq==26.0.3 ; python_version >= "3.9" and python_version < "4.0"
referencing==0.35.1 ; python_version >= "3.9" and python_version < "4.0"
regex==2024.5.15 ; python_version >= "3.9" and python_version < "4.0"
requests==2.32.2 ; python_version >= "3.9" and python_version < "4.0"
requests==2.32.3 ; python_version >= "3.9" and python_version < "4.0"
rpds-py==0.18.1 ; python_version >= "3.9" and python_version < "4.0"
scipy==1.13.1 ; python_version >= "3.9" and python_version < "4.0"
shapely==2.0.4 ; python_version >= "3.9" and python_version < "4.0"
Expand All @@ -162,6 +165,7 @@ watchdog==4.0.1 ; python_version >= "3.9" and python_version < "4.0"
wcwidth==0.2.13 ; python_version >= "3.9" and python_version < "4.0"
webencodings==0.5.1 ; python_version >= "3.9" and python_version < "4.0"
webob==1.8.7 ; python_version >= "3.9" and python_version < "3.10"
widgetsnbextension==4.0.11 ; python_version >= "3.9" and python_version < "4.0"
xarray-selafin==0.1.6 ; python_version >= "3.9" and python_version < "4.0"
xarray==2024.5.0 ; python_version >= "3.9" and python_version < "4.0"
xarray[accel,io]==2024.5.0 ; python_version >= "3.9" and python_version < "4.0"
Expand Down
4 changes: 2 additions & 2 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ distributed==2024.5.1 ; python_version >= "3.9" and python_version < "4.0"
docopt==0.6.2 ; python_version < "3.10" and python_version >= "3.9"
fasteners==0.19 ; python_version >= "3.9" and python_version < "4.0" and sys_platform != "emscripten"
fiona==1.9.6 ; python_version >= "3.9" and python_version < "4.0"
flox==0.9.7 ; python_version >= "3.9" and python_version < "4.0"
flox==0.9.8 ; python_version >= "3.9" and python_version < "4.0"
fonttools==4.52.4 ; python_version >= "3.9" and python_version < "4.0"
fsspec==2024.5.0 ; python_version >= "3.9" and python_version < "4.0"
future==1.0.0 ; python_version >= "3.9" and python_version < "4.0"
Expand Down Expand Up @@ -78,7 +78,7 @@ python-dateutil==2.9.0.post0 ; python_version >= "3.9" and python_version < "4.0
pytz==2024.1 ; python_version >= "3.9" and python_version < "4.0"
pyviz-comms==3.0.2 ; python_version >= "3.9" and python_version < "4.0"
pyyaml==6.0.1 ; python_version >= "3.9" and python_version < "4.0"
requests==2.32.2 ; python_version >= "3.9" and python_version < "4.0"
requests==2.32.3 ; python_version >= "3.9" and python_version < "4.0"
scipy==1.13.1 ; python_version >= "3.9" and python_version < "4.0"
shapely==2.0.4 ; python_version >= "3.9" and python_version < "4.0"
six==1.16.0 ; python_version >= "3.9" and python_version < "4.0"
Expand Down
Loading
Loading