Skip to content

Commit

Permalink
Merge pull request #96 from CIAT-DAPA/develop
Browse files Browse the repository at this point in the history
fix season check to do the addition of 29 day in case of leap year
  • Loading branch information
santiago123x authored Oct 15, 2024
2 parents bb473fa + c26a74d commit c5ed81b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/aclimate_resampling/resampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,12 @@ def forecast_station(self, station, prob, daily_data_root, output_root, year_for

# Adjust the year if the forecast period is 'tri' if necessary
for idx2, sublist2 in enumerate(seasons_1):
if season == sublist2:
year_forecast = year_forecast+1
if any(s in sublist2 for s in season):
year_forecast += 1
break

# Check if year of forecast is a leap year for February
leap_forecast = ((year_forecast %400 == 0) and (year_forecast % 100 == 0)) or ((year_forecast%4==0) and (year_forecast%100!=0))
leap_forecast = (year_forecast % 4 == 0) and (year_forecast % 100 != 0 or year_forecast % 400 == 0)

# Filter the February data for leap years
clim_feb = clim.loc[clim['month'] == 2]
Expand Down

0 comments on commit c5ed81b

Please sign in to comment.