Skip to content

Commit 5bce78f

Browse files
Merge branch 'main' into pip_refactor
2 parents 24efa1f + 2109c1d commit 5bce78f

File tree

13 files changed

+148
-72
lines changed

13 files changed

+148
-72
lines changed

MDTF_diagnostics/data/fieldlist_CMIP.jsonc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@
248248
},
249249
"tos": {
250250
"standard_name": "sea_surface_temperature",
251+
"realm": "ocean",
251252
"units": "degC",
252253
"ndim": 3
253254
},
@@ -258,11 +259,6 @@
258259
"modifier": "atmos_height",
259260
"ndim": 3
260261
},
261-
"tos": {
262-
"standard_name": "sea_surface_temperature",
263-
"units": "K",
264-
"ndim": 3
265-
},
266262
// radiative fluxes:
267263
"rsus": {
268264
"standard_name": "surface_upwelling_shortwave_flux_in_air",

MDTF_diagnostics/diagnostics/mar/SST_bias_NOAA_OISSTv2/SST_bias_NOAA_OISSTv2.ipynb

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"\n",
2020
"\n",
2121
"# For testing and development purposes, enter a start year, end year, and\n",
22-
"# an dora id number to analyze. The value of dora_id can also be a direct\n",
22+
"# a dora id number to analyze. The value of dora_id can also be a direct\n",
2323
"# path to a /pp directory.\n",
2424
"\n",
2525
"config = {\n",
@@ -64,12 +64,10 @@
6464
]
6565
},
6666
{
67-
"cell_type": "code",
68-
"id": "dfcdc828-ad45-4ef0-92bc-05df9c036270",
6967
"metadata": {},
68+
"cell_type": "code",
7069
"source": [
7170
"import doralite\n",
72-
"import glob\n",
7371
"import momlevel\n",
7472
"import subprocess\n",
7573
"import os\n",
@@ -85,6 +83,7 @@
8583
"\n",
8684
"from matplotlib.colors import ListedColormap, BoundaryNorm"
8785
],
86+
"id": "c57e0f8b0c23ad83",
8887
"outputs": [],
8988
"execution_count": null
9089
},
@@ -149,11 +148,7 @@
149148
{
150149
"cell_type": "code",
151150
"id": "382835f3-a3d7-419f-a92f-e65808230c59",
152-
"metadata": {
153-
"jupyter": {
154-
"is_executing": true
155-
}
156-
},
151+
"metadata": {},
157152
"source": [
158153
"# Determine what files are needed (leave this up to the developer for flexibility)\n",
159154
"# This is an example of what someone might do:\n",

MDTF_diagnostics/diagnostics/mar/SST_bias_NOAA_OISSTv2/settings.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"long_name" : "Sea Surface Temperature Bias - NOAA OISSTv2",
55
"convention": "gfdl",
66
"mar": true,
7-
"description" : "This notebook plots the SST bias of a model simulation vs. climataology derived from NOAA OISSTv2",
7+
"description" : "This notebook plots the SST bias of a model simulation vs. climatology derived from NOAA OISSTv2",
88
"runtime_requirements": {
99
"python3": ["matplotlib", "xarray", "netCDF4"]
1010
}

MDTF_diagnostics/src/conda/env_dev.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ dependencies:
1010
- netCDF4=1.6.5
1111
- cftime=1.6.2
1212
- scikit-learn=1.4.2
13-
- xesmf=0.8.1
14-
- esmf=8.4.2
15-
- esmpy=8.4.2
13+
- xesmf=0.8.9
14+
- esmf=8.8.1
15+
- esmpy=8.8.1
1616
- xarray=2025.1.2
1717
- matplotlib=3.8.2
1818
- cartopy=0.22.0

MDTF_diagnostics/src/conda/env_python3_base.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ dependencies:
2020
- dask=2025.2.0
2121
- numba=0.60.0
2222
- scikit-learn=1.4.2
23-
- xesmf=0.8.7
24-
- esmf=8.4.2
25-
- esmpy=8.4.2
23+
- xesmf=0.8.9
24+
- esmf=8.8.1
25+
- esmpy=8.8.1
2626
- gsw=3.6.17
27+
- cfunits=3.3.6
2728
- metpy=1.5.1
2829
#- enso_metrics=3.1.1 Required by pcmdi_metrics, but no support for python>3.10
2930
#- pcmdi_metrics=3.0.2 Not used by current PODs-implement later

MDTF_diagnostics/src/conda/env_python3_base_micromamba.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ dependencies:
2020
- dask=2025.2.0
2121
- numba=0.60.0
2222
- scikit-learn=1.4.2
23-
- xesmf=0.8.1
24-
- esmf=8.4.2
25-
- esmpy=8.4.2
23+
- xesmf=0.8.9
24+
- esmf=8.8.1
25+
- esmpy=8.8.1
2626
- gsw=3.6.17
2727
- metpy=1.5.1
2828
#- enso_metrics=3.1.1 Required by pcmdi_metrics, but no support for python>3.10

MDTF_diagnostics/tools/run-MDTF/config/pod_config.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,26 @@
22
"Wheeler_Kiladis": {
33
"realm": "atmos_cmip",
44
"frequency": "day",
5-
"vars": ["rlut","pr","wap500","ua200","ua850"]
5+
"vars": ["rlut", "pr", "wap500", "ua200", "ua850"]
66
},
77
"MJO_suite": {
88
"realm": "atmos_cmip",
99
"frequency": "day",
10-
"vars": ["rlut","pr","ua200","ua850","va200","va850"]
10+
"vars": ["rlut", "pr", "ua200", "ua850", "va200", "va850"]
1111
},
1212
"ocn_surf_flux_diag": {
1313
"realm": "atmos_cmip",
1414
"frequency": "day",
15-
"vars": ["ts","psl","sfcWind","huss","hfls","pr"]
15+
"vars": ["ts", "psl", "sfcWind", "huss", "hfls" ,"pr"]
1616
},
1717
"forcing_feedback": {
1818
"realm": "atmos_cmip",
1919
"frequency": "mon",
20-
"vars": ["ts","ta","hus","rsus","rsuscs","rsds","rsdscs","rsdt","rsut","rsutcs","rlut","rlutcs"]
21-
}
20+
"vars": ["ts", "ta", "hus", "rsus", "rsuscs", "rsds", "rsdscs", "rsdt", "rsut", "rsutcs", "rlut", "rlutcs"]
21+
},
22+
"SST_bias_NOAA_OISSTv2": {
23+
"realm": "ocean_monthly",
24+
"frequency": "mon",
25+
"vars": ["tos", "areacello"]
26+
}
2227
}

MDTF_diagnostics/tools/run-MDTF/doc/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# run-MDTF
22
Shell driver script to run the MDTF-diagnostics package with the GFDL FRE workflow <br />
3+
This script automatially generates an intake-ESM catalog with files in the target directory
4+
using the GFDL catalogBuilder tool with --slow option to ensure that all required variable
5+
metadata are populated. If a catalog exists in the input data directory or the output directory,
6+
the script will skip the catalog generation step.
37

48
Command-line usage:
59

@@ -15,3 +19,14 @@ Input:
1519
- `-o`: path to directory to write the output
1620
- `-s`: start year of the dataset
1721
- `-e`: end year of the dataset
22+
- `-c`: (optional) data convention, cmip (default), gfdl, or cesm
23+
24+
Example using GFDL central MDTF-diagnostics installation. Note that the resulting catalog will not include static files with
25+
variables required by the example mar SST_bias_NOAA_OISSTvs notebook. In the following example, the information for `ocean_monthly.static.nc`
26+
needs to be entered manually at this time, so the user needs to call `run-MDTF.sh` twice:
27+
28+
```
29+
$ /home/oar.gfdl.mdtf/mdtf/MDTF-diagnostics/tools/run-MDTF/run-MDTF.sh
30+
-i /archive/John.Krasting/fre_om5/FMS2024.02_om5_20250206/om5_b08/gfdl.ncrc5-intel23-prod/pp/ocean_monthly/ts
31+
-o ~/mdtf_test_out -s 1978 -e 1988 -l config/pod_config.json
32+
```

MDTF_diagnostics/tools/run-MDTF/run-MDTF.sh

Lines changed: 50 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
# dir references
77
run_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
8+
echo "${run_dir}"
89
mdtf_dir=/home/oar.gfdl.mdtf/mdtf/MDTF-diagnostics
9-
#mdtf_dir=/home/Jacob.Mims/mdtf/MDTF-diagnostics
1010
activate=/home/oar.gfdl.mdtf/miniconda3/bin/activate
1111

1212
#TEST: /archive/jpk/fre/FMS2024.02_OM5_20240819/CM4.5v01_om5b06_piC_noBLING_xrefine_test4/gfdl.ncrc5-intel23-prod-openmp/pp/ starts 0001
@@ -23,7 +23,7 @@ usage() {
2323
tempdir=""
2424
pod_config=""
2525
declare -a pods=()
26-
while getopts "hi:o:s:e:p:t:l:" arg; do
26+
while getopts "hi:o:s:e:p:t:l:c:" arg; do
2727
case "${arg}" in
2828
h)
2929
usage
@@ -60,76 +60,87 @@ while getopts "hi:o:s:e:p:t:l:" arg; do
6060
;;
6161
l)
6262
pod_config="${OPTARG}"
63+
;;
64+
c)
65+
convention="${OPTARG}"
6366
esac
6467
done
68+
6569
shift $((OPTIND-1))
66-
if ! [ -d $outdir/config ]; then
67-
mkdir -p $outdir/config
70+
if ! [ -d "${outdir}"/config ]; then
71+
mkdir -p "${outdir}"/config
6872
fi
69-
if [ -z $tempdir ]; then
70-
wkdir=$outdir
73+
74+
if [ -z "${tempdir}" ]; then
75+
wkdir="${outdir}"
7176
else
72-
wkdir=$tempdir
77+
wkdir="${tempdir}"
7378
fi
74-
if [ -z $pod_config ]; then
75-
pod_config="$run_dir/config/pod_config.json"
79+
80+
if [ -z "${pod_config}" ]; then
81+
pod_config="${run_dir}/config/pod_config.json"
7682
fi
7783

7884
# check to see if catalog exists
7985
# ^..^
8086
# /o o\
8187
# oo--oo~~~
82-
echo "looking for catalog in $ppdir"
83-
cat=$(grep -s -H "esmcat_version" $ppdir/*.json | cut -d: -f1)
84-
if [[ "$cat" == "" ]]; then
85-
env=/nbhome/fms/conda/envs/fre-2025.01
86-
source $activate $env
87-
fre catalog builder --overwrite $ppdir $outdir/catalog
88-
cat=$outdir/catalog.json
89-
echo "new catalog generated: $cat"
90-
else
91-
echo "found catalog: $cat"
92-
fi
88+
output_catalog="${outdir}"/catalog.json
89+
if [ ! -f "${output_catalog}" ]; then
90+
echo "Looking for catalog in ${ppdir}"
91+
input_catalog=$(grep -s -H "esmcat_version" "${ppdir}"/*.json | cut -d: -f1)
92+
if [[ "${input_catalog}" == "" ]]; then
93+
env=/nbhome/fms/conda/envs/fre-2025.01
94+
source $activate ${env}
95+
fre catalog builder --slow --overwrite "${ppdir}" "${outdir}"/catalog
96+
echo "New catalog generated: ${output_catalog}"
97+
else
98+
echo "found catalog: ${input_catalog}"
99+
fi
93100

101+
fi
94102
# edit template config file
95-
cp $run_dir/config/template_config.jsonc $outdir
96-
f=$outdir/template_config.jsonc
97-
if [ ! -f $f ]; then
98-
echo "ERROR: failed to find $f"
103+
cp "${run_dir}"/config/template_config.jsonc "${outdir}"
104+
f=${outdir}/template_config.jsonc
105+
if [ ! -f "${f}" ]; then
106+
echo "ERROR: failed to find ${f}"
99107
exit 0
100108
fi
101109
config='"DATA_CATALOG": "",'
102-
config_edit='"DATA_CATALOG": "'"${cat}"'",'
103-
sed -i "s|$config|$config_edit|ig" $f
110+
config_edit='"DATA_CATALOG": "'"${output_catalog}"'",'
111+
sed -i "s|${config}|${config_edit}|ig" "${f}"
104112
config='"WORK_DIR": "",'
105113
config_edit='"WORK_DIR": "'"${wkdir}"'",'
106-
sed -i "s|$config|$config_edit|ig" $f
114+
sed -i "s|${config}|${config_edit}|ig" "${f}"
107115
config='"OUTPUT_DIR": "",'
108116
config_edit='"OUTPUT_DIR": "'"${outdir}"'",'
109-
sed -i "s|$config|$config_edit|ig" $f
117+
sed -i "s|${config}|${config_edit}|ig" "${f}"
110118
config='"startdate": "",'
111119
config_edit='"startdate": "'"${startyr}"'",'
112-
sed -i "s|$config|$config_edit|ig" $f
120+
sed -i "s|${config}|${config_edit}|ig" "${f}"
113121
config='"enddate": ""'
114122
config_edit='"enddate": "'"${endyr}"'"'
115-
sed -i "s|$config|$config_edit|ig" $f
116-
echo "edited file $f"
123+
sed -i "s|${config}|${config_edit}|ig" "${f}"
124+
config_edit='"convention": "'"${convention}"'"'
125+
sed -i "s|${config}|${config_edit}|ig" "${f}"
126+
echo "edited file ${f}"
117127

118128
# load mdtf base conda env
119129
env=/home/oar.gfdl.mdtf/miniconda3/envs/_MDTF_base
120-
source $activate $env
130+
source ${activate} ${env}
121131
#generate config files
122-
python $run_dir/scripts/gen_config.py $outdir/ $pod_config
132+
python "${run_dir}"/scripts/gen_config.py "${outdir}"/ "${pod_config}"
123133

124134
# launch the mdtf with the config files
125-
for f in $(ls ${outdir}/config) ; do
126-
echo "launching MDTF with $f"
127-
"$mdtf_dir"/mdtf -f $outdir/config/$f
135+
file_list=$( ls "${outdir}"/config )
136+
for f in ${file_list}; do
137+
echo "Launching MDTF-diagnostics with configuration ${f}"
138+
"${mdtf_dir}"/mdtf -f "${outdir}/config/${f}"
128139
done
129140

130141
# consolidate outputs into index
131-
cp $run_dir/scripts/index.html $outdir/
132-
cp $run_dir/scripts/mdtf_diag_banner.png $outdir/
133-
python $run_dir/scripts/gen_index.py $outdir/ $pod_config
142+
cp "${run_dir}"/scripts/index.html "${outdir}"/
143+
cp "${run_dir}"/scripts/mdtf_diag_banner.png "${outdir}"/
144+
python "${run_dir}"/scripts/gen_index.py "${outdir}"/ "${pod_config}"
134145

135146
exit 0

MDTF_diagnostics/tools/run-MDTF/run-MDTF_frepp.csh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ endif
3636

3737
set ppdir = `echo ${in_data_dir} | sed 's|\(.*pp\).*|\1|'`
3838

39-
/home/oar.gfdl.mdtf/mdtf/MDTF-diagnostics/tools/run-MDTF/run-MDTF.sh -i ${ppdir} -o ${out_dir}/mdtf -s $yr1 -e $yr2
39+
/home/oar.gfdl.mdtf/mdtf/MDTF-diagnostics/tools/run-MDTF/run-MDTF.sh -i ${ppdir} -o ${out_dir}/mdtf -s ${yr1} -e ${yr2}
4040

0 commit comments

Comments
 (0)