{ "cells": [ { "cell_type": "markdown", "id": "2bf103d2-0215-4e91-828b-76ca0ca34dea", "metadata": {}, "source": [ "## Loading 2D fields into yt \n", "\n", "`yt_xarray` can also load in 2D fields from xarray into a yt dataset. To do so, all you have to do is provide a selection dictionary that will reduce your chosen field down to 2D. \n", "\n", "First, let's import and create a test dataset with dimensions that yt will not know:" ] }, { "cell_type": "code", "execution_count": 1, "id": "6310866a-5207-4bab-9feb-408038f2d78a", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset>\n",
"Dimensions: (x: 15, y: 10, z: 15, time: 5)\n",
"Coordinates:\n",
" * x (x) float64 0.0 0.07143 0.1429 0.2143 ... 0.7857 0.8571 0.9286 1.0\n",
" * y (y) float64 0.0 0.1111 0.2222 0.3333 ... 0.6667 0.7778 0.8889 1.0\n",
" * z (z) float64 0.0 0.07143 0.1429 0.2143 ... 0.7857 0.8571 0.9286 1.0\n",
" * time (time) float64 0.0 0.25 0.5 0.75 1.0\n",
"Data variables:\n",
" temp (x, y, z) float64 0.326 0.4565 0.3212 ... 0.5516 0.8988 0.3817\n",
" precip (x, y) float64 0.2222 0.153 0.6116 0.9373 ... 0.2619 0.4644 0.4776\n",
" precip_t (x, y, time) float64 0.06265 0.5747 0.3099 ... 0.6112 0.5412\n",
"Attributes:\n",
" geospatial_vertical_units: m