{ "cells": [ { "cell_type": "markdown", "id": "f32579d0-cc66-4531-9378-c348afa93a6a", "metadata": {}, "source": [ "# Tutorial Datasets\n", "\n", "The module {mod}`melodies_monet.tutorial` enables automatic downloading and caching of small[^a] versions of the tutorial datasets.\n", "This functionality requires [pooch](https://www.fatiando.org/pooch/latest/), an optional dependency.\n", "\n", "[^a]: Only a few variables included, levels limited to surface or near-surface, NCO compression applied. Full versions are also available via ." ] }, { "cell_type": "code", "execution_count": 1, "id": "0769d026-6169-4fa6-a5a9-29ecccf7cf85", "metadata": {}, "outputs": [], "source": [ "import xarray as xr\n", "\n", "import melodies_monet as mm" ] }, { "cell_type": "code", "execution_count": 2, "id": "3eeb69f7-7f38-46a6-9e8d-398ada9f8d99", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['wrfchem:racm_esrl',\n", " 'wrfchem:racm_esrl_vcp',\n", " 'airnow:2019-09',\n", " 'airnow:2019-08',\n", " 'airnow:2019-07',\n", " 'camchem:fv',\n", " 'camchem:se',\n", " 'camchem:se_scrip',\n", " 'aeronet:2019-09',\n", " 'aeronet:2019-08',\n", " 'csn:2019_daily',\n", " 'improve:2019_daily',\n", " 'ncore:2019_daily']" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mm.tutorial.example_ids" ] }, { "cell_type": "markdown", "id": "e3655cc6-6de4-43a8-b765-8e25628b1186", "metadata": {}, "source": [ "The example IDs above can be used inside a control file to specify to use that dataset, downloading if necessary but otherwise loading from the pooch cache.\n", "\n", "For example:\n", "```yaml\n", "model:\n", " cam-chem:\n", " files: 'example:camchem:fv'\n", "```\n", "(for model)\n", "\n", "```yaml\n", "obs:\n", " airnow:\n", " filename: 'example:airnow:2019-09'\n", "```\n", "(for obs)\n", "\n", "Note that you can also use {func}`melodies_monet.tutorial.fetch_example` to load data directly." ] }, { "cell_type": "code", "execution_count": 3, "id": "af79bb70-9b29-4d5b-b62b-488991792868", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
<xarray.Dataset>\n",
       "Dimensions:    (time: 36, lev: 1, lat: 192, lon: 288, ilev: 2, nbnd: 2)\n",
       "Coordinates:\n",
       "  * ilev       (ilev) float64 985.0 1e+03\n",
       "  * lat        (lat) float64 -90.0 -89.06 -88.12 -87.17 ... 88.12 89.06 90.0\n",
       "  * lev        (lev) float64 992.5\n",
       "  * lon        (lon) float64 0.0 1.25 2.5 3.75 5.0 ... 355.0 356.2 357.5 358.8\n",
       "  * time       (time) datetime64[ns] 2019-09-01T06:00:00 ... 2019-09-10\n",
       "Dimensions without coordinates: nbnd\n",
       "Data variables:\n",
       "    O3         (time, lev, lat, lon) float32 ...\n",
       "    P0         float64 1e+05\n",
       "    PM25       (time, lev, lat, lon) float32 ...\n",
       "    PS         (time, lat, lon) float32 ...\n",
       "    date       (time) int32 20190901 20190901 20190901 ... 20190909 20190910\n",
       "    datesec    (time) int32 21600 43200 64800 0 21600 ... 0 21600 43200 64800 0\n",
       "    hyai       (ilev) float64 4.805e-05 0.0\n",
       "    hyam       (lev) float64 2.402e-05\n",
       "    hybi       (ilev) float64 0.985 1.0\n",
       "    hybm       (lev) float64 0.9925\n",
       "    time_bnds  (time, nbnd) datetime64[ns] 2019-09-01 ... 2019-09-10\n",
       "Attributes:\n",
       "    Conventions:       CF-1.0\n",
       "    source:            CAM\n",
       "    case:              fmerra.2.1003.FCSD.f09.qfedcmip.56L.001.branch02\n",
       "    logname:           buchholz\n",
       "    host:              cheyenne3\n",
       "    initial_file:      /glade/p/cesmdata/cseg/inputdata/atm/cam/inic/fv/f.e20...\n",
       "    topography_file:   /glade/p/cesmdata/cseg/inputdata/atm/cam/met/MERRA2/0....\n",
       "    model_doi_url:     https://doi.org/10.5065/D67H1H0V\n",
       "    time_period_freq:  hour_6\n",
       "    history:           Mon Feb 28 16:25:23 2022: ncks -7 -L 1 --baa=4 --ppc d...\n",
       "    NCO:               netCDF Operators version 5.0.6 (Homepage = http://nco....
" ], "text/plain": [ "\n", "Dimensions: (time: 36, lev: 1, lat: 192, lon: 288, ilev: 2, nbnd: 2)\n", "Coordinates:\n", " * ilev (ilev) float64 985.0 1e+03\n", " * lat (lat) float64 -90.0 -89.06 -88.12 -87.17 ... 88.12 89.06 90.0\n", " * lev (lev) float64 992.5\n", " * lon (lon) float64 0.0 1.25 2.5 3.75 5.0 ... 355.0 356.2 357.5 358.8\n", " * time (time) datetime64[ns] 2019-09-01T06:00:00 ... 2019-09-10\n", "Dimensions without coordinates: nbnd\n", "Data variables:\n", " O3 (time, lev, lat, lon) float32 ...\n", " P0 float64 ...\n", " PM25 (time, lev, lat, lon) float32 ...\n", " PS (time, lat, lon) float32 ...\n", " date (time) int32 ...\n", " datesec (time) int32 ...\n", " hyai (ilev) float64 ...\n", " hyam (lev) float64 ...\n", " hybi (ilev) float64 ...\n", " hybm (lev) float64 ...\n", " time_bnds (time, nbnd) datetime64[ns] ...\n", "Attributes:\n", " Conventions: CF-1.0\n", " source: CAM\n", " case: fmerra.2.1003.FCSD.f09.qfedcmip.56L.001.branch02\n", " logname: buchholz\n", " host: cheyenne3\n", " initial_file: /glade/p/cesmdata/cseg/inputdata/atm/cam/inic/fv/f.e20...\n", " topography_file: /glade/p/cesmdata/cseg/inputdata/atm/cam/met/MERRA2/0....\n", " model_doi_url: https://doi.org/10.5065/D67H1H0V\n", " time_period_freq: hour_6\n", " history: Mon Feb 28 16:25:23 2022: ncks -7 -L 1 --baa=4 --ppc d...\n", " NCO: netCDF Operators version 5.0.6 (Homepage = http://nco...." ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fp = mm.tutorial.fetch_example(\"camchem:fv\")\n", "xr.open_dataset(fp)" ] } ], "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.8.13" } }, "nbformat": 4, "nbformat_minor": 5 }