Open LukeJones123 opened 4 months ago
@LukeJones123 Sorry for the delay here. It seems that both unit-strings are valid ISO 8601 datetime strings and refer to the same time. So technically this is no bug, but nevertheless we should enforce similar behaviour.
Thanks. It would be very useful for us because in our organisation we try to supply stable and consistent netCDF to external users (for whom stability and consistency are very important) and it currently means the time units string changes under certain circumstances.
What happened?
I want to write a dataset containing a time variable to netCDF. I specify the units I want in the variable encoding, but the precise string I specify is only written if the time values are a dask array. Otherwise, a "cleaned up" version is written in which the part of the string is removed.
What did you expect to happen?
The time units string written shouldn't depend on whether the time values are a dask array or not.
The "clean up" of the units string is done in _eagerly_encode_cf_datetime but is ignored (only) for dask arrays in _lazily_encode_cf_datetime. They should both behave the same.
Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
Anything else we need to know?
This is related to, but not the same as, #1449 and #8137. A solution to those issues would likely also be a solution to this one. I see no reason for the cleanup in _eagerly_encode_cf_datetime persisting through to the output file, so I think these strings should be written as they are.
Environment