Skip to content

Commit

Permalink
notebooks: Add Public API.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
pmav99 committed Sep 27, 2023
1 parent 3b5449a commit d50baf2
Show file tree
Hide file tree
Showing 4 changed files with 510 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,6 @@ data.bak/
data_/

.config_jupyter/

*.zarr/
*.nc
23 changes: 15 additions & 8 deletions notebooks/API.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,16 @@
},
"outputs": [],
"source": [
"#variable, layer, timestamp = \"salt\", 40, ds.time.values[4]\n",
"#variable, layer, timestamp = \"salt\", 40, \n",
"#variable, layer, timestamp = \"depth\", None, None\n",
"variable, layer, timestamp = \"zeta\", None, \"max\"\n",
"variable, layer, timestamp = \"zeta\", None, ds.time.values[4]\n",
"\n",
"# 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(ds=ds, variable=variable, timestamp=timestamp, layer=layer)\n",
"trimesh = api.create_trimesh(ds=ds.sel(time=timestamp), variable=variable)\n",
"\n",
"# The wireframe is the representation of the mesh\n",
"wireframe = api.get_wireframe(trimesh=trimesh)\n",
"wireframe = api.get_wireframe(trimesh)\n",
"\n",
"# The tiles is using the tiling service from Open Street maps\n",
"tiles = api.get_tiles() \n",
Expand Down Expand Up @@ -183,10 +183,17 @@
"cell_type": "code",
"execution_count": null,
"id": "cd80deda",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"(pointer_dmap + tap_dmap).opts(shared_axes=False)"
"import warnings\n",
"\n",
"with warnings.catch_warnings():\n",
" warnings.simplefilter(\"ignore\")\n",
" \n",
" tap_dmap"
]
},
{
Expand All @@ -205,7 +212,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "thalassa",
"language": "python",
"name": "python3"
},
Expand All @@ -219,7 +226,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.0"
"version": "3.10.12"
}
},
"nbformat": 4,
Expand Down
15 changes: 6 additions & 9 deletions notebooks/BBox_filtering.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
"\n",
"filename = \"../tests/data/fort.63.nc\"\n",
"ds = api.open_dataset(filename)\n",
"ds = ds.assign(zeta_max=ds.zeta.max(\"time\"))\n",
"ds"
]
},
Expand Down Expand Up @@ -243,10 +244,8 @@
"source": [
"# The full dataset\n",
"trimesh = api.create_trimesh(\n",
" ds=ds,\n",
" variable=\"zeta\",\n",
" timestamp=\"max\",\n",
" layer=None,\n",
" ds,\n",
" variable=\"zeta_max\",\n",
")\n",
"dmap = api.get_tiles() * api.get_raster(trimesh=trimesh) #* api.get_wireframe(trimesh=trimesh)\n",
"dmap.opts(width=600, title=\"Full dataset\")"
Expand All @@ -264,9 +263,7 @@
"# The filtered dataset\n",
"ftrimesh = api.create_trimesh(\n",
" ds=fds,\n",
" variable=\"zeta\",\n",
" timestamp=\"max\",\n",
" layer=None,\n",
" variable=\"zeta_max\",\n",
")\n",
"fdmap = api.get_tiles() * api.get_raster(trimesh=ftrimesh) * api.get_wireframe(trimesh=ftrimesh)\n",
"fdmap.opts(width=600, title=\"Filtered Dataset\")"
Expand All @@ -290,7 +287,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "python3",
"display_name": "thalassa",
"language": "python",
"name": "python3"
},
Expand All @@ -304,7 +301,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.16"
"version": "3.10.12"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit d50baf2

Please sign in to comment.