Example #1
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

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

    true_result = np.array(
      [[ 1. -0.j, 0.99982567-0.01867173j, 0.99930273-0.03733694j,
         0.99843138-0.05598914j ],
       [ 0.75320598+0.65778473j, 0.76535665+0.6436064j, 0.77724047+0.62920367j,
         0.78885329+0.61458156j ],
       [ 0.1346385+0.99089478j, 0.15311675+0.98820811j, 0.1715416+0.98517688j,
         0.18990665+0.98180215j ],
       [-0.55038493+0.83491103j, -0.53469975+0.84504211j, -0.51882814+0.85487856j,
        -0.50277564+0.86441695j ]]
      )

    assert_allclose( result, true_result, atol=1E-7 )
Example #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)