Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor ApertureScatterguard to return individual signals #769

Merged
merged 7 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/dodal/beamline_specific_utils/i03.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from dataclasses import dataclass

from dodal.devices.aperturescatterguard import SingleAperturePosition

I03_BEAM_HEIGHT_UM = 20


Expand All @@ -11,6 +9,5 @@ class BeamSize:
y_um: float | None


def beam_size_from_aperture(position: SingleAperturePosition):
aperture_size = position.radius_microns
def beam_size_from_aperture(aperture_size: float | None):
return BeamSize(aperture_size, I03_BEAM_HEIGHT_UM if aperture_size else None)
4 changes: 2 additions & 2 deletions src/dodal/beamlines/i03.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline
from dodal.common.udc_directory_provider import PandASubdirectoryProvider
from dodal.devices.aperturescatterguard import (
AperturePosition,
ApertureScatterguard,
load_positions_from_beamline_parameters,
load_tolerances_from_beamline_params,
)
from dodal.devices.attenuator import Attenuator
from dodal.devices.backlight import Backlight
Expand Down Expand Up @@ -71,7 +71,7 @@ def aperture_scatterguard(
wait=wait_for_connection,
fake=fake_with_ophyd_sim,
loaded_positions=load_positions_from_beamline_parameters(params),
tolerances=load_tolerances_from_beamline_params(params),
tolerances=AperturePosition.tolerances_from_gda_params(params),
)


Expand Down
4 changes: 2 additions & 2 deletions src/dodal/beamlines/i04.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from dodal.common.beamlines.beamline_utils import device_instantiation
from dodal.common.beamlines.beamline_utils import set_beamline as set_utils_beamline
from dodal.devices.aperturescatterguard import (
AperturePosition,
ApertureScatterguard,
load_positions_from_beamline_parameters,
load_tolerances_from_beamline_params,
)
from dodal.devices.attenuator import Attenuator
from dodal.devices.backlight import Backlight
Expand Down Expand Up @@ -236,7 +236,7 @@ def aperture_scatterguard(
wait=wait_for_connection,
fake=fake_with_ophyd_sim,
loaded_positions=load_positions_from_beamline_parameters(params),
tolerances=load_tolerances_from_beamline_params(params),
tolerances=AperturePosition.tolerances_from_gda_params(params),
)


Expand Down
7 changes: 4 additions & 3 deletions src/dodal/common/beamlines/beamline_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
class GDABeamlineParameters:
params: dict[str, Any]

def __init__(self, params: dict[str, Any]):
self.params = params

def __repr__(self) -> str:
return repr(self.params)

Expand All @@ -23,7 +26,6 @@ def __getitem__(self, item: str):

@classmethod
def from_lines(cls, file_name: str, config_lines: list[str]):
ob = cls()
config_lines_nocomments = [line.split("#", 1)[0] for line in config_lines]
config_lines_sep_key_and_value = [
# XXX removes all whitespace instead of just trim
Expand All @@ -46,8 +48,7 @@ def from_lines(cls, file_name: str, config_lines: list[str]):
except Exception as e:
LOGGER.warning(f"Unable to parse {file_name} line {i}: {e}")

ob.params = dict(config_pairs)
return ob
return cls(params=dict(config_pairs))

@classmethod
def from_file(cls, path: str):
Expand Down
Loading
Loading