def error_resampler(errors):
"""
For use with ``pandas``.
Method for performing the proper ``mean`` resampling of the *uncertainties* (error bars)
in the time series with ``pandas``. Note that doing a simple resampling
will fail to propagate uncertainties, since error in the mean goes as
.. math:: \sigma=\sqrt{\Sigma_n \sigma_n^2}
Example: Resamples the errors with 30 day averages:
::
# df['errflux'] has the 1sigma uncertainties
err=df['errflux'].resample('30d').apply(nmmn.dsp.error_resampler)
# plot y-values (df['flux']) with errors (err)
df['flux'].resample('30d').mean().plot(yerr=err)
"""
err=errors**2
return numpy.sqrt(err.sum())/err.size
评论列表
文章目录