{ "cells": [ { "cell_type": "markdown", "id": "2158d56a118cc6d", "metadata": {}, "source": [ "# Interpolate hybrid sigma pressure coordinates to pressure\n", "\n", "Quite a few models usee hybrid sigma coordinates which means that the pressure level follows the surface close to the surface, before becoming less and influenced by it further up. This is to make it easier numerically to solve the equations. See e.g. here: [link](https://www2.cesm.ucar.edu/models/atm-cam/docs/usersguide/node25.html)" ] }, { "cell_type": "markdown", "id": "f07e18054f07429a", "metadata": {}, "source": [ "This means that if we want to e.g. average over a specific pressure level, we have to first interpolate to pressure levels. This is done in the below for an example with CMIP6. It's not a given however that this works for any model, so adjustments might have to be made based on the models vertical coordinates. " ] }, { "cell_type": "code", "execution_count": 1, "id": "9d61986d-c16f-4b29-9e55-56b7be0b71ac", "metadata": {}, "outputs": [], "source": [ "from geocat.comp.interpolation import interp_hybrid_to_pressure" ] }, { "cell_type": "code", "execution_count": 2, "id": "dbacfe9b-b5ff-48b9-a430-333e8102dfc5", "metadata": { "tags": [] }, "outputs": [], "source": [ "import xarray as xr\n", "xr.set_options(display_style='html')\n", "import intake\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "from dask.diagnostics import ProgressBar\n" ] }, { "cell_type": "markdown", "id": "97d19c48-11e2-4054-9815-ba541ee08370", "metadata": {}, "source": [ "### Open CMIP6 online catalog" ] }, { "cell_type": "code", "execution_count": 3, "id": "99657c37-6406-4da0-a77b-e65ce64ad1dd", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "
pangeo-cmip6 catalog with 7674 dataset(s) from 514818 asset(s):
\n", " | unique | \n", "
---|---|
activity_id | \n", "18 | \n", "
institution_id | \n", "36 | \n", "
source_id | \n", "88 | \n", "
experiment_id | \n", "170 | \n", "
member_id | \n", "657 | \n", "
table_id | \n", "37 | \n", "
variable_id | \n", "700 | \n", "
grid_label | \n", "10 | \n", "
zstore | \n", "514818 | \n", "
dcpp_init_year | \n", "60 | \n", "
version | \n", "736 | \n", "
derived_variable_id | \n", "0 | \n", "
\n", " | activity_id | \n", "institution_id | \n", "source_id | \n", "experiment_id | \n", "member_id | \n", "table_id | \n", "variable_id | \n", "grid_label | \n", "zstore | \n", "dcpp_init_year | \n", "version | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "CMIP | \n", "NCAR | \n", "CESM2 | \n", "historical | \n", "r1i1p1f1 | \n", "AERmon | \n", "mmrso4 | \n", "gn | \n", "gs://cmip6/CMIP6/CMIP/NCAR/CESM2/historical/r1... | \n", "NaN | \n", "20190308 | \n", "
<xarray.DataArray 'mmrso4' (member_id: 1, dcpp_init_year: 1, time: 12, lev: 32,\n", " lat: 192, lon: 288)> Size: 85MB\n", "dask.array<getitem, shape=(1, 1, 12, 32, 192, 288), dtype=float32, chunksize=(1, 1, 10, 32, 192, 288), chunktype=numpy.ndarray>\n", "Coordinates:\n", " * lat (lat) float64 2kB -90.0 -89.06 -88.12 ... 88.12 89.06 90.0\n", " * lev (lev) float64 256B 364.3 759.5 ... 9.763e+04 9.926e+04\n", " * lon (lon) float64 2kB 0.0 1.25 2.5 3.75 ... 356.2 357.5 358.8\n", " * time (time) object 96B 2000-01-15 12:00:00 ... 2000-12-15 12:0...\n", " * member_id (member_id) object 8B 'r1i1p1f1'\n", " * dcpp_init_year (dcpp_init_year) float64 8B nan\n", "Attributes: (12/19)\n", " cell_measures: area: areacella\n", " cell_methods: area: time: mean\n", " comment: Dry mass of sulfate (SO4) in aerosol particles as a fract...\n", " description: Dry mass of sulfate (SO4) in aerosol particles as a fract...\n", " frequency: mon\n", " id: mmrso4\n", " ... ...\n", " time_label: time-mean\n", " time_title: Temporal mean\n", " title: Aerosol Sulfate Mass Mixing Ratio\n", " type: real\n", " units: kg kg-1\n", " variable_id: mmrso4
<xarray.DataArray 'p0' ()> Size: 4B\n", "array(100000., dtype=float32)\n", "Attributes:\n", " long_name: vertical coordinate formula term: reference pressure\n", " units: Pa