Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update xarray time derivative for subsecond precision #1217

Merged
merged 1 commit into from
Oct 28, 2019
Merged

Update xarray time derivative for subsecond precision #1217

merged 1 commit into from
Oct 28, 2019

Conversation

jthielen
Copy link
Collaborator

Description Of Changes

In working with some high-temporal-resolution data with MetPy and xarray, I realized that the xarray time derivative only allows precision to the nearest second, since I had implemented it via conversion to a Unix timestamp in #899. Oops!

This PR modifies this to use np.timedelta64[us] to permit microsecond precision instead, which should be fine enough for any meteorological application I can think of, but also coarse enough to fit climatological timescales in 64 bits (if I'm interpreting https://docs.scipy.org/doc/numpy/reference/arrays.datetime.html#datetime-units correctly).

Since DataArray.metpy.as_timestamp() was previously documented in the public API in #1175, I also deprecated it instead of removing it in favor of DataArray.metpy.time_deltas.

Also, should this be a property or method on the accessor?

Checklist

  • Tests added
  • Fully documented

@zbruick zbruick added this to the 0.12 milestone Oct 24, 2019
@zbruick zbruick added Area: Xarray Pertains to xarray integration Type: API Change Changes to how existing functionality works Type: Enhancement Enhancement to existing functionality labels Oct 24, 2019
@zbruick
Copy link
Contributor

zbruick commented Oct 24, 2019

Python 2 was just dropped, so this can be rebased to get CI passing. Otherwise this looks good to me.

@jthielen
Copy link
Collaborator Author

Just rebased, but there were also some strange errors on AppVeyor with the time delta somehow returning negative? (see https://ci.appveyor.com/project/Unidata/metpy/builds/28338909/job/u4v2ik490pnbe0yx) I have no idea what is going wrong there.

@jthielen
Copy link
Collaborator Author

After finally getting my windows test env back up and working, I think the issue was ndarray.astype('int') defaulting to int32 instead of int64 on windows. If so, it should hopefully be fixed now.

Copy link
Contributor

@zbruick zbruick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you caught the issue. Thanks for handling!

@zbruick zbruick merged commit 3193e9e into Unidata:master Oct 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Xarray Pertains to xarray integration Type: API Change Changes to how existing functionality works Type: Enhancement Enhancement to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants