Ejemplo n.º 1
0
def test_blsStrength():

    size = 100
    width = 10
    depth = 1
    y = np.zeros(size)
    counts = np.ones(size)

    y[40:40+width] -= depth

    bls = fbls.computeBlsForOnePeriod(y, counts, width, 1)

    expectedBls = (depth*width) / (np.sqrt(width))

    assert( np.fabs( np.max(bls) - expectedBls) < .01*expectedBls)
    mp.plot(bls, 'ko')
    mp.axhline(expectedBls, color='r')
Ejemplo n.º 2
0
def test_blsStrength():

    size = 100
    width = 10
    depth = 1
    y = np.zeros(size)
    counts = np.ones(size)

    y[40:40 + width] -= depth

    bls = fbls.computeBlsForOnePeriod(y, counts, width, 1)

    expectedBls = (depth * width) / (np.sqrt(width))

    assert (np.fabs(np.max(bls) - expectedBls) < .01 * expectedBls)
    mp.plot(bls, 'ko')
    mp.axhline(expectedBls, color='r')
Ejemplo n.º 3
0
def phaseAttenuation(period):
    #29.771 causes this test to fail because the period is folded to split
    #the transit over the end of the folded array
#    period = 10 + np.random.rand()*90
    size = 10000
    sigma = 1
    depth = 20
    duration = 10


    x = np.linspace(0, size, size)
    y = sigma * np.random.randn(size)

    phase = 25
    for i in np.arange(0, size, period):
        y[i+phase:i+phase+duration] -= depth


    n0 = duration * size/period
    expectedMaxBls = (depth*n0) / (sigma*np.sqrt(n0))


    isPass = True
    mp.clf()
    mp.axhline(expectedMaxBls)
    for phaseOverResolution in np.arange(1, 8):
        nBins = phaseOverResolution * period / duration
        nBins = int(np.ceil(nBins))
        binnedFlux, counts = fbls.fastFoldAndBin(x, y, period, nBins)

        mp.plot(binnedFlux, 'k.-')

        transitWidth = phaseOverResolution
        expectedAttenuation = 1 - 1/ float(2*phaseOverResolution)

        if transitWidth > 0 and transitWidth < len(binnedFlux):
            bls = fbls.computeBlsForOnePeriod(binnedFlux, counts,
                                             transitWidth, sigma)

            obs = np.max(bls)
            expected = expectedMaxBls * expectedAttenuation
            if obs < expected:
                isPass = False

    assert(isPass)
Ejemplo n.º 4
0
def phaseAttenuation(period):
    #29.771 causes this test to fail because the period is folded to split
    #the transit over the end of the folded array
    #    period = 10 + np.random.rand()*90
    size = 10000
    sigma = 1
    depth = 20
    duration = 10

    x = np.linspace(0, size, size)
    y = sigma * np.random.randn(size)

    phase = 25
    for i in np.arange(0, size, period):
        y[i + phase:i + phase + duration] -= depth

    n0 = duration * size / period
    expectedMaxBls = (depth * n0) / (sigma * np.sqrt(n0))

    isPass = True
    mp.clf()
    mp.axhline(expectedMaxBls)
    for phaseOverResolution in np.arange(1, 8):
        nBins = phaseOverResolution * period / duration
        nBins = int(np.ceil(nBins))
        binnedFlux, counts = fbls.fastFoldAndBin(x, y, period, nBins)

        mp.plot(binnedFlux, 'k.-')

        transitWidth = phaseOverResolution
        expectedAttenuation = 1 - 1 / float(2 * phaseOverResolution)

        if transitWidth > 0 and transitWidth < len(binnedFlux):
            bls = fbls.computeBlsForOnePeriod(binnedFlux, counts, transitWidth,
                                              sigma)

            obs = np.max(bls)
            expected = expectedMaxBls * expectedAttenuation
            if obs < expected:
                isPass = False

    assert (isPass)