Skip to content

Commit

Permalink
Merge pull request #123 from DiamondLightSource/artemis_810_ensure_us…
Browse files Browse the repository at this point in the history
…e_of_dataclasses_are_correct

Fix use of class variables
  • Loading branch information
DominicOram authored Aug 3, 2023
2 parents 443c1fd + 36e0efe commit 346f7f5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 45 deletions.
7 changes: 2 additions & 5 deletions src/dodal/devices/det_dist_to_beam_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ class Axis(Enum):


class DetectorDistanceToBeamXYConverter:
lookup_file: str
lookup_table_values: list

def __init__(self, lookup_file: str):
self.lookup_file = lookup_file
self.lookup_table_values = self.parse_table()
self.lookup_file: str = lookup_file
self.lookup_table_values: list = self.parse_table()

def get_beam_xy_from_det_dist(self, det_dist_mm: float, beam_axis: Axis) -> float:
beam_axis_values = self.lookup_table_values[beam_axis.value]
Expand Down
64 changes: 24 additions & 40 deletions src/dodal/devices/oav/oav_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,20 @@


class OAVParameters:
zoom_params_file: str
oav_config_json: str
display_config: str
global_params: dict[str, Any]
context_dicts: dict[str, dict]
active_params: ChainMap

exposure: float
acquire_period: float
gain: float
canny_edge_upper_threshold: float
canny_edge_lower_threshold: float
minimum_height: int
zoom: float
preprocess: int # gets blur type, e.g. 8 = gaussianBlur, 9 = medianBlur
preprocess_K_size: int # length scale for blur preprocessing
detection_script_filename: str
close_ksize: int
min_callback_time: float
direction: int
max_tip_distance: float

def __init__(
self,
context="loopCentring",
zoom_params_file=OAV_CONFIG_FILE_DEFAULTS["zoom_params_file"],
oav_config_json=OAV_CONFIG_FILE_DEFAULTS["oav_config_json"],
display_config=OAV_CONFIG_FILE_DEFAULTS["display_config"],
):
self.zoom_params_file = zoom_params_file
self.oav_config_json = oav_config_json
self.display_config = display_config
self.zoom_params_file: str = zoom_params_file
self.oav_config_json: str = oav_config_json
self.display_config: str = display_config
self.context = context

self.global_params, self.context_dicts = self.load_json(self.oav_config_json)
self.active_params = ChainMap(
self.active_params: ChainMap = ChainMap(
self.context_dicts[self.context], self.global_params
)
self.update_self_from_current_context()
Expand Down Expand Up @@ -91,22 +69,28 @@ def update(name, param_type, default=None):
f"wrong type, should be {param_type} but is {type(param)}."
)

self.exposure = update("exposure", float)
self.acquire_period = update("acqPeriod", float)
self.gain = update("gain", float)
self.canny_edge_upper_threshold = update("CannyEdgeUpperThreshold", float)
self.canny_edge_lower_threshold = update(
self.exposure: float = update("exposure", float)
self.acquire_period: float = update("acqPeriod", float)
self.gain: float = update("gain", float)
self.canny_edge_upper_threshold: float = update(
"CannyEdgeUpperThreshold", float
)
self.canny_edge_lower_threshold: float = update(
"CannyEdgeLowerThreshold", float, default=5.0
)
self.minimum_height = update("minheight", int)
self.zoom = update("zoom", float)
self.preprocess = update("preprocess", int)
self.preprocess_K_size = update("preProcessKSize", int)
self.detection_script_filename = update("filename", str)
self.close_ksize = update("close_ksize", int, default=11)
self.min_callback_time = update("min_callback_time", float, default=0.08)
self.direction = update("direction", int)
self.max_tip_distance = update("max_tip_distance", float, default=300)
self.minimum_height: int = update("minheight", int)
self.zoom: float = update("zoom", float)
self.preprocess: int = update(
"preprocess", int
) # gets blur type, e.g. 8 = gaussianBlur, 9 = medianBlur
self.preprocess_K_size: int = update(
"preProcessKSize", int
) # length scale for blur preprocessing
self.detection_script_filename: str = update("filename", str)
self.close_ksize: int = update("close_ksize", int, default=11)
self.min_callback_time: float = update("min_callback_time", float, default=0.08)
self.direction: int = update("direction", int)
self.max_tip_distance: float = update("max_tip_distance", float, default=300)

def load_microns_per_pixel(self, zoom=None):
"""
Expand Down

0 comments on commit 346f7f5

Please sign in to comment.