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_series
TimeSeries The time series to downsample.
- time_bin_size
QuantityorTimeDelta[: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_endshould not be provided.- time_bin_start
Timeor iterable, optional The start time for the binned time series - this can be either given directly as a
Timearray or as any iterable that initializes theTimeclass. This can also be a scalar value iftime_bin_sizeortime_bin_endis provided. Defaults to the first time in the sampled time series.- time_bin_end
Timeor iterable, optional The times of the end of each bin - this can be either given directly as a
Timearray or as any iterable that initializes theTimeclass. This can only be given iftime_bin_startis provided or its default is used. Iftime_bin_endis scalar andtime_bin_startis an array, time bins are assumed to be contiguous; the end of each bin is the start of the next one, andtime_bin_endgives the end time for the last bin. Iftime_bin_endis an array andtime_bin_startis scalar, bins will be contiguous. If bothtime_bin_endandtime_bin_startare arrays, bins do not need to be contiguous. If this argument is provided,time_bin_sizeshould not be provided.- n_bins
int, optional The number of bins to use. Defaults to the number needed to fit all the original points. If both
time_bin_startandtime_bin_sizeare provided and are scalar values, this determines the total bins within that interval. Iftime_bin_startis an iterable, this parameter will be ignored.- aggregate_func
callable(), optional The function to use for combining points in the same bin. Defaults to np.nanmean.
- time_series
- Returns:
- binned_time_series
BinnedTimeSeries The downsampled time series.
- binned_time_series