xarray-contrib / pint-xarray

Interface for using pint with xarray, providing convenience accessors
https://pint-xarray.readthedocs.io/en/latest/
Apache License 2.0
101 stars 12 forks source link

Draft: add wraps_ufunc decorator #203

Open tbody-cfs opened 1 year ago

tbody-cfs commented 1 year ago
tbody-cfs commented 1 year ago

Hi, Thanks for making a great project — I've always wanted xarray to support pint units. Dropping here in case it's useful — I often need to use functions written for float or numpy arrays. To handle units I'd use ureg.wraps and to handle xarrays I'd use apply_ufunc. I've looked at the inner workings of ureg.wraps and tried to approximate it, adding in apply_ufunc.

If this seems helpful, I could tidy it up. If you've got a better way of doing this, I'd be very happy to hear :)

tbody-cfs commented 1 year ago

This might be a duplicate of https://github.com/xarray-contrib/pint-xarray/pull/143.

keewis commented 1 year ago

thanks for the PR and sorry for the delay, @tbody-cfs. This is definitely something on our roadmap, but unfortunately I didn't have too much time to work on this in the past few months.

Indeed, this PR is a duplicate of #143, which as an initial version should be very close. However, I fear we didn't try using too much, yet, so the API might not be as useful as we thought it would be (and of course there might be bugs). If you want to help moving that forward, I think it would be great to just experiment with expects and report your findings in #143 (and post any questions / feedback you might have).