Utility functions

gerbls.calculate_number_of_periods(pyDataContainer data, double min_period, double max_period, double t_samp=0., bool downsample=False, double ds_invpower=3., double ds_threshold=1.1)

Calculate the number of tested periods in a fast-folded BLS (pyFastBLS).

Parameters:
  • data (gerbls.pyDataContainer) – Input data.

  • min_period (float) – Minimum searched orbital period.

  • max_period (float) – Maximum searched orbital period.

  • t_samp (float, optional) – Desired initial time sampling of the data, by default 0. If 0, the median time cadence of the input data will be used instead.

  • downsample (bool, optional) – Whether to automatically downsample the data at longer periods, by default False.

  • downsample_invpower (float, optional) – Affects the rate of downsampling, by default 3.

  • downsample_threshold (float, optional) – Affects the threshold that triggers downsampling, by default 1.1.

Return type:

int

gerbls.fit_chi2_dist(double[:] sample)

A wrapper to fit a chi-squared distribution to a sample using scipy.optimize.minimize(). Returns a scipy.optimize.OptimizeResult object. To retrieve the three distribution parameters [DoF, loc, scale], use numpy.exp(res.x).

Parameters:

sample (ArrayLike) – Sample of values drawn from the chi-squared distribution.

Returns:

res – The optimization result (refer to SciPy docs for more specific documentation).

Return type:

scipy.optimize.OptimizeResult

gerbls.resample(pyDataContainer data, double t_samp, bool fractional_weights=True, double t_samp_old=0.)

Returns a copy of the input data, resampled to the specified time cadence.

Parameters:
  • data (gerbls.pyDataContainer) – Input data.

  • t_samp (float) – Desired time cadence.

  • fractional_weights (bool, optional) – Whether to use fractional weights to split up input data points into resampled data bins (if False, each data point will be placed in its nearest resampled bin). By default True.

  • t_samp_old (float, optional) – Allows the input data time cadence to be specified explicitly. If zero (default), the median time difference between input data points will be used. Only has an effect if fractional_weights is True.

Returns:

Resampled data.

Return type:

gerbls.pyDataContainer