Skip to content

Commit ec64df5

Browse files
authored
Merge pull request #16 from LIVVkit/mkstratos/mvkxx
Add MVKxx to K-S test
2 parents 01b0e09 + 62bcbca commit ec64df5

File tree

13 files changed

+320
-189
lines changed

13 files changed

+320
-189
lines changed

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
python-version: ["3.9", "3.10", "3.11", "3.12"]
19+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
2020

2121
steps:
2222
- uses: actions/checkout@v4

.pre-commit-config.yaml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.0.1
3+
rev: v6.0.0
44
hooks:
55
- id: end-of-file-fixer
66
- id: trailing-whitespace
77
- id: check-toml
8-
- repo: https://github.com/psf/black
9-
rev: 22.3.0
10-
hooks:
11-
- id: black
12-
- repo: https://github.com/pycqa/isort
13-
rev: 5.13.2
14-
hooks:
15-
- id: isort
8+
- id: check-yaml
9+
args: [--unsafe]
10+
- id: debug-statements
11+
- id: destroyed-symlinks
12+
- id: detect-private-key
1613
- repo: https://github.com/astral-sh/ruff-pre-commit
1714
# Ruff version.
18-
rev: v0.3.7
15+
rev: v0.13.0
1916
hooks:
2017
# Run the linter.
21-
- id: ruff
18+
- id: ruff-check
19+
# Run the formatter.
20+
- id: ruff-format
21+
args: [--verbose]
22+
- repo: https://github.com/pycqa/isort
23+
rev: 6.0.1
24+
hooks:
25+
- id: isort

evv4esm/ensembles/e3sm.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ def file_date_str(case_file, style="short", hist_name="h0"):
5757
search_regex = r"{}\.[0-9]+-[0-9]+.nc".format(hist_name)
5858
else:
5959
search_regex = r"{}\.[0-9]+-[0-9]+.nc".format(hist_name)
60-
6160
result = re.search(search_regex, case_file).group(0)
6261
return result.replace("{}.".format(hist_name), "").replace(".nc", "")
6362

@@ -103,13 +102,13 @@ def get_variable_meta(dataset, var_name):
103102
return {"long_name": _name, "units": _units}
104103

105104

106-
def gather_monthly_averages(ensemble_files, variable_set=None):
105+
def gather_monthly_averages(ensemble_files, variable_set=None, hist_name="h0"):
107106
monthly_avgs = []
108107
for case, inst_dict in six.iteritems(ensemble_files):
109108
for inst, i_files in six.iteritems(inst_dict):
110109
# Get monthly averages from files
111110
for file_ in i_files:
112-
date_str = file_date_str(file_)
111+
date_str = file_date_str(file_, hist_name=hist_name)
113112

114113
data = None
115114
try:

evv4esm/ensembles/tools.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030

3131
"""General tools for working with ensembles."""
32+
3233
import os
3334

3435
import matplotlib.pyplot as plt

evv4esm/extensions/ks.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def parse_args(args=None):
122122
"--ninst",
123123
default=30,
124124
type=int,
125-
help="The number of instances (should be the same for " "both cases).",
125+
help="The number of instances (should be the same for both cases).",
126126
)
127127

128128
parser.add_argument(
@@ -158,6 +158,13 @@ def parse_args(args=None):
158158
"--alpha", default=0.05, type=float, help="Alpha threshold for pass / fail"
159159
)
160160

161+
parser.add_argument(
162+
"--hist-name",
163+
default="h0",
164+
help="History file extension [eam: h0, scream: h, mpas: hist], default: h0",
165+
type=str,
166+
)
167+
161168
args, _ = parser.parse_known_args(args)
162169

163170
# use config file arguments, but override with command line arguments
@@ -287,10 +294,13 @@ def case_files(args):
287294
if args.test_case == args.ref_case:
288295
key1 += "1"
289296
key2 += "2"
290-
291297
f_sets = {
292-
key1: e3sm.component_monthly_files(args.test_dir, args.component, args.ninst),
293-
key2: e3sm.component_monthly_files(args.ref_dir, args.component, args.ninst),
298+
key1: e3sm.component_monthly_files(
299+
args.test_dir, args.component, args.ninst, hist_name=args.hist_name
300+
),
301+
key2: e3sm.component_monthly_files(
302+
args.ref_dir, args.component, args.ninst, hist_name=args.hist_name
303+
),
294304
}
295305

296306
for key in f_sets:
@@ -428,7 +438,9 @@ def main(args):
428438
args.test_case = key1
429439
args.ref_case = key2
430440

431-
monthly_avgs = e3sm.gather_monthly_averages(ens_files, args.var_set)
441+
monthly_avgs = e3sm.gather_monthly_averages(
442+
ens_files, args.var_set, hist_name=args.hist_name
443+
)
432444
annual_avgs = (
433445
monthly_avgs.groupby(["case", "variable", "instance"])
434446
.monthly_mean.aggregate(monthly_to_annual_avg)

0 commit comments

Comments
 (0)