Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rounding of Pandas datetimes in ICON CMORizer #2529

Merged
merged 10 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies:
- netcdf4
- numpy !=1.24.3,<2.0.0 # avoid pulling 2.0.0rcX
- packaging
- pandas !=2.2.0,!=2.2.1,!=2.2.2 # github.com/ESMValGroup/ESMValCore/pull/2305 and #2349
- pandas
- pillow
- pip !=21.3
- prov
Expand Down
7 changes: 5 additions & 2 deletions esmvalcore/cmor/_fixes/icon/icon.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,11 @@ def _fix_invalid_time_units(time_coord):
# Finally, add date and day fraction to get final datetime and convert
# it to correct units. Note: we also round to next second, otherwise
# this results in times that are off by 1s (e.g., 13:59:59 instead of
# 14:00:00).
rounded_datetimes = (year_month_day + day_float).round('s')
# 14:00:00). We round elements individually since rounding the
# pd.Series object directly is broken
# (https://github.com/pandas-dev/pandas/issues/57002).
datetimes = year_month_day + day_float
rounded_datetimes = pd.Series(dt.round('s') for dt in datetimes)
with warnings.catch_warnings():
# We already fixed the deprecated code as recommended in the
# warning, but it still shows up -> ignore it
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
'netCDF4',
'numpy!=1.24.3,<2.0.0', # avoid pulling 2.0.0rc1
'packaging',
'pandas!=2.2.0,!=2.2.1,!=2.2.2', # GH #2305 #2349 etc
'pandas',
'pillow',
'prov',
'psutil',
Expand Down