Convert a `numpy.ndarray` of np.datetime64 to Gregorian date as UTC float relative to the epoch (see `.get_epoch`). Roundoff is float64 precision. Practically: microseconds for dates between 290301 BC, 294241 AD, milliseconds for larger dates (see `numpy.datetime64`).
(d)
| 308 | |
| 309 | |
| 310 | def _dt64_to_ordinalf(d): |
| 311 | """ |
| 312 | Convert a `numpy.ndarray` of np.datetime64 to |
| 313 | Gregorian date as UTC float relative to the epoch (see `.get_epoch`). |
| 314 | Roundoff is float64 precision. Practically: microseconds for dates |
| 315 | between 290301 BC, 294241 AD, milliseconds for larger dates |
| 316 | (see `numpy.datetime64`). |
| 317 | """ |
| 318 | |
| 319 | # the "extra" ensures that we at least allow the dynamic range out to |
| 320 | # seconds. That should get out to +/-2e11 years. |
| 321 | dseconds = d.astype('datetime64[s]') |
| 322 | extra = (d - dseconds).astype('timedelta64[ns]') |
| 323 | t0 = np.datetime64(get_epoch(), 's') |
| 324 | dt = (dseconds - t0).astype(np.float64) |
| 325 | dt += extra.astype(np.float64) / 1.0e9 |
| 326 | dt = dt / SEC_PER_DAY |
| 327 | |
| 328 | dt[np.isnat(d)] = np.nan |
| 329 | return dt |
| 330 | |
| 331 | |
| 332 | def _from_ordinalf(x, tz=None): |