示例#1
0
def test_grid_scan():
    start = (0, 0)
    end = (1, 2)
    scan = GridScan(start, end, gpts=5, endpoint=True)

    positions = scan.get_positions()
    assert np.all(positions[0] == start)
    assert np.all(positions[-1] == end)
    assert np.allclose(positions[4], [start[1], end[1]])
    assert np.allclose(np.linalg.norm(np.diff(positions[:4], axis=0), axis=1), scan.sampling[1])

    scan = GridScan(start, end, gpts=5, endpoint=False)
    positions = scan.get_positions()
    assert np.all(positions[0] == start)
    assert np.allclose(positions[-1], (end[0] - (end[0] - start[0]) / 5, end[1] - (end[1] - start[1]) / 5))
示例#2
0
def test_partition():
    gridscan = GridScan(start=(0, 0), end=(2, 2), sampling=.5, endpoint=False)
    scans = gridscan.partition_scan((2, 2))
    positions = []
    for scan in scans:
        positions.append(scan.get_positions())

    assert np.allclose(((np.vstack(positions)[None] - gridscan.get_positions()[:, None]) ** 2).min(0), 0)
    assert np.allclose(((np.vstack(positions)[None] - gridscan.get_positions()[:, None]) ** 2).min(1), 0)

    gridscan = GridScan(start=(0, 0), end=(2, 2), sampling=.5, endpoint=True)
    scans = gridscan.partition_scan((2, 2))
    positions = []
    for scan in scans:
        positions.append(scan.get_positions())

    assert np.allclose(((np.vstack(positions)[None] - gridscan.get_positions()[:, None]) ** 2).min(0), 0)
    assert np.allclose(((np.vstack(positions)[None] - gridscan.get_positions()[:, None]) ** 2).min(1), 0)
示例#3
0
def test_calibration_coordinates():
    for endpoint in (True, False):
        gridscan = GridScan(sampling=.7,
                            start=(0, 0),
                            end=(4, 4),
                            endpoint=endpoint)
        calibration_coordinates = gridscan.calibrations[0].coordinates(
            gridscan.gpts[0])
        assert np.all(calibration_coordinates == gridscan.get_positions()
                      [::gridscan.gpts[0], 0])