Greenland time series

An Exception was encountered at ‘In [5]’.

Greenland time series#

This notebook plots whole-ice-sheet scalar diagnostics (GrIS) from the CISM component history stream over the full run: ice area (grounded/floating), ice mass (total / above flotation), and the individual mass balance flux terms (SMB, calving, frontal melt, basal melt, grounding-line flux, and the force-retreat / remove-icecap correction terms).

Hide code cell source

# Import packages
import os

import matplotlib.pyplot as plt

from cupid_utils.glc import utils

# to display figures in notebook after executing the code.
%matplotlib inline

Parameter configuration#

Some parameters are set in CUPiD’s config.yml file, others are derived from these parameters.

Hide code cell source

# Parameter Defaults

CESM_output_dir = ""
case_name = ""  # case name
start_date = ""
end_date = ""
# Parameters
case_name = "N1850.n30b23MM.506.20260821"
base_case_name = ""
CESM_output_dir = "/datalake/NS9560K/noresm3/cases"
start_date = "1407-01-01"
end_date = "1466-01-01"
base_start_date = "0000-01-01"
base_end_date = "0000-01-01"
lc_kwargs = {"threads_per_worker": 1}
serial = False
subset_kwargs = {}
product = "/nird/datapeak/NS9560K/users/heig/CUPiD_Apr/examples/glc_full_test/computed_notebooks//glc/Greenland_time_series.ipynb"

Hide code cell source

start_year = int(start_date.split("-")[0])
end_year = int(end_date.split("-")[0])

case_path = os.path.join(
    CESM_output_dir, case_name, "glc", "hist"
)  # path to CISM component history output

Make dataset#

Read the scalar time series over the full run and convert to the same units used elsewhere in CUPiD’s glc notebooks (Gt, Gt/yr, km2).

Execution using papermill encountered an exception here and stopped:

Hide code cell content

AREA_VARS = ["iareag"]  # floating ice area omitted for GrIS (negligible)
MASS_VARS = ["imass", "imass_above_flotation"]
FLUX_VARS = [
    "total_smb_flux",
    "total_calving_flux",
    "total_frontal_melt_flux",
    "total_bmb_flux",
    "total_rmicecap_flux",
    "total_forceretreat_flux",
    "total_gl_flux",
]

scalars = utils.read_cesm_scalars(
    case_path, case_name, 'GrIS', start_year, end_year, AREA_VARS + MASS_VARS + FLUX_VARS,
)
if scalars is None:
    raise RuntimeError(f"GrIS not present in {case_name!r} output — skipping notebook.")
No cism.gris.h files found for 1407-1466; skipping GrIS.
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[5], line 17
     13 scalars = utils.read_cesm_scalars(
     14     case_path, case_name, 'GrIS', start_year, end_year, AREA_VARS + MASS_VARS + FLUX_VARS,
     15 )
     16 if scalars is None:
---> 17     raise RuntimeError(f"GrIS not present in {case_name!r} output — skipping notebook.")

RuntimeError: GrIS not present in 'N1850.n30b23MM.506.20260821' output — skipping notebook.

Hide code cell source

# Unit conversions
sec_in_yr = 60 * 60 * 24 * 365
kg_to_Gt = 1e-12
m2_to_km2 = 1e-6

area = {v: scalars[v].data * m2_to_km2 for v in AREA_VARS}
mass = {v: scalars[v].data * kg_to_Gt for v in MASS_VARS}
flux = {v: scalars[v].data * sec_in_yr * kg_to_Gt for v in FLUX_VARS}

# CISM time is cftime, not plottable directly; use integer years instead
time = scalars["time"].dt.year.data

Generate plots#

Three panels: ice area, ice mass, and the individual mass balance flux terms, following the same line-plot style used for the SMB average evolution time series.

Hide code cell source

LONG_NAMES = {
    "iareag": "grounded ice area",
    "iareaf": "floating ice area",
    "imass": "total ice mass",
    "imass_above_flotation": "ice mass above flotation",
    "total_smb_flux": "surface mass balance",
    "total_calving_flux": "calving",
    "total_frontal_melt_flux": "frontal melt",
    "total_bmb_flux": "basal mass balance",
    "total_rmicecap_flux": "remove-icecap",
    "total_forceretreat_flux": "force-retreat",
    "total_gl_flux": "grounding-line flux",
}

# Dashed for the two removal/correction terms, dotted for grounding-line
# flux, solid for the physical mass balance terms.
FLUX_LINESTYLES = {
    "total_rmicecap_flux": "--",
    "total_forceretreat_flux": "--",
    "total_gl_flux": ":",
}

area_colors = ["steelblue", "darkorange"]
mass_colors = ["steelblue", "darkorange"]
flux_colors = ["#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd", "#8c564b", "#e377c2"]

sizefont = 14

fig, axes = plt.subplots(3, 1, figsize=(16, 15), sharex=True)

plt.sca(axes[0])
for v, color in zip(AREA_VARS, area_colors):
    utils.plot_line(area[v], time, line="-", color=color, label=LONG_NAMES[v], linewidth=2)
axes[0].set_ylabel("Ice area\n(km$^2$)", fontsize=sizefont, fontweight="bold")
axes[0].legend(loc="best", fontsize=11)
axes[0].grid(True, alpha=0.3)

plt.sca(axes[1])
for v, color in zip(MASS_VARS, mass_colors):
    utils.plot_line(mass[v], time, line="-", color=color, label=LONG_NAMES[v], linewidth=2)
axes[1].set_ylabel("Ice mass\n(Gt)", fontsize=sizefont, fontweight="bold")
axes[1].legend(loc="best", fontsize=11)
axes[1].grid(True, alpha=0.3)

plt.sca(axes[2])
for v, color in zip(FLUX_VARS, flux_colors):
    utils.plot_line(
        flux[v], time, line=FLUX_LINESTYLES.get(v, "-"), color=color, label=LONG_NAMES[v], linewidth=2,
    )
axes[2].set_ylabel("Mass balance fluxes\n(Gt/yr)", fontsize=sizefont, fontweight="bold")
axes[2].legend(loc="best", fontsize=10, ncol=2)
axes[2].grid(True, alpha=0.3)
axes[2].set_xlabel(r"$Time$ (y)", fontsize=sizefont, fontweight="bold")

fig.suptitle(f"{case_name}\nGreenland time series", fontsize=sizefont)
plt.tight_layout()