Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 38 additions & 7 deletions notebooks/tutorials/inversion.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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": {},
Expand Down Expand Up @@ -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)"
]
},
{
Expand Down Expand Up @@ -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",
Expand All @@ -509,7 +535,7 @@
"metadata": {},
"outputs": [],
"source": [
"graphics.plot_distributed_thickness(sel_gdirs)"
"graphics.plot_distributed_thickness(sel_gdirs);"
]
},
{
Expand All @@ -532,7 +558,7 @@
"metadata": {},
"outputs": [],
"source": [
"graphics.plot_inversion(sel_gdirs, extend_plot_limit=True)"
"graphics.plot_inversion(sel_gdirs, extend_plot_limit=True);"
]
},
{
Expand Down Expand Up @@ -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",
Expand All @@ -637,7 +668,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.4"
"version": "3.11.3"
},
"metadata": {
"interpreter": {
Expand Down
100 changes: 77 additions & 23 deletions notebooks/tutorials/preprocessing_errors.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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/'"
]
},
{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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*"
]
},
{
Expand All @@ -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*"
]
},
{
Expand All @@ -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"
]
},
{
Expand All @@ -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"
]
},
{
Expand All @@ -293,8 +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') "
]
},
{
Expand All @@ -312,15 +353,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",
Expand All @@ -331,7 +385,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.11.3"
},
"toc": {
"base_numbering": 1,
Expand Down
Loading