Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into further-revisions
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenDoornbos committed Oct 3, 2024
2 parents e29ccc4 + 5ca3011 commit 2962eb1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion openwfs/algorithms/basic_fourier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 12 additions & 6 deletions tests/test_wfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -471,17 +471,23 @@ def test_custom_blind_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_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

Expand Down

0 comments on commit 2962eb1

Please sign in to comment.