Add probe propagation with initialization as a base feature to fancy_ptycho, and fix the test for orthogonalize_probes

This commit is contained in:
Abe Levitan committed 2019-05-03 12:30:53 -04:00
1 parent 26de79ca92
commit 22899288fc
7 files changed
+70 -26

No files matched your search

+10 -7
View File
@@ -25,21 +25,24 @@ def test_orthogonalize_probes():
3*np.exp(-probe_Rs**2 / (2 * 12**2)),
1*np.exp(-probe_Rs**2 / (2 * 15**2))]).astype(np.complex64)
ortho_probes = cmath.torch_to_complex(analysis.orthogonalize_probes(probes))
# test that it works on numpy arrays
ortho_probes = analysis.orthogonalize_probes(probes)
# test that it also works on torch tensors
ortho_probes_t = cmath.torch_to_complex(analysis.orthogonalize_probes(cmath.complex_to_torch(probes)))
for p1,p2 in combinations(ortho_probes,2):
assert np.sum(np.conj(p1)*p2) / np.sum(np.abs(p1)**2) < 1e-6
for probe in ortho_probes:
print(np.sum(np.abs(probe)**2))
for p1,p2 in combinations(ortho_probes_t,2):
assert np.sum(np.conj(p1)*p2) / np.sum(np.abs(p1)**2) < 1e-6
for probe in probes:
print(np.sum(np.abs(probe)**2))
probe_intensity = np.sum(np.abs(probes)**2,axis=0)
ortho_probe_intensity = np.sum(np.abs(ortho_probes)**2,axis=0)
ortho_probe_t_intensity = np.sum(np.abs(ortho_probes_t)**2,axis=0)
assert np.allclose(probe_intensity,ortho_probe_intensity)
assert np.allclose(probe_intensity,ortho_probe_t_intensity)
+5 -1
View File
@@ -186,4 +186,8 @@ def test_SHARP_style_probe(ptycho_cxi_1):
probe = initializers.SHARP_style_probe(dataset, shape, det_slice)
assert probe.shape == t.Size([256,256,2])
probe = initializers.SHARP_style_probe(dataset, shape, det_slice, propagation_distance=20e-6)
assert probe.shape == t.Size([256,256,2])