{ "cells": [ { "cell_type": "markdown", "id": "d4185627-8c90-40df-be43-405dd22a6cf0", "metadata": {}, "source": [ "# Workflow to analyse the raw oggm output per glacier projection files " ] }, { "cell_type": "code", "execution_count": 1, "id": "89e71823-f643-4620-8b81-2aa2864435af", "metadata": {}, "outputs": [], "source": [ "import xarray as xr\n", "import pandas as pd\n", "import progressbar\n", "import numpy as np\n", "from oggm.utils import mkdir\n", "import matplotlib.pyplot as plt\n", "import json\n", "import os\n" ] }, { "cell_type": "code", "execution_count": 2, "id": "71b8a117-a7e4-43fc-91dc-8cce26277771", "metadata": {}, "outputs": [], "source": [ "# raw output files -> change that to your local path\n", "dirpath = '/home/www/oggm/oggm-standard-projections/oggm_v16/2023.3'" ] }, { "cell_type": "markdown", "id": "fb4722df-0532-4ec4-8702-40598c377ca2", "metadata": {}, "source": [ "### Load a single file" ] }, { "cell_type": "code", "execution_count": 3, "id": "a13c426b-f2d4-4ac3-ab71-46ebd91ff424", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset>\n", "Dimensions: (time: 301, rgi_id: 1000, month_2d: 12)\n", "Coordinates:\n", " * time (time) float64 2e+03 2.001e+03 ... 2.3e+03\n", " * rgi_id (rgi_id) object 'RGI60-11.00001' ... 'RGI60...\n", " * month_2d (month_2d) int64 1 2 3 4 5 6 7 8 9 10 11 12\n", "Data variables: (12/29)\n", " volume (time, rgi_id) float32 dask.array<chunksize=(301, 1000), meta=np.ndarray>\n", " volume_bsl (time, rgi_id) float32 dask.array<chunksize=(301, 1000), meta=np.ndarray>\n", " volume_bwl (time, rgi_id) float32 dask.array<chunksize=(301, 1000), meta=np.ndarray>\n", " area (time, rgi_id) float32 dask.array<chunksize=(301, 1000), meta=np.ndarray>\n", " length (time, rgi_id) float32 dask.array<chunksize=(301, 1000), meta=np.ndarray>\n", " calving (time, rgi_id) float32 dask.array<chunksize=(301, 1000), meta=np.ndarray>\n", " ... ...\n", " snowfall_on_glacier_monthly (time, month_2d, rgi_id) float32 dask.array<chunksize=(301, 12, 1000), meta=np.ndarray>\n", " snow_bucket_monthly (time, month_2d, rgi_id) float32 dask.array<chunksize=(301, 12, 1000), meta=np.ndarray>\n", " residual_mb_monthly (time, month_2d, rgi_id) float32 dask.array<chunksize=(301, 12, 1000), meta=np.ndarray>\n", " water_level (rgi_id) float32 dask.array<chunksize=(1000,), meta=np.ndarray>\n", " glen_a (rgi_id) float32 dask.array<chunksize=(1000,), meta=np.ndarray>\n", " fs (rgi_id) float32 dask.array<chunksize=(1000,), meta=np.ndarray>\n", "Attributes:\n", " description: OGGM model output\n", " oggm_version: 1.6.1.dev26+gf8a1745\n", " calendar: 365-day no leap\n", " creation_date: 2023-07-26 15:18:51
<xarray.Dataset>\n", "Dimensions: (time: 301, rgi_id: 1000, month_2d: 12)\n", "Coordinates:\n", " * time (time) float64 2e+03 2.001e+03 ... 2.3e+03\n", " * rgi_id (rgi_id) object 'RGI60-11.00001' ... 'RGI60...\n", " * month_2d (month_2d) int64 1 2 3 4 5 6 7 8 9 10 11 12\n", "Data variables: (12/29)\n", " volume (time, rgi_id) float32 dask.array<chunksize=(301, 1000), meta=np.ndarray>\n", " volume_bsl (time, rgi_id) float32 dask.array<chunksize=(301, 1000), meta=np.ndarray>\n", " volume_bwl (time, rgi_id) float32 dask.array<chunksize=(301, 1000), meta=np.ndarray>\n", " area (time, rgi_id) float32 dask.array<chunksize=(301, 1000), meta=np.ndarray>\n", " length (time, rgi_id) float32 dask.array<chunksize=(301, 1000), meta=np.ndarray>\n", " calving (time, rgi_id) float32 dask.array<chunksize=(301, 1000), meta=np.ndarray>\n", " ... ...\n", " snowfall_on_glacier_monthly (time, month_2d, rgi_id) float32 dask.array<chunksize=(301, 12, 1000), meta=np.ndarray>\n", " snow_bucket_monthly (time, month_2d, rgi_id) float32 dask.array<chunksize=(301, 12, 1000), meta=np.ndarray>\n", " residual_mb_monthly (time, month_2d, rgi_id) float32 dask.array<chunksize=(301, 12, 1000), meta=np.ndarray>\n", " water_level (rgi_id) float32 dask.array<chunksize=(1000,), meta=np.ndarray>\n", " glen_a (rgi_id) float32 dask.array<chunksize=(1000,), meta=np.ndarray>\n", " fs (rgi_id) float32 dask.array<chunksize=(1000,), meta=np.ndarray>\n", "Attributes:\n", " description: OGGM model output\n", " oggm_version: 1.6.1.dev26+gf8a1745\n", " calendar: 365-day no leap\n", " creation_date: 2023-07-26 15:18:51
\n", " | description | \n", "unit | \n", "coords | \n", "
---|---|---|---|
variable | \n", "\n", " | \n", " | \n", " |
volume | \n", "Total glacier volume | \n", "m 3 | \n", "['time', 'rgi_id'] | \n", "
volume_bsl | \n", "Glacier volume below sea-level | \n", "m 3 | \n", "['time', 'rgi_id'] | \n", "
volume_bwl | \n", "Glacier volume below water-level | \n", "m 3 | \n", "['time', 'rgi_id'] | \n", "
area | \n", "Total glacier area | \n", "m 2 | \n", "['time', 'rgi_id'] | \n", "
length | \n", "Glacier length | \n", "m | \n", "['time', 'rgi_id'] | \n", "
calving | \n", "Total accumulated calving flux | \n", "m 3 | \n", "['time', 'rgi_id'] | \n", "
calving_rate | \n", "Calving rate | \n", "m yr-1 | \n", "['time', 'rgi_id'] | \n", "
off_area | \n", "Off-glacier area | \n", "m 2 | \n", "['time', 'rgi_id'] | \n", "
on_area | \n", "On-glacier area | \n", "m 2 | \n", "['time', 'rgi_id'] | \n", "
melt_off_glacier | \n", "Off-glacier melt | \n", "kg yr-1 | \n", "['time', 'rgi_id'] | \n", "
melt_on_glacier | \n", "On-glacier melt | \n", "kg yr-1 | \n", "['time', 'rgi_id'] | \n", "
liq_prcp_off_glacier | \n", "Off-glacier liquid precipitation | \n", "kg yr-1 | \n", "['time', 'rgi_id'] | \n", "
liq_prcp_on_glacier | \n", "On-glacier liquid precipitation | \n", "kg yr-1 | \n", "['time', 'rgi_id'] | \n", "
snowfall_off_glacier | \n", "Off-glacier solid precipitation | \n", "kg yr-1 | \n", "['time', 'rgi_id'] | \n", "
snowfall_on_glacier | \n", "On-glacier solid precipitation | \n", "kg yr-1 | \n", "['time', 'rgi_id'] | \n", "
snow_bucket | \n", "Off-glacier snow reservoir (state variable) | \n", "kg | \n", "['time', 'rgi_id'] | \n", "
model_mb | \n", "Annual mass balance from dynamical model | \n", "kg yr-1 | \n", "['time', 'rgi_id'] | \n", "
residual_mb | \n", "Difference (before correction) between mb mode... | \n", "kg yr-1 | \n", "['time', 'rgi_id'] | \n", "
melt_off_glacier_monthly | \n", "\n", " | kg month-1 | \n", "['time', 'rgi_id', 'month_2d'] | \n", "
melt_on_glacier_monthly | \n", "\n", " | kg month-1 | \n", "['time', 'rgi_id', 'month_2d'] | \n", "
liq_prcp_off_glacier_monthly | \n", "\n", " | kg month-1 | \n", "['time', 'rgi_id', 'month_2d'] | \n", "
liq_prcp_on_glacier_monthly | \n", "\n", " | kg month-1 | \n", "['time', 'rgi_id', 'month_2d'] | \n", "
snowfall_off_glacier_monthly | \n", "\n", " | kg month-1 | \n", "['time', 'rgi_id', 'month_2d'] | \n", "
snowfall_on_glacier_monthly | \n", "\n", " | kg month-1 | \n", "['time', 'rgi_id', 'month_2d'] | \n", "
snow_bucket_monthly | \n", "\n", " | kg month-1 | \n", "['time', 'rgi_id', 'month_2d'] | \n", "
residual_mb_monthly | \n", "\n", " | kg month-1 | \n", "['time', 'rgi_id', 'month_2d'] | \n", "
water_level | \n", "Calving water level | \n", "\n", " | ['rgi_id'] | \n", "
glen_a | \n", "Simulation Glen A | \n", "\n", " | ['rgi_id'] | \n", "
fs | \n", "Simulation sliding parameter | \n", "\n", " | ['rgi_id'] | \n", "
<xarray.Dataset>\n", "Dimensions: (time: 301, rgi_id: 995, month_2d: 12)\n", "Coordinates:\n", " * time (time) float64 2e+03 2.001e+03 ... 2.3e+03\n", " * rgi_id (rgi_id) object 'RGI60-11.00001' ... 'RGI60...\n", " * month_2d (month_2d) int64 1 2 3 4 5 6 7 8 9 10 11 12\n", "Data variables: (12/29)\n", " volume (time, rgi_id) float32 dask.array<chunksize=(301, 995), meta=np.ndarray>\n", " volume_bsl (time, rgi_id) float32 dask.array<chunksize=(301, 995), meta=np.ndarray>\n", " volume_bwl (time, rgi_id) float32 dask.array<chunksize=(301, 995), meta=np.ndarray>\n", " area (time, rgi_id) float32 dask.array<chunksize=(301, 995), meta=np.ndarray>\n", " length (time, rgi_id) float32 dask.array<chunksize=(301, 995), meta=np.ndarray>\n", " calving (time, rgi_id) float32 dask.array<chunksize=(301, 995), meta=np.ndarray>\n", " ... ...\n", " snowfall_on_glacier_monthly (time, month_2d, rgi_id) float32 dask.array<chunksize=(301, 12, 995), meta=np.ndarray>\n", " snow_bucket_monthly (time, month_2d, rgi_id) float32 dask.array<chunksize=(301, 12, 995), meta=np.ndarray>\n", " residual_mb_monthly (time, month_2d, rgi_id) float32 dask.array<chunksize=(301, 12, 995), meta=np.ndarray>\n", " water_level (rgi_id) float32 dask.array<chunksize=(995,), meta=np.ndarray>\n", " glen_a (rgi_id) float32 dask.array<chunksize=(995,), meta=np.ndarray>\n", " fs (rgi_id) float32 dask.array<chunksize=(995,), meta=np.ndarray>\n", "Attributes:\n", " description: OGGM model output\n", " oggm_version: 1.6.1.dev26+gf8a1745\n", " calendar: 365-day no leap\n", " creation_date: 2023-07-26 15:18:51
<xarray.Dataset>\n", "Dimensions: (gcm_scenario: 16, time: 301)\n", "Coordinates:\n", " * time (time) float64 2e+03 2.001e+03 ... 2.299e+03 2.3e+03\n", " hydro_year (time) int64 2000 2001 2002 2003 ... 2297 2298 2299 2300\n", " hydro_month (time) int64 4 4 4 4 4 4 4 4 4 4 4 ... 4 4 4 4 4 4 4 4 4 4\n", " calendar_year (time) int64 2000 2001 2002 2003 ... 2297 2298 2299 2300\n", " calendar_month (time) int64 1 1 1 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1 1 1\n", " * gcm_scenario (gcm_scenario) <U24 'CanESM5_ssp585' ... 'ACCESS-ESM1-5_...\n", " gcm (gcm_scenario) <U13 'CanESM5' ... 'ACCESS-ESM1-5'\n", " scenario (gcm_scenario) <U11 'ssp585' 'ssp534-over' ... 'ssp585'\n", " bias_correction <U12 'bc_2000_2019'\n", " hist <U13 'gcm_from_2000'\n", "Data variables:\n", " volume (gcm_scenario, time) float32 1.429e+13 ... 2.508e+07\n", " volume_bsl (gcm_scenario, time) float32 1.613e+12 ... 8.174e+06
<xarray.Dataset>\n", "Dimensions: (gcm_scenario: 16, time: 301, rgi_id: 498)\n", "Coordinates:\n", " * time (time) float64 2e+03 2.001e+03 ... 2.299e+03 2.3e+03\n", " * rgi_id (rgi_id) object 'RGI60-09.00027' ... 'RGI60-09.01069'\n", " hydro_month (time) int64 4 4 4 4 4 4 4 4 4 4 4 ... 4 4 4 4 4 4 4 4 4 4\n", " calendar_month (time) int64 1 1 1 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1 1 1\n", " rgi_reg (rgi_id) <U2 '09' '09' '09' '09' ... '09' '09' '09' '09'\n", " * gcm_scenario (gcm_scenario) <U24 'CanESM5_ssp585' ... 'ACCESS-ESM1-5_...\n", " gcm (gcm_scenario) <U13 'CanESM5' ... 'ACCESS-ESM1-5'\n", " scenario (gcm_scenario) <U11 'ssp585' 'ssp534-over' ... 'ssp585'\n", " bias_correction <U12 'bc_2000_2019'\n", " hist <U13 'gcm_from_2000'\n", "Data variables:\n", " volume (gcm_scenario, time, rgi_id) float32 9.405e+08 ... 0.0\n", " volume_bsl (gcm_scenario, time, rgi_id) float32 3.694e+07 ... 0.0\n", "Attributes:\n", " description: OGGM model output\n", " oggm_version: 1.6.1.dev26+gf8a1745\n", " calendar: 365-day no leap\n", " creation_date: 2023-07-26 14:41:40" ], "text/plain": [ "
<xarray.Dataset>\n", "Dimensions: (rgi_reg: 1, scenario: 3, gcm: 5, time: 100, month_2d: 12)\n", "Coordinates: (12/13)\n", " * time (time) float64 2e+03 2.001e+03 ... 2.098e+03 2.099e+03\n", " hydro_year (time) int64 2000 2001 2002 2003 ... 2096 2097 2098 2099\n", " hydro_month (time) int64 4 4 4 4 4 4 4 4 4 4 ... 4 4 4 4 4 4 4 4 4 4\n", " calendar_year (time) int64 2000 2001 2002 2003 ... 2096 2097 2098 2099\n", " calendar_month (time) int64 1 1 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1 1 1\n", " * month_2d (month_2d) int64 1 2 3 4 5 6 7 8 9 10 11 12\n", " ... ...\n", " * rgi_reg (rgi_reg) <U2 '11'\n", " gcm_scenario (scenario, gcm) <U20 'mri-esm2-0_ssp585' ... 'ipsl-cm6...\n", " * gcm (gcm) <U13 'mri-esm2-0' 'ukesm1-0-ll' ... 'ipsl-cm6a-lr'\n", " * scenario (scenario) <U6 'ssp585' 'ssp126' 'ssp370'\n", " bias_correction <U1 ''\n", " hist <U15 'w5e5_gcm_merged'\n", "Data variables:\n", " runoff (rgi_reg, scenario, gcm, time) float32 8.553e+12 ... 5...\n", " runoff_monthly (rgi_reg, scenario, gcm, time, month_2d) float32 3.138...
\n", " | MRBID | \n", "RIVER_BASI | \n", "CONTINENT | \n", "OCEAN | \n", "SEA | \n", "AREA_CALC | \n", "Shape_Leng | \n", "Shape_Area | \n", "RGI_AREA | \n", "geometry | \n", "
---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "2103 | \n", "INDIGIRKA | \n", "Asia | \n", "Arctic Ocean | \n", "East Siberian Sea | \n", "341234.0 | \n", "85.604051 | \n", "70.212499 | \n", "171.941 | \n", "POLYGON ((151.72500 70.97500, 151.72500 70.970... | \n", "
1 | \n", "2108 | \n", "OB | \n", "Asia | \n", "Arctic Ocean | \n", "Kara Sea | \n", "3040606.1 | \n", "168.355250 | \n", "448.342075 | \n", "763.493 | \n", "POLYGON ((91.75000 57.70417, 91.74542 57.70299... | \n", "
2 | \n", "2302 | \n", "BRAHMAPUTRA | \n", "Asia | \n", "Indian Ocean | \n", "Bay of Bengal | \n", "540782.5 | \n", "66.054440 | \n", "49.686611 | \n", "10528.496 | \n", "POLYGON ((97.76667 28.77083, 97.76335 28.77168... | \n", "
3 | \n", "2306 | \n", "GANGES | \n", "Asia | \n", "Indian Ocean | \n", "Bay of Bengal | \n", "1006558.6 | \n", "122.349983 | \n", "90.946880 | \n", "7906.081 | \n", "MULTIPOLYGON (((88.02555 21.57150, 88.02361 21... | \n", "
4 | \n", "2309 | \n", "INDUS | \n", "Asia | \n", "Indian Ocean | \n", "Arabian Sea | \n", "865012.6 | \n", "81.286291 | \n", "82.852275 | \n", "27206.546 | \n", "MULTIPOLYGON (((67.44167 23.97006, 67.44028 23... | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
70 | \n", "6241 | \n", "PO | \n", "Europe | \n", "Atlantic Ocean | \n", "Adriatic Sea | \n", "73289.5 | \n", "21.576098 | \n", "8.425867 | \n", "313.417 | \n", "POLYGON ((9.68333 46.42500, 9.68418 46.42168, ... | \n", "
71 | \n", "6242 | \n", "RHINE | \n", "Europe | \n", "Atlantic Ocean | \n", "North Sea | \n", "163122.3 | \n", "48.247612 | \n", "20.200160 | \n", "336.922 | \n", "POLYGON ((4.45638 52.14527, 4.46175 52.14110, ... | \n", "
72 | \n", "6243 | \n", "RHONE | \n", "Europe | \n", "Atlantic Ocean | \n", "Mediterranean Sea | \n", "96637.6 | \n", "28.004916 | \n", "11.197342 | \n", "917.302 | \n", "POLYGON ((6.84167 47.82083, 6.84167 47.81667, ... | \n", "
73 | \n", "6254 | \n", "THJORSA | \n", "Europe | \n", "Atlantic Ocean | \n", "North Atlantic | \n", "8277.8 | \n", "9.270847 | \n", "1.545336 | \n", "972.419 | \n", "POLYGON ((-17.50000 64.62500, -17.50035 64.605... | \n", "
74 | \n", "6255 | \n", "TORNEALVEN (also TORNIONJOKI, also TORNIONVAYLA) | \n", "Europe | \n", "Atlantic Ocean | \n", "Baltic Sea | \n", "40545.2 | \n", "28.919025 | \n", "8.685652 | \n", "34.257 | \n", "POLYGON ((23.69167 68.84167, 23.70214 68.84102... | \n", "
75 rows × 10 columns
\n", "