def test_add_diffraction_image(self): dtd = mdtd.DiffractionTestDataset(noise=False) di = mdtd.DiffractionTestImage(intensity_noise=False) di.add_cubic_disks(20, 20, n=1) data = di.get_diffraction_test_image() dtd.add_diffraction_image(di) for ix, iy in np.ndindex(dtd.data.shape[:2]): assert (dtd.data[ix, iy] == data).all()
def get_nanobeam_electron_diffraction_signal(): """Get a signal emulating a NBED dataset. Returns ------- signal : Diffraction2D Example ------- >>> s = pxm.dummy_data.get_nanobeam_electron_diffraction_signal() >>> s.plot() """ di0 = mdtd.DiffractionTestImage(intensity_noise=False) di0.add_disk(x=128, y=128, intensity=10.0) di0.add_cubic_disks(vx=20, vy=20, intensity=2.0, n=5) di0.add_background_lorentz(intensity=50, width=30) di1 = di0.copy() di1.rotation = 10 di2 = di0.copy() di2.rotation = -10 position_array0 = np.zeros((50, 50), dtype=bool) r = np.array([15, 15, 0, 0]) c = np.array([0, 15, 31, 0]) rr, cc = polygon(r, c) position_array0[rr, cc] = True r = np.array([10, 19, 29, 40]) c = np.array([49, 35, 35, 49]) rr, cc = polygon(r, c) position_array0[rr, cc] = True position_array1 = np.zeros((50, 50), dtype=bool) r = np.array([32, 41, 41, 49, 49]) c = np.array([0, 18, 49, 49, 0]) rr, cc = polygon(r, c) position_array1[rr, cc] = True position_array2 = np.invert(np.bitwise_or(position_array0, position_array1)) dtd = mdtd.DiffractionTestDataset(50, 50, 256, 256) dtd.add_diffraction_image(di0, position_array0) dtd.add_diffraction_image(di1, position_array1) dtd.add_diffraction_image(di2, position_array2) s = dtd.get_signal() return s
def test_get_signal(self): dtd = mdtd.DiffractionTestDataset() s = dtd.get_signal() assert hasattr(s, "plot")
def test_plot(self): dtd = mdtd.DiffractionTestDataset() dtd.plot()
def test_dataset_size(self): dtd = mdtd.DiffractionTestDataset(probe_x=5, probe_y=15, detector_x=101, detector_y=200) assert dtd.data.shape == (5, 15, 101, 200)
def test_simple(self): mdtd.DiffractionTestDataset()
def test_repr(self): dtd = mdtd.DiffractionTestDataset(probe_x=21) repr_string = dtd.__repr__() assert str(21) in repr_string