How to use the aotools.functions.pupil function in aotools

To help you get started, we’ve selected a few aotools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AOtools / aotools / aotools / functions / _functions.py View on Github external
warnings.warn(
        "This function will be removed in version 0.5, instead use aotools.image_processing.encircled_energy",
        DeprecationWarning)

    dim = data.shape[0] // 2
    if center is None:
        center = [dim, dim]
    xc = center[0]
    yc = center[1]
    e = 1.9
    npt = 20
    rad = numpy.linspace(0, dim**(1. / e), npt)**e
    ee = numpy.empty(rad.shape)

    for i in range(npt):
        pup = pupil.circle(rad[i],
                           int(dim) * 2,
                           circle_centre=(xc, yc),
                           origin='corner')
        rad[i] = numpy.sqrt(numpy.sum(pup) * 4 / numpy.pi)  # diameter
        ee[i] = numpy.sum(pup * data)

    rad = numpy.append(0, rad)
    ee = numpy.append(0, ee)
    ee /= numpy.sum(data)
    xi = numpy.linspace(0, dim, int(4 * dim))
    yi = numpy.interp(xi, rad, ee)

    if eeDiameter is False:
        return xi, yi
    else:
        ee50d = float(xi[numpy.argmin(numpy.abs(yi - fraction))])
github AOtools / aotools / test / testCircle.py View on Github external
def test_circle( self ):

        log.info("Create circles with (0,5), (1,5), (2,5), (0,6),...,(3,6)")
        # Define the expected outputs:
        # >>> circle.circle(0, 5)
        ce = numpy.array([[ 0.,  0.,  0.,  0.,  0.],
                          [ 0.,  0.,  0.,  0.,  0.],
                          [ 0.,  0.,  1.,  0.,  0.],
                          [ 0.,  0.,  0.,  0.,  0.],
                          [ 0.,  0.,  0.,  0.,  0.]])
        c = pupil.circle(0, 5)
        self.assertEqual( c.tolist(), ce.tolist() )
        self.assertTrue( (c == ce).all() )

        #  circle.circle(1, 5)
        ce = numpy.array([[ 0.,  0.,  0.,  0.,  0.],
                          [ 0.,  0.,  1.,  0.,  0.],
                          [ 0.,  1.,  1.,  1.,  0.],
                          [ 0.,  0.,  1.,  0.,  0.],
                          [ 0.,  0.,  0.,  0.,  0.]])
        c = pupil.circle(1, 5)
        self.assertEqual( c.tolist(), ce.tolist() )
        self.assertTrue( (c == ce).all() )

        #  circle.circle(2, 5)
        ce = numpy.array([[ 0.,  0.,  1.,  0.,  0.],
                          [ 0.,  1.,  1.,  1.,  0.],
github AOtools / aotools / test / testCircle.py View on Github external
self.assertEqual( c1.tolist(), c2.tolist() )
        self.assertTrue( (c1 == c2).all() )

        c1 = pupil.circle(0, 5, (0.5, 0.5))[1:, 1:]
        c2 = pupil.circle(0, 6)[1:-1, 1:-1]
        self.assertEqual( c1.tolist(), c2.tolist() )
        self.assertTrue( (c1 == c2).all() )

        c1 = pupil.circle(1, 5, (0.5, 0.5))[1:, 1:]
        c2 = pupil.circle(1, 6)[1:-1, 1:-1]
        #c2[3,2] = 3.0 # to test the testing
        self.assertEqual( c1.tolist(), c2.tolist() )
        self.assertTrue( (c1 == c2).all() )

        c1 = pupil.circle(2, 5, (0.5, 0.5))[1:, 1:]
        c2 = pupil.circle(2, 6)[1:-1, 1:-1]
        self.assertEqual( c1.tolist(), c2.tolist() )
        self.assertTrue( (c1 == c2).all() )


        log.info("Raise TypeError if inputs not of correct type")

        # For testing by hand and observing the result:
        if False:
            import pylab; pylab.ion()

            c = pupil.circle(2, 5, (0.5, 0.5))
            pylab.imshow(c, interpolation="nearest")

            c1 = pupil.circle(1, 5)
            #pylab.imshow(c-c1, interpolation="nearest")
github AOtools / aotools / aotools / functions / _functions.py View on Github external
"""
    Measure the azimuthal average of a 2d array

    Args:
        data (ndarray): A 2-d array of data

    Returns:
        ndarray: A 1-d vector of the azimuthal average
    """
    warnings.warn("This function will be removed in version 0.5, instead use aotools.image_processing.azimuthal_average",
                  DeprecationWarning)

    size = data.shape[0]
    avg = numpy.empty(int(size / 2), dtype="float")
    for i in range(int(size / 2)):
        ring = pupil.circle(i + 1, size) - pupil.circle(i, size)
        avg[i] = (ring * data).sum() / (ring.sum())

    return avg
github AOtools / aotools / aotools / image_processing / psf.py View on Github external
def azimuthal_average(data):
    """
    Measure the azimuthal average of a 2d array

    Args:
        data (ndarray): A 2-d array of data

    Returns:
        ndarray: A 1-d vector of the azimuthal average
    """
    size = data.shape[0]
    avg = numpy.empty(int(size / 2), dtype="float")
    for i in range(int(size / 2)):
        ring = functions.pupil.circle(i + 1, size) - functions.pupil.circle(i, size)
        avg[i] = (ring * data).sum() / (ring.sum())

    return avg