astrobase.periodbase.saov module

Contains the Schwarzenberg-Czerny Analysis of Variance period-search algorithm implementation for periodbase.

astrobase.periodbase.saov.aov_theta(times, mags, errs, frequency, binsize=0.05, minbin=9)[source]

Calculates the Schwarzenberg-Czerny AoV statistic at a test frequency.

  • times,mags,errs (np.array) – The input time-series and associated errors.
  • frequency (float) – The test frequency to calculate the theta statistic at.
  • binsize (float) – The phase bin size to use.
  • minbin (int) – The minimum number of items in a phase bin to consider in the calculation of the statistic.

theta_aov – The value of the AoV statistic at the specified frequency.

Return type:


astrobase.periodbase.saov.aov_periodfind(times, mags, errs, magsarefluxes=False, startp=None, endp=None, stepsize=0.0001, autofreq=True, normalize=True, phasebinsize=0.05, mindetperbin=9, nbestpeaks=5, periodepsilon=0.1, sigclip=10.0, nworkers=None, verbose=True)[source]

This runs a parallelized Analysis-of-Variance (AoV) period search.

NOTE: normalize = True here as recommended by Schwarzenberg-Czerny 1996, i.e. mags will be normalized to zero and rescaled so their variance = 1.0.

  • times,mags,errs (np.array) – The mag/flux time-series with associated measurement errors to run the period-finding on.
  • magsarefluxes (bool) – If the input measurement values in mags and errs are in fluxes, set this to True.
  • startp,endp (float or None) – The minimum and maximum periods to consider for the transit search.
  • stepsize (float) – The step-size in frequency to use when constructing a frequency grid for the period search.
  • autofreq (bool) – If this is True, the value of stepsize will be ignored and the astrobase.periodbase.get_frequency_grid() function will be used to generate a frequency grid based on startp, and endp. If these are None as well, startp will be set to 0.1 and endp will be set to times.max() - times.min().
  • normalize (bool) – This sets if the input time-series is normalized to 0.0 and rescaled such that its variance = 1.0. This is the recommended procedure by Schwarzenberg-Czerny 1996.
  • phasebinsize (float) – The bin size in phase to use when calculating the AoV theta statistic at a test frequency.
  • mindetperbin (int) – The minimum number of elements in a phase bin to consider it valid when calculating the AoV theta statistic at a test frequency.
  • nbestpeaks (int) – The number of ‘best’ peaks to return from the periodogram results, starting from the global maximum of the periodogram peak values.
  • periodepsilon (float) – The fractional difference between successive values of ‘best’ periods when sorting by periodogram power to consider them as separate periods (as opposed to part of the same periodogram peak). This is used to avoid broad peaks in the periodogram and make sure the ‘best’ periods returned are all actually independent.
  • sigclip (float or int or sequence of two floats/ints or None) –

    If a single float or int, a symmetric sigma-clip will be performed using the number provided as the sigma-multiplier to cut out from the input time-series.

    If a list of two ints/floats is provided, the function will perform an ‘asymmetric’ sigma-clip. The first element in this list is the sigma value to use for fainter flux/mag values; the second element in this list is the sigma value to use for brighter flux/mag values. For example, sigclip=[10., 3.], will sigclip out greater than 10-sigma dimmings and greater than 3-sigma brightenings. Here the meaning of “dimming” and “brightening” is set by physics (not the magnitude system), which is why the magsarefluxes kwarg must be correctly set.

    If sigclip is None, no sigma-clipping will be performed, and the time-series (with non-finite elems removed) will be passed through to the output.

  • nworkers (int) – The number of parallel workers to use when calculating the periodogram.
  • verbose (bool) – If this is True, will indicate progress and details about the frequency grid used for the period search.

This function returns a dict, referred to as an lspinfo dict in other astrobase functions that operate on periodogram results. This is a standardized format across all astrobase period-finders, and is of the form below:

{'bestperiod': the best period value in the periodogram,
 'bestlspval': the periodogram peak associated with the best period,
 'nbestpeaks': the input value of nbestpeaks,
 'nbestlspvals': nbestpeaks-size list of best period peak values,
 'nbestperiods': nbestpeaks-size list of best periods,
 'lspvals': the full array of periodogram powers,
 'periods': the full array of periods considered,
 'method':'aov' -> the name of the period-finder method,
 'kwargs':{ dict of all of the input kwargs for record-keeping}}

Return type:


astrobase.periodbase.saov.analytic_false_alarm_probability(lspinfo, times, conservative_nfreq_eff=True, peakvals=None, inplace=True)[source]

This returns the analytic false alarm probabilities for periodogram peak values.

FIXME: this doesn’t actually work. Fix later.

The calculation follows that on page 3 of Zechmeister & Kurster (2009):

FAP = 1 − [1 − Prob(z > z0)]**M


M is the number of independent frequencies
Prob(z > z0) is the probability of peak with value > z0
z0 is the peak value we're evaluating

For AoV and AoV-harmonic, the Prob(z > z0) is described by the F distribution, according to:

This is given by:

F( (B-1), (N-B); theta_aov )


N = number of observations
B = number of phase bins

This translates to a scipy.stats call to the F distribution CDF:

x = theta_aov_best
prob_exceeds_val = scipy.stats.f.cdf(x, (B-1.0), (N-B))

Which we can then plug into the false alarm prob eqn above with the calculation of M.

  • lspinfo (dict) – The dict returned by the aov_periodfind() function.
  • times (np.array) – The times for which the periodogram result in lspinfo was calculated.
  • conservative_nfreq_eff (bool) –

    If True, will follow the prescription given in Schwarzenberg-Czerny (2003):

    and estimate the effective number of independent frequences M_eff as:

    min(N_obs, N_freq, DELTA_f/delta_f)
  • peakvals (sequence or None) – The peak values for which to evaluate the false-alarm probability. If None, will calculate this for each of the peak values in the nbestpeaks key of the lspinfo dict.
  • inplace (bool) – If True, puts the results of the FAP calculation into the lspinfo dict as a list available as lspinfo['falsealarmprob'].

The calculated false alarm probabilities for each of the peak values in peakvals.

Return type: