{ "cells": [ { "cell_type": "markdown", "id": "8d1f3060-1bba-4336-bbd0-e074a80ed0e7", "metadata": {}, "source": [ "# TerraFirma UKESM long-term stabilisation and overshoot scenarios" ] }, { "cell_type": "markdown", "id": "ae3d7093-ab76-4465-bd05-c5dfd14239e8", "metadata": {}, "source": [ "#### Steps to do\n", "- decide how the bias correction should be applied\n", " - according to Tom Mitcham: simulation years 10 to 50 of the ramp-up phase are most equal to 1975-2025 in terms of warming trend\n", " - global mean temperature is similar (+0.26°C), but there is another period (simulation year 0 to 40 which would fit better\n", " - [ ] double-check the warming trend?\n", "- [ ] create a `process_terrafirma_ukesm_data()`,\n", "- [ ] test with HEF using W5E5 or ERA5, RGI7?, regional spinup ...\n", " - do they need that we start from pre-industrial state, or would it be ok, if we just start at simulation year 30 (which would correspond best to a \"climate\" as we had around year 2000, which is around RGI/glavier volume inventory year ... I guess the problem is that their ice sheet / sea-level rise output will be relative to \"pre-industrial\", and therefore, we also need the glaciers to have the \"pre-industrial\" baseline...? \n", "- [ ] do I need to do sth. about the growing out of border issue ...https://github.com/OGGM/oggm/issues/1822 \n", " " ] }, { "cell_type": "code", "execution_count": 65, "id": "6d0764b7-cede-4d23-b4e2-82768d9b2434", "metadata": {}, "outputs": [], "source": [ "import xarray as xr\n", "xr.set_options(use_new_combine_kwarg_defaults=True)\n", "import numpy as np\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "markdown", "id": "7fac9731-8e55-4db6-86dc-342e81ab93bd", "metadata": {}, "source": [ "- \"esm-up2p0\" is the \"ramp-up\" phase.\n", "- \"esm-up2p0-gwl2p0\" is stabilisation at 2C \n", "- \"esm-up2p0-gwl2p0-50y-dn2p0\" is a \"ramp-down\" from the 2C stabilisation after 50 years'\n", "- \"esm-up2p0-gwl4p0\" is stabilisation at 4C\n", "- \"esm-up2p0-gwl4p0-50y-dn2p0\" is a \"ramp-down\" from the 4C stabilisation after 50 years'\n", "- \"esm-hist\" is the same model (UKESM1.2-LL) being forced through the CMIP historical forcing'\n", "- \"esm-piControl\" is the same model with pre-industrial forcing'" ] }, { "cell_type": "code", "execution_count": 66, "id": "c79ac93c-beb3-4686-b36b-947e0b53f077", "metadata": {}, "outputs": [], "source": [ "variables = ['pr','tas']\n", "period = '205001-213912'\n", "scenarios = ['hist', # same model (UKESM1.2-LL) being forced through the CMIP historical forcing\n", " 'up2p0', # ramp-up phase\n", " 'up2p0-gwl2p0', # stabilisation at 2°C\n", " 'up2p0-gwl2p0-50y-dn2p0', # \"ramp-down\" from 2C stabilisation after 50 years'\n", " 'up2p0-gwl4p0', # stabilisation at 4C\n", " \"up2p0-gwl4p0-50y-dn2p0\", # \"ramp-down\" from 4C stabilisation after 50 years'\n", " \"piControl\" # same model with pre-industrial forcing'\n", " ]" ] }, { "cell_type": "code", "execution_count": 67, "id": "0449132e-6d07-452f-806d-cdb688dc8ba8", "metadata": {}, "outputs": [], "source": [ "time_coder = xr.coders.CFDatetimeCoder(use_cftime=True)\n", "run = False\n", "if run:\n", " for var in ['pr','tas']:\n", " _dt = xr.open_mfdataset(f'terrafirma_data/raw_data/{var}_Amon_UKESM1-2-LL_esm-{scen}_r1i1p1f1_gn_*.nc', \n", " decode_times=time_coder).load()\n", " if var == 'tas':\n", " _dt['tas'] = _dt.tas\n", " _dt.tas.attrs['units'] = '°C'\n", " else:\n", " # already in correct format... \n", " assert 'kg m-2 s-1' in _dt.pr.units, 'Precip units not understood'\n", " _dt = _dt.drop_vars(['time_bnds','lat_bnds', 'lon_bnds'])\n", " y0=_dt.time.dt.year.values[0]\n", " y1=_dt.time.dt.year.values[-1]\n", " _dt.to_netcdf(f'terrafirma_data/{var}_Amon_UKESM1-2-LL_esm-{scen}_r1i1p1f1_gn.nc')" ] }, { "cell_type": "code", "execution_count": 91, "id": "6f34a523-934c-41df-9114-a6e6d19dc386", "metadata": {}, "outputs": [], "source": [ "run = False\n", "if run:\n", " for var in ['pr','tas']:\n", " time_coder = xr.coders.CFDatetimeCoder(use_cftime=True)\n", " global_var_mean_dict = {}\n", " for scen in scenarios:\n", " _dt = xr.open_dataset(f'terrafirma_data/{var}_Amon_UKESM1-2-LL_esm-{scen}_r1i1p1f1_gn.nc',\n", " decode_times=time_coder).groupby('time.year').mean().load()\n", " ### check the global mean temperature and precipitation time series\n", " # weighted average over latitudes\n", " if var == 'tas':\n", " _dt[var] = _dt[var]-273.15\n", " weight = np.cos(np.deg2rad(_dt.lat))\n", " weight = weight / weight.sum()\n", " global_var_mean_dict[scen] = (_dt.mean(dim='lon') * weight).sum(dim='lat')\n", " keys = list(global_var_mean_dict.keys())\n", " vals = list(global_var_mean_dict.values())\n", "\n", " ds_global_var_mean = xr.concat(vals, dim=\"scenario\", join='outer')\n", " ds_global_var_mean = ds_global_var_mean.assign_coords(scenario=keys)\n", " ds_global_var_mean.to_netcdf(f'terrafirma_global_annual_mean_{var}_scenarios.nc')\n", "ds_global_tas_mean = xr.open_dataset('terrafirma_global_annual_mean_tas_scenarios.nc')\n", "ds_global_pr_mean = xr.open_dataset('terrafirma_global_annual_mean_pr_scenarios.nc')\n", "\n", "ds_w5e5 = xr.open_dataset('/home/www/oggm/climate/gswp3-w5e5/unflattened/monthly/gswp3-w5e5_obsclim_tas_global_monthly_1901_2019.nc')\n", "ds_w5e5 = ds_w5e5.groupby('time.year').mean().load()\n", "ds_w5e5['tas'] = ds_w5e5['tas'] -273.15\n", "weight = np.cos(np.deg2rad(ds_w5e5.lat))\n", "weight = weight / weight.sum()\n", "ds_global_tas_mean_w5e5 = (ds_w5e5.mean(dim='lon') * weight).sum(dim='lat')" ] }, { "cell_type": "code", "execution_count": 93, "id": "efdea528-12f3-44d4-9ccd-6ebe1506de08", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset> Size: 45kB\n",
"Dimensions: (scenario: 7, year: 695)\n",
"Coordinates:\n",
" * scenario (scenario) <U22 616B 'hist' 'up2p0' ... 'piControl'\n",
" * year (year) int64 6kB 1850 1851 1852 1853 1854 ... 2541 2542 2543 2544\n",
" height float64 8B ...\n",
"Data variables:\n",
" tas (scenario, year) float64 39kB ...<xarray.Dataset> Size: 17kB\n",
"Dimensions: (time: 1428)\n",
"Coordinates:\n",
" * time (time) datetime64[ns] 11kB 1901-01-01 1901-02-01 ... 2019-12-01\n",
"Data variables:\n",
" tas (time) float32 6kB 11.64 12.03 12.67 13.7 ... 14.89 13.75 13.23"
],
"text/plain": [
"<xarray.Dataset> Size: 1GB\n",
"Dimensions: (time: 1428, lat: 360, lon: 720)\n",
"Coordinates:\n",
" * time (time) datetime64[ns] 11kB 1901-01-01 1901-02-01 ... 2019-12-01\n",
" * lat (lat) float32 1kB 89.75 89.25 88.75 88.25 ... -88.75 -89.25 -89.75\n",
" * lon (lon) float32 3kB -179.8 -179.2 -178.8 -178.2 ... 178.8 179.2 179.8\n",
"Data variables:\n",
" tas (time, lat, lon) float32 1GB ...\n",
"Attributes:\n",
" title: GSWP3-W5E5 observational climate input data fo...\n",
" institution: Potsdam Institute for Climate Impact Research ...\n",
" project: Inter-Sectoral Impact Model Intercomparison Pr...\n",
" contact: ISIMIP cross-sectoral science team <info@isimi...\n",
" summary: GSWP3 v1.09 bias-adjusted to W5E5 v2.0 with IS...\n",
" references: Kim (2017) <https://doi.org/10.20783/DIAS.501>...\n",
" postprocessing_date: 2022-05-12\n",
" postprocessing_scientist: lilian.schuster@student.uibk.ac.at\n",
" postprocessing_actions: using xarray: ds = xr.open_mfdataset(gswp3-w5e...<xarray.DataArray 'tas' (year: 290)> Size: 2kB\n",
"array([13.661966, 13.743564, 13.805403, ..., 19.755408, 19.778811, 19.862972])\n",
"Coordinates:\n",
" * year (year) int64 2kB 1850 1851 1852 1853 1854 ... 2136 2137 2138 2139\n",
" height float64 8B ...\n",
" scenario <U22 88B 'up2p0'<xarray.DataArray 'year' ()> Size: 8B\n",
"array(39.)\n",
"Coordinates:\n",
" height float64 8B 1.5"
],
"text/plain": [
"<xarray.DataArray 'year' ()> Size: 8B\n",
"array(1889.)\n",
"Coordinates:\n",
" height float64 8B 1.5