MAVENSDC / cdflib

A python module for reading NASA's Common Data Format (cdf) files
MIT License
82 stars 45 forks source link

Use nanosecond precision when returning datetime64 objects from to_datetime() #242

Closed jameswilburlewis closed 5 months ago

jameswilburlewis commented 6 months ago

to_datetime() currently returns numpy datetime64 objects with microsecond precision. This causes warnings when passing them to the xarray DataArray constructor. See: https://github.com/MAVENSDC/cdflib/issues/236

Changing to nanosecond precision eliminates the warnings.

bryan-harter commented 6 months ago

Thanks! I was curious if this was a design choice, but I believe the micro-second precision was a relic of this function once returning the regular python "datetime" object.

I'm pretty sure everything will be fine if we now have it return nanoseconds. It does look like the unit tests need to be updated though, specifically test_parse_cdfepoch16 fails simply because its more precise now

bryan-harter commented 5 months ago

The newest version of to_datetime has this feature in it, thanks!

bryan-harter commented 5 months ago

Feel free to reopen this though if you're still seeing the warning in 1.3.0