From 3bd6c871160d67ac028454a85b49dfa2d43d1ba3 Mon Sep 17 00:00:00 2001 From: gampnico <45390064+gampnico@users.noreply.github.com> Date: Thu, 17 Sep 2026 12:26:48 +0100 Subject: [PATCH] chore: replace pickle with store --- notebooks/10minutes/preprocessed_directories.ipynb | 2 +- .../tutorials/elevation_bands_vs_centerlines.ipynb | 6 +++--- .../tutorials/ingest_gridded_data_on_flowlines.ipynb | 6 +++--- notebooks/tutorials/inversion.ipynb | 2 +- notebooks/tutorials/massbalance_calibration.ipynb | 2 +- notebooks/tutorials/numeric_solvers.ipynb | 4 ++-- .../observed_thickness_with_dynamic_spinup.ipynb | 12 ++++++------ notebooks/tutorials/plot_mass_balance.ipynb | 2 +- .../tutorials/running_oggm_with_avalanches.ipynb | 2 +- notebooks/tutorials/where_are_the_flowlines.ipynb | 4 ++-- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/notebooks/10minutes/preprocessed_directories.ipynb b/notebooks/10minutes/preprocessed_directories.ipynb index 88737a8f..b5f64529 100644 --- a/notebooks/10minutes/preprocessed_directories.ipynb +++ b/notebooks/10minutes/preprocessed_directories.ipynb @@ -505,7 +505,7 @@ }, "outputs": [], "source": [ - "inversion_output = gdir.read_pickle('inversion_output') # The task above wrote the data to a pickle file - but we write to plenty of other files!\n", + "inversion_output = gdir.read_store('inversion_output') # The task above wrote the data to a npz file - but we write to plenty of other files!\n", "\n", "# Take the first flowline\n", "fl = inversion_output[0]\n", diff --git a/notebooks/tutorials/elevation_bands_vs_centerlines.ipynb b/notebooks/tutorials/elevation_bands_vs_centerlines.ipynb index 95a51b87..96a7b062 100644 --- a/notebooks/tutorials/elevation_bands_vs_centerlines.ipynb +++ b/notebooks/tutorials/elevation_bands_vs_centerlines.ipynb @@ -146,8 +146,8 @@ }, "outputs": [], "source": [ - "fls_cl = gdir_cl.read_pickle('model_flowlines')\n", - "fls_eb = gdir_eb.read_pickle('model_flowlines')" + "fls_cl = gdir_cl.read_store('model_flowlines')\n", + "fls_eb = gdir_eb.read_store('model_flowlines')" ] }, { @@ -347,7 +347,7 @@ "colors = sns.color_palette('rocket', len(sel_years))\n", "with plt.rc_context({'axes.prop_cycle': plt.cycler(color=colors)}):\n", " f, (ax1, ax2) = plt.subplots(1, 2, figsize=(15, 5.5), sharey=True, sharex=True)\n", - " n_lines = len(gdir_cl.read_pickle('model_flowlines'))\n", + " n_lines = len(gdir_cl.read_store('model_flowlines'))\n", " with xr.open_dataset(gdir_cl.get_filepath('fl_diagnostics', filesuffix=rid), group=f'fl_{n_lines-1}') as ds:\n", " (ds.bed_h + ds.sel(time=sel_years).thickness_m).plot(ax=ax1, hue='time')\n", " ds.bed_h.plot(ax=ax1, c='k')\n", diff --git a/notebooks/tutorials/ingest_gridded_data_on_flowlines.ipynb b/notebooks/tutorials/ingest_gridded_data_on_flowlines.ipynb index 90692b94..959f1541 100644 --- a/notebooks/tutorials/ingest_gridded_data_on_flowlines.ipynb +++ b/notebooks/tutorials/ingest_gridded_data_on_flowlines.ipynb @@ -618,7 +618,7 @@ }, "outputs": [], "source": [ - "fl = gdir.read_pickle('inversion_flowlines')[0]\n", + "fl = gdir.read_store('inversion_flowlines')[0]\n", "df_regular['mean_elevation'] = fl.surface_h" ] }, @@ -661,7 +661,7 @@ }, "outputs": [], "source": [ - "inv = gdir.read_pickle('inversion_output')[0]" + "inv = gdir.read_store('inversion_output')[0]" ] }, { @@ -751,7 +751,7 @@ }, "outputs": [], "source": [ - "inv = gdir.read_pickle('inversion_output')[0]" + "inv = gdir.read_store('inversion_output')[0]" ] }, { diff --git a/notebooks/tutorials/inversion.ipynb b/notebooks/tutorials/inversion.ipynb index cb5e2089..34f6bb3b 100644 --- a/notebooks/tutorials/inversion.ipynb +++ b/notebooks/tutorials/inversion.ipynb @@ -591,7 +591,7 @@ "# Add the glaciers outlines\n", "for gdir in sel_gdirs:\n", " crs = gdir.grid.center_grid\n", - " geom = gdir.read_pickle('geometries')\n", + " geom = gdir.read_store('geometries')\n", " poly_pix = geom['polygon_pix']\n", " smap.set_geometry(poly_pix, crs=crs, fc='none', zorder=2, linewidth=.2)\n", " for l in poly_pix.interiors:\n", diff --git a/notebooks/tutorials/massbalance_calibration.ipynb b/notebooks/tutorials/massbalance_calibration.ipynb index 3b146ee8..d07eb378 100644 --- a/notebooks/tutorials/massbalance_calibration.ipynb +++ b/notebooks/tutorials/massbalance_calibration.ipynb @@ -182,7 +182,7 @@ "source": [ "for gdir in gdirs:\n", " mbmod = massbalance.MonthlyTIModel(gdir)\n", - " mean_mb = mbmod.get_specific_mb(fls=gdir.read_pickle('inversion_flowlines'),\n", + " mean_mb = mbmod.get_specific_mb(fls=gdir.read_store('inversion_flowlines'),\n", " year=np.arange(2000,2020,1)).mean()\n", " print(gdir.rgi_id, f': average MB 2000-2020 = {mean_mb:.1f} kg m-2, ',\n", " f\"prcp_fac: {gdir.read_json('mb_calib')['prcp_fac']:.2f}\")" diff --git a/notebooks/tutorials/numeric_solvers.ipynb b/notebooks/tutorials/numeric_solvers.ipynb index b44053fc..0912401d 100644 --- a/notebooks/tutorials/numeric_solvers.ipynb +++ b/notebooks/tutorials/numeric_solvers.ipynb @@ -339,7 +339,7 @@ "metadata": {}, "outputs": [], "source": [ - "fl_trap = gdir_eb.read_pickle('model_flowlines')\n", + "fl_trap = gdir_eb.read_store('model_flowlines')\n", "fl_trap[-1].is_trapezoid[fl_trap[-1].thick == 0]" ] }, @@ -366,7 +366,7 @@ "# IMPORTANT: need to call init_present_time_glacier to take effect\n", "tasks.init_present_time_glacier(gdir_eb)\n", "\n", - "fl_trap = gdir_eb.read_pickle('model_flowlines')\n", + "fl_trap = gdir_eb.read_store('model_flowlines')\n", "fl_trap[-1].is_trapezoid[fl_trap[-1].thick == 0]" ] }, diff --git a/notebooks/tutorials/observed_thickness_with_dynamic_spinup.ipynb b/notebooks/tutorials/observed_thickness_with_dynamic_spinup.ipynb index 51dba7da..226b1316 100644 --- a/notebooks/tutorials/observed_thickness_with_dynamic_spinup.ipynb +++ b/notebooks/tutorials/observed_thickness_with_dynamic_spinup.ipynb @@ -116,9 +116,9 @@ " use_binned_thickness_data='millan_ice_thickness')\n", "\n", "# open the default oggm flowline and the two we just created\n", - "fls_oggm = gdir.read_pickle('model_flowlines')\n", - "fls_consensus = gdir.read_pickle('model_flowlines', filesuffix='_consensus')\n", - "fls_millan = gdir.read_pickle('model_flowlines', filesuffix='_millan')\n", + "fls_oggm = gdir.read_store('model_flowlines')\n", + "fls_consensus = gdir.read_store('model_flowlines', filesuffix='_consensus')\n", + "fls_millan = gdir.read_store('model_flowlines', filesuffix='_millan')\n", "\n", "# plot the created dynamic flowlines, including the oggm default\n", "fig, axs = plt.subplots(2, 2, figsize=(10, 7))\n", @@ -288,7 +288,7 @@ " else:\n", " label = filesuffix[1:]\n", "\n", - " fl = gdir.read_pickle('model_flowlines', filesuffix=filesuffix)[0]\n", + " fl = gdir.read_store('model_flowlines', filesuffix=filesuffix)[0]\n", " with xr.open_dataset(\n", " gdir.get_filepath('model_diagnostics',\n", " filesuffix=f'_spinup_historical{filesuffix}')) as ds:\n", @@ -360,7 +360,7 @@ " ref_volume = fls_millan[0].volume_m3\n", " workflow.execute_entity_task(\n", " tasks.run_dynamic_melt_f_calibration, gdirs,\n", - " init_model_fls=gdir.read_pickle('model_flowlines',\n", + " init_model_fls=gdir.read_store('model_flowlines',\n", " filesuffix='_millan_adapted'),\n", " err_dmdtda_scaling_factor=0.2,\n", " ys=1979, ye=2020,\n", @@ -385,7 +385,7 @@ "# conduct the dynamic initialisation once more to be sure the right one is saved\n", "workflow.execute_entity_task(\n", " tasks.run_dynamic_melt_f_calibration, gdirs,\n", - " init_model_fls=gdir.read_pickle('model_flowlines', filesuffix='_millan_adapted'),\n", + " init_model_fls=gdir.read_store('model_flowlines', filesuffix='_millan_adapted'),\n", " err_dmdtda_scaling_factor=0.2,\n", " ys=1979, ye=2020,\n", " melt_f_max=cfg.PARAMS['melt_f_max'],\n", diff --git a/notebooks/tutorials/plot_mass_balance.ipynb b/notebooks/tutorials/plot_mass_balance.ipynb index 88c4747c..957f263f 100644 --- a/notebooks/tutorials/plot_mass_balance.ipynb +++ b/notebooks/tutorials/plot_mass_balance.ipynb @@ -114,7 +114,7 @@ "mbmod = massbalance.MultipleFlowlineMassBalance(gdir)\n", "\n", "# Compute the specific MB for this glacier\n", - "fls = gdir.read_pickle('model_flowlines')\n", + "fls = gdir.read_store('model_flowlines')\n", "years = np.arange(1950, 2019)\n", "mb_ts = mbmod.get_specific_mb(fls=fls, year=years)\n", "\n", diff --git a/notebooks/tutorials/running_oggm_with_avalanches.ipynb b/notebooks/tutorials/running_oggm_with_avalanches.ipynb index 1fd621c2..59960eda 100644 --- a/notebooks/tutorials/running_oggm_with_avalanches.ipynb +++ b/notebooks/tutorials/running_oggm_with_avalanches.ipynb @@ -314,7 +314,7 @@ "from snowslide.oggm_snowslide_compat_minimal import MonthlyTIAvalancheModel\n", "\n", "# Get flowline\n", - "flowline = gdir.read_pickle('inversion_flowlines')[0]\n", + "flowline = gdir.read_store('inversion_flowlines')[0]\n", "\n", "# get mass balance model\n", "mb_control = MonthlyTIModel(gdir)\n", diff --git a/notebooks/tutorials/where_are_the_flowlines.ipynb b/notebooks/tutorials/where_are_the_flowlines.ipynb index 1d05bf52..e86405c0 100644 --- a/notebooks/tutorials/where_are_the_flowlines.ipynb +++ b/notebooks/tutorials/where_are_the_flowlines.ipynb @@ -162,7 +162,7 @@ "outputs": [], "source": [ "# Get the centerlines\n", - "cls = gdir.read_pickle('centerlines')\n", + "cls = gdir.read_store('centerlines')\n", "# Get the coord of the last point of the main centerline\n", "cl = cls[-1]\n", "i, j = cl.line.coords[-1]\n", @@ -195,7 +195,7 @@ "outputs": [], "source": [ "# Get the flowlines\n", - "cls = gdir.read_pickle('inversion_flowlines')\n", + "cls = gdir.read_store('inversion_flowlines')\n", "# Get the coord of the last point of the main centerline\n", "cl = cls[-1]\n", "i, j = cl.line.coords[-1]\n",