smurfs.Frequency

class Frequency(time, flux, window_size, snr, flux_err=None, f_min=None, f_max=None, rm_ranges=None)[source]

The Frequency class represents a single frequency of a given data set. It takes the frequency of maximum power as the guess for pre-whitening. It also computes the Signal to noise ratio of that frequency. After instantiating this class, you can call pre-whiten, which tries to fit the frequency to the light curve, and returns the residual between the original light curve and the model of the frequency.

Parameters
  • time (ndarray) – Time axis

  • flux (ndarray) – Flux axis

  • window_size (float) – Window size, used to compute the SNR

  • snr (float) – Lower end signal to noise ratio, defines if a frequency is marked as significant

  • flux_err (Optional[ndarray]) – Error in the flux

  • f_min (Optional[float]) – Lower end of the frequency range considered. If None, it uses 0

  • f_max (Optional[float]) – Upper end of the frequency range considered. If None, it uses the Nyquist frequency

  • rm_ranges (Optional[List[Tuple[float]]]) – Ranges of frequencies, that should be ignored (List of tuples, that contain a f_min -> f_max range. These areas are ignored)

property amp

Returns the amplitude of the found frequency (in mag)

Return type

Union[float, Variable]

property f

Returns the frequency of the found frequency (in c/d)

Return type

Union[float, Variable]

property phase

Returns the phase of the found frequency (between 0 and 1)

Return type

Union[float, Variable]

property significant

Returns the significance of the frequency. True –> significant, False –> insignificant

Return type

bool

property label

Returns the label of the found frequency

Return type

str

property lc

Represents the light curve on which the analysis is performed

Return type

LightCurve

property snr

Computes the signal to noise ratio of a given frequency. It considers the area from the first minima before the peak until window halfed, as well as the area from the first minima after the peak until window halfed.

Return type

float

Returns

Signal to noise ratio of the peak

scipy_fit()[source]

Performs a scipy fit on the light curve of the object. Limits are 50% up and down from the initial guess. Computes uncertainties using the provided covariance matrix from curve_fit.

Return type

Tuple[Variable, Variable, Variable, Tuple[float, float, float]]

Returns

values for amplitude,frequency, phase (in this order) including their uncertainties, as well as the param object

lmfit_fit()[source]

Uses lmfit to perform the sin fit on the light curve. We first fit all three free parameters, and then vary the phase parameter, to get a more accurate value for it. Uncertainties are computed according to Montgomery & O’Donoghue (1999).

Return type

Tuple[Variable, Variable, Variable, List[float]]

Returns

values for amplitude,frequency, phase (in this order) including their uncertainties, as well as the param object

pre_whiten(mode='lmfit')[source]

‘Pre whitens’ a given light curve. As an estimate, the method always uses the frequency with maximum power. It then performs the fit according to the mode parameter, and returns a Lightcurve object with the reduced light curve

:param mode:’scipy’ or ‘lmfit’ :rtype: LightCurve :return: Pre-whitened lightcurve object

plot(ax=None, show=False, use_guess=False)[source]

Plots the periodogramm. If a fit was already performed, it uses the fit _result by default. This can be overwritten by setting use_guess to True

Parameters
  • ax (Optional[Axes]) – Axis object

  • show – Shows the plot

  • use_guess – Uses the guess

Return type

Optional[Axes]

Returns

Axis object if plot was not shown

find_adjacent_minima()[source]

Finds the adjacent minima to the guessed frequency, and sets them within the class.