def test_gridscan_to_file(tmp_path): d = tmp_path / 'sub' d.mkdir() path = d / 'measurement2.hdf5' atoms = read(_set_path('orthogonal_graphene.cif')) potential = Potential(atoms=atoms, sampling=.05) probe = Probe(energy=200e3, semiangle_cutoff=30) probe.grid.match(potential) scan = GridScan(start=[0, 0], end=[0, potential.extent[1]], gpts=(10, 9)) detector = PixelatedDetector() export_detector = PixelatedDetector(save_file=path) measurements = probe.scan(scan, [detector, export_detector], potential, pbar=False) measurement = measurements[0] imported_measurement = Measurement.read(measurements[1]) assert np.allclose(measurement.array, imported_measurement.array) assert measurement.calibrations[0] == imported_measurement.calibrations[0] assert measurement.calibrations[1] == imported_measurement.calibrations[1]
def test_export_import_measurement(tmp_path): d = tmp_path / 'sub' d.mkdir() path = d / 'measurement.hdf5' calibrations = calibrations_from_grid((512, 256), (.1, .3), ['x', 'y'], 'Å') measurement = Measurement(np.random.rand(512, 256), calibrations) measurement.write(path) imported_measurement = Measurement.read(path) assert np.allclose(measurement.array, imported_measurement.array) assert measurement.calibrations[0] == imported_measurement.calibrations[0] assert measurement.calibrations[1] == imported_measurement.calibrations[1]
from abtem.measure import Measurement import matplotlib.pyplot as plt measurement = Measurement.read('STEM_MoS2.hdf5') measurement.tile((5, 3)).interpolate(.01).show() plt.show()