diff --git a/notebooks/TELEMAC.ipynb b/notebooks/TELEMAC.ipynb new file mode 100644 index 0000000..d93cba8 --- /dev/null +++ b/notebooks/TELEMAC.ipynb @@ -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 +}