Skip to content

Commit a67d3a1

Browse files
Bugfix/adjust (#92)
* 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>
1 parent e6ba2ee commit a67d3a1

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ Keep it human-readable, your future self will thank you!
1010

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

13+
### Changed
14+
15+
- Bugfix in `auto_adjust`
1316

1417
### Added
1518

src/anemoi/datasets/data/misc.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,16 +235,21 @@ def _auto_adjust(datasets, kwargs):
235235
if set(d.variables) != variables:
236236
subset_kwargs[i]["select"] = sorted(variables)
237237

238+
if "start" or "end" in adjust_set:
239+
common = datasets[0].dates
240+
for d in datasets[0:]:
241+
common = np.intersect1d(common, d.dates)
242+
238243
if "start" in adjust_set:
239244
assert "start" not in kwargs, "Cannot use 'start' in adjust and kwargs"
240-
start = max(d.dates[0] for d in datasets).astype(object)
245+
start = min(common).astype(object)
241246
for i, d in enumerate(datasets):
242247
if start != d.dates[0]:
243248
subset_kwargs[i]["start"] = start
244249

245250
if "end" in adjust_set:
246251
assert "end" not in kwargs, "Cannot use 'end' in adjust and kwargs"
247-
end = min(d.dates[-1] for d in datasets).astype(object)
252+
end = max(common).astype(object)
248253
for i, d in enumerate(datasets):
249254
if end != d.dates[-1]:
250255
subset_kwargs[i]["end"] = end

0 commit comments

Comments
 (0)