Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mean climate 3d field vertical coordinate QC #978

Merged
merged 13 commits into from
Sep 19, 2023
Prev Previous commit
Next Next commit
add option for realization selection: first only realization
  • Loading branch information
lee1043 committed Aug 23, 2023
commit 51d301f9f90d466633b09a9a04f1a30a173e8657
9 changes: 8 additions & 1 deletion pcmdi_metrics/mean_climate/mean_climate_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
mean_climate_metrics_to_json,
)
from pcmdi_metrics.variability_mode.lib import tree
from pcmdi_metrics.variability_mode.lib import sort_human


parser = create_mean_climate_parser()
Expand Down Expand Up @@ -59,13 +60,16 @@
diagnostics_output_path = diagnostics_output_path.replace('%(case_id)', case_id)

find_all_realizations = False
first_realization_only = False
if realization is None:
realization = ""
realizations = [realization]
elif isinstance(realization, str):
if realization.lower() in ["all", "*"]:
find_all_realizations = True
realizations = "Search for all realizations!!"
elif realization.lower() in ["first", "first_only"]:
first_realization_only = True
else:
realizations = [realization]

Expand Down Expand Up @@ -206,7 +210,7 @@

result_dict["RESULTS"][model][ref]["source"] = ref_dataset_name

if find_all_realizations:
if find_all_realizations or first_realization_only:
test_data_full_path = os.path.join(
test_data_path,
filename_template).replace('%(variable)', varname).replace('%(model)', model).replace('%(model_version)', model).replace('%(realization)', '*')
Expand All @@ -215,6 +219,9 @@
realizations = []
for ncfile in ncfiles:
realizations.append(ncfile.split('/')[-1].split('.')[3])
realizations = sort_human(realizations)
if first_realization_only:
realizations == realizations[0:1]
print('realizations (after search): ', realizations)

for run in realizations:
Expand Down