You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a set of measurement data with errors that vary across the measurements, and I would like to fit a polynomial to them. However, the w argument of DataArray.polyfit only accepts a one-dimensional array:
The w argument of DataArray.polyfit should accept a DataArray, which would be broadcast against the array that is being fit. Perhaps for Dataset, w could also be the name of a variable in the dataset that is then used as the weights.
Describe alternatives you've considered
I tried to work around this using curvefit, but that doesn't support multidimensional weights / sigma either, as they are passed through kwargs to scipy, and not broadcast on the xarray side. And even if it worked, I would need to manually define a polynomial function and to use polyval, I would have to juggle with the degree dimension.
My current workaround is to manually use apply_ufunc with vectorize=True, but there I ran into #9845.
Additional context
No response
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem?
I have a set of measurement data with errors that vary across the measurements, and I would like to fit a polynomial to them. However, the
w
argument ofDataArray.polyfit
only accepts a one-dimensional array:xarray/xarray/core/dataset.py
Lines 9165 to 9166 in 7fd572d
Here's a minimum example code snippet:
Describe the solution you'd like
The
w
argument ofDataArray.polyfit
should accept a DataArray, which would be broadcast against the array that is being fit. Perhaps forDataset
,w
could also be the name of a variable in the dataset that is then used as the weights.Describe alternatives you've considered
I tried to work around this using
curvefit
, but that doesn't support multidimensional weights / sigma either, as they are passed throughkwargs
to scipy, and not broadcast on the xarray side. And even if it worked, I would need to manually define a polynomial function and to usepolyval
, I would have to juggle with thedegree
dimension.My current workaround is to manually use
apply_ufunc
withvectorize=True
, but there I ran into #9845.Additional context
No response
The text was updated successfully, but these errors were encountered: