mathutils.py - Math utils

Miscellaneous math utilities used throughout the code.

everest.mathutils.Chunks(l, n, all=False)

Returns a generator of consecutive n-sized chunks of list l. If all is True, returns all n-sized chunks in l by iterating over the starting point.

everest.mathutils.Downbin(x, newsize, axis=0, operation='mean')

Downbins an array to a smaller size.

Parameters:
  • x (array_like) – The array to down-bin
  • newsize (int) – The new size of the axis along which to down-bin
  • axis (int) – The axis to operate on. Default 0
  • operation (str) – The operation to perform when down-binning. Default mean
everest.mathutils.Interpolate(time, mask, y)

Masks certain elements in the array y and linearly interpolates over them, returning an array y’ of the same length.

Parameters:
  • time (array_like) – The time array
  • mask (array_like) – The indices to be interpolated over
  • y (array_like) – The dependent array
everest.mathutils.MedianFilter(x, kernel_size=5)

A silly wrapper around scipy.signal.medfilt().

everest.mathutils.NumRegressors(npix, pld_order, cross_terms=True)

Return the number of regressors for npix pixels and PLD order pld_order.

Parameters:cross_terms (bool) – Include pixel cross-terms? Default True
everest.mathutils.SavGol(y, win=49)

Subtracts a second order Savitsky-Golay filter with window size win and returns the result. This acts as a high pass filter.

everest.mathutils.Scatter(y, win=13, remove_outliers=False)

Return the scatter in ppm based on the median running standard deviation for a window size of win = 13 cadences (for K2, this is ~6.5 hours, as in VJ14).

Parameters:
  • y (ndarray) – The array whose CDPP is to be computed
  • win (int) – The window size in cadences. Default 13
  • remove_outliers (bool) – Clip outliers at 5 sigma before computing the CDPP? Default False
everest.mathutils.Smooth(x, window_len=100, window='hanning')

Smooth data by convolving on a given timescale.

Parameters:
  • x (ndarray) – The data array
  • window_len (int) – The size of the smoothing window. Default 100
  • window (str) – The window type. Default hanning