Open riley-brady opened 2 years ago
OK that wont work but it should have not gone down this code path at all in xarray. But it looks like I only tested pure pint arrays not pint + dask: https://github.com/pydata/xarray/blob/50ea159bfd0872635ebf4281e741f3c87f0bef6b/xarray/core/utils.py#L980
It'd be nice to add full pint support here but it'll be a bit of effort. Are you interested in working on it?
@dcherian sorry for the delay here. I could work on this effort, but unfortunately only on weekends, so it might be a long process. I would appreciate some guidance if you have some time (either over chat here or a zoom call) on which parts of the code to target, since I haven't worked closely with the package.
My current solution is to dequantify
, run resample()
or whichever other method this is happening on, and then quantify
, which isn't ideal but works. The error message is not super clear, so I'm not sure that's a sustainable solution for the community as a whole.
Thanks for offering to help @riley-brady
My current solution is to dequantify, run resample() or whichever other method this is happening on, and then quantify, which isn't ideal but works.
I think this is what we'll have to do since pint's support for ufuncs isn't great apparently.
lets strip array units if any right at the beginning, and reapply it at the end https://github.com/xarray-contrib/flox/blob/e3ea0e75a19c867aa6d6858cdf94810c0741a74b/flox/core.py#L1641
by
but I think that's OK for now? Alternatively you could again dequantify and then quantify after compute.getattr(numpy, agg.name)(Quantity([1, 1,], dtype=array.dtype, units=array.units)
So basically run the aggregation on a small problem to determine what the output units are (necessary for any
, all
, var
, arg*
for e.g.), and apply that at the end. This approach won't work for "custom aggregations" but we can deal with that later when we need to.
After upgrading to the latest
xarray
version and installingflox
, I find that chunkedpint
arrays break with the.resample()
method. I'm posting this here instead ofpint_xarray
since it looks like from the traceback this is coming fromflox
.I imagine this has to do with the complexity of working with duck-arrays like
pint_xarray
.Possible related threads: