Skip to content

Commit

Permalink
making year in extract_time possible as None
Browse files Browse the repository at this point in the history
  • Loading branch information
Elizaveta Malinina committed Jul 24, 2024
1 parent 7884e2c commit 494fc5f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions esmvalcore/preprocessor/_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def extract_time(
start_year: int | None,
start_month: int,
start_day: int,
end_year: int | None,
end_year: int | None ,
end_month: int,
end_day: int,
) -> Cube:
Expand Down Expand Up @@ -111,7 +111,7 @@ def extract_time(
end_year = int(end_year)
if (isinstance(start_year, int) ^ isinstance(end_year, int)):
raise ValueError("If start_year or end_year is None, both "
"start_year and end_year have to be None."
"start_year and end_year have to be None. "
f"Currently, start_year is {start_year} "
f"and end_year is {end_year}.")

Expand Down Expand Up @@ -227,7 +227,7 @@ def _extract_datetime(
if isinstance(end_datetime.day, int) and end_datetime.day > 30:
end_datetime.day = 30

if not cube.coord_dims(time_coord):
if (not cube.coord_dims(time_coord)) | (start_datetime.year == None):
constraint = iris.Constraint(
time=lambda t: start_datetime <= t.point < end_datetime)
cube_slice = cube.extract(constraint)
Expand Down

0 comments on commit 494fc5f

Please sign in to comment.