Skip to content

Commit

Permalink
Merge pull request #983 from PCMDI/mjo_ewr_update_20230921
Browse files Browse the repository at this point in the history
Update MJO EWR calculation
  • Loading branch information
lee1043 committed Sep 25, 2023
2 parents 4ee8610 + 93dbc97 commit e6e7154
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 27 deletions.
6 changes: 3 additions & 3 deletions pcmdi_metrics/mean_climate/mean_climate_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@

if debug:
print('ds_test_tmp:', ds_test_tmp)
ds_test_dict[region].to_netcdf('_'.join([var, 'model', model, run, region + '.nc']))
ds_test_dict[region].to_netcdf('_'.join([var, 'model', model, run, region, case_id + '.nc']))
if model == test_data_set[0] and run == realizations[0]:
ds_ref_dict[region].to_netcdf('_'.join([var, 'ref', region + '.nc']))

Expand All @@ -297,7 +297,7 @@

# write individual JSON
# --- single simulation, obs (need to accumulate later) / single variable
json_filename_tmp = "_".join([var, model, run, target_grid, regrid_tool, "metrics", ref])
json_filename_tmp = "_".join([var, model, run, target_grid, regrid_tool, "metrics", ref, case_id])
mean_climate_metrics_to_json(
os.path.join(metrics_output_path, var),
json_filename_tmp,
Expand All @@ -319,7 +319,7 @@
# ------------------------------------------------------------------------
if not parallel:
# write collective JSON --- all models / all obs / single variable
json_filename = "_".join([var, target_grid, regrid_tool, "metrics"])
json_filename = "_".join([var, target_grid, regrid_tool, "metrics", case_id])
mean_climate_metrics_to_json(
metrics_output_path,
json_filename,
Expand Down
44 changes: 29 additions & 15 deletions pcmdi_metrics/mjo/lib/mjo_metric_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,35 @@ def mjo_metric_ewr_calculation(
if plot:
os.makedirs(outdir(output_type="graphics"), exist_ok=True)
fout = os.path.join(outdir(output_type="graphics"), output_filename)
title = (
mip.upper()
+ ": "
+ model
+ " ("
+ run
+ ") \n"
+ var.capitalize()
+ ", "
+ season
+ " "
+ str(startYear)
+ "-"
+ str(endYear)
)
if model == 'obs':
title = (
" OBS ("
+ run
+ ") \n"
+ var.capitalize()
+ ", "
+ season
+ " "
+ str(startYear)
+ "-"
+ str(endYear)
)
else:
title = (
mip.upper()
+ ": "
+ model
+ " ("
+ run
+ ") \n"
+ var.capitalize()
+ ", "
+ season
+ " "
+ str(startYear)
+ "-"
+ str(endYear)
)
if cmmGrid:
title += ", common grid (2.5x2.5deg)"
plot_power(OEE, title, fout, ewr)
Expand Down
2 changes: 1 addition & 1 deletion pcmdi_metrics/mjo/param/myParam_mjo.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def find_latest(path):
# Observation
# -------------------------------------------------
reference_data_name = "GPCP-1-3"
reference_data_path = "/p/user_pub/PCMDIobs/PCMDIobs2/atmos/day/pr/GPCP-1-3/gn/v20200707/pr_day_GPCP-1-3_BE_gn_v20200707_19961002-20170101.nc" # noqa
reference_data_path = "/p/user_pub/PCMDIobs/obs4MIPs_legacy/PCMDIobs2/atmos/day/pr/GPCP-1-3/gn/v20200924/pr_day_GPCP-1-3_BE_gn_v20200924_19961002-20170101.nc" # noqa

varOBS = "pr"
ObsUnitsAdjust = (True, "multiply", 86400.0, "mm d-1") # kg m-2 s-1 to mm day-1
Expand Down
5 changes: 2 additions & 3 deletions pcmdi_metrics/mjo/scripts/parallel_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@
# =================================================
# Generates list of command
# -------------------------------------------------
param_file = "../doc/myParam_mjo.py"
param_file = "../param/myParam_mjo.py"

if debug:
param_file = "../doc/myParam_test.py"
param_file = "../param/myParam_test.py"
print("number of models (debug mode):", len(models))

cmds_list = list()
Expand Down Expand Up @@ -148,7 +148,6 @@
for r, run in enumerate(runs_list):
# command line for queue
cmd = [
"python",
"mjo_metrics_driver.py",
"-p",
param_file,
Expand Down
7 changes: 2 additions & 5 deletions pcmdi_metrics/mjo/scripts/run.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#!/bin/sh
set -a

# grim: pmp_nightly_20190628
# gates: cdat82_20191107_py37, pmp_nightly_20190912

#parallel=no
parallel=yes

Expand All @@ -17,15 +14,15 @@ mkdir -p log
if [ $parallel == no ]; then
echo 'parallel no'
for mip in $mips; do
python -u mjo_metrics_driver.py -p ../doc/myParam_mjo.py --mip ${mip} >& log/log.${mip}.txt &
mjo_metrics_driver.py -p ../param/myParam_mjo.py --mip ${mip} >& log/log.${mip}.txt &
disown
done
elif [ $parallel == yes ]; then
echo 'parallel yes'
modnames="all"
realization="all"
for mip in $mips; do
python -u ./parallel_driver.py -p ../doc/myParam_mjo.py --mip ${mip} --num_workers $num_workers --modnames $modnames --realization $realization >& log/log.parallel.${mip}.txt &
python -u ./parallel_driver.py -p ../param/myParam_mjo.py --mip ${mip} --num_workers $num_workers --modnames $modnames --realization $realization >& log/log.parallel.${mip}.txt &
disown
done
fi

0 comments on commit e6e7154

Please sign in to comment.