Conversation
| cube.add_aux_coord(dim_coord, coord_dim) | ||
|
|
||
|
|
||
| def _num2date_to_nearest_second(time_value, units): |
There was a problem hiding this comment.
I think that this function may prove to be useful for users experiencing issues with netcdf4 times
I think that it is worth considering making it public and adapting the first few comment lines as the docstring.
I would likely leave the note that this behaviour... as a developer comment and not include it in teh docstring in this case
|
this looks like a sensible and well crafted change. It deals with a set of known issues within netcdf4-python and should make Iris less fragile with respect to versions of netcdf4 the open question for me is the public/private nature of the |
Perhaps it could be added to the cf_units api, possibly as an optional argument to |
I like this apporach, I think that num <> date is already in scope for cf_units @bjlittle @pelson would you support this approach? |
|
The change has been made to cf_units (SciTools/cf-units#66) so this PR is no longer needed. |
Since the
netcdftime.datetimeobject now has microsecond precision, some tests are failing due to rounding errors.This change fixes the errors by introducing a function
num2date_to_nearest_second, which attempts to replicate the old behaviour ofnetcdftime.num2date(although it accepts acf_units.Unitrather than unit string and calendar arguments.)I say 'attempts' because when
num2dateis given a value in seconds representing a time with a half second, it will round it up or down arbitrarily, and it is apparently impossible to replicate this behaviour with the new version. The new function will always round up.