Skip to content

Commit

Permalink
Bugfix/adjust (#92)
Browse files Browse the repository at this point in the history
* bugfix

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update changelog

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
mpvginde and pre-commit-ci[bot] authored Oct 23, 2024
1 parent e6ba2ee commit a67d3a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Keep it human-readable, your future self will thank you!

## [Unreleased](https://github.com/ecmwf/anemoi-datasets/compare/0.5.7...HEAD)

### Changed

- Bugfix in `auto_adjust`

### Added

Expand Down
9 changes: 7 additions & 2 deletions src/anemoi/datasets/data/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,16 +235,21 @@ def _auto_adjust(datasets, kwargs):
if set(d.variables) != variables:
subset_kwargs[i]["select"] = sorted(variables)

if "start" or "end" in adjust_set:
common = datasets[0].dates
for d in datasets[0:]:
common = np.intersect1d(common, d.dates)

if "start" in adjust_set:
assert "start" not in kwargs, "Cannot use 'start' in adjust and kwargs"
start = max(d.dates[0] for d in datasets).astype(object)
start = min(common).astype(object)
for i, d in enumerate(datasets):
if start != d.dates[0]:
subset_kwargs[i]["start"] = start

if "end" in adjust_set:
assert "end" not in kwargs, "Cannot use 'end' in adjust and kwargs"
end = min(d.dates[-1] for d in datasets).astype(object)
end = max(common).astype(object)
for i, d in enumerate(datasets):
if end != d.dates[-1]:
subset_kwargs[i]["end"] = end
Expand Down

0 comments on commit a67d3a1

Please sign in to comment.