Example #1
0
def test_false_alarm_equivalence(method, normalization, use_errs, units):
    # Note: the PSD normalization is not equivalent to the others, in that it
    # depends on the absolute errors rather than relative errors. Because the
    # scaling contributes to the distribution, it cannot be converted directly
    # from any of the three normalized versions.
    if not HAS_SCIPY and method in ['baluev', 'davies']:
        pytest.skip("SciPy required")

    kwds = METHOD_KWDS.get(method, None)
    t, y, dy, fmax = make_data(units=units)
    if not use_errs:
        dy = None

    ls = LombScargle(t, y, dy, normalization=normalization)
    freq, power = ls.autopower(maximum_frequency=fmax)
    Z = np.linspace(power.min(), power.max(), 30)
    fap = ls.false_alarm_probability(Z,
                                     maximum_frequency=fmax,
                                     method=method,
                                     method_kwds=kwds)

    # Compute the equivalent Z values in the standard normalization
    # and check that the FAP is consistent
    Z_std = convert_normalization(Z,
                                  len(t),
                                  from_normalization=normalization,
                                  to_normalization='standard',
                                  chi2_ref=compute_chi2_ref(y, dy))
    ls = LombScargle(t, y, dy, normalization='standard')
    fap_std = ls.false_alarm_probability(Z_std,
                                         maximum_frequency=fmax,
                                         method=method,
                                         method_kwds=kwds)

    assert_allclose(fap, fap_std, rtol=0.1)
Example #2
0
def test_false_alarm_equivalence(method, normalization, use_errs):
    # Note: the PSD normalization is not equivalent to the others, in that it
    # depends on the absolute errors rather than relative errors. Because the
    # scaling contributes to the distribution, it cannot be converted directly
    # from any of the three normalized versions.
    if not HAS_SCIPY and method in ['baluev', 'davies']:
        pytest.skip("SciPy required")

    kwds = METHOD_KWDS.get(method, None)
    t, y, dy = make_data()
    if not use_errs:
        dy = None
    fmax = 5

    ls = LombScargle(t, y, dy, normalization=normalization)
    freq, power = ls.autopower(maximum_frequency=fmax)
    Z = np.linspace(power.min(), power.max(), 30)
    fap = ls.false_alarm_probability(Z, maximum_frequency=fmax,
                                     method=method, method_kwds=kwds)

    # Compute the equivalent Z values in the standard normalization
    # and check that the FAP is consistent
    Z_std = convert_normalization(Z, len(t),
                                  from_normalization=normalization,
                                  to_normalization='standard',
                                  chi2_ref=compute_chi2_ref(y, dy))
    ls = LombScargle(t, y, dy, normalization='standard')
    fap_std = ls.false_alarm_probability(Z_std, maximum_frequency=fmax,
                                         method=method, method_kwds=kwds)

    assert_allclose(fap, fap_std, rtol=0.1)
Example #3
0
def test_convert_normalization(norm_in, norm_out, data):
    t, y, dy = data

    _, power_in = LombScargle(t, y, dy).autopower(maximum_frequency=5,
                                                  normalization=norm_in)
    _, power_out = LombScargle(t, y, dy).autopower(maximum_frequency=5,
                                                   normalization=norm_out)
    power_in_converted = convert_normalization(power_in, N=len(t),
                                               from_normalization=norm_in,
                                               to_normalization=norm_out,
                                               chi2_ref = compute_chi2_ref(y, dy))
    assert_allclose(power_in_converted, power_out)
Example #4
0
def test_convert_normalization(norm_in, norm_out, data):
    t, y, dy = data

    _, power_in = LombScargle(t, y, dy).autopower(maximum_frequency=5,
                                                  normalization=norm_in)
    _, power_out = LombScargle(t, y, dy).autopower(maximum_frequency=5,
                                                   normalization=norm_out)
    power_in_converted = convert_normalization(power_in, N=len(t),
                                               from_normalization=norm_in,
                                               to_normalization=norm_out,
                                               chi2_ref = compute_chi2_ref(y, dy))
    assert_allclose(power_in_converted, power_out)