Skip to content
Merged
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 .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
docs/images/** filter=lfs diff=lfs merge=lfs -text
pan3d/utils/data/** filter=lfs diff=lfs merge=lfs -text
examples/data/tas_Amon_ACCESS-ESM1-5_historical_r10i1p1f1_gn_185001-201412.nc filter=lfs diff=lfs merge=lfs -text
Git LFS file not shown
108 changes: 108 additions & 0 deletions examples/jupyter/xarray-analytics.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "cd15ae3c-235b-4c53-a32e-76e4e9a1dca2",
"metadata": {},
"source": [
"### Open Xarray data set with xCDAT for Analytics Explorer\n",
"\n",
"The following code open the xarray dataset with xCDAT and prepares it for processing with the Analytics Explorer from pan3D\n",
"\n",
"The data is a full resolution example used for [xCDAT tutorials](https://github.com/xCDAT/xcdat-data.git)\n",
"\n",
"After opening the dataset, we convert the unit of \"average surface temperature\" from Kelvin to Celsius."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "5866dd3b-1dbd-4b3b-b8ba-b61aae2d71fa",
"metadata": {},
"outputs": [],
"source": [
"# import the necessary packages, we only need xcdat to open local data file\n",
"import xcdat as xc\n",
"\n",
"# specify local data file\n",
"# The example xcdat datasets can be downloaded from\n",
"# https://github.com/xCDAT/xcdat-data\n",
"filepath = \"../data/tas_Amon_ACCESS-ESM1-5_historical_r10i1p1f1_gn_185001-201412.nc\"\n",
"\n",
"# open dataset\n",
"ds = xc.open_dataset(filepath).sel(time=slice(\"1980-01-01\", \"2005-01-01\"))\n",
"\n",
"# Unit adjust (-273.15, K to C)\n",
"ds[\"tas\"] = ds.tas - 273.15"
]
},
{
"cell_type": "markdown",
"id": "6eea4c25-3e81-4fb8-a61a-c5019b3972ea",
"metadata": {},
"source": [
"### Launch the explorer with the Xarray data set\n",
"\n",
"The following code configures the Analytics Explorer, which can later be used interactively for data analysis through plots generated using xCDAT and plotly.\n",
"The interaction is facilitated by the trame widget library [trame-plotly](https://github.com/Kitware/trame-plotly.git)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c2aeb1cd-f058-4a77-a2e9-ecab0b2494ba",
"metadata": {},
"outputs": [],
"source": [
"# Import the installed pan3d explorer\n",
"from pan3d.explorers.analytics import AnalyticsExplorer\n",
"\n",
"# Instantiate the explorer and wait until it finishes setting up\n",
"explorer = AnalyticsExplorer(xarray=ds, server=\"esgf-slicer\")\n",
"await explorer.ui.ready\n",
"\n",
"# Launch the interactive explorer within jypyter notebook\n",
"explorer.ui"
]
},
{
"cell_type": "markdown",
"id": "4ed417cf-5ba2-48ab-99e7-7f0974e624c2",
"metadata": {},
"source": [
"### Get the link to launch the explorer in the browser"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9cc244a4-2f42-4fc9-b70a-2d31ca6af913",
"metadata": {},
"outputs": [],
"source": [
"explorer.ui.url"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"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.13.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}