{
"cells": [
{
"cell_type": "markdown",
"id": "623cbc23-45bf-4dfd-9f49-8d814d0394ba",
"metadata": {
"papermill": {
"duration": 0.0079,
"end_time": "2025-10-28T23:29:57.626218",
"exception": false,
"start_time": "2025-10-28T23:29:57.618318",
"status": "completed"
},
"tags": []
},
"source": [
"# LDF\n",
"\n",
"The output from the stand-alone LDF configuration is in the link below\n",
"\n",
"\n",
"Note that LDF is currently run by users. Temporarily, we suggest users walk through the following process:\n",
"1) Install LDF and activate cupid-analysis\n",
"2) Use the `CUPiD/helper_scripts/generate_ldf_config_file.py` script to generate a LDF config file based on a CUPiD configuration file.\n",
" * `cd CUPiD/examples/external_diag_packages`\n",
" * `../../helper_scripts/generate_ldf_config_file.py --cupid-config-loc . --ldf-template ../../externals/LDF/config_clm_unstructured_plots.yaml --out-file LDF_config.yaml`\n",
"2) Run LDF with the newly created configuration file.\n",
" * `../../externals/LDF/run_adf_diag LDF_config.yaml`"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "82af7435-3849-4fd1-bb2d-2e062719ec5b",
"metadata": {
"editable": true,
"execution": {
"iopub.execute_input": "2025-10-28T23:29:57.630497Z",
"iopub.status.busy": "2025-10-28T23:29:57.630175Z",
"iopub.status.idle": "2025-10-28T23:30:00.259945Z",
"shell.execute_reply": "2025-10-28T23:30:00.259517Z"
},
"papermill": {
"duration": 2.633266,
"end_time": "2025-10-28T23:30:00.261306",
"exception": false,
"start_time": "2025-10-28T23:29:57.628040",
"status": "completed"
},
"slideshow": {
"slide_type": ""
},
"tags": [
"hide-cell"
]
},
"outputs": [],
"source": [
"import os\n",
"\n",
"from IPython.core.display import HTML, Image\n",
"from IPython.display import display\n",
"import pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "2a759f1b-eca7-4eec-a16a-eede1a6ab36c",
"metadata": {
"editable": true,
"execution": {
"iopub.execute_input": "2025-10-28T23:30:00.266848Z",
"iopub.status.busy": "2025-10-28T23:30:00.266686Z",
"iopub.status.idle": "2025-10-28T23:30:00.269147Z",
"shell.execute_reply": "2025-10-28T23:30:00.268839Z"
},
"papermill": {
"duration": 0.004568,
"end_time": "2025-10-28T23:30:00.269519",
"exception": false,
"start_time": "2025-10-28T23:30:00.264951",
"status": "completed"
},
"slideshow": {
"slide_type": ""
},
"tags": [
"parameters",
"hide-cell"
]
},
"outputs": [],
"source": [
"ldf_root = \".\"\n",
"case_name = None\n",
"base_case_name = None\n",
"start_date = \"\"\n",
"end_date = \"\"\n",
"base_start_date = None\n",
"base_end_date = None\n",
"key_plots = None\n",
"# ldf_root will be external_diag_packages/computed_notebooks/LDF/"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "80770d7a",
"metadata": {
"execution": {
"iopub.execute_input": "2025-10-28T23:30:00.272419Z",
"iopub.status.busy": "2025-10-28T23:30:00.272323Z",
"iopub.status.idle": "2025-10-28T23:30:00.283262Z",
"shell.execute_reply": "2025-10-28T23:30:00.282740Z"
},
"papermill": {
"duration": 0.013383,
"end_time": "2025-10-28T23:30:00.284252",
"exception": false,
"start_time": "2025-10-28T23:30:00.270869",
"status": "completed"
},
"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",
"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",
"base_start_date = \"0001-01-01\"\n",
"base_end_date = \"0045-01-01\"\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",
"ldf_root = \"../../examples/key_metrics/LDF_output/\"\n",
"key_plots = [\n",
" \"GPP_ANN_LatLon_Mean.png\",\n",
" \"ELAI_ANN_LatLon_Mean.png\",\n",
" \"TOTECOSYSC_GlobalMean_ANN_TimeSeries_Mean.png\",\n",
" \"RegionalClimo_Amazonia_RegionalClimo_Mean.png\",\n",
"]\n",
"subset_kwargs = {}\n",
"product = \"/glade/work/richling/CUPid_pr_test/CUPiD/examples/key_metrics/computed_notebooks//lnd/LDF.ipynb\"\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "81bf4573-8806-486f-a2f6-79e244415c07",
"metadata": {
"editable": true,
"execution": {
"iopub.execute_input": "2025-10-28T23:30:00.292871Z",
"iopub.status.busy": "2025-10-28T23:30:00.292632Z",
"iopub.status.idle": "2025-10-28T23:30:00.295904Z",
"shell.execute_reply": "2025-10-28T23:30:00.295421Z"
},
"papermill": {
"duration": 0.007746,
"end_time": "2025-10-28T23:30:00.296553",
"exception": false,
"start_time": "2025-10-28T23:30:00.288807",
"status": "completed"
},
"slideshow": {
"slide_type": ""
},
"tags": [
"hide-cell"
]
},
"outputs": [],
"source": [
"# Want some base case parameter defaults to equal control case values\n",
"if base_case_name is not None:\n",
" if base_start_date is None:\n",
" base_start_date = start_date\n",
"\n",
" if base_end_date is None:\n",
" base_end_date = end_date"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "4104f878-a8c3-4d0f-8c00-555e6b2b3273",
"metadata": {
"editable": true,
"execution": {
"iopub.execute_input": "2025-10-28T23:30:00.299900Z",
"iopub.status.busy": "2025-10-28T23:30:00.299637Z",
"iopub.status.idle": "2025-10-28T23:30:00.304958Z",
"shell.execute_reply": "2025-10-28T23:30:00.304743Z"
},
"papermill": {
"duration": 0.007375,
"end_time": "2025-10-28T23:30:00.305329",
"exception": false,
"start_time": "2025-10-28T23:30:00.297954",
"status": "completed"
},
"slideshow": {
"slide_type": ""
},
"tags": [
"hide-cell"
]
},
"outputs": [],
"source": [
"# convert start-date and end-date to year range\n",
"case_year_range = [int(start_date.split(\"-\")[0]), int(end_date.split(\"-\")[0]) - 1]\n",
"\n",
"base_case_year_range = [\n",
" int(base_start_date.split(\"-\")[0]),\n",
" int(base_end_date.split(\"-\")[0]) - 1,\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "ee0774cc-c68a-4385-b94c-08fa806f28c0",
"metadata": {
"editable": true,
"execution": {
"iopub.execute_input": "2025-10-28T23:30:00.308340Z",
"iopub.status.busy": "2025-10-28T23:30:00.308242Z",
"iopub.status.idle": "2025-10-28T23:30:00.320767Z",
"shell.execute_reply": "2025-10-28T23:30:00.320380Z"
},
"papermill": {
"duration": 0.014847,
"end_time": "2025-10-28T23:30:00.321586",
"exception": false,
"start_time": "2025-10-28T23:30:00.306739",
"status": "completed"
},
"slideshow": {
"slide_type": ""
},
"tags": [
"hide-input"
]
},
"outputs": [
{
"data": {
"text/html": [
"Full LDF output"
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"ldf_comparison_name = f\"{case_name}_{case_year_range[0]}_{case_year_range[1]}_vs_{base_case_name}_{base_case_year_range[0]}_{base_case_year_range[1]}\"\n",
"ldf_root = os.path.join(ldf_root, ldf_comparison_name)\n",
"display(\n",
" HTML(\n",
" f'Full LDF output'\n",
" )\n",
")"
]
},
{
"cell_type": "markdown",
"id": "f9234aec-1fe5-4bbf-ad6c-fb565297afbe",
"metadata": {
"papermill": {
"duration": 0.004013,
"end_time": "2025-10-28T23:30:00.329076",
"exception": false,
"start_time": "2025-10-28T23:30:00.325063",
"status": "completed"
},
"tags": []
},
"source": [
"## Key Metrics from LDF\n",
"\n",
"Some important things to look at from LDF include a comparison table and a few maps:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "a5b02451-98ad-4089-b184-75391a262db3",
"metadata": {
"editable": true,
"execution": {
"iopub.execute_input": "2025-10-28T23:30:00.332120Z",
"iopub.status.busy": "2025-10-28T23:30:00.332012Z",
"iopub.status.idle": "2025-10-28T23:30:00.334911Z",
"shell.execute_reply": "2025-10-28T23:30:00.334389Z"
},
"papermill": {
"duration": 0.005001,
"end_time": "2025-10-28T23:30:00.335429",
"exception": false,
"start_time": "2025-10-28T23:30:00.330428",
"status": "completed"
},
"slideshow": {
"slide_type": ""
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"comparison_table = os.path.join(ldf_root, \"amwg_table_comp.csv\")\n",
"if os.path.isfile(comparison_table):\n",
" table = pd.read_csv(comparison_table)\n",
" display(HTML(table.to_html(index=False, float_format=\"{:6g}\".format)))"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "be819352-c723-4f48-afac-d93f6d192f96",
"metadata": {
"editable": true,
"execution": {
"iopub.execute_input": "2025-10-28T23:30:00.339034Z",
"iopub.status.busy": "2025-10-28T23:30:00.338764Z",
"iopub.status.idle": "2025-10-28T23:30:00.484822Z",
"shell.execute_reply": "2025-10-28T23:30:00.484219Z"
},
"papermill": {
"duration": 0.14933,
"end_time": "2025-10-28T23:30:00.486316",
"exception": false,
"start_time": "2025-10-28T23:30:00.336986",
"status": "completed"
},
"slideshow": {
"slide_type": ""
},
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"for path_to_key_plot in key_plots:\n",
" full_path = os.path.join(ldf_root, path_to_key_plot)\n",
" if os.path.isfile(full_path):\n",
" display(Image(full_path))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "cupid-infrastructure",
"language": "python",
"name": "cupid-infrastructure"
},
"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": 4.518432,
"end_time": "2025-10-28T23:30:00.707442",
"exception": null,
"input_path": "/glade/derecho/scratch/richling/tmp/tmpvbqekcs4.ipynb",
"output_path": "/glade/work/richling/CUPid_pr_test/CUPiD/examples/key_metrics/computed_notebooks/lnd/LDF.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_end_date": "0045-01-01",
"base_start_date": "0001-01-01",
"case_name": "b.e30_alpha07c_cesm.B1850C_LTso.ne30_t232_wgx3.232",
"end_date": "0021-01-01",
"key_plots": [
"GPP_ANN_LatLon_Mean.png",
"ELAI_ANN_LatLon_Mean.png",
"TOTECOSYSC_GlobalMean_ANN_TimeSeries_Mean.png",
"RegionalClimo_Amazonia_RegionalClimo_Mean.png"
],
"lc_kwargs": {
"threads_per_worker": 1
},
"ldf_root": "../../examples/key_metrics/LDF_output/",
"obs_data_dir": "/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data",
"product": "/glade/work/richling/CUPid_pr_test/CUPiD/examples/key_metrics/computed_notebooks//lnd/LDF.ipynb",
"serial": false,
"start_date": "0001-01-01",
"subset_kwargs": {},
"ts_dir": null
},
"start_time": "2025-10-28T23:29:56.189010"
}
},
"nbformat": 4,
"nbformat_minor": 5
}