lightkurve.LightCurve.bin#
- LightCurve.bin(time_bin_size=None, time_bin_start=None, time_bin_end=None, n_bins=None, aggregate_func=None, bins=None, binsize=None)[source]#
Bins a lightcurve in equally-spaced bins in time.
If the original light curve contains flux uncertainties (
flux_err), the binned lightcurve will report the root-mean-square error. If no uncertainties are included, the binned curve will return the standard deviation of the data.- Parameters
- time_bin_size
QuantityorTimeDelta, 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. (Default: 0.5 days; default unit: days.)- 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_sizeis 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 an array of values. Iftime_bin_endis a scalar, time bins are assumed to be contiguous, such that 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, the time bins do not need to be contiguous. If this argument is provided,time_bin_sizeshould not be provided. This option, like the iterable form oftime_bin_start, requires Astropy 5.0.- n_binsint, optional
The number of bins to use. Defaults to the number needed to fit all the original points. Note that this will create this number of bins of length
time_bin_sizeindependent of the lightkurve length.- aggregate_funccallable, optional
The function to use for combining points in the same bin. Defaults to np.nanmean.
- binsint, iterable or str, optional
If an int, this gives the number of bins to divide the lightkurve into. In contrast to
n_binsthis adjusts the length oftime_bin_sizeto accommodate the input time series length. If it is an iterable of ints, it specifies the indices of the bin edges. If a string, it must be one of ‘blocks’, ‘knuth’, ‘scott’ or ‘freedman’ defining a method of automatically determining an optimal bin size. Seehistogramfor a description of each method. Note that ‘blocks’ is not a useful method for regularly sampled data.- binsizeint
In Lightkurve v1.x, the default behavior of
bin()was to create bins which contained an equal number data points in each bin. This type of binning is discouraged because it usually makes more sense to create equally-sized bins in time duration, which is the new default behavior in Lightkurve v2.x. Nevertheless, thisbinsizeparameter allows users to simulate the old behavior of Lightkurve v1.x. For ease of implementation, setting this parameter is identical to passingtime_bin_size = lc.time[binsize] - time[0], which means that the bins are not guaranteed to contain an identical number of data points.
- time_bin_size
- Returns
- binned_lc
LightCurve A new light curve which has been binned.
- binned_lc