Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
cutout
Browse files Browse the repository at this point in the history
b8raoult committed Feb 27, 2024
1 parent 711bb05 commit cf42cdb
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ecml_tools/__init__.py
Original file line number Diff line number Diff line change
@@ -5,4 +5,4 @@
# granted to it by virtue of its status as an intergovernmental organisation
# nor does it submit to any jurisdiction.

__version__ = "0.4.7"
__version__ = "0.4.8"
19 changes: 12 additions & 7 deletions ecml_tools/data.py
Original file line number Diff line number Diff line change
@@ -1043,6 +1043,9 @@ def frequency(self):
def source(self, index):
return Source(self, index, self.forward.source(index))

def __repr__(self):
return f"Subset({self.dates[0]}, {self.dates[-1]}, {self.frequency})"


class Select(Forwards):
"""
@@ -1317,8 +1320,8 @@ def _auto_adjust(datasets, kwargs):
"""Adjust the datasets for concatenation or joining based
on parameters set to 'matching'"""

if kwargs.get("ajust") == "matching":
kwargs.pop("ajust")
if kwargs.get("adjust") == "matching":
kwargs.pop("adjust")
for p in ("select", "frequency", "start", "end"):
kwargs[p] = "matching"

@@ -1327,27 +1330,29 @@ def _auto_adjust(datasets, kwargs):
if kwargs.get("select") == "matching":
kwargs.pop("select")
variables = None

for d in datasets:
if variables is None:
variables = set(d.variables)
else:
variables &= set(d.variables)

if len(variables) == 0:
raise ValueError("No common variables")

adjust["select"] = sorted(variables)

if kwargs.get("frequency") == "matching":
kwargs.pop("frequency")
adjust["frequency"] = max(d.frequency for d in datasets)

if kwargs.get("start") == "matching":
kwargs.pop("start")
adjust["start"] = max(d.dates[0] for d in datasets).astype(object)

if kwargs.get("end") == "matching":
kwargs.pop("end")
adjust["end"] = max(d.dates[-1] for d in datasets).astype(object)
adjust["end"] = min(d.dates[-1] for d in datasets).astype(object)

if kwargs.get("frequency") == "matching":
kwargs.pop("frequency")
adjust["frequency"] = max(d.frequency for d in datasets)

if adjust:
datasets = [d._subset(**adjust) for d in datasets]

0 comments on commit cf42cdb

Please sign in to comment.