{ "cells": [ { "cell_type": "markdown", "id": "9db624df", "metadata": { "tags": [ "papermill-error-cell-tag" ] }, "source": [ "An Exception was encountered at 'In [5]'." ] }, { "cell_type": "markdown", "id": "462ee1c1", "metadata": { "papermill": { "duration": 0.002445, "end_time": "2026-08-26T20:27:18.225531+00:00", "exception": false, "start_time": "2026-08-26T20:27:18.223086+00:00", "status": "completed" }, "tags": [] }, "source": [ "# Antarctic time series\n", "This notebook plots whole-ice-sheet scalar diagnostics (AIS) from the CISM\n", "component history stream over the full run: ice area (grounded/floating),\n", "ice mass (total / above flotation), and the individual mass balance flux\n", "terms (SMB, calving, frontal melt, basal melt, grounding-line flux, and\n", "the force-retreat / remove-icecap correction terms)." ] }, { "cell_type": "code", "execution_count": 1, "id": "562f98c6", "metadata": { "execution": { "iopub.execute_input": "2026-08-26T20:27:18.229314Z", "iopub.status.busy": "2026-08-26T20:27:18.229122Z", "iopub.status.idle": "2026-08-26T20:27:18.956482Z", "shell.execute_reply": "2026-08-26T20:27:18.955930Z" }, "papermill": { "duration": 0.730128, "end_time": "2026-08-26T20:27:18.957244+00:00", "exception": false, "start_time": "2026-08-26T20:27:18.227116+00:00", "status": "completed" }, "tags": [ "hide-input" ] }, "outputs": [], "source": [ "# Import packages\n", "import os\n", "\n", "import matplotlib.pyplot as plt\n", "\n", "from cupid_utils.glc import utils\n", "\n", "# to display figures in notebook after executing the code.\n", "%matplotlib inline" ] }, { "cell_type": "markdown", "id": "2faef713", "metadata": { "papermill": { "duration": 0.001431, "end_time": "2026-08-26T20:27:18.961148+00:00", "exception": false, "start_time": "2026-08-26T20:27:18.959717+00:00", "status": "completed" }, "tags": [] }, "source": [ "## Parameter configuration\n", "\n", "Some parameters are set in CUPiD's `config.yml` file,\n", "others are derived from these parameters." ] }, { "cell_type": "code", "execution_count": 2, "id": "5aaaeed3", "metadata": { "execution": { "iopub.execute_input": "2026-08-26T20:27:18.964882Z", "iopub.status.busy": "2026-08-26T20:27:18.964596Z", "iopub.status.idle": "2026-08-26T20:27:18.967133Z", "shell.execute_reply": "2026-08-26T20:27:18.966672Z" }, "papermill": { "duration": 0.004998, "end_time": "2026-08-26T20:27:18.967558+00:00", "exception": false, "start_time": "2026-08-26T20:27:18.962560+00:00", "status": "completed" }, "tags": [ "parameters", "hide-input" ] }, "outputs": [], "source": [ "# Parameter Defaults\n", "\n", "CESM_output_dir = \"\"\n", "case_name = \"\" # case name\n", "start_date = \"\"\n", "end_date = \"\"\n" ] }, { "cell_type": "code", "execution_count": 3, "id": "c5146e35", "metadata": { "execution": { "iopub.execute_input": "2026-08-26T20:27:18.971331Z", "iopub.status.busy": "2026-08-26T20:27:18.971103Z", "iopub.status.idle": "2026-08-26T20:27:18.973734Z", "shell.execute_reply": "2026-08-26T20:27:18.973292Z" }, "papermill": { "duration": 0.005103, "end_time": "2026-08-26T20:27:18.974148+00:00", "exception": false, "start_time": "2026-08-26T20:27:18.969045+00:00", "status": "completed" }, "tags": [ "injected-parameters" ] }, "outputs": [], "source": [ "# Parameters\n", "case_name = \"N1850.n30b23MM.506.20260821\"\n", "base_case_name = \"\"\n", "CESM_output_dir = \"/datalake/NS9560K/noresm3/cases\"\n", "start_date = \"1407-01-01\"\n", "end_date = \"1466-01-01\"\n", "base_start_date = \"0000-01-01\"\n", "base_end_date = \"0000-01-01\"\n", "lc_kwargs = {\"threads_per_worker\": 1}\n", "serial = False\n", "subset_kwargs = {}\n", "product = \"/nird/datapeak/NS9560K/users/heig/CUPiD_Apr/examples/glc_full_test/computed_notebooks//glc/Antarctica_time_series.ipynb\"\n" ] }, { "cell_type": "code", "execution_count": 4, "id": "531ee174", "metadata": { "execution": { "iopub.execute_input": "2026-08-26T20:27:18.977880Z", "iopub.status.busy": "2026-08-26T20:27:18.977672Z", "iopub.status.idle": "2026-08-26T20:27:18.980166Z", "shell.execute_reply": "2026-08-26T20:27:18.979717Z" }, "papermill": { "duration": 0.004898, "end_time": "2026-08-26T20:27:18.980570+00:00", "exception": false, "start_time": "2026-08-26T20:27:18.975672+00:00", "status": "completed" }, "tags": [ "hide-input" ] }, "outputs": [], "source": [ "start_year = int(start_date.split(\"-\")[0])\n", "end_year = int(end_date.split(\"-\")[0])\n", "\n", "case_path = os.path.join(\n", " CESM_output_dir, case_name, \"glc\", \"hist\"\n", ") # path to CISM component history output\n" ] }, { "cell_type": "markdown", "id": "56541d09", "metadata": { "papermill": { "duration": 0.001491, "end_time": "2026-08-26T20:27:18.983610+00:00", "exception": false, "start_time": "2026-08-26T20:27:18.982119+00:00", "status": "completed" }, "tags": [] }, "source": [ "## Make dataset\n", "\n", "Read the scalar time series over the full run and convert to the\n", "same units used elsewhere in CUPiD's glc notebooks (Gt, Gt/yr, km2)." ] }, { "cell_type": "markdown", "id": "59b84902", "metadata": { "tags": [ "papermill-error-cell-tag" ] }, "source": [ "Execution using papermill encountered an exception here and stopped:" ] }, { "cell_type": "code", "execution_count": 5, "id": "a775e669", "metadata": { "execution": { "iopub.execute_input": "2026-08-26T20:27:18.992414Z", "iopub.status.busy": "2026-08-26T20:27:18.992262Z", "iopub.status.idle": "2026-08-26T20:27:19.106233Z", "shell.execute_reply": "2026-08-26T20:27:19.105657Z" }, "papermill": { "duration": 0.116836, "end_time": "2026-08-26T20:27:19.106891+00:00", "exception": true, "start_time": "2026-08-26T20:27:18.990055+00:00", "status": "failed" }, "tags": [ "hide-cell" ] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "No cism.ais.h files found for 1407-1466; skipping AIS.\n" ] }, { "ename": "RuntimeError", "evalue": "AIS not present in 'N1850.n30b23MM.506.20260821' output — skipping notebook.", "output_type": "error", "traceback": [ "\u001b[31m---------------------------------------------------------------------------\u001b[39m", "\u001b[31mRuntimeError\u001b[39m Traceback (most recent call last)", "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[5]\u001b[39m\u001b[32m, line 17\u001b[39m\n\u001b[32m 13\u001b[39m scalars = utils.read_cesm_scalars(\n\u001b[32m 14\u001b[39m case_path, case_name, \u001b[33m'AIS'\u001b[39m, start_year, end_year, AREA_VARS + MASS_VARS + FLUX_VARS,\n\u001b[32m 15\u001b[39m )\n\u001b[32m 16\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m scalars \u001b[38;5;28;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[32m---> \u001b[39m\u001b[32m17\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m RuntimeError(f\"AIS not present in {case_name!r} output — skipping notebook.\")\n", "\u001b[31mRuntimeError\u001b[39m: AIS not present in 'N1850.n30b23MM.506.20260821' output — skipping notebook." ] } ], "source": [ "AREA_VARS = [\"iareag\", \"iareaf\"]\n", "MASS_VARS = [\"imass\", \"imass_above_flotation\"]\n", "FLUX_VARS = [\n", " \"total_smb_flux\",\n", " \"total_calving_flux\",\n", " \"total_frontal_melt_flux\",\n", " \"total_bmb_flux\",\n", " \"total_rmicecap_flux\",\n", " \"total_forceretreat_flux\",\n", " \"total_gl_flux\",\n", "]\n", "\n", "scalars = utils.read_cesm_scalars(\n", " case_path, case_name, 'AIS', start_year, end_year, AREA_VARS + MASS_VARS + FLUX_VARS,\n", ")\n", "if scalars is None:\n", " raise RuntimeError(f\"AIS not present in {case_name!r} output — skipping notebook.\")\n" ] }, { "cell_type": "code", "execution_count": null, "id": "d40d7d83", "metadata": { "papermill": { "duration": null, "end_time": null, "exception": null, "start_time": null, "status": "pending" }, "tags": [ "hide-input" ] }, "outputs": [], "source": [ "# Unit conversions\n", "sec_in_yr = 60 * 60 * 24 * 365\n", "kg_to_Gt = 1e-12\n", "m2_to_km2 = 1e-6\n", "\n", "area = {v: scalars[v].data * m2_to_km2 for v in AREA_VARS}\n", "mass = {v: scalars[v].data * kg_to_Gt for v in MASS_VARS}\n", "flux = {v: scalars[v].data * sec_in_yr * kg_to_Gt for v in FLUX_VARS}\n", "\n", "# CISM time is cftime, not plottable directly; use integer years instead\n", "time = scalars[\"time\"].dt.year.data" ] }, { "cell_type": "markdown", "id": "2c2dee7f", "metadata": { "papermill": { "duration": null, "end_time": null, "exception": null, "start_time": null, "status": "pending" }, "tags": [] }, "source": [ "## Generate plots\n", "\n", "Three panels: ice area, ice mass, and the individual mass balance flux\n", "terms, following the same line-plot style used for the SMB average\n", "evolution time series." ] }, { "cell_type": "code", "execution_count": null, "id": "53702b16", "metadata": { "papermill": { "duration": null, "end_time": null, "exception": null, "start_time": null, "status": "pending" }, "tags": [ "hide-input" ] }, "outputs": [], "source": [ "LONG_NAMES = {\n", " \"iareag\": \"grounded ice area\",\n", " \"iareaf\": \"floating ice area\",\n", " \"imass\": \"total ice mass\",\n", " \"imass_above_flotation\": \"ice mass above flotation\",\n", " \"total_smb_flux\": \"surface mass balance\",\n", " \"total_calving_flux\": \"calving\",\n", " \"total_frontal_melt_flux\": \"frontal melt\",\n", " \"total_bmb_flux\": \"basal mass balance\",\n", " \"total_rmicecap_flux\": \"remove-icecap\",\n", " \"total_forceretreat_flux\": \"force-retreat\",\n", " \"total_gl_flux\": \"grounding-line flux\",\n", "}\n", "\n", "# Dashed for the two removal/correction terms, dotted for grounding-line\n", "# flux, solid for the physical mass balance terms.\n", "FLUX_LINESTYLES = {\n", " \"total_rmicecap_flux\": \"--\",\n", " \"total_forceretreat_flux\": \"--\",\n", " \"total_gl_flux\": \":\",\n", "}\n", "\n", "area_colors = [\"steelblue\", \"darkorange\"]\n", "mass_colors = [\"steelblue\", \"darkorange\"]\n", "flux_colors = [\"#1f77b4\", \"#ff7f0e\", \"#2ca02c\", \"#d62728\", \"#9467bd\", \"#8c564b\", \"#e377c2\"]\n", "\n", "sizefont = 14\n", "\n", "fig, axes = plt.subplots(3, 1, figsize=(16, 15), sharex=True)\n", "\n", "plt.sca(axes[0])\n", "for v, color in zip(AREA_VARS, area_colors):\n", " utils.plot_line(area[v], time, line=\"-\", color=color, label=LONG_NAMES[v], linewidth=2)\n", "axes[0].set_ylabel(\"Ice area\\n(km$^2$)\", fontsize=sizefont, fontweight=\"bold\")\n", "axes[0].legend(loc=\"best\", fontsize=11)\n", "axes[0].grid(True, alpha=0.3)\n", "\n", "plt.sca(axes[1])\n", "for v, color in zip(MASS_VARS, mass_colors):\n", " utils.plot_line(mass[v], time, line=\"-\", color=color, label=LONG_NAMES[v], linewidth=2)\n", "axes[1].set_ylabel(\"Ice mass\\n(Gt)\", fontsize=sizefont, fontweight=\"bold\")\n", "axes[1].legend(loc=\"best\", fontsize=11)\n", "axes[1].grid(True, alpha=0.3)\n", "\n", "plt.sca(axes[2])\n", "for v, color in zip(FLUX_VARS, flux_colors):\n", " utils.plot_line(\n", " flux[v], time, line=FLUX_LINESTYLES.get(v, \"-\"), color=color, label=LONG_NAMES[v], linewidth=2,\n", " )\n", "axes[2].set_ylabel(\"Mass balance fluxes\\n(Gt/yr)\", fontsize=sizefont, fontweight=\"bold\")\n", "axes[2].legend(loc=\"best\", fontsize=10, ncol=2)\n", "axes[2].grid(True, alpha=0.3)\n", "axes[2].set_xlabel(r\"$Time$ (y)\", fontsize=sizefont, fontweight=\"bold\")\n", "\n", "fig.suptitle(f\"{case_name}\\nAntarctic time series\", fontsize=sizefont)\n", "plt.tight_layout()" ] } ], "metadata": { "kernelspec": { "display_name": "cupid-analysis", "language": "python", "name": "cupid-analysis" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.11" }, "papermill": { "duration": 1.938346, "end_time": "2026-08-26T20:27:19.425613+00:00", "exception": true, "input_path": "/tmp/tmpqcva_gl7.ipynb", "output_path": "/nird/datapeak/NS9560K/users/heig/CUPiD_Apr/examples/glc_full_test/computed_notebooks/glc/Antarctica_time_series.ipynb", "parameters": { "CESM_output_dir": "/datalake/NS9560K/noresm3/cases", "base_case_name": "", "base_end_date": "0000-01-01", "base_start_date": "0000-01-01", "case_name": "N1850.n30b23MM.506.20260821", "end_date": "1466-01-01", "lc_kwargs": { "threads_per_worker": 1 }, "product": "/nird/datapeak/NS9560K/users/heig/CUPiD_Apr/examples/glc_full_test/computed_notebooks//glc/Antarctica_time_series.ipynb", "serial": false, "start_date": "1407-01-01", "subset_kwargs": {} }, "start_time": "2026-08-26T20:27:17.487267+00:00" } }, "nbformat": 4, "nbformat_minor": 5 }