Skip to content

Commit

Permalink
Add wavenumber frequency set from e3sm_diags (#560)
Browse files Browse the repository at this point in the history
* add wavenumber frequency set from e3sm_diags

* fix year range format; fix dependency

* update default.ini

* address review comments
  • Loading branch information
chengzhuzhang authored Apr 11, 2024
1 parent ff3a998 commit bab6b25
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 5 deletions.
22 changes: 22 additions & 0 deletions zppy/e3sm_diags.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,12 @@ def e3sm_diags(config, scriptDir, existing_bundles, job_ids_file): # noqa: C901
c["gauges_path"] = os.path.join(
gauges_path_prefix, gauges_path_suffix
)
if ("tropical_subseasonal" in c["sets"]) and (
c["reference_data_path_ts_daily"] == ""
):
c[
"reference_data_path_ts_daily"
] = f"{reference_data_path}/atm/{c['grid']}/ts/daily"
else:
raise ValueError("Invalid run_type={}".format(c["run_type"]))
if "diurnal_cycle" in c["sets"]:
Expand Down Expand Up @@ -197,6 +203,14 @@ def e3sm_diags(config, scriptDir, existing_bundles, job_ids_file): # noqa: C901
ts_sub = c["ts_subsection"]
else:
ts_sub = c["sub"]

if (
"ts_daily_subsection" in c.keys()
and c["ts_daily_subsection"] != ""
):
ts_sub = c["ts_daily_subsection"]
else:
ts_sub = c["sub"]
if (
("enso_diags" in c["sets"])
or ("qbo" in c["sets"])
Expand All @@ -217,6 +231,14 @@ def e3sm_diags(config, scriptDir, existing_bundles, job_ids_file): # noqa: C901
% (start_yr, end_yr, c["ts_num_years"]),
)
)
if "tropical_subseasonal" in c["sets"]:
dependencies.append(
os.path.join(
scriptDir,
"ts_%s_%04d-%04d-%04d.status"
% (ts_sub, start_yr, end_yr, c["ts_num_years"]),
)
)
with open(settingsFile, "w") as sf:
p = pprint.PrettyPrinter(indent=2, stream=sf)
p.pprint(c)
Expand Down
17 changes: 12 additions & 5 deletions zppy/templates/default.ini
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,20 @@ reference_data_path_tc = string(default="")
# `reference_data_path` but for "enso_diags"/"qbo"/"area_mean_time_series" runs
# Required for run_type="model_vs_model" "enso_diags"/"qbo"/"area_mean_time_series" runs
reference_data_path_ts = string(default="")
# Required for "tropical_subseasonal" runs
reference_data_path_ts_daily = string(default="")
# `reference_data_path` but for "streamflow" runs
# Required for run_type="model_vs_model" "streamflow" runs
reference_data_path_ts_rof = string(default="")
# See https://e3sm-project.github.io/e3sm_diags/_build/html/master/available-parameters.html
# Some parameters are required if run_type="model_vs_model": `diff_title`, `ref_name`, `reference_data_path`, `short_ref_name`
# Required for "model_vs_model" "area_mean_time_series" runs: `reference_data_path_ts`, `ts_num_years_ref`, `ts_subsection`
# Required for "model_vs_model" "diurnal_cycle" runs: `reference_path_climo_diurnal`
# Required for "model_vs_model" "streamflow" runs: `gauges_path`, `reference_data_path_ts_rof`
# Required for "model_vs_model" "tc_analysis" runs: `reference_diurnal_path_tc`
# Required for "model_vs_model" "enso_diags"/"qbo"/"area_mean_time_series" runs: `reference_data_path_ts`
# Required for "model_vs_model" "enso_diags"/"qbo"/"area_mean_time_series"/"streamflow" runs: `ts_num_years_ref`, `ts_subsection`
# Required for "model_vs_model" "enso_diags"/"streamflow"/"tc_analysis" runs: `ref_final_yr`, `ref_start_yr`
# Required for "model_vs_model" "enso_diags" runs: `ref_final_yr`, `ref_start_yr`, `reference_data_path_ts`, `ts_num_years_ref`, `ts_subsection`
# Required for "model_vs_model" "qbo" runs: `reference_data_path_ts`, `ts_num_years_ref`, `ts_subsection`
# Required for "model_vs_model" "streamflow" runs: `gauges_path`, `ref_final_yr`, `ref_start_yr`, `reference_data_path_ts_rof`, `ts_num_years_ref`, `ts_subsection`
# Required for "model_vs_model" "tc_analysis" runs: `ref_final_yr`, `ref_start_yr`, `reference_diurnal_path_tc`
# Required for "model_vs_model" "tropical_subseasonal" runs: `ref_final_yr`, `ref_start_yr`, `reference_data_path_ts_daily`, `ts_num_years_ref`, `ts_subsection`
run_type = string(default="model_vs_obs")
# The sets to run
# All available sets (16) = "aerosol_aeronet","aerosol_budget","annual_cycle_zonal_mean","area_mean_time_series","cosp_histogram","diurnal_cycle","enso_diags","lat_lon","meridional_mean_2d","polar","qbo","streamflow","tc_analysis","zonal_mean_2d","zonal_mean_2d_stratosphere","zonal_mean_xy"
Expand Down Expand Up @@ -226,6 +229,8 @@ ts_num_years_ref = integer(default=5)
# Name of the `[ts]` subtask for "enso_diags"/"qbo"/"area_mean_time_series"/"streamflow" runs
# Required for run_type="model_vs_model" "enso_diags"/"qbo"/"area_mean_time_series"/"streamflow" runs
ts_subsection = string(default="")
# Required for "tropical_subseasonal" run
ts_daily_subsection = string(default="")

[[__many__]]
backend = string(default=None)
Expand All @@ -250,6 +255,7 @@ ts_subsection = string(default="")
reference_data_path_climo_diurnal = string(default=None)
reference_data_path_tc = string(default=None)
reference_data_path_ts = string(default=None)
reference_data_path_ts_daily = string(default=None)
reference_data_path_ts_rof = string(default=None)
run_type = string(default=None)
sets = string_list(default=None)
Expand All @@ -262,6 +268,7 @@ ts_subsection = string(default="")
ts_num_years = integer(default=None)
ts_num_years_ref = integer(default=None)
ts_subsection = string(default=None)
ts_daily_subsection = string(default=None)

[mpas_analysis]
anomalyRefYear = integer(default=1)
Expand Down
37 changes: 37 additions & 0 deletions zppy/templates/e3sm_diags.bash
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ create_links_ts_rof()
cd ..
}


{%- if ("lat_lon_land" in sets) %}
{% if run_type == "model_vs_obs" %}
climo_dir_primary_land=climo_land
Expand Down Expand Up @@ -206,6 +207,11 @@ create_links_ts ${ts_dir_source} ${ts_dir_ref} ${ref_Y1} ${ref_Y2} 6
{%- endif %}
{%- endif %}

ts_daily_dir={{ output }}/post/atm/{{ grid }}/ts/daily/{{ '%dyr' % (ts_num_years) }}
{% if run_type == "model_vs_model" %}
ts_daily_dir_ref={{ reference_data_path_ts_daily }}/{{ ts_num_years_ref }}yr
{%- endif %}

{%- if "streamflow" in sets %}
{% if run_type == "model_vs_obs" %}
ts_rof_dir_primary=rof
Expand Down Expand Up @@ -262,6 +268,9 @@ from e3sm_diags.parameter.tc_analysis_parameter import TCAnalysisParameter
{%- if "lat_lon_land" in sets %}
from e3sm_diags.parameter.lat_lon_land_parameter import LatLonLandParameter
{%- endif %}
{%- if "tropical_subseasonal" in sets %}
from e3sm_diags.parameter.tropical_subseasonal_parameter import TropicalSubseasonalParameter
{%- endif %}
from e3sm_diags.run import runner
Expand Down Expand Up @@ -363,6 +372,34 @@ if {{ swap_test_ref }}:
params.append(enso_param)
{%- endif %}
{%- if "tropical_subseasonal" in sets %}
trop_param = TropicalSubseasonalParameter()
trop_param.test_data_path = '${ts_daily_dir}'
trop_param.test_name = short_name
trop_param.test_start_yr = f'{start_yr:04}'
trop_param.test_end_yr = f'{end_yr:04}'
{% if run_type == "model_vs_obs" %}
# Obs
trop_param.reference_data_path = '{{ obs_ts }}'
trop_param.ref_start_yr = 2001
trop_param.ref_end_yr = 2010
{% elif run_type == "model_vs_model" %}
trop_param.reference_data_path = '${ts_daily_dir_ref}'
trop_param.ref_name = '${ref_name}'
trop_param.short_ref_name = '{{ short_ref_name }}'
ref_start_yr = {{ ref_start_yr }}
ref_end_yr = {{ ref_end_yr }}
trop_param.ref_start_yr = f'{ref_start_yr:04}'
trop_param.ref_end_yr = f'{ref_final_yr:04}'
# Optionally, swap test and reference model
if {{ swap_test_ref }}:
trop_param.test_data_path, trop_param.reference_data_path = trop_param.reference_data_path, trop_param.test_data_path
trop_param.test_name, trop_param.ref_name = trop_param.ref_name, trop_param.test_name
trop_param.short_test_name, trop_param.short_ref_name = trop_param.short_ref_name, trop_param.short_test_name
{%- endif %}
params.append(trop_param)
{%- endif %}
{%- if "qbo" in sets %}
qbo_param = QboParameter()
Expand Down

0 comments on commit bab6b25

Please sign in to comment.