Skip to content

Commit

Permalink
Merge pull request #204 from aspitarl/dt-ns-fix
Browse files Browse the repository at this point in the history
change _diff_coord to use nanosecond precision
  • Loading branch information
roxyboy authored Jul 1, 2024
2 parents 1a9b8af + b23caad commit 83b0a75
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion xrft/xrft.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ def _diff_coord(coord):
coord = xr.DataArray(decoded_time, dims=coord.dims, coords=coord.coords)
return np.diff(coord)
elif pd.api.types.is_datetime64_dtype(v0):
return np.diff(coord).astype("timedelta64[s]").astype("f8")
diff = np.diff(coord).astype("timedelta64[ns]").astype("f8")
diff = (diff/1e9) #convert back to seconds
return diff
else:
return np.diff(coord)

Expand Down

0 comments on commit 83b0a75

Please sign in to comment.