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
Quantity
orTimeDelta
[: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_start
Time
or python: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 theTime
class. This can also be a scalar value iftime_bin_size
ortime_bin_end
is provided. Defaults to the first time in the sampled time series.- time_bin_end
Time
or python: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 theTime
class. This can only be given iftime_bin_start
is provided or its default is used. Iftime_bin_end
is scalar andtime_bin_start
is an array, time bins are assumed to be contiguous; the end of each bin is the start of the next one, andtime_bin_end
gives the end time for the last bin. Iftime_bin_end
is an array andtime_bin_start
is scalar, bins will be contiguous. If bothtime_bin_end
andtime_bin_start
are arrays, bins do not need to be contiguous. If this argument is provided,time_bin_size
should not be provided.- n_bins
python:int
, optional The number of bins to use. Defaults to the number needed to fit all the original points. If both
time_bin_start
andtime_bin_size
are provided and are scalar values, this determines the total bins within that interval. Iftime_bin_start
is an iterable, this parameter will be ignored.- aggregate_func
python: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