Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
Expand Down
26 changes: 15 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1
rev: v6.0.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-toml
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
- id: check-yaml
args: [--unsafe]
- id: debug-statements
- id: destroyed-symlinks
- id: detect-private-key
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.3.7
rev: v0.13.0
hooks:
# Run the linter.
- id: ruff
- id: ruff-check
# Run the formatter.
- id: ruff-format
args: [--verbose]
- repo: https://github.com/pycqa/isort
rev: 6.0.1
hooks:
- id: isort
5 changes: 2 additions & 3 deletions evv4esm/ensembles/e3sm.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def file_date_str(case_file, style="short", hist_name="h0"):
search_regex = r"{}\.[0-9]+-[0-9]+.nc".format(hist_name)
else:
search_regex = r"{}\.[0-9]+-[0-9]+.nc".format(hist_name)

result = re.search(search_regex, case_file).group(0)
return result.replace("{}.".format(hist_name), "").replace(".nc", "")

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


def gather_monthly_averages(ensemble_files, variable_set=None):
def gather_monthly_averages(ensemble_files, variable_set=None, hist_name="h0"):
monthly_avgs = []
for case, inst_dict in six.iteritems(ensemble_files):
for inst, i_files in six.iteritems(inst_dict):
# Get monthly averages from files
for file_ in i_files:
date_str = file_date_str(file_)
date_str = file_date_str(file_, hist_name=hist_name)

data = None
try:
Expand Down
1 change: 1 addition & 0 deletions evv4esm/ensembles/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

"""General tools for working with ensembles."""

import os

import matplotlib.pyplot as plt
Expand Down
22 changes: 17 additions & 5 deletions evv4esm/extensions/ks.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def parse_args(args=None):
"--ninst",
default=30,
type=int,
help="The number of instances (should be the same for " "both cases).",
help="The number of instances (should be the same for both cases).",
)

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

parser.add_argument(
"--hist-name",
default="h0",
help="History file extension [eam: h0, scream: h, mpas: hist], default: h0",
type=str,
)

args, _ = parser.parse_known_args(args)

# use config file arguments, but override with command line arguments
Expand Down Expand Up @@ -287,10 +294,13 @@ def case_files(args):
if args.test_case == args.ref_case:
key1 += "1"
key2 += "2"

f_sets = {
key1: e3sm.component_monthly_files(args.test_dir, args.component, args.ninst),
key2: e3sm.component_monthly_files(args.ref_dir, args.component, args.ninst),
key1: e3sm.component_monthly_files(
args.test_dir, args.component, args.ninst, hist_name=args.hist_name
),
key2: e3sm.component_monthly_files(
args.ref_dir, args.component, args.ninst, hist_name=args.hist_name
),
}

for key in f_sets:
Expand Down Expand Up @@ -428,7 +438,9 @@ def main(args):
args.test_case = key1
args.ref_case = key2

monthly_avgs = e3sm.gather_monthly_averages(ens_files, args.var_set)
monthly_avgs = e3sm.gather_monthly_averages(
ens_files, args.var_set, hist_name=args.hist_name
)
annual_avgs = (
monthly_avgs.groupby(["case", "variable", "instance"])
.monthly_mean.aggregate(monthly_to_annual_avg)
Expand Down
Loading