{ "cells": [ { "cell_type": "markdown", "id": "9abc7ae0-1bba-47d8-a1df-17386def470c", "metadata": {}, "source": [ "## yt_xarray and cartopy\n", "\n", "This notebook demonstrates loading a geographic xarray dataset into yt. In addition to `yt_xarray` and `xarray`, this notebook requires `cartopy` and relies on the netcdf-gridded seismic tomography model of Schmand and Humphreys 2010, available from IRIS [here](https://doi.org/10.17611/DP/9991760).\n", "\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "12f7f44b-5041-4254-9e42-29586311b9cf", "metadata": {}, "outputs": [], "source": [ "import xarray as xr\n", "import yt_xarray\n", "import yt\n", "from cartopy.feature import NaturalEarthFeature" ] }, { "cell_type": "markdown", "id": "c0f06a1a-7196-4da0-b41d-4298fa5644e7", "metadata": {}, "source": [ "yt_xarray provides a simple wrapper of the standard xarray `open_dataset` function that will check yt's `test_data_dir` for data if the file is not found in the local path: " ] }, { "cell_type": "code", "execution_count": 2, "id": "625a2709-5d7f-43c5-a2cf-3d5e23d6930b", "metadata": {}, "outputs": [], "source": [ "ds = yt_xarray.open_dataset(\"IRIS/wUS-SH-2010_percent.nc\")" ] }, { "cell_type": "code", "execution_count": 3, "id": "272662d7-65cc-426f-8a42-b41cf5a07313", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset>\n",
"Dimensions: (depth: 19, latitude: 93, longitude: 122)\n",
"Coordinates:\n",
" * depth (depth) float32 60.0 90.0 125.0 160.0 ... 700.0 760.0 820.0 885.0\n",
" * latitude (latitude) float32 27.5 27.75 28.0 28.25 ... 50.0 50.25 50.5\n",
" * longitude (longitude) float32 -125.8 -125.5 -125.2 ... -96.0 -95.75 -95.5\n",
"Data variables:\n",
" dvp (depth, latitude, longitude) float32 ...\n",
" dvs (depth, latitude, longitude) float32 ...\n",
"Attributes: (12/32)\n",
" title: P and S teleseismic body-wave tomography o...\n",
" id: wUS-SH-2010_percent\n",
" summary: Teleseismic travel-time residuals from the...\n",
" keywords: seismic, tomography, compressional wave, p...\n",
" Conventions: CF-1.0\n",
" Metadata_Conventions: Unidata Dataset Discovery v1.0\n",
" ... ...\n",
" author_email: bschmandt@unm.edu\n",
" author_institution: Department of Earth and Planetary Science,...\n",
" author_url: \n",
" repository_name: EMC\n",
" repository_institution: IRIS DMC\n",
" repository_pid: doi:10.17611/DP/9991760