{ "cells": [ { "cell_type": "code", "execution_count": 112, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import os\n", "from glob import glob\n", "import xarray as xr\n", "import numpy as np" ] }, { "cell_type": "code", "execution_count": 82, "metadata": {}, "outputs": [], "source": [ "fdir = '/home/www/oggm/cmip5-ng'\n", "fl = []\n", "fl_2100 = []\n", "fl_2300 = []\n", "for x in os.walk(fdir):\n", " for y in glob(os.path.join(x[0], '*.nc')):\n", " # exclude the redundant folder!\n", " if 'redundant' not in y:\n", " # the gcsm until 2300 are separately in 2300/ subfolders\n", " if '2300' in y:\n", " fl_2300.append(y)\n", " else:\n", " fl_2100.append(y)" ] }, { "cell_type": "code", "execution_count": 83, "metadata": {}, "outputs": [], "source": [ "df_2100 = pd.DataFrame(fl_2100, columns=['path'])\n", "df_2100.columns = ['path']\n", "\n", "df_2300 = pd.DataFrame(fl_2300, columns=['path'])\n", "df_2300.columns = ['path']" ] }, { "cell_type": "code", "execution_count": 84, "metadata": {}, "outputs": [], "source": [ "for i, p in df_2100.iterrows():\n", " p = p['path'].replace(fdir, '')\n", " fn = p.split('/')[-1]\n", " df_2100.loc[i, 'fname'] = fn\n", " assert len(fn.split('_')) == 6\n", " assert fn.split('_')[1] == 'mon'\n", " df_2100.loc[i, 'var'] = fn.split('_')[0]\n", " df_2100.loc[i, 'gcm'] = fn.split('_')[2]\n", " df_2100.loc[i, 'rcp'] = fn.split('_')[3]\n", " df_2100.loc[i, 'rea'] = fn.split('_')[4]\n", "\n", "### \n", "for i, p in df_2300.iterrows():\n", " p = p['path'].replace(fdir, '')\n", " fn = p.split('/')[-1]\n", " df_2300.loc[i, 'fname'] = fn\n", " # there is no _g025 in the 2300 GCM names\n", " assert len(fn.split('_')) == 5\n", " assert fn.split('_')[1] == 'mon'\n", " df_2300.loc[i, 'var'] = fn.split('_')[0]\n", " df_2300.loc[i, 'gcm'] = fn.split('_')[2]\n", " df_2300.loc[i, 'rcp'] = fn.split('_')[3]\n", " df_2300.loc[i, 'rea'] = fn.split('_')[4][:-3]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Note that the newer downloaded 2300 GCMs have another grid than the 2100 GCMs which are 2.5° bilinear interpolated (and are thus named `_g025.nc`**\n", "Therefore, we use for the 2100 simulations the `_g025.nc` simulations where possible. There is just one GCM until 2300, which has not yet existed until 2100. We will add that one to the `all_gcm_list_2100.csv` " ] }, { "cell_type": "code", "execution_count": 123, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset>\n", "Dimensions: (time: 5412, bnds: 2, lat: 96, lon: 144)\n", "Coordinates:\n", " * time (time) object 1850-01-16 12:00:00 ... 2300-12-16 12:00:00\n", " * lat (lat) float64 -90.0 -88.11 -86.21 -84.32 ... 86.21 88.11 90.0\n", " * lon (lon) float64 0.0 2.5 5.0 7.5 10.0 ... 350.0 352.5 355.0 357.5\n", "Dimensions without coordinates: bnds\n", "Data variables:\n", " time_bnds (time, bnds) object 1850-01-01 00:00:00 ... 2301-01-01 00:00:00\n", " lat_bnds (lat, bnds) float64 -90.0 -89.05 -89.05 ... 89.05 89.05 90.0\n", " lon_bnds (lon, bnds) float64 -1.25 1.25 1.25 3.75 ... 356.2 356.2 358.8\n", " pr (time, lat, lon) float32 ...\n", "Attributes: (12/27)\n", " institution: Norwegian Climate Centre\n", " institute_id: NCC\n", " experiment_id: rcp45\n", " source: NorESM1-M 2011 atmosphere: CAM-Oslo (CAM4-Oslo-n...\n", " model_id: NorESM1-M\n", " forcing: GHG, SA, Oz, Sl, Vl, BC, OC\n", " ... ...\n", " title: NorESM1-M model output prepared for CMIP5 RCP4.5\n", " parent_experiment: pre-industrial control\n", " modeling_realm: atmos\n", " realization: 1\n", " cmor_version: 2.6.0\n", " modification: Downloaded from Copernicus (Copernicus Climate Ch...