{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Get grid\n", "\n", "The `get_grid` method returns an `xarray.Dataset` containing grid variables for a given model grid. It relies on a checkout of binary horizontal grid and topography files from the CESM [inputdata repository](https://svn-ccsm-inputdata.cgd.ucar.edu/trunk/inputdata). The vertical grid files are in the [POP2-CESM repository](https://github.com/escomp/pop2-cesm) in the `input_templates` directory; they are maintained separately as part of the `pop-tools` repository. \n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "import xarray as xr\n", "\n", "import pop_tools" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Get a dataset for the `POP_tx0.v3` tripole grid." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ds = pop_tools.get_grid('POP_tx0.1v3')\n", "ds.info()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Visualize grid\n", "\n", "Take a quick look at `KMT` (`k` Index of Deepest Grid Cell on T Grid), applying a land-mask criterion along the way." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "h = ds.KMT.where(ds.KMT > 0).plot()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "And the coordinates: `TLAT`" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "h = ds.TLAT.where(ds.KMT > 0).plot()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "and `TLONG`" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "h = ds.TLONG.where(ds.KMT > 0).plot()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## SCRIP format\n", "\n", "It is also possible to get the grid file in [SCRIP format](http://www.earthsystemmodeling.org/esmf_releases/public/last/ESMF_refdoc/node3.html#SECTION03028000000000000000) which is useful for regridding applications with ESMF." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ds = pop_tools.get_grid('POP_tx0.1v3', scrip=True)\n", "ds.info()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%load_ext watermark\n", "%watermark -d -iv -m -g" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.8.8" }, "widgets": { "application/vnd.jupyter.widget-state+json": { "state": {}, "version_major": 2, "version_minor": 0 } } }, "nbformat": 4, "nbformat_minor": 4 }