From d7b8d410285f65ec60719aa18cfa8092e8d42e1b Mon Sep 17 00:00:00 2001 From: Daniel Cox Date: Thu, 3 Oct 2024 10:42:58 +0200 Subject: [PATCH 1/3] Fix FourierDualReference --- openwfs/algorithms/basic_fourier.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openwfs/algorithms/basic_fourier.py b/openwfs/algorithms/basic_fourier.py index 2b1f32b..62bd394 100644 --- a/openwfs/algorithms/basic_fourier.py +++ b/openwfs/algorithms/basic_fourier.py @@ -52,13 +52,14 @@ def __init__( self.k_step = k_step self._slm_shape = slm_shape group_mask = np.zeros(slm_shape, dtype=bool) - group_mask[:, slm_shape[1] // 2 :] = True + group_mask[:, slm_shape[1] // 2:] = True super().__init__( feedback=feedback, slm=slm, phase_patterns=None, group_mask=group_mask, phase_steps=phase_steps, + amplitude='uniform', iterations=iterations, optimized_reference=optimized_reference, analyzer=analyzer, From 5edcbb5d4f6eac09954f92bf138fd87f0d1dc967 Mon Sep 17 00:00:00 2001 From: Daniel Cox Date: Thu, 3 Oct 2024 10:50:03 +0200 Subject: [PATCH 2/3] Rename tests --- tests/test_wfs.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_wfs.py b/tests/test_wfs.py index 17574b9..b2e9163 100644 --- a/tests/test_wfs.py +++ b/tests/test_wfs.py @@ -403,8 +403,8 @@ def test_simple_genetic(population_size: int, elite_size: int): @pytest.mark.parametrize("basis_str", ("plane_wave", "hadamard")) @pytest.mark.parametrize("shape", ((8, 8), (16, 4))) -def test_custom_blind_dual_reference_ortho_split(basis_str: str, shape): - """Test custom blind dual reference with an orthonormal phase-only basis. +def test_dual_reference_ortho_split(basis_str: str, shape): + """Test dual reference with an orthonormal phase-only basis. Two types of bases are tested: plane waves and Hadamard""" do_debug = False N = shape[0] * (shape[1] // 2) @@ -479,9 +479,9 @@ def test_custom_blind_dual_reference_ortho_split(basis_str: str, shape): assert np.abs(field_correlation(sim.t, result.t)) > 0.95 -def test_custom_blind_dual_reference_non_ortho(): +def test_dual_reference_non_ortho_split(): """ - Test custom blind dual reference with a non-orthogonal basis. + Test dual reference with a non-orthogonal basis. """ do_debug = False From 5ca3011057f232bd64880e5461e103baad966c0a Mon Sep 17 00:00:00 2001 From: Daniel Cox Date: Thu, 3 Oct 2024 10:56:40 +0200 Subject: [PATCH 3/3] Add phase only assertion dual reference test --- tests/test_wfs.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/test_wfs.py b/tests/test_wfs.py index b2e9163..d1f0734 100644 --- a/tests/test_wfs.py +++ b/tests/test_wfs.py @@ -471,12 +471,18 @@ def test_dual_reference_ortho_split(basis_str: str, shape): plt.colorbar() plt.show() - # Checks for orthonormal bases + # Checks for orthonormal basis properties assert np.allclose(alg.gram, np.eye(N), atol=1e-6) # Gram matrix must be I assert np.allclose(alg.cobasis[0], mode_set.conj(), atol=1e-6) # Cobasis vectors are just the complex conjugates + # Test phase-only field correlation + sim_t_phase_only = np.exp(1j * np.angle(sim.t)) + result_t_phase_only = np.exp(1j * np.angle(result.t)) + assert np.abs(field_correlation(sim_t_phase_only, result_t_phase_only)) > 0.999 + # todo: find out why this is not higher - assert np.abs(field_correlation(sim.t, result.t)) > 0.95 + # Test field correlation + assert np.abs(field_correlation(sim.t, result.t)) > 0.9 def test_dual_reference_non_ortho_split():