spedas / pyspedas

Python-based Space Physics Environment Data Analysis Software
https://pyspedas.readthedocs.io/
MIT License
143 stars 58 forks source link

pytplot.derive does not account for timestamp resolution #842

Open jameswilburlewis opened 2 months ago

jameswilburlewis commented 2 months ago

pytplot.derive calls xarray's DataArray.differentiate function, but doesn't pass anything in the datetime_unit parameter. It seems to assume units of seconds, but the tplot variable will either be a Python datatime object (resolution in seconds) or a numpy datetime64 object (nanoseconds). So the results are off by a large factor. deriv_data seems to do the right thing (by using get_data to convert back to seconds), so maybe pytplot.derive should be retired.