Skip to content

Commit

Permalink
Fix mask tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ebezzam committed May 14, 2024
1 parent 5445d93 commit f5f7b45
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions test/test_masks.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ def test_phlatcam():
feature_size=d1,
distance_sensor=dz,
)
assert np.all(mask.mask.shape == resolution)
assert np.all(mask.shape == resolution)
desired_psf_shape = np.array(tuple(resolution) + (len(mask.psf_wavelength),))
assert np.all(mask.psf.shape == desired_psf_shape)

u1 = mask.height_map_to_field(wavelength=mask.design_wv)
Mp = np.sqrt(mask.target_psf) * np.exp(
1j * np.angle(fresnel_conv(mask.mask, mask.design_wv, d1, dz, dtype=np.float32)[0])
1j * np.angle(fresnel_conv(u1, mask.design_wv, d1, dz, dtype=np.float32)[0])
)
assert mse(abs(Mp), np.sqrt(mask.target_psf)) < 0.1
assert psnr(abs(Mp), np.sqrt(mask.target_psf)) > 30
Expand All @@ -72,21 +73,21 @@ def test_classmethod():
mask1 = CodedAperture.from_sensor(
sensor_name="rpi_hq", downsample=downsample, distance_sensor=dz
)
assert np.all(mask1.mask.shape == resolution)
assert np.all(mask1.shape == resolution)
desired_psf_shape = np.array(tuple(resolution) + (len(mask1.psf_wavelength),))
assert np.all(mask1.psf.shape == desired_psf_shape)

mask2 = PhaseContour.from_sensor(
sensor_name="rpi_hq", downsample=downsample, distance_sensor=dz
)
assert np.all(mask2.mask.shape == resolution)
assert np.all(mask2.shape == resolution)
desired_psf_shape = np.array(tuple(resolution) + (len(mask2.psf_wavelength),))
assert np.all(mask2.psf.shape == desired_psf_shape)

mask3 = FresnelZoneAperture.from_sensor(
sensor_name="rpi_hq", downsample=downsample, distance_sensor=dz
)
assert np.all(mask3.mask.shape == resolution)
assert np.all(mask3.shape == resolution)
desired_psf_shape = np.array(tuple(resolution) + (len(mask3.psf_wavelength),))
assert np.all(mask3.psf.shape == desired_psf_shape)

Expand Down

0 comments on commit f5f7b45

Please sign in to comment.