-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Read aperture size in serialisable format (#549)
- Add a Converter and method to convert SingleAperturePosition - Add a util to get beam size x and y from the above
- Loading branch information
Showing
5 changed files
with
70 additions
and
13 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from dataclasses import dataclass | ||
|
||
from dodal.devices.aperturescatterguard import SingleAperturePosition | ||
|
||
I03_BEAM_HEIGHT_UM = 20 | ||
|
||
|
||
@dataclass | ||
class BeamSize: | ||
x_um: float | None | ||
y_um: float | None | ||
|
||
|
||
def beam_size_from_aperture(position: SingleAperturePosition): | ||
aperture_size = position.radius_microns | ||
return BeamSize(aperture_size, I03_BEAM_HEIGHT_UM if aperture_size else None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
tests/devices/unit_tests/util/test_beamline_specific_utils.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import pytest | ||
|
||
from dodal.beamline_specific_utils.i03 import ( | ||
I03_BEAM_HEIGHT_UM, | ||
beam_size_from_aperture, | ||
) | ||
from dodal.devices.aperturescatterguard import ( | ||
ApertureFiveDimensionalLocation, | ||
SingleAperturePosition, | ||
) | ||
|
||
RADII_AND_SIZES = [ | ||
(None, (None, None)), | ||
(123, (123, I03_BEAM_HEIGHT_UM)), | ||
(23.45, (23.45, I03_BEAM_HEIGHT_UM)), | ||
(888, (888, I03_BEAM_HEIGHT_UM)), | ||
] | ||
|
||
|
||
def get_single_ap(radius): | ||
return SingleAperturePosition( | ||
"", "", radius, ApertureFiveDimensionalLocation(0, 0, 0, 0, 0) | ||
) | ||
|
||
|
||
@pytest.mark.parametrize(["aperture_radius", "beam_size"], RADII_AND_SIZES) | ||
def test_beam_size_from_aperture(aperture_radius, beam_size): | ||
beamsize = beam_size_from_aperture(get_single_ap(aperture_radius)) | ||
assert beamsize.x_um == beam_size[0] | ||
assert beamsize.y_um == beam_size[1] |