From caced1341d02af8effe3ec23cd3d17343b1fc048 Mon Sep 17 00:00:00 2001 From: lilianschuster Date: Wed, 18 Mar 2026 13:34:18 +0100 Subject: [PATCH 1/2] updated remaining tutorials to oggm v16 --- notebooks/tutorials/inversion.ipynb | 41 +++++++- .../tutorials/preprocessing_errors.ipynb | 99 ++++++++++++++----- 2 files changed, 113 insertions(+), 27 deletions(-) diff --git a/notebooks/tutorials/inversion.ipynb b/notebooks/tutorials/inversion.ipynb index df0b407c..ff20c214 100644 --- a/notebooks/tutorials/inversion.ipynb +++ b/notebooks/tutorials/inversion.ipynb @@ -66,6 +66,9 @@ "# This is useful here\n", "cfg.PARAMS['use_multiprocessing'] = True\n", "\n", + "# continue if some individual glaciers give errors\n", + "cfg.PARAMS['continue_on_error'] = True\n", + "\n", "# RGI file\n", "path = utils.get_rgi_region_file(rgi_region)\n", "rgidf = gpd.read_file(path)\n", @@ -82,7 +85,7 @@ "# (we specifically need `geometries.pkl` in the gdirs)\n", "cfg.PARAMS['border'] = 80\n", "base_url = ('https://cluster.klima.uni-bremen.de/~oggm/gdirs/oggm_v1.6/'\n", - " 'L3-L5_files/2025.6/centerlines/W5E5/per_glacier_spinup') # todo<-- here is an issue with preprocessed gdir...todo\n", + " 'L3-L5_files/2025.6/centerlines/W5E5/per_glacier_spinup')\n", "gdirs = workflow.init_glacier_directories(rgidf, from_prepro_level=3,\n", " prepro_base_url=base_url)\n", "\n", @@ -181,6 +184,27 @@ "There are only 35 glaciers in the Pyrenees! That's why the run was relatively fast." ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# is there any glacier that is failing?\n", + "failing_glaciers = df[df.isna().any(axis=1)].index\n", + "df[df.isna().any(axis=1)]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# if yes, remove that glacier, for the further analysis \n", + "df = df.dropna()" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -441,8 +465,9 @@ "# The default path of the geotiff file is in the glacier directory with the name \"distributed_thickness.tif\"\n", "# Let's check if the file exists\n", "for gdir in gdirs:\n", - " path = os.path.join(gdir.dir, 'distributed_thickness.tif')\n", - " assert os.path.exists(path)" + " if gdir.rgi_id not in failing_glaciers:\n", + " path = os.path.join(gdir.dir, 'distributed_thickness.tif')\n", + " assert os.path.exists(path)" ] }, { @@ -482,7 +507,8 @@ "metadata": {}, "outputs": [], "source": [ - "rgi_ids = ['RGI60-11.0{}'.format(i) for i in range(3205, 3211)]\n", + "# 'RGI60-11.03207' is failing for OGGM v1.6.3, so we only show 3208 to 3211, instead of 3205 to 3211\n", + "rgi_ids = ['RGI60-11.0{}'.format(i) for i in range(3208, 3211)] \n", "sel_gdirs = [gdir for gdir in gdirs if gdir.rgi_id in rgi_ids]\n", "graphics.plot_googlemap(sel_gdirs)\n", "# you might need to install motionless if it is not yet in your environment\n", @@ -627,6 +653,11 @@ ], "metadata": { "hide_input": false, + "kernelspec": { + "display_name": "Python [conda env:oggm_v16]", + "language": "python", + "name": "conda-env-oggm_v16-py" + }, "language_info": { "codemirror_mode": { "name": "ipython", @@ -637,7 +668,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.4" + "version": "3.11.3" }, "metadata": { "interpreter": { diff --git a/notebooks/tutorials/preprocessing_errors.ipynb b/notebooks/tutorials/preprocessing_errors.ipynb index 49d57915..e89e79cc 100644 --- a/notebooks/tutorials/preprocessing_errors.ipynb +++ b/notebooks/tutorials/preprocessing_errors.ipynb @@ -53,7 +53,7 @@ "outputs": [], "source": [ "# W5E5 centerlines\n", - "url = 'https://cluster.klima.uni-bremen.de/~oggm/gdirs/oggm_v1.6/L3-L5_files/2025.6/centerlines/W5E5/per_glacier_spinup/RGI62/b_080/L5/summary/' #todo-wait-until-gdir-ready" + "url = 'https://cluster.klima.uni-bremen.de/~oggm/gdirs/oggm_v1.6/L3-L5_files/2025.6/centerlines/W5E5/per_glacier_spinup/RGI62/b_080/L5/summary/'" ] }, { @@ -171,7 +171,7 @@ "outputs": [], "source": [ "# W5E5 elevation bands\n", - "url = 'https://cluster.klima.uni-bremen.de/~oggm/gdirs/oggm_v1.6/L3-L5_files/2023.3/elev_bands/W5E5/RGI62/b_080/L5/summary/'\n", + "url = 'https://cluster.klima.uni-bremen.de/~oggm/gdirs/oggm_v1.6/L3-L5_files/2025.6/elev_bands/W5E5/per_glacier_spinup/RGI62/b_080/L5/summary/'\n", "# this can take some time\n", "df_elev = []\n", "# we don't look at RGI19 (Antarctic glaciers), because no climate available for CRU\n", @@ -218,8 +218,10 @@ "metadata": {}, "source": [ "- **Compare different climate datasets**\n", - " - this works only when using OGGM v1.4 urls (comparing **CRU vs ERA5**)\n", - " - in OGGM v1.6 (state: March 2023), only GSWP3_W5E5 exists" + " - comparing **ERA5 vs GSWP3_W5E5** (using OGGM v1.6.3 2025.6 gdirs) \n", + " - comparing **ERA5 vs CRU** (using OGGM v1.4) \n", + "\n", + "*CRU not available for region 19, so we exclude this region from the intercomparison*" ] }, { @@ -228,17 +230,50 @@ "metadata": {}, "outputs": [], "source": [ - "# attention here OGGM_v1.4 is used and this is just for demonstration purposes how to compare\n", + "# attention here OGGM_v1.6 is used and this is just for demonstration purposes how to compare\n", "# different preprocessed directories!\n", - "# This is CRU + centerlines. But you can try CRU+elev_bands, or ERA5+elev_bands, etc!\n", - "url = 'https://cluster.klima.uni-bremen.de/~oggm/gdirs/oggm_v1.4/L3-L5_files/CRU/centerlines/qc3/pcp2.5/no_match/RGI62/b_040/L5/summary/'\n", + "# This is ERA5 + elevation bands ... \n", + "url = 'https://cluster.klima.uni-bremen.de/~oggm/gdirs/oggm_v1.6/L3-L5_files/2025.6/elev_bands/ERA5/per_glacier_spinup/RGI62/b_080/L5/summary/'\n", "# this can take some time\n", - "df_cru_v14 = []\n", - "# we don't look at RGI19 (Antarctic glaciers), because no climate available for CRU\n", + "df_era5_v16 = []\n", "for rgi_reg in range(1, 19):\n", " fpath = utils.file_downloader(url + f'glacier_statistics_{rgi_reg:02d}.csv')\n", - " df_cru_v14.append(pd.read_csv(fpath, index_col=0, low_memory=False))\n", - "df_cru_v14 = pd.concat(df_cru_v14, sort=False).sort_index()" + " df_era5_v16.append(pd.read_csv(fpath, index_col=0, low_memory=False))\n", + "df_era5_v16 = pd.concat(df_era5_v16, sort=False).sort_index()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# The same for W5E5 \n", + "url = 'https://cluster.klima.uni-bremen.de/~oggm/gdirs/oggm_v1.6/L3-L5_files/2025.6/elev_bands/W5E5/per_glacier_spinup/RGI62/b_080/L5/summary/'\n", + "df_w5e5_v16 = []\n", + "for rgi_reg in range(1, 19):\n", + " fpath = utils.file_downloader(url + f'glacier_statistics_{rgi_reg:02d}.csv')\n", + " df_w5e5_v16.append(pd.read_csv(fpath, index_col=0, low_memory=False))\n", + "df_w5e5_v16 = pd.concat(df_w5e5_v16, sort=False).sort_index()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "rel_area_cent_era5_v16 = df_era5_v16.loc[~df_era5_v16['error_task'].isnull()].rgi_area_km2.sum() / df_era5_v16.rgi_area_km2.sum() * 100\n", + "rel_area_cent_w5e5_v16 = df_w5e5_v16.loc[~df_w5e5_v16['error_task'].isnull()].rgi_area_km2.sum() / df_w5e5_v16.rgi_area_km2.sum() * 100\n", + "print(f\"% area errors all sources for W5E5 is {rel_area_cent_w5e5_v16:.2f}% compared to {rel_area_cent_era5_v16:.2f}% for ERA5\")\n", + " " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "*overall, similar amount of failing area between W5E5 and ERA5*" ] }, { @@ -247,15 +282,22 @@ "metadata": {}, "outputs": [], "source": [ + "# Now OGGM v1.4\n", + "# This is CRU + elev_bands. But you can try CRU+elev_bands, or ERA5+elev_bands, etc!\n", + "url = 'https://cluster.klima.uni-bremen.de/~oggm/gdirs/oggm_v1.4/L3-L5_files/CRU/elev_bands/qc3/pcp2.5/no_match/RGI62/b_080/L5/summary/'\n", + "df_cru_v14 = []\n", + "for rgi_reg in range(1, 19):\n", + " fpath = utils.file_downloader(url + f'glacier_statistics_{rgi_reg:02d}.csv')\n", + " df_cru_v14.append(pd.read_csv(fpath, index_col=0, low_memory=False))\n", + "df_cru_v14 = pd.concat(df_cru_v14, sort=False).sort_index()\n", + "\n", "# ERA5 uses a different precipitation factor in OGGM_v1.4\n", - "url = 'https://cluster.klima.uni-bremen.de/~oggm/gdirs/oggm_v1.4/L3-L5_files/ERA5/centerlines/qc3/pcp1.6/no_match/RGI62/b_040/L5/summary/'\n", - "# this can take some time\n", + "url = 'https://cluster.klima.uni-bremen.de/~oggm/gdirs/oggm_v1.4/L3-L5_files/ERA5/elev_bands/qc3/pcp1.6/no_match/RGI62/b_080/L5/summary/'\n", "df_era5_v14 = []\n", - "# we don't look at RGI19 (Antarctic glaciers), because no climate available for CRU\n", "for rgi_reg in range(1, 19):\n", " fpath = utils.file_downloader(url + f'glacier_statistics_{rgi_reg:02d}.csv')\n", " df_era5_v14.append(pd.read_csv(fpath, index_col=0, low_memory=False))\n", - "df_era5_v14 = pd.concat(df_era5_v14, sort=False).sort_index()" + "df_era5_v14 = pd.concat(df_era5_v14, sort=False).sort_index()\n" ] }, { @@ -266,15 +308,14 @@ "source": [ "rel_area_cent_era5_v14 = df_era5_v14.loc[~df_era5_v14['error_task'].isnull()].rgi_area_km2.sum() / df_era5_v14.rgi_area_km2.sum() * 100\n", "rel_area_cent_cru_v14 = df_cru_v14.loc[~df_cru_v14['error_task'].isnull()].rgi_area_km2.sum() / df_cru_v14.rgi_area_km2.sum() * 100\n", - "print(f\"% area errors all sources for ERA5 is {rel_area_cent_era5_v14:.2f}% compared to {rel_area_cent_cru_v14:.2f}% for CRU\")\n", - " " + "print(f\"% area errors all sources for ERA5 is {rel_area_cent_era5_v14:.2f}% compared to {rel_area_cent_cru_v14:.2f}% for CRU\") " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "*more than three times fewer errors from the climate tasks occur when using ERA5 than when using CRU* !" + "*more than three times fewer errors from the climate tasks occur when using ERA5 than when using CRU* ! (not the E" ] }, { @@ -293,7 +334,8 @@ "print('% area errors from all sources for centerlines is: \\n'+\n", " f'{rel_area_cent_cru_v14:.2f}% for CRU and OGGM_v14 \\n'+\n", " f'{rel_area_cent_era5_v14:.2f}% for ERA5 and OGGM_v14 \\n'+\n", - " f'{rel_area_cent:.2f}% for W5E5 and OGGM_v16')\n", + " f'{rel_area_cent_w5e5_v16:.2f}% for W5E5 and OGGM_v16 \\n' +\n", + " f'{rel_area_cent_era5_v16:.2f}% for ERA5 and OGGM_v16')\n", " " ] }, @@ -312,15 +354,28 @@ "source": [ "## What's next?\n", "\n", - "- A more detailed analysis of the type, amount and relative failing glacier area (in total and per RGI region) can be found in [this error analysis jupyter notebook](https://nbviewer.org/urls/cluster.klima.uni-bremen.de/~lschuster/error_analysis/error_analysis_v1.ipynb?flush_cache=true). It also includes an error analysis for different [MB calibration and climate quality check methods](https://nbviewer.org/urls/cluster.klima.uni-bremen.de/~lschuster/error_analysis/error_analysis_v1.ipynb?flush_cache=true#Analysis-for-Level-5-pre-processing-directories!).\n", - "- If you are interested in how the “common” non-failing glaciers differ in terms of historical volume change, total mass change and specific mass balance between different pre-processed glacier directories, you can check out [this jupyter notebook](https://nbviewer.org/urls/cluster.klima.uni-bremen.de/~lschuster/error_analysis/working_glacier_gdirs_comparison.ipynb?flush_cache=true).\n", + "- A more detailed analysis of the type, amount and relative failing glacier area (in total and per RGI region) can be found in [this OGGM v1.6.3 error analysis jupyter notebook](https://nbviewer.org/urls/cluster.klima.uni-bremen.de/~oggm/oggm-standard-projections/analysis_notebooks/1.6.3_2025_6_gdirs_proj_comparisons/0_error_analysis_gdirs_oggm_v16_2025.6.ipynb)\n", + "- If you are interested in how the “common” non-failing glaciers differ in terms of historical volume change, total mass change and specific mass balance between different pre-processed glacier directories, you can check out [this jupyter notebook](https://nbviewer.org/urls/cluster.klima.uni-bremen.de/~oggm/oggm-standard-projections/analysis_notebooks/1.6.3_2025_6_gdirs_proj_comparisons/3_volume_projection_differences.ipynb)\n", + "- Reasons for the different error, calibration and projection differences between preprocessed glacier directories of OGGM v1.6. are summarised in this [OGGM blogpost](https://oggm.org/2026/01/07/oggm_v16-gdirs-and-projection-options/).\n", "- return to the [OGGM documentation](https://docs.oggm.org)\n", "- back to the [table of contents](../welcome.ipynb)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "hide_input": false, + "kernelspec": { + "display_name": "Python [conda env:oggm_v16]", + "language": "python", + "name": "conda-env-oggm_v16-py" + }, "language_info": { "codemirror_mode": { "name": "ipython", @@ -331,7 +386,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.4" + "version": "3.11.3" }, "toc": { "base_numbering": 1, From 9c12357528984468e1ec1ff435adaae35678a15e Mon Sep 17 00:00:00 2001 From: lilianschuster Date: Wed, 18 Mar 2026 13:46:21 +0100 Subject: [PATCH 2/2] removed cell output --- notebooks/tutorials/inversion.ipynb | 4 ++-- notebooks/tutorials/preprocessing_errors.ipynb | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/notebooks/tutorials/inversion.ipynb b/notebooks/tutorials/inversion.ipynb index ff20c214..696e8e05 100644 --- a/notebooks/tutorials/inversion.ipynb +++ b/notebooks/tutorials/inversion.ipynb @@ -535,7 +535,7 @@ "metadata": {}, "outputs": [], "source": [ - "graphics.plot_distributed_thickness(sel_gdirs)" + "graphics.plot_distributed_thickness(sel_gdirs);" ] }, { @@ -558,7 +558,7 @@ "metadata": {}, "outputs": [], "source": [ - "graphics.plot_inversion(sel_gdirs, extend_plot_limit=True)" + "graphics.plot_inversion(sel_gdirs, extend_plot_limit=True);" ] }, { diff --git a/notebooks/tutorials/preprocessing_errors.ipynb b/notebooks/tutorials/preprocessing_errors.ipynb index e89e79cc..eb535538 100644 --- a/notebooks/tutorials/preprocessing_errors.ipynb +++ b/notebooks/tutorials/preprocessing_errors.ipynb @@ -335,8 +335,7 @@ " f'{rel_area_cent_cru_v14:.2f}% for CRU and OGGM_v14 \\n'+\n", " f'{rel_area_cent_era5_v14:.2f}% for ERA5 and OGGM_v14 \\n'+\n", " f'{rel_area_cent_w5e5_v16:.2f}% for W5E5 and OGGM_v16 \\n' +\n", - " f'{rel_area_cent_era5_v16:.2f}% for ERA5 and OGGM_v16')\n", - " " + " f'{rel_area_cent_era5_v16:.2f}% for ERA5 and OGGM_v16') " ] }, {