示例#1
0
def test_assertioned_xc(create_spot):
    spr = SubpixelrefinementGenerator(create_spot,
                                      np.asarray([[90 - 64, 30 - 64]]))
    s = spr.conventional_xc(12, 4, 8)
    error = np.subtract(s[0, 0], np.asarray([[90 - 64, 30 - 64]]))
    rms_error = np.sqrt(error[0, 0]**2 + error[0, 1]**2)
    assert rms_error < 0.2  # 1/5th a pixel
def test_xy_errors_in_conventional_xc_method_as_per_issue_490():
    """ This was the MWE example code for the issue """
    dp = get_simulated_disc(100, 20)
    # translate y by +4
    shifted = np.pad(dp, ((0, 4), (0, 0)),
                     'constant')[4:].reshape(1, 1, *dp.shape)
    signal = ElectronDiffraction2D(shifted)
    spg = SubpixelrefinementGenerator(signal, np.array([[0, 0]]))
    peaks = spg.conventional_xc(100, 20, 1).data[0, 0,
                                                 0]  # as quoted in the issue
    np.testing.assert_allclose([0, -4], peaks)
    """ we also test com method for clarity """
    peaks = spg.center_of_mass_method(60).data[0, 0, 0]
    np.testing.assert_allclose([0, -4], peaks, atol=1.5)
示例#3
0
def test_conventional_xc(diffraction_pattern):
    SPR_generator = SubpixelrefinementGenerator(diffraction_pattern,
                                                np.asarray([[1, -1]]))
    assert SPR_generator.calibration == 1
    assert np.allclose(SPR_generator.center, 4)
    diff_vect = SPR_generator.conventional_xc(4, 2, 10)
示例#4
0
def test_assertioned_xc(dp, diffraction_vectors):
    spr = SubpixelrefinementGenerator(dp, diffraction_vectors)
    s = spr.conventional_xc(12, 4, 8)
    error = s.data[0, 0] - np.asarray([[90 - 64, 30 - 64]])
    rms_error = np.sqrt(error[0, 0]**2 + error[0, 1]**2)
    assert rms_error < 0.2  # 1/5th a pixel