parcels icon indicating copy to clipboard operation
parcels copied to clipboard

Support timedelta in Fields

Open VeckoTheGecko opened this issue 9 months ago • 1 comments

Support time dimension in Field to be timedelta array (to support those wanting to work with analytical fields).

Those with time dimension as float will need to convert their time dimension to timedelta (or datetime).

Details:

  • Extend TimeInterval to also allow timedelta as input.
  • Update time.is_compatible to fail if left or right is timedelta and other is not

VeckoTheGecko avatar Jun 11 '25 13:06 VeckoTheGecko

Note that this would be limited to the np.timedelta objects as that is what is supported in xarray https://docs.xarray.dev/en/latest/user-guide/time-series.html (if users provide datetime.timedelta as input into pset.execute). ~~I think we should further limit to second precision in the internal model for Parcels (so that it simplifies arithmetic internally). This can be asserted in the initialiser, and when users call the methods this conversion can be done automatically.~~. Hmm. Actually it looks like this conversion is automatically handled by numpy and automatically converts the precisions, for some reason I didn't think that it did that.

VeckoTheGecko avatar Jun 13 '25 15:06 VeckoTheGecko