# [AstroPy] Intelligent averaging of time series data

Peter Williams peter at newton.cx
Sat Sep 29 15:04:46 EDT 2018

```Hi Nic,

I have some code that does this sort of thing in my "pwkit" package of
astro-related Python utilities. The "documentation" is here but it's
sparse:

I should really put together some examples, but unfortunately haven't
done so yet — and that's not something I expect to be able to spend
time on in the near future. Given that, it probably is not enough of a
turn-key solution for you, but I thought I'd at least mention its
existence. FWIW, here's the source:

https://github.com/pkgw/pwkit/blob/master/pwkit/numutil.py#L219

Peter

On Sat, 2018-09-29 at 09:27 +0000, Nicholas Ross wrote:
> Hi Astropy,
>
> I have what seems a very easy problem, but I haven’t found an elegant solution yet.
>
> I have the following (time-series) data:
> 	t = [5.13,   5.27,   5.40,   5.46,  190.99, 191.13, 191.267, 368.70, 368.83,  368.90, 368.93]
> 	y = [17.17, 17.18, 17.014, 17.104,  16.981,  16.96,   16.85,  17.27, 17.66,   17.76, 18.01]
> so, groups of data in short (time) intervals then separated cleanly by a long time gap.
> I'm looking for a simple method that will intelligently average these together; sort of a 'Bayesian blocks’
> but for non-histogram data.
>
> The return of
> 	t_prime=[5.315, 191.129, 368.84],
> 	y_prime=[17.117, 16.930, 17.660]
> is the first-order result I'd be after, but with the option to include weights/weighted data in more sophisticated analyses.
> The suggested approaches to this problem are doing a simple moving average, or maybe a numpy convolution,
> but I'm looking for something a bit more elegant and that can generalize to larger, similar, but not identical datasets.
>
> Best,
> Nic
>
>
> _______________________________________________
> AstroPy mailing list
> AstroPy at python.org
> https://mail.python.org/mailman/listinfo/astropy
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20180929/abc9edc8/attachment.html>
```