xarray_assign_polyfit_stddev

PlasmaCalcs.tools.xarray_tools.xarray_sci.xarray_assign_polyfit_stddev(dataset, *, keep_cov=True)

assign polyfit stddev to dataset[‘polyfit_stddev’], treating dataset like a result of polyfit.

These provide some measure of “goodness of fit”; smaller stddev means better fit.
Specifically, stddev[k] = (covariance matrix)[k,k]**0.5 for k in range(len(dataset[‘degree’]));
one might quote +-stddev[k] as the error bar for the coefficient at degree=dataset[‘degree’][k].
dataset: xarray.Dataset
dataset to use for calculating polyfit_stderr and in which to assign the result.
must contain variable ‘polyfit_covariance’ and dimension ‘degree’.
keep_cov: bool
whether to keep the ‘polyfit_covariance’ and ‘polyfit_residuals’ vars in the result.
The original dataset will not be altered; a new dataset will be returned.