Skip to content
Merged
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
7 changes: 6 additions & 1 deletion lib/iris/fileformats/pp_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,12 @@ def _convert_time_coords(lbcode, lbtim, epoch_hours_unit,

"""
def date2hours(t):
epoch_hours = epoch_hours_unit.date2num(t)
# netcdf4python has changed it's behaviour, at version 1.2, such
# that a date2num calculation returns a python float, not
# numpy.float64. The behaviour of round is to recast this to an
# int, which is not the desired behaviour for PP files.
# So, cast the answer to numpy.float_ to be safe.
epoch_hours = np.float_(epoch_hours_unit.date2num(t))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marqh OMGosh ... thanks for digging!

if t.minute == 0 and t.second == 0:
epoch_hours = round(epoch_hours)
return epoch_hours
Expand Down