Skip to content

Commit e8a7412

Browse files
New Feature: Support plotting native grid data in lat_lon plots (#968)
* add notebook to visualize native grid data * add skeleton for a the new lat_lon_native set * add dependencies; make simple plotting/viewer work * fix variable description in viewer * make variable derivation work * make 2d model only run plotting work * model vs model works * fix for region e.g. 60S60N work * add uxarray's nearest neighbor regridding and make diff plot work * clean up debug lines * reorg plot funcs * create subset region metrics * update standard variable list for native grid plotting * fix sets in cfg * more code clean up * temporal fix for input data with n time snapshots * add TGCLDLWP variable * update default var in cfg * fix pre-commit errors * pin uxarray to avoid latest version(2025.6.0) * simplify derived var logic;code cleanup * create new get_native_dataset function * add time snapshot selection function for visualize native history file * update granulation list to avoid looping over seasons; fix viewer * Refactor Jill's initial PR for maintainability add testing script and cfg file Move METRICS_DEFAULT_VALUE to /driver/__init__.py Refactor `default_viewer.py` and `main.py` Move `run_native_grid_test.py` to `debug/968-native-grid-vis` Refactor `lat_lon_native_parameter.py` and `core_parameter.py` - Update type annotations, re-order methods in `LatLonNativeParameter` class Add a comment for granulation in `core_parser.py` Extract code from LatLonNativeDriver into NativeDataset class - Move `TimeSlice` and `TimeSelection` into `type_annotations.py` and update all references Add type annotations and comments Add fixme and todo comments in driver and plotter Update run script to use single run * fix importing ClimoFreq and using it * relax uxarray version by remove dependency on periodic_elements * refactor to use utils in plotting * refactor metrics generation and using weighted mean,rsme,corr * reformat testing run script * make metrics work on regional subset * clean up * update example script * fix provenance command-line; fix metrics for model_only case
1 parent 5720f7b commit e8a7412

33 files changed

+4188
-27
lines changed

auxiliary_tools/LCF_mixed-phase_partition_diagram.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@
220220
],
221221
"metadata": {
222222
"kernelspec": {
223-
"display_name": "Python [conda env:e3sm_unified_1.6.0_nompi] *",
223+
"display_name": "Python [conda env:e3sm_unified_1.6.0_nompi]",
224224
"language": "python",
225225
"name": "conda-env-e3sm_unified_1.6.0_nompi-py"
226226
},
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[#]
2+
sets = ["lat_lon_native"]
3+
case_id = "model_vs_model"
4+
variables = ["TGCLDLWP"]
5+
seasons = ["ANN", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "DJF", "MAM", "JJA", "SON"]
6+
#regions = ["global"]
7+
regions = ["global", "30S30N-150E90W"]
8+
#test_colormap = "Blues"
9+
#reference_colormap = "Blues"
10+
diff_colormap = "RdBu"
11+
contour_levels = [10, 25, 50, 75, 100, 125, 150, 175, 200,225, 250]
12+
diff_levels = [-35, -30, -25, -20, -15, -10, -5, 5, 10, 15, 20, 25, 30, 35]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[#]
2+
sets = ["lat_lon_native"]
3+
case_id = "model_vs_model"
4+
variables = ["PRECT"]
5+
seasons = ["ANN", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12", "DJF", "MAM", "JJA", "SON"]
6+
regions = ["global", "60S60N", "30S30N-150E90W"]
7+
test_colormap = "WhiteBlueGreenYellowRed.rgb"
8+
reference_colormap = "WhiteBlueGreenYellowRed.rgb"
9+
diff_colormap = "BrBG"
10+
contour_levels = [0.5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16]
11+
diff_levels = [-2.5, -2, -1.5, -1, -0.5, -0.25, 0.25, 0.5, 1, 1.5, 2, 2.5]
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/usr/bin/env python3
2+
"""
3+
This script runs e3sm_diags with the lat_lon_native set to visualize native grid data.
4+
"""
5+
6+
import os
7+
import sys
8+
9+
from e3sm_diags.parameter.lat_lon_native_parameter import LatLonNativeParameter
10+
from e3sm_diags.run import runner
11+
12+
# Auto-detect username
13+
username = os.environ.get('USER', 'unknown_user')
14+
15+
# Create parameter objects for 3 different runs
16+
params = []
17+
18+
## (1) First test configuration
19+
#param1 = LatLonNativeParameter()
20+
#param1.results_dir = f"/lcrc/group/e3sm/public_html/diagnostic_output/{username}/tests/lat_lon_native_test_1"
21+
#param1.test_data_path = "/lcrc/group/e3sm/public_html/e3sm_diags_test_data/native_grid"
22+
#param1.test_name = "v3.LR.amip_0101"
23+
#param1.short_test_name = "v3.LR.amip_0101"
24+
#param1.reference_data_path = "/lcrc/group/e3sm/public_html/e3sm_diags_test_data/native_grid"
25+
#param1.ref_name = "v3.HR.test4"
26+
#param1.short_ref_name = "v3.HR.test4"
27+
#param1.seasons = ["DJF"]
28+
#param1.test_grid_file = "/lcrc/group/e3sm/diagnostics/grids/ne30pg2.nc"
29+
#param1.ref_grid_file = "/lcrc/group/e3sm/diagnostics/grids/ne120pg2.nc"
30+
#param1.case_id = "model_vs_model"
31+
#param1.run_type = "model_vs_model"
32+
#params.append(param1)
33+
#
34+
## (2) Second test configuration
35+
#param2 = LatLonNativeParameter()
36+
#param2.results_dir = f"/lcrc/group/e3sm/public_html/diagnostic_output/{username}/tests/lat_lon_native_test_2"
37+
#param2.test_data_path = "/lcrc/group/e3sm/public_html/e3sm_diags_test_data/native_grid"
38+
#param2.test_file = "v3.LR.amip_0101_DJF_climo.nc"
39+
#param2.short_test_name = "v3.LR.amip_0101"
40+
#param2.reference_data_path = "/lcrc/group/e3sm/public_html/e3sm_diags_test_data/native_grid"
41+
#param2.ref_file = "v3.HR.test4_DJF_climo.nc"
42+
#param2.short_ref_name = "v3.HR.test4"
43+
#param2.seasons = ["DJF"]
44+
#param2.test_grid_file = "/lcrc/group/e3sm/diagnostics/grids/ne30pg2.nc"
45+
#param2.ref_grid_file = "/lcrc/group/e3sm/diagnostics/grids/ne120pg2.nc"
46+
#param2.case_id = "model_vs_model"
47+
#param2.run_type = "model_vs_model"
48+
#params.append(param2)
49+
50+
# (3) Third test configuration
51+
param3 = LatLonNativeParameter()
52+
param3.results_dir = f"/lcrc/group/e3sm/public_html/diagnostic_output/{username}/tests/lat_lon_native_test_3"
53+
param3.test_data_path = "/lcrc/group/e3sm/public_html/e3sm_diags_test_data/native_grid"
54+
param3.test_file = "v3.LR.amip_0101.eam.h0.1989-12.nc"
55+
param3.reference_data_path = "/lcrc/group/e3sm/public_html/e3sm_diags_test_data/native_grid"
56+
param3.ref_file = "v3.LR.amip_0101.eam.h0.1989-12.nc"
57+
param3.short_ref_name = "v3.HR.test4"
58+
param3.time_slices = ["0"]
59+
param3.test_grid_file = "/lcrc/group/e3sm/diagnostics/grids/ne30pg2.nc"
60+
param3.ref_grid_file = "/lcrc/group/e3sm/diagnostics/grids/ne30pg2.nc"
61+
param3.case_id = "model_vs_model"
62+
param3.run_type = "model_vs_model"
63+
params.append(param3)
64+
65+
# Run the single diagnostic, comment out for complete diagnostics.
66+
cfg_path = "auxiliary_tools/debug/968-native-grid-vis/TGCLDLWP.cfg"
67+
sys.argv.extend(["--diags", cfg_path])
68+
69+
runner.sets_to_run = ["lat_lon_native"]
70+
71+
# Run each test sequentially
72+
for i, param in enumerate(params, 1):
73+
print(f"\n{'='*60}")
74+
print(f"Running Test {i}: {param.results_dir}")
75+
print(f"{'='*60}")
76+
77+
# Create results directory
78+
if not os.path.exists(param.results_dir):
79+
os.makedirs(param.results_dir)
80+
81+
# Run the diagnostic
82+
runner.run_diags([param])
83+
print(f"Test {i} completed!")
84+
85+
print(f"\n{'='*60}")
86+
print("All tests completed!")
87+
print(f"{'='*60}")
88+
89+

0 commit comments

Comments
 (0)