Ejemplo n.º 1
0
def setup_sf():
    """Initialize values for these parameters needed for the analyticnrm2 tests.

    Returns
    -------
    pixel (optional, via **kwargs) : float
        pixel scale

    fov : integer
        number of detector pixels on a side

    oversample : integer
        oversampling factor

    ctrs : float, float
        coordinates of hole centers

    d : float
        hole diameter

    lam : float
        wavelength

    phi : float
        distance of fringe from hole center in units of waves

    centering : string
        if set to 'PIXELCENTERED' or unspecified, the offsets will be set to
        (0.5,0.5); if set to 'PIXELCORNER', the offsets will be set to
        (0.0,0.0).

    aff : Affine2d object
        Affine2d object

    """
    pixel = 3.1125038327232215e-07
    fov = 2
    oversample = 3
    ctrs = np.array(
        [
            [0.06864653, -2.63910736],
            [-2.28553695, -0.05944972],
            [2.31986022, -1.26010406],
            [-2.31986022, 1.26010406],
            [-1.19424838, 1.94960579],
            [2.25121368, 1.3790035],
            [1.09127858, 2.00905525],
        ]
    )
    d = 0.8
    lam = 2.3965000082171173e-06
    phi = np.zeros(7, dtype=np.float32)
    centering = (0.5, 0.5)
    aff_obj = utils.Affine2d(rotradccw=0.4)

    return pixel, fov, oversample, ctrs, d, lam, phi, centering, aff_obj
Ejemplo n.º 2
0
def test_analyticnrm2_phasor():
    ''' Test of phasor() in the analyticnrm2 module '''

    ASIZE = 4
    kx = np.arange(ASIZE * ASIZE).reshape((ASIZE, ASIZE))

    for ii in np.arange(ASIZE):
        kx[:, ii] = ii

    ky = kx.transpose()

    hx = 0.06864653345335156
    hy = -2.6391073592116028

    lam = 2.3965000082171173e-06
    phi = 0.0
    pitch = 1.0375012775744072e-07

    aff_obj = utils.Affine2d(rotradccw=0.4)

    result = phasor(kx, ky, hx, hy, lam, phi, pitch, aff_obj)

    true_result = np.array(
        [
            [
                1.0 + 0.0j,
                0.96578202 + 0.25935515j,
                0.86546981 + 0.50096108j,
                0.70592834 + 0.70828326j,
            ],
            [
                0.78476644 + 0.61979161j,
                0.59716716 + 0.80211681j,
                0.36870018 + 0.92954837j,
                0.11500085 + 0.99336539j,
            ],
            [
                0.23171672 + 0.97278331j,
                -0.02850852 + 0.99959355j,
                -0.28678275 + 0.95799564j,
                -0.52543073 + 0.85083638j,
            ],
            [
                -0.42107943 + 0.90702377j,
                -0.64191223 + 0.76677812j,
                -0.81881514 + 0.57405728j,
                -0.93968165 + 0.34205027j,
            ],
        ]
    )

    assert_allclose(result, true_result, atol=1e-7)