def aov_theta(times, mags, errs, frequency,<EOL>binsize=<NUM_LIT>, minbin=<NUM_LIT:9>):
period = <NUM_LIT:1.0>/frequency<EOL>fold_time = times[<NUM_LIT:0>]<EOL>phased = phase_magseries(times,<EOL>mags,<EOL>period,<EOL>fold_time,<EOL>wrap=False,<EOL>sort=True)<EOL>phases = phased['<STR_LIT>']<EOL>pmags = phased['<STR_LIT>']<EOL>bins = nparange(<NUM_LIT:0.0>, <NUM_LIT:1.0>, binsize)<EOL>ndets = phases.size<EOL>binnedphaseinds = npdigitize(phases, bins)<EOL>bin_s1_tops = []<EOL>bin_s2_tops = []<EOL>binndets = []<EOL>goodbins = <NUM_LIT:0><EOL>all_xbar = npmedian(pmags)<EOL>for x in npunique(binnedphaseinds):<EOL><INDENT>thisbin_inds = binnedphaseinds == x<EOL>thisbin_mags = pmags[thisbin_inds]<EOL>if thisbin_mags.size > minbin:<EOL><INDENT>thisbin_ndet = thisbin_mags.size<EOL>thisbin_xbar = npmedian(thisbin_mags)<EOL>thisbin_s1_top = (<EOL>thisbin_ndet *<EOL>(thisbin_xbar - all_xbar) *<EOL>(thisbin_xbar - all_xbar)<EOL>)<EOL>thisbin_s2_top = npsum((thisbin_mags - all_xbar) *<EOL>(thisbin_mags - all_xbar))<EOL>bin_s1_tops.append(thisbin_s1_top)<EOL>bin_s2_tops.append(thisbin_s2_top)<EOL>binndets.append(thisbin_ndet)<EOL>goodbins = goodbins + <NUM_LIT:1><EOL><DEDENT><DEDENT>bin_s1_tops = nparray(bin_s1_tops)<EOL>bin_s2_tops = nparray(bin_s2_tops)<EOL>binndets = nparray(binndets)<EOL>s1 = npsum(bin_s1_tops)/(goodbins - <NUM_LIT:1.0>)<EOL>s2 = npsum(bin_s2_tops)/(ndets - goodbins)<EOL>theta_aov = s1/s2<EOL>return theta_aov<EOL>
Calculates the Schwarzenberg-Czerny AoV statistic at a test frequency.

    Parameters
    ----------

    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.

    Returns
    -------

    theta_aov : float
        The value of the AoV statistic at the specified `frequency`.