Skip to content

Commit

Permalink
DiamondLightSource/hyperion#1033 fix param classes and test files
Browse files Browse the repository at this point in the history
  • Loading branch information
dperl-dls committed Mar 18, 2024
1 parent ea74313 commit 5dce042
Show file tree
Hide file tree
Showing 35 changed files with 84 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def event(self, doc: Event):

def get_grid_parameters(self) -> GridScanParams:
return GridScanParams(
transmission_fraction=0.01,
dwell_time_ms=self.exposure_time * 1000,
x_start=self.start_positions[0][0],
y1_start=self.start_positions[0][1],
Expand All @@ -80,6 +81,7 @@ def get_grid_parameters(self) -> GridScanParams:

def get_panda_grid_parameters(self) -> PandAGridScanParams:
return PandAGridScanParams(
transmission_fraction=0.01,
run_up_distance_mm=self.run_up_distance_mm,
x_start=self.start_positions[0][0],
y1_start=self.start_positions[0][1],
Expand Down
5 changes: 1 addition & 4 deletions src/hyperion/parameters/internal_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ def extract_experiment_params_from_flat_dict(
experiment_param_class, flat_params: dict[str, Any]
):
# Use __fields__ to get inherited attributes from BaseModels
if issubclass(experiment_param_class, BaseModel):
experiment_field_keys = list(experiment_param_class.__fields__.keys())
else:
experiment_field_keys = list(experiment_param_class.__annotations__.keys())
experiment_field_keys = list(experiment_param_class.__fields__.keys())

experiment_params_args = fetch_subdict_from_bucket(
experiment_field_keys, flat_params
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from dodal.devices.detector import TriggerMode
from dodal.parameters.experiment_parameter_base import AbstractExperimentWithBeamParams
from pydantic import validator
from pydantic.dataclasses import dataclass

from hyperion.external_interaction.ispyb.ispyb_dataclass import GridscanIspybParams
from hyperion.parameters.internal_parameters import (
Expand All @@ -20,7 +19,6 @@
)


@dataclass
class GridScanWithEdgeDetectParams(AbstractExperimentWithBeamParams):
"""
Holder class for the parameters of a grid scan that uses edge detection to detect the grid.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from dodal.devices.detector import TriggerMode
from dodal.parameters.experiment_parameter_base import AbstractExperimentWithBeamParams
from pydantic import validator
from pydantic.dataclasses import dataclass

from hyperion.external_interaction.ispyb.ispyb_dataclass import GridscanIspybParams
from hyperion.parameters.internal_parameters import (
Expand All @@ -20,7 +19,6 @@
)


@dataclass
class PinCentreThenXrayCentreParams(AbstractExperimentWithBeamParams):
"""
Holder class for the parameters of a plan that does a pin centre then xray centre
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from dodal.devices.motors import XYZLimitBundle
from dodal.devices.zebra import RotationDirection
from dodal.parameters.experiment_parameter_base import AbstractExperimentWithBeamParams
from pydantic import BaseModel, validator
from pydantic import validator
from scanspec.core import Path as ScanPath
from scanspec.specs import Line

Expand Down Expand Up @@ -36,7 +36,7 @@ class Config:
}


class RotationScanParams(BaseModel, AbstractExperimentWithBeamParams):
class RotationScanParams(AbstractExperimentWithBeamParams):
"""
Holder class for the parameters of a rotation data collection.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

import numpy as np
from dodal.devices.detector import DetectorParams, TriggerMode
from dodal.parameters.experiment_parameter_base import AbstractExperimentParameterBase
from dodal.parameters.experiment_parameter_base import AbstractExperimentWithBeamParams
from pydantic import validator
from pydantic.dataclasses import dataclass

from hyperion.external_interaction.ispyb.ispyb_dataclass import (
GRIDSCAN_ISPYB_PARAM_DEFAULTS,
Expand All @@ -33,8 +32,7 @@ class Config:
}


@dataclass
class WaitForRobotLoadThenCentreParams(AbstractExperimentParameterBase):
class WaitForRobotLoadThenCentreParams(AbstractExperimentWithBeamParams):
"""
Holder class for the parameters of a plan that waits for robot load then does a
centre.
Expand All @@ -56,6 +54,9 @@ class WaitForRobotLoadThenCentreParams(AbstractExperimentParameterBase):
# plugin
use_ophyd_pin_tip_detect: bool = False

def get_num_images(self):
return 0


class WaitForRobotLoadThenCentreInternalParameters(InternalParameters):
experiment_params: WaitForRobotLoadThenCentreParams
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
"omega_start": {
"type": "number"
},
"transmission_fraction": {
"type": "number"
},
"set_stub_offsets": {
"type": "boolean"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@
},
"use_panda": {
"type": "boolean"
},
"transmission_fraction": {
"type": "number"
}

},
"required": [
"exposure_time",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@
"set_stub_offsets": {
"type": "boolean"
},
"transmission_fraction": {
"type": "number"
},
"run_up_distance_mm": {
"type": "number"
}

},
"minProperties": 12,
"additionalProperties": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
},
"shutter_opening_time_s": {
"type": "number"
},
"transmission_fraction": {
"type": "number"
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@
"type": "boolean"
},
"requested_energy_kev": {
"type": ["number", "null"]
"type": [
"number",
"null"
]
},
"use_panda": {
"type": "boolean"
},
"transmission_fraction": {
"type": "number"
}

},
"required": [
"exposure_time",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "object",
"properties": {
"params_version": {
"const": "4.0.4"
"const": "5.0.0"
},
"hyperion_params": {
"type": "object",
Expand Down
9 changes: 4 additions & 5 deletions src/hyperion/parameters/schemas/ispyb_parameters_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@
"type": "string"
}
},
"transmission_fraction": {
"type": "number"
},
"flux": {
"type": "number"
},
Expand Down Expand Up @@ -76,15 +73,17 @@
"type": "number"
},
"ispyb_experiment_type": {
"type": ["string", "null"]
"type": [
"string",
"null"
]
}
},
"required": [
"visit_path",
"microns_per_pixel_x",
"microns_per_pixel_y",
"position",
"transmission_fraction",
"flux",
"beam_size_x",
"beam_size_y",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"params_version": "4.0.4",
"params_version": "5.0.0",
"hyperion_params": {
"beamline": "BL03S",
"insertion_prefix": "SR03S",
Expand All @@ -23,7 +23,6 @@
20.0,
30.0
],
"transmission_fraction": 1.0,
"flux": 10.0,
"beam_size_x": 1.0,
"beam_size_y": 1.0,
Expand All @@ -41,6 +40,7 @@
"exposure_time": 0.1,
"detector_distance": 100.0,
"omega_start": 0.0,
"grid_width_microns": 151
"grid_width_microns": 151,
"transmission_fraction": 1.0
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"params_version": "4.0.4",
"params_version": "5.0.0",
"hyperion_params": {
"beamline": "BL03S",
"insertion_prefix": "SR03S",
Expand Down Expand Up @@ -43,7 +43,6 @@
"test_2",
"test_3"
],
"transmission_fraction": 1.0,
"flux": 10.0,
"beam_size_x": 1.0,
"beam_size_y": 1.0,
Expand All @@ -70,6 +69,7 @@
"z2_start": 0.0,
"exposure_time": 0.1,
"detector_distance": 100.0,
"omega_start": 0.0
"omega_start": 0.0,
"transmission_fraction": 1.0
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"params_version": "4.0.4",
"params_version": "5.0.0",
"hyperion_params": {
"beamline": "BL03S",
"insertion_prefix": "SR03S",
Expand All @@ -23,7 +23,6 @@
20.0,
30.0
],
"transmission_fraction": 1.0,
"flux": 10.0,
"beam_size_x": 1.0,
"beam_size_y": 1.0,
Expand All @@ -44,6 +43,7 @@
"tip_offset_microns": 108.9,
"grid_width_microns": 290.6,
"oav_centring_file": "tests/test_data/test_OAVCentring.json",
"use_ophyd_pin_tip_detect": true
"use_ophyd_pin_tip_detect": true,
"transmission_fraction": 1.0
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"params_version": "4.0.4",
"params_version": "5.0.0",
"hyperion_params": {
"beamline": "BL03S",
"insertion_prefix": "SR03S",
Expand Down Expand Up @@ -43,7 +43,6 @@
"test_2",
"test_3"
],
"transmission_fraction": 1.0,
"flux": 10.0,
"beam_size_x": 1.0,
"beam_size_y": 1.0,
Expand All @@ -62,6 +61,7 @@
"phi_start": 0.0,
"chi_start": 0,
"x": 1.0,
"transmission_fraction": 1.0,
"y": 2.0,
"z": 3.0,
"exposure_time": 0.1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"params_version": "4.0.4",
"params_version": "5.0.0",
"hyperion_params": {
"beamline": "BL03S",
"insertion_prefix": "SR03S",
Expand Down Expand Up @@ -43,7 +43,6 @@
"test_2",
"test_3"
],
"transmission_fraction": 1.0,
"flux": 10.0,
"beam_size_x": 1.0,
"beam_size_y": 1.0,
Expand All @@ -56,6 +55,7 @@
}
},
"experiment_params": {
"transmission_fraction": 1.0,
"rotation_axis": "omega",
"rotation_angle": 180.0,
"omega_start": 0.0,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"params_version": "4.0.4",
"params_version": "5.0.0",
"hyperion_params": {
"beamline": "BL03S",
"insertion_prefix": "SR03S",
Expand Down Expand Up @@ -44,7 +44,6 @@
"test_2",
"test_3"
],
"transmission_fraction": 1.0,
"flux": 10.0,
"beam_size_x": 1.0,
"beam_size_y": 1.0,
Expand All @@ -60,6 +59,7 @@
"x_steps": 5,
"y_steps": 10,
"z_steps": 2,
"transmission_fraction": 1.0,
"x_step_size": 0.1,
"y_step_size": 0.1,
"z_step_size": 0.1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"params_version": "4.0.4",
"params_version": "5.0.0",
"hyperion_params": {
"zocalo_environment": "artemis",
"beamline": "BL03I",
Expand All @@ -21,7 +21,6 @@
0,
0
],
"transmission_fraction": 1.0,
"flux": 10.0,
"beam_size_x": 0.1,
"beam_size_y": 0.1,
Expand All @@ -34,6 +33,7 @@
},
"experiment_params": {
"omega_start": 0,
"transmission_fraction": 1.0,
"exposure_time": 0.004,
"detector_distance": 255,
"snapshot_dir": "/tmp",
Expand Down
Loading

0 comments on commit 5dce042

Please sign in to comment.