|
1 | 1 | """ |
2 | | -Ensemble Statistical Test using multi-instance capability. |
| 2 | +Reproducible Climate Statistics testing using multi-instance capability. |
3 | 3 |
|
4 | 4 | This test runs multiple EAMxx instances with different perturbation seeds |
5 | 5 | and uses statistical tests to verify that the climate state is identical |
6 | 6 | between different runs. |
7 | 7 |
|
8 | | -EST inherits from SystemTestsCommon and only overrides: |
| 8 | +RCS inherits from SystemTestsCommon and only overrides: |
9 | 9 | - setup_phase (to setup multi-instance with per-instance perturbed seeds) |
10 | 10 | - _generate_baseline (move needed hist files to baseline directory) |
11 | 11 | - _compare_baseline methods (to run the statistical tests) |
12 | 12 |
|
13 | | -EST relies on two util files: |
14 | | -- est_perts.py: functions to duplicate and modify yaml files |
15 | | -- est_stats.py: functions to conduct statistical testing |
| 13 | +RCS relies on two util files: |
| 14 | +- rcs_perts.py: functions to duplicate and modify yaml files |
| 15 | +- rcs_stats.py: functions to conduct statistical testing |
16 | 16 | """ |
17 | 17 |
|
18 | 18 | import os |
|
30 | 30 |
|
31 | 31 |
|
32 | 32 | # pylint: disable=too-few-public-methods |
33 | | -class EST(SystemTestsCommon): |
34 | | - """Ensemble Statistical Test using multi-instance capability""" |
| 33 | +class RCS(SystemTestsCommon): |
| 34 | + """Reproducible Climate Statistics Test using multi-instance capability""" |
| 35 | + |
| 36 | + # File pattern for multi-instance ensemble output files |
| 37 | + # Use ???? as placeholder for 4-digit instance number |
| 38 | + ENSEMBLE_FILE_PATTERN = "*.scream_????.h.AVERAGE.*.nc" |
35 | 39 |
|
36 | 40 | # pylint: disable=too-many-arguments, too-many-positional-arguments |
37 | 41 | def setup_phase( |
@@ -72,19 +76,19 @@ def setup_phase( |
72 | 76 | ) |
73 | 77 | raise ValueError(msg) |
74 | 78 |
|
75 | | - # get est_perts functions |
| 79 | + # get rcs_perts functions |
76 | 80 | # but first add the directory to sys.path if not already there |
77 | | - est_perts_path = os.path.join( |
78 | | - os.path.dirname(__file__), 'est_perts.py' |
| 81 | + rcs_perts_path = os.path.join( |
| 82 | + os.path.dirname(__file__), 'rcs_perts.py' |
79 | 83 | ) |
80 | | - if not os.path.exists(est_perts_path): |
| 84 | + if not os.path.exists(rcs_perts_path): |
81 | 85 | raise ImportError( |
82 | | - f"Cannot find est_perts.py at {est_perts_path}" |
| 86 | + f"Cannot find rcs_perts.py at {rcs_perts_path}" |
83 | 87 | ) |
84 | 88 | if os.path.dirname(__file__) not in sys.path: |
85 | 89 | sys.path.insert(0, os.path.dirname(__file__)) |
86 | 90 | # pylint: disable=import-outside-toplevel |
87 | | - from est_perts import duplicate_yaml_file, update_yaml_file |
| 91 | + from rcs_perts import duplicate_yaml_file, update_yaml_file |
88 | 92 |
|
89 | 93 | # duplicate the yaml files n_inst times |
90 | 94 | duplicate_yaml_file(f"{run_dir}/data/scream_input.yaml", n_inst) |
@@ -115,10 +119,9 @@ def _generate_baseline(self): |
115 | 119 | ) |
116 | 120 | run_dir = self._case.get_value("RUNDIR") |
117 | 121 |
|
118 | | - # for eamxx, we need to get all files that have |
119 | | - # *scream_????.h.*.nc added to this list |
| 122 | + # Get all files that match the ensemble pattern |
120 | 123 | hists = glob.glob( |
121 | | - os.path.join(run_dir, "*scream_????.h.AVERAGE.*.nc") |
| 124 | + os.path.join(run_dir, self.ENSEMBLE_FILE_PATTERN) |
122 | 125 | ) |
123 | 126 | hist_files = [os.path.basename(h) for h in hists] |
124 | 127 |
|
@@ -162,28 +165,30 @@ def _compare_baseline(self): |
162 | 165 | ) |
163 | 166 |
|
164 | 167 | # launch the statistics tests |
165 | | - # first, import est_stats funcs from the other file |
166 | | - est_stats_path = os.path.join( |
167 | | - os.path.dirname(__file__), 'est_stats.py' |
| 168 | + # first, import rcs_stats funcs from the other file |
| 169 | + rcs_stats_path = os.path.join( |
| 170 | + os.path.dirname(__file__), 'rcs_stats.py' |
168 | 171 | ) |
169 | | - if not os.path.exists(est_stats_path): |
| 172 | + if not os.path.exists(rcs_stats_path): |
170 | 173 | raise ImportError( |
171 | | - f"Cannot find est_stats.py at {est_stats_path}" |
| 174 | + f"Cannot find rcs_stats.py at {rcs_stats_path}" |
172 | 175 | ) |
173 | 176 | # Add the directory to sys.path if not already there |
174 | 177 | if os.path.dirname(__file__) not in sys.path: |
175 | 178 | sys.path.insert(0, os.path.dirname(__file__)) |
176 | 179 | # note be extra safe and import whole file |
177 | 180 | # because we want to avoid import errors of needed pkgs |
178 | 181 | # pylint: disable=import-outside-toplevel |
179 | | - import est_stats as est |
| 182 | + import rcs_stats as rcss |
180 | 183 | # now, launch |
181 | | - comments, new_ts = est.run_stats_comparison( |
| 184 | + comments, new_ts = rcss.run_stats_comparison( |
182 | 185 | run_dir, |
183 | 186 | base_dir, |
184 | 187 | analysis_type="spatiotemporal", |
185 | 188 | test_type="ks", |
186 | 189 | alpha=0.01, |
| 190 | + run_file_pattern=self.ENSEMBLE_FILE_PATTERN, |
| 191 | + base_file_pattern=self.ENSEMBLE_FILE_PATTERN, |
187 | 192 | ) |
188 | 193 |
|
189 | 194 | if new_ts == "PASS": |
|
0 commit comments