Skip to content

Commit

Permalink
Fix bug in TsDistributor
Browse files Browse the repository at this point in the history
  • Loading branch information
wpreimes committed Aug 24, 2023
1 parent 9de477d commit 28f0eaa
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/pytesmo/time_series/grouping.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,23 +368,22 @@ def filter(self, idx: pd.DatetimeIndex):
if self.yearless_date_ranges is not None:
for i, gdrange in enumerate(self.yearless_date_ranges):
for y in np.unique(idx.year):
start = gdrange[0]

if not calendar.isleap(y) and (gdrange[0].doy == 60):
start = YearlessDatetime(3, 1)
else:
start = gdrange[0]

if (not calendar.isleap(y)) and (gdrange[1].doy == 60):
end = YearlessDatetime(2, 28, 23, 59, 59)
else:
end = gdrange[1]

start_dt = start.to_datetime(years=y)

end = gdrange[1]

if end < start:
end_dt = end.to_datetime(years=y + 1)
else:
end_dt = end.to_datetime(years=y)
y += 1

if (not calendar.isleap(y)) and (end.doy == 60):
end = YearlessDatetime(2, 28, 23, 59, 59)

end_dt = end.to_datetime(years=y)

mask[f"gen_range{y}-{i}"] = (idx >= start_dt) & (
idx <= end_dt)
Expand Down

0 comments on commit 28f0eaa

Please sign in to comment.