Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1271 from DiamondLightSource/1033_clarify_desired…
Browse files Browse the repository at this point in the history
…_transmission

Clarify which transmission is which
  • Loading branch information
dperl-dls authored Apr 4, 2024
2 parents 3d5ab75 + 662149a commit f939ffb
Show file tree
Hide file tree
Showing 40 changed files with 74 additions and 60 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ install_requires =
xarray
doct
databroker
dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git
dls-dodal @ git+https://github.com/DiamondLightSource/dodal.git@7068bf2f0e75f8fffa83693136cb555b03ce8545
pydantic<2.0 # See https://github.com/DiamondLightSource/hyperion/issues/774
scipy
pyzmq<25 # See https://github.com/DiamondLightSource/hyperion/issues/1103
Expand Down
4 changes: 2 additions & 2 deletions src/hyperion/experiment_plans/experiment_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from dodal.devices.fast_grid_scan import GridScanParams
from dodal.devices.panda_fast_grid_scan import PandAGridScanParams
from dodal.parameters.experiment_parameter_base import AbstractExperimentParameterBase
from dodal.parameters.experiment_parameter_base import AbstractExperimentWithBeamParams

import hyperion.experiment_plans.flyscan_xray_centre_plan as flyscan_xray_centre_plan
import hyperion.experiment_plans.panda_flyscan_xray_centre_plan as panda_flyscan_xray_centre_plan
Expand Down Expand Up @@ -61,7 +61,7 @@ class ExperimentRegistryEntry(TypedDict):
| RobotLoadThenCentreInternalParameters
| PandAGridscanInternalParameters
]
experiment_param_type: type[AbstractExperimentParameterBase]
experiment_param_type: type[AbstractExperimentWithBeamParams]
callbacks_factory: CallbacksFactory


Expand Down
2 changes: 1 addition & 1 deletion src/hyperion/experiment_plans/flyscan_xray_centre_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def flyscan_xray_centre(
@transmission_and_xbpm_feedback_for_collection_decorator(
composite.xbpm_feedback,
composite.attenuator,
parameters.hyperion_params.ispyb_params.transmission_fraction,
parameters.experiment_params.transmission_fraction,
)
def run_gridscan_and_move_and_tidy(fgs_composite, params):
yield from run_gridscan_and_move(fgs_composite, params)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def panda_flyscan_xray_centre(
@transmission_and_xbpm_feedback_for_collection_decorator(
composite.xbpm_feedback,
composite.attenuator,
parameters.hyperion_params.ispyb_params.transmission_fraction,
parameters.experiment_params.transmission_fraction,
)
def run_gridscan_and_move_and_tidy(fgs_composite, params):
yield from run_gridscan_and_move(fgs_composite, params)
Expand Down
2 changes: 1 addition & 1 deletion src/hyperion/experiment_plans/rotation_scan_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def rotation_with_cleanup_and_stage(params: RotationInternalParameters):
composite.detector_motion,
composite.backlight,
composite.attenuator,
params.hyperion_params.ispyb_params.transmission_fraction,
params.experiment_params.transmission_fraction,
params.hyperion_params.detector_params.detector_distance,
)
LOGGER.info("moving to position (if specified)")
Expand Down
2 changes: 1 addition & 1 deletion src/hyperion/experiment_plans/set_energy_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import dataclasses
from typing import Any, Generator

from bluesky import Msg
from bluesky import plan_stubs as bps
from bluesky.utils import Msg
from dodal.devices.attenuator import Attenuator
from dodal.devices.DCM import DCM
from dodal.devices.focusing_mirror import FocusingMirror, VFMMirrorVoltages
Expand Down
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
9 changes: 3 additions & 6 deletions src/hyperion/parameters/internal_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Any

from dodal.devices.eiger import DetectorParams
from dodal.parameters.experiment_parameter_base import AbstractExperimentParameterBase
from dodal.parameters.experiment_parameter_base import AbstractExperimentWithBeamParams
from pydantic import BaseModel, root_validator
from semver import Version

Expand Down 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 Expand Up @@ -159,7 +156,7 @@ def _hyperion_param_key_definitions():
def _preprocess_experiment_params(
cls,
experiment_params: dict[str, Any],
) -> AbstractExperimentParameterBase: ...
) -> AbstractExperimentWithBeamParams: ...

@abstractmethod
def _preprocess_hyperion_params(
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 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 GridscanIspybParams
from hyperion.parameters.internal_parameters import (
Expand All @@ -20,8 +19,7 @@
)


@dataclass
class GridScanWithEdgeDetectParams(AbstractExperimentParameterBase):
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 @@ -4,9 +4,8 @@

import numpy as np
from dodal.devices.detector import 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 GridscanIspybParams
from hyperion.parameters.internal_parameters import (
Expand All @@ -20,8 +19,7 @@
)


@dataclass
class PinCentreThenXrayCentreParams(AbstractExperimentParameterBase):
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 @@ -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 RobotLoadThenCentreParams(AbstractExperimentParameterBase):
class RobotLoadThenCentreParams(AbstractExperimentWithBeamParams):
"""
Holder class for the parameters of a plan that waits for robot load then does a
centre.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from dodal.devices.detector import DetectorParams
from dodal.devices.motors import XYZLimitBundle
from dodal.devices.zebra import RotationDirection
from dodal.parameters.experiment_parameter_base import AbstractExperimentParameterBase
from pydantic import BaseModel, validator
from dodal.parameters.experiment_parameter_base import AbstractExperimentWithBeamParams
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, AbstractExperimentParameterBase):
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 @@ -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 @@ -22,6 +22,9 @@
},
"use_panda": {
"type": "boolean"
},
"transmission_fraction": {
"type": "number"
}
},
"required": [
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
2 changes: 1 addition & 1 deletion tests/system_tests/experiment_plans/test_fgs_plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def test_xbpm_feedback_decorator(
@transmission_and_xbpm_feedback_for_collection_decorator(
fxc_composite.xbpm_feedback,
fxc_composite.attenuator,
params.hyperion_params.ispyb_params.transmission_fraction,
params.experiment_params.transmission_fraction,
)
def decorated_plan():
yield from bps.sleep(0.1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
Expand Up @@ -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 @@ -43,6 +42,7 @@
"omega_start": 0.0,
"tip_offset_microns": 108.9,
"grid_width_microns": 290.6,
"oav_centring_file": "tests/test_data/test_OAVCentring.json"
"oav_centring_file": "tests/test_data/test_OAVCentring.json",
"transmission_fraction": 1.0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@ -35,6 +34,7 @@
},
"experiment_params": {
"omega_start": 0,
"transmission_fraction": 1.0,
"exposure_time": 0.004,
"detector_distance": 255,
"snapshot_dir": "/tmp",
Expand Down
Original file line number Diff line number Diff line change
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
Loading

0 comments on commit f939ffb

Please sign in to comment.