{
"cells": [
{
"cell_type": "markdown",
"id": "e2957f00",
"metadata": {
"tags": [
"papermill-error-cell-tag"
]
},
"source": [
"An Exception was encountered at 'In [1]'."
]
},
{
"cell_type": "markdown",
"id": "e45c723f-aa6f-4db4-a197-492132cc8156",
"metadata": {
"editable": true,
"papermill": {
"duration": 0.003552,
"end_time": "2025-11-25T01:42:39.246189",
"exception": false,
"start_time": "2025-11-25T01:42:39.242637",
"status": "completed"
},
"slideshow": {
"slide_type": ""
},
"tags": []
},
"source": [
"# Greenland Ice Sheet SMB comparison with MAR\n",
"This notebook compares the downscaled output of surface mass balance (SMB) over the Greenland ice sheet (GrIS) to the regional model MAR. In what follows, we interchangeably call the MAR data \"observation\".\n",
"\\\n",
"Note1: the MAR data are processed as a climatology spanning 1960-1999.\\\n",
"Note2: the MAR data are available at a uniform resolution of 1km using the same projection as the CISM grid. This notebook requires the interpolation of the MAR data on the CISM grid. The interpolation is done in this notebook (for now) to allow for the eventuality of the CISM grid or the MAR grid to change in the future. \\\n",
"creation: 05-26-24 \\\n",
"contact: Gunter Leguy (gunterl@ucar.edu)"
]
},
{
"cell_type": "markdown",
"id": "9a776fc7",
"metadata": {
"tags": [
"papermill-error-cell-tag"
]
},
"source": [
"Execution using papermill encountered an exception here and stopped:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "81bedf90-288c-4cfa-add5-b199ca9bcf72",
"metadata": {
"editable": true,
"execution": {
"iopub.execute_input": "2025-11-25T01:42:39.254011Z",
"iopub.status.busy": "2025-11-25T01:42:39.253704Z",
"iopub.status.idle": "2025-11-25T01:42:44.703619Z",
"shell.execute_reply": "2025-11-25T01:42:44.702992Z"
},
"papermill": {
"duration": 5.454915,
"end_time": "2025-11-25T01:42:44.704476",
"exception": true,
"start_time": "2025-11-25T01:42:39.249561",
"status": "failed"
},
"slideshow": {
"slide_type": ""
},
"tags": [
"hide-input"
]
},
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'cupid_utils'",
"output_type": "error",
"traceback": [
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
"\u001b[31mModuleNotFoundError\u001b[39m Traceback (most recent call last)",
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[1]\u001b[39m\u001b[32m, line 9\u001b[39m\n\u001b[32m 6\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mscipy\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01minterpolate\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m RegularGridInterpolator\n\u001b[32m 7\u001b[39m \u001b[38;5;28;01mimport\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mxarray\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mas\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mxr\u001b[39;00m\n\u001b[32m----> \u001b[39m\u001b[32m9\u001b[39m \u001b[38;5;28;01mfrom\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34;01mcupid_utils\u001b[39;00m\u001b[34;01m.\u001b[39;00m\u001b[34;01mglc\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[38;5;28;01mimport\u001b[39;00m utils\n\u001b[32m 11\u001b[39m \u001b[38;5;66;03m# to display figures in notebook after executing the code.\u001b[39;00m\n\u001b[32m 12\u001b[39m get_ipython().run_line_magic(\u001b[33m'\u001b[39m\u001b[33mmatplotlib\u001b[39m\u001b[33m'\u001b[39m, \u001b[33m'\u001b[39m\u001b[33minline\u001b[39m\u001b[33m'\u001b[39m)\n",
"\u001b[31mModuleNotFoundError\u001b[39m: No module named 'cupid_utils'"
]
}
],
"source": [
"# Import packages\n",
"import os\n",
"\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from scipy.interpolate import RegularGridInterpolator\n",
"import xarray as xr\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": "24029ab9-fe52-4c7e-bb41-847c7f3a0b1d",
"metadata": {
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "pending"
},
"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": null,
"id": "e02f1300-e0e1-448c-b534-68146555d660",
"metadata": {
"editable": true,
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "pending"
},
"slideshow": {
"slide_type": ""
},
"tags": [
"parameters",
"hide-input"
]
},
"outputs": [],
"source": [
"# Parameter Defaults\n",
"\n",
"CESM_output_dir = \"\"\n",
"case_name = \"\" # case name\n",
"climo_nyears = 0 # number of years to compute the climatology for main case\n",
"end_date = \"\"\n",
"\n",
"base_case_output_dir = None\n",
"base_case_name = None\n",
"base_end_date = None\n",
"base_climo_nyears = 0 # number of years to compute the climatology for base case\n",
"\n",
"obs_data_dir = \"\" # global directory containing observed dataset\n",
"obs_path = \"\" # specific directory containing observed dataset\n",
"obs_name = \"\" # file name for observed dataset"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "16664d92",
"metadata": {
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "pending"
},
"tags": [
"injected-parameters"
]
},
"outputs": [],
"source": [
"# Parameters\n",
"case_name = \"b.e30_alpha07c_cesm.B1850C_LTso.ne30_t232_wgx3.232\"\n",
"base_case_name = \"b.e30_alpha07c_cesm.B1850C_LTso.ne30_t232_wgx3.228\"\n",
"case_nickname = \"BLT1850_232\"\n",
"base_case_nickname = \"BLT1850_228\"\n",
"CESM_output_dir = \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CESM_output_for_testing\"\n",
"start_date = \"0001-01-01\"\n",
"end_date = \"0021-01-01\"\n",
"climo_start_year = 11\n",
"climo_end_year = 21\n",
"base_start_date = \"0001-01-01\"\n",
"base_end_date = \"0045-01-01\"\n",
"base_climo_start_year = 36\n",
"base_climo_end_year = 45\n",
"obs_data_dir = (\n",
" \"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data\"\n",
")\n",
"ts_dir = None\n",
"lc_kwargs = {\"threads_per_worker\": 1}\n",
"serial = False\n",
"obs_path = \"glc/analysis_datasets/multi_grid/annual_avg/SMB_data\"\n",
"obs_name = \"GrIS_MARv3.12_climo_1960_1999.nc\"\n",
"climo_nyears = 40\n",
"subset_kwargs = {}\n",
"product = \"/glade/work/richling/cupid-test-2/CUPiD/examples/key_metrics/computed_notebooks//glc/Greenland_SMB_visual_compare_obs.ipynb\"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2cd40a4e-95b6-4ce7-9e48-694ef3b9ebac",
"metadata": {
"editable": true,
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "pending"
},
"slideshow": {
"slide_type": ""
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"# Want some base case parameter defaults to equal control case values\n",
"if base_case_name is not None:\n",
" if base_case_output_dir is None:\n",
" base_case_output_dir = CESM_output_dir\n",
"\n",
" if base_end_date is None:\n",
" base_end_date = end_date\n",
"\n",
" if base_climo_nyears == 0:\n",
" base_climo_nyears = climo_nyears"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "08146fd8-d631-46c5-abc3-04fc1a004b77",
"metadata": {
"editable": true,
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "pending"
},
"slideshow": {
"slide_type": ""
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"last_year = int(end_date.split(\"-\")[0])\n",
"\n",
"case_init_file = os.path.join(\n",
" obs_data_dir, obs_path, \"cism.gris.initial_hist.0001-01-01-00000.nc\"\n",
") # name of glc file output\n",
"\n",
"case_path = os.path.join(\n",
" CESM_output_dir, case_name, \"cpl\", \"hist\"\n",
") # path to glc output\n",
"case_file = os.path.join(\n",
" case_path, f\"{case_name}.cpl.hx.1yr2glc.{last_year:04d}-01-01-00000.nc\"\n",
") # name of glc file output\n",
"obs_file = os.path.join(\n",
" obs_data_dir, obs_path, obs_name\n",
") # name of observed dataset file\n",
"\n",
"if base_case_name is not None:\n",
" base_last_year = int(base_end_date.split(\"-\")[0])\n",
" base_case_path = os.path.join(\n",
" base_case_output_dir, base_case_name, \"cpl\", \"hist\"\n",
" ) # path to cpl output\n",
" base_file = os.path.join(\n",
" base_case_path,\n",
" f\"{base_case_name}.cpl.hx.1yr2glc.{base_last_year:04d}-01-01-00000.nc\",\n",
" ) # name of last cpl simulation output"
]
},
{
"cell_type": "markdown",
"id": "70ee51c9-1c10-475d-a45b-b97583a3a5a9",
"metadata": {
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "pending"
},
"tags": []
},
"source": [
"## Set up grid\n",
"\n",
"Read in the grid data, compute resolution and other grid-specific parameters"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "27373d08-084b-4c3f-8c3f-d5c8a445b2dc",
"metadata": {
"editable": true,
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "pending"
},
"slideshow": {
"slide_type": ""
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"## Get grid from initial_hist stream\n",
"thk_init_da = xr.open_dataset(case_init_file).isel(time=0)[\"thk\"]\n",
"mask = thk_init_da.data[:, :] == 0\n",
"\n",
"# Shape of array is (ny, nx)\n",
"grid_dims = thk_init_da.shape"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "05eee529-d42f-4872-8cf2-f484ca44bf3f",
"metadata": {
"editable": true,
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "pending"
},
"slideshow": {
"slide_type": ""
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"# Constants\n",
"res = np.abs(\n",
" thk_init_da[\"x1\"].data[1] - thk_init_da[\"x1\"].data[0]\n",
") # CISM output resolution\n",
"\n",
"rhow = 1000 # water density kg/m3\n",
"kg_to_Gt = 1e-12 # Converting kg to Gt\n",
"mm_to_Gt = rhow * 1e-3 * res**2 * kg_to_Gt # converting mm/yr to Gt/yr"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "44eda4c4-3c23-450d-83d8-c76204cefdc4",
"metadata": {
"editable": true,
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "pending"
},
"slideshow": {
"slide_type": ""
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"params = {\n",
" \"grid_dims\": grid_dims,\n",
" \"mm_to_Gt\": mm_to_Gt,\n",
" \"mask\": mask,\n",
"}"
]
},
{
"cell_type": "markdown",
"id": "68fca423-582b-4179-8771-16250a5f1904",
"metadata": {
"editable": true,
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "pending"
},
"slideshow": {
"slide_type": ""
},
"tags": []
},
"source": [
"## Make datasets\n",
"\n",
"Read in observations and CESM output.\n",
"Also do necessary computations\n",
"(global mean for time series, temporal mean for climatology)."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bb81be67-98d6-4924-a90e-930d9b2caed8",
"metadata": {
"editable": true,
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "pending"
},
"slideshow": {
"slide_type": ""
},
"tags": [
"hide-cell"
]
},
"outputs": [],
"source": [
"# creating the SMB climatology for new case\n",
"smb_case = utils.read_cesm_smb(case_path, case_name, last_year, climo_nyears, params)\n",
"smb_case_climo = smb_case.mean(\"time\")\n",
"\n",
"# creating the SMB climatology for base_case\n",
"if base_case_name:\n",
" smb_base_case = utils.read_cesm_smb(\n",
" base_case_path, base_case_name, base_last_year, base_climo_nyears, params\n",
" )\n",
" smb_base_climo = smb_base_case.mean(\"time\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ac96bb16-7bd8-4d7b-b00b-d315feeb1a5d",
"metadata": {
"editable": true,
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "pending"
},
"slideshow": {
"slide_type": ""
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"# Interpolating the observed data onto the CISM grid\n",
"smb_obs_da = xr.open_dataset(obs_file).isel(time=0)[\"SMB\"]\n",
"\n",
"# Defining the interpolation functions\n",
"myInterpFunction_smb_obs = RegularGridInterpolator(\n",
" (smb_obs_da[\"x\"].data, smb_obs_da[\"y\"].data),\n",
" smb_obs_da.data.transpose(),\n",
" method=\"linear\",\n",
" bounds_error=False,\n",
" fill_value=None,\n",
")\n",
"\n",
"# Initializing the glacier ID variable\n",
"smb_obs_climo = xr.DataArray(np.zeros(grid_dims), dims=[\"glc1Exp_ny\", \"glc1Exp_nx\"])\n",
"\n",
"# Performing the interpolation\n",
"for j in range(grid_dims[0]):\n",
" point_y = np.zeros(grid_dims[1])\n",
" point_y[:] = thk_init_da[\"y1\"].data[j]\n",
" pts = (thk_init_da[\"x1\"].data[:], point_y[:])\n",
" smb_obs_climo.data[j, :] = myInterpFunction_smb_obs(pts)\n",
"\n",
"# Filtering out fill values\n",
"smb_obs_climo.data = np.where(\n",
" np.logical_or(mask, smb_obs_climo > 1e20), 0, smb_obs_climo\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a38682c9-dc87-4d7b-887d-8abbbe8a7265",
"metadata": {
"editable": true,
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "pending"
},
"slideshow": {
"slide_type": ""
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"# Integrated SMB time series\n",
"first_year = last_year - len(smb_case[\"time\"]) + 1\n",
"avg_smb_case_climo = smb_case.sum([\"glc1Exp_ny\", \"glc1Exp_nx\"]) * params[\"mm_to_Gt\"]\n",
"\n",
"if base_case_name:\n",
" base_first_year = base_last_year - len(smb_base_case[\"time\"]) + 1\n",
" avg_smb_base_case_climo = (\n",
" smb_base_case.sum([\"glc1Exp_ny\", \"glc1Exp_nx\"]) * params[\"mm_to_Gt\"]\n",
" )"
]
},
{
"cell_type": "markdown",
"id": "1641747b-4997-45ad-bf70-981ed97688dd",
"metadata": {
"editable": true,
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "pending"
},
"slideshow": {
"slide_type": ""
},
"tags": []
},
"source": [
"## Generate plots\n",
"\n",
"Map comparing CESM to observation,\n",
"possibly map comparing CESM to older case,\n",
"and time series of spatial mean SMB."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c7973cfe-64e0-47d4-a1b6-73cd9e62fdb2",
"metadata": {
"editable": true,
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "pending"
},
"slideshow": {
"slide_type": ""
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"# Comparing SMB new run vs obs\n",
"\n",
"# Colormap choice\n",
"my_cmap = plt.get_cmap(\"Spectral\")\n",
"my_cmap_diff = plt.get_cmap(\"bwr_r\")\n",
"\n",
"\n",
"# Colorbar bounds\n",
"vmin = -2000\n",
"vmax = 2000\n",
"\n",
"# Figure\n",
"fig, ax = plt.subplots(1, 3, sharey=True, figsize=[22, 9])\n",
"\n",
"## Left panel\n",
"utils.plot_contour(\n",
" smb_case_climo,\n",
" fig,\n",
" ax[0],\n",
" 0.35,\n",
" f\"{case_name}\\nSMB (mm/y w.e.)\\nMean from {first_year:04d} - {last_year:04d}\",\n",
" vmin,\n",
" vmax,\n",
" my_cmap,\n",
" mm_to_Gt,\n",
")\n",
"\n",
"## Center panel\n",
"utils.plot_contour(\n",
" smb_obs_climo,\n",
" fig,\n",
" ax[1],\n",
" 0.35,\n",
" \"SMB Obs\\n(mm/y w.e.)\",\n",
" vmin,\n",
" vmax,\n",
" my_cmap,\n",
" mm_to_Gt,\n",
")\n",
"\n",
"## Right panel\n",
"utils.plot_contour(\n",
" smb_case_climo - smb_obs_climo,\n",
" fig,\n",
" ax[2],\n",
" 0.89,\n",
" \"SMB bias (mm/yr w.e.)\",\n",
" vmin,\n",
" vmax,\n",
" my_cmap_diff,\n",
" mm_to_Gt,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "176594bc-53a1-4934-8210-7aa7d62f5659",
"metadata": {
"editable": true,
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "pending"
},
"slideshow": {
"slide_type": ""
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"# Comparing SMB new run vs base case\n",
"if base_case_name:\n",
" # Colormap choice\n",
" my_cmap = plt.get_cmap(\"Spectral\")\n",
" my_cmap_diff = plt.get_cmap(\"bwr_r\")\n",
"\n",
" # Colorbar bounds\n",
" vmin = -2000\n",
" vmax = 2000\n",
"\n",
" # Figure\n",
" fig, ax = plt.subplots(1, 3, sharey=True, figsize=[22, 9])\n",
"\n",
" ## Left panel\n",
" utils.plot_contour(\n",
" smb_case_climo,\n",
" fig,\n",
" ax[0],\n",
" 0.35,\n",
" f\"{case_name}\\nSMB (mm/y w.e.)\\nMean from {first_year:04d} - {last_year:04d}\",\n",
" vmin,\n",
" vmax,\n",
" my_cmap,\n",
" mm_to_Gt,\n",
" )\n",
"\n",
" ## Center panel\n",
" utils.plot_contour(\n",
" smb_base_climo,\n",
" fig,\n",
" ax[1],\n",
" 0.35,\n",
" f\"{base_case_name}\\nSMB (mm/y w.e.)\\nMean from {base_first_year:04d} - {base_last_year:04d}\",\n",
" vmin,\n",
" vmax,\n",
" my_cmap,\n",
" mm_to_Gt,\n",
" )\n",
"\n",
" ## Right panel\n",
" utils.plot_contour(\n",
" smb_case_climo - smb_base_climo,\n",
" fig,\n",
" ax[2],\n",
" 0.89,\n",
" \"SMB difference (mm/yr w.e.)\",\n",
" vmin,\n",
" vmax,\n",
" my_cmap_diff,\n",
" mm_to_Gt,\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "01af1cd1-0351-452c-99e7-125546469f69",
"metadata": {
"editable": true,
"papermill": {
"duration": null,
"end_time": null,
"exception": null,
"start_time": null,
"status": "pending"
},
"slideshow": {
"slide_type": ""
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"# Plotting the SMB spatially averaged time series\n",
"\n",
"# TODO: include base case, base case climo (horizontal line), new case, new case climo, and obs climo\n",
"# Note: base case is 10 years of historical, new case is PI.\n",
"# what comparisons make sense when base case is HIST and new case is 1850?\n",
"\n",
"\n",
"time = np.arange(first_year, last_year + 1)\n",
"full_time = time\n",
"if base_case_name:\n",
" base_time = (\n",
" np.arange(base_first_year, base_last_year + 1) + first_year - base_first_year\n",
" )\n",
" base_nt = len(base_time)\n",
" full_time = np.arange(time[0], max(time[-1], base_time[-1]) + 1)\n",
"nt = len(time)\n",
"\n",
"avg_smb_obs_timeseries = np.zeros(len(full_time))\n",
"avg_smb_case_timeseries = np.zeros(nt)\n",
"if base_case_name:\n",
" avg_smb_base_timeseries = np.zeros(base_nt)\n",
"\n",
"avg_smb_obs_timeseries[:] = np.round(smb_obs_climo.sum() * mm_to_Gt, 2)\n",
"avg_smb_case_timeseries[:] = np.round(smb_case_climo.sum() * mm_to_Gt, 2)\n",
"if base_case_name:\n",
" avg_smb_base_timeseries[:] = np.round(smb_base_climo.sum() * mm_to_Gt, 2)\n",
"\n",
"\n",
"x_ticks = np.arange(full_time[0], full_time[-1] + 2, 5)\n",
"tickx = x_ticks\n",
"\n",
"ymin = 100\n",
"ymax = 600\n",
"y_step = 50\n",
"y_ticks = np.arange(ymin, ymax + y_step, y_step)\n",
"\n",
"\n",
"plt.figure(figsize=(16, 7))\n",
"\n",
"# Plotting annual / spatial means\n",
"plt.subplot(111)\n",
"utils.plot_line(\n",
" avg_smb_case_climo,\n",
" time,\n",
" line=\"-\",\n",
" color=\"blue\",\n",
" label=f\"{case_name} ({first_year:04d} - {last_year:04d})\",\n",
" linewidth=2,\n",
")\n",
"utils.plot_line(\n",
" avg_smb_case_timeseries[:],\n",
" time,\n",
" line=\":\",\n",
" color=\"blue\",\n",
" label=f\"{case_name} (mean from {first_year:04d} - {last_year:04d})\",\n",
" linewidth=2,\n",
")\n",
"if base_case_name:\n",
" utils.plot_line(\n",
" avg_smb_base_case_climo,\n",
" base_time,\n",
" line=\"-\",\n",
" color=\"red\",\n",
" label=f\"{base_case_name} ({base_first_year:04d} - {base_last_year:04d})\",\n",
" linewidth=2,\n",
" )\n",
" utils.plot_line(\n",
" avg_smb_base_timeseries[:],\n",
" base_time,\n",
" line=\":\",\n",
" color=\"red\",\n",
" label=f\"{base_case_name} (mean from {base_first_year:04d} - {base_last_year:04d})\",\n",
" linewidth=2,\n",
" )\n",
"utils.plot_line(\n",
" avg_smb_obs_timeseries[:],\n",
" full_time,\n",
" line=\"-\",\n",
" color=\"black\",\n",
" label=\"Observations (mean)\",\n",
" linewidth=2,\n",
")\n",
"\n",
"sizefont = 16\n",
"plt.xlim([first_year, last_year])\n",
"plt.xticks(x_ticks, tickx, fontsize=sizefont)\n",
"plt.xlabel(r\"$Time$ (y)\", fontsize=sizefont)\n",
"plt.ylabel(\"SMB average evolution (Gt/yr)\", multialignment=\"center\", fontsize=sizefont)\n",
"plt.ylim([ymin, ymax])\n",
"plt.yticks(fontsize=sizefont)\n",
"plt.legend(loc=\"upper left\", ncol=1, frameon=True, borderaxespad=0)\n",
"\n",
"plt.title(\"SMB average evolution\", fontsize=sizefont);"
]
}
],
"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.11.4"
},
"papermill": {
"duration": 7.11021,
"end_time": "2025-11-25T01:42:45.429197",
"exception": true,
"input_path": "/glade/derecho/scratch/richling/tmp/tmp8hdpy3o2.ipynb",
"output_path": "/glade/work/richling/cupid-test-2/CUPiD/examples/key_metrics/computed_notebooks/glc/Greenland_SMB_visual_compare_obs.ipynb",
"parameters": {
"CESM_output_dir": "/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CESM_output_for_testing",
"base_case_name": "b.e30_alpha07c_cesm.B1850C_LTso.ne30_t232_wgx3.228",
"base_case_nickname": "BLT1850_228",
"base_climo_end_year": 45,
"base_climo_start_year": 36,
"base_end_date": "0045-01-01",
"base_start_date": "0001-01-01",
"case_name": "b.e30_alpha07c_cesm.B1850C_LTso.ne30_t232_wgx3.232",
"case_nickname": "BLT1850_232",
"climo_end_year": 21,
"climo_nyears": 40,
"climo_start_year": 11,
"end_date": "0021-01-01",
"lc_kwargs": {
"threads_per_worker": 1
},
"obs_data_dir": "/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data",
"obs_name": "GrIS_MARv3.12_climo_1960_1999.nc",
"obs_path": "glc/analysis_datasets/multi_grid/annual_avg/SMB_data",
"product": "/glade/work/richling/cupid-test-2/CUPiD/examples/key_metrics/computed_notebooks//glc/Greenland_SMB_visual_compare_obs.ipynb",
"serial": false,
"start_date": "0001-01-01",
"subset_kwargs": {},
"ts_dir": null
},
"start_time": "2025-11-25T01:42:38.318987"
}
},
"nbformat": 4,
"nbformat_minor": 5
}