{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "4ee5bc0f", "metadata": { "tags": [] }, "outputs": [], "source": [ "from siphon.catalog import TDSCatalog\n", "import xarray as xr\n", "import pyvista as pv\n", "import pvxarray\n", "import numpy as np\n", "import ipywidgets as widgets\n", "import matplotlib.pyplot as plt\n", "\n", "pv.set_plot_theme(\"document\")\n", "pv.set_jupyter_backend(\"server\") # critical for large data" ] }, { "cell_type": "code", "execution_count": null, "id": "9342ad3d-0966-4526-84e4-0d79badbf7a3", "metadata": {}, "outputs": [], "source": [ "# Temporary manual mode override; waiting for pyvista release including changes from https://github.com/pyvista/pyvista/pull/5798\n", "\n", "pv.global_theme.trame.server_proxy_enabled = False\n", "pv.global_theme.trame.jupyter_extension_enabled = True" ] }, { "cell_type": "markdown", "id": "e2f22803", "metadata": {}, "source": [ "https://thredds.ucar.edu/thredds/catalog/grib/NCEP/GFS/Global_0p25deg_ana/catalog.html?dataset=grib/NCEP/GFS/Global_0p25deg_ana/TP" ] }, { "cell_type": "code", "execution_count": null, "id": "3aaa938b", "metadata": { "tags": [] }, "outputs": [], "source": [ "catUrl = \"https://thredds.ucar.edu/thredds/catalog/grib/NCEP/GFS/Global_0p25deg_ana/catalog.xml\"\n", "datasetName = \"Full Collection Dataset\";" ] }, { "cell_type": "code", "execution_count": null, "id": "c42d2f2f", "metadata": { "tags": [] }, "outputs": [], "source": [ "catalog = TDSCatalog(catUrl)\n", "ds = catalog.datasets[datasetName].remote_access(use_xarray=True)\n", "ds" ] }, { "cell_type": "code", "execution_count": null, "id": "25092b2c", "metadata": { "tags": [] }, "outputs": [], "source": [ "da = ds[\"Temperature_isobaric\"]\n", "da" ] }, { "cell_type": "code", "execution_count": null, "id": "30408a51", "metadata": { "tags": [] }, "outputs": [], "source": [ "dt = da[dict(time=0)]" ] }, { "cell_type": "code", "execution_count": null, "id": "ff642973", "metadata": { "tags": [] }, "outputs": [], "source": [ "mesh = dt.pyvista.mesh(x=\"lon\", y=\"lat\", z=\"isobaric\")\n", "mesh" ] }, { "cell_type": "code", "execution_count": null, "id": "a2757ccf", "metadata": { "tags": [] }, "outputs": [], "source": [ "pl = pv.Plotter()\n", "pl.add_mesh(mesh, cmap=\"coolwarm\")\n", "pl.set_scale(zscale=0.001)\n", "pl.show(cpos=\"xy\")" ] }, { "cell_type": "code", "execution_count": null, "id": "a194d4d1", "metadata": { "tags": [] }, "outputs": [], "source": [ "pl = pv.Plotter()\n", "pl.add_mesh(\n", " mesh.contour(\n", " [\n", " 273.15,\n", " ]\n", " ),\n", " color=True,\n", ")\n", "pl.set_scale(zscale=0.001)\n", "pl.show(cpos=\"xy\")" ] }, { "cell_type": "code", "execution_count": null, "id": "b2031510", "metadata": { "tags": [] }, "outputs": [], "source": [ "pl = pv.Plotter()\n", "pl.add_mesh(mesh.contour(), cmap=\"coolwarm\")\n", "pl.set_scale(zscale=0.001)\n", "pl.show(cpos=\"xy\")" ] } ], "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.9.18" } }, "nbformat": 4, "nbformat_minor": 5 }