aggregate_downsample#

astropy.timeseries.aggregate_downsample(time_series, *, time_bin_size=None, time_bin_start=None, time_bin_end=None, n_bins=None, aggregate_func=None)[source]#

Downsample a time series by binning values into bins with a fixed size or custom sizes, using a single function to combine the values in the bin.

Parameters:
time_seriesTimeSeries

The time series to downsample.

time_bin_sizeQuantity or TimeDelta [:ref: ‘time’], optional

The time interval for the binned time series - this is either a scalar value (in which case all time bins will be assumed to have the same duration) or as an array of values (in which case each time bin can have a different duration). If this argument is provided, time_bin_end should not be provided.

time_bin_startTime or iterable, optional

The start time for the binned time series - this can be either given directly as a Time array or as any iterable that initializes the Time class. This can also be a scalar value if time_bin_size or time_bin_end is provided. Defaults to the first time in the sampled time series.

time_bin_endTime or iterable, optional

The times of the end of each bin - this can be either given directly as a Time array or as any iterable that initializes the Time class. This can only be given if time_bin_start is provided or its default is used. If time_bin_end is scalar and time_bin_start is an array, time bins are assumed to be contiguous; the end of each bin is the start of the next one, and time_bin_end gives the end time for the last bin. If time_bin_end is an array and time_bin_start is scalar, bins will be contiguous. If both time_bin_end and time_bin_start are arrays, bins do not need to be contiguous. If this argument is provided, time_bin_size should not be provided.

n_binsint, optional

The number of bins to use. Defaults to the number needed to fit all the original points. If both time_bin_start and time_bin_size are provided and are scalar values, this determines the total bins within that interval. If time_bin_start is an iterable, this parameter will be ignored.

aggregate_funccallable(), optional

The function to use for combining points in the same bin. Defaults to np.nanmean.

Returns:
binned_time_seriesBinnedTimeSeries

The downsampled time series.