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

Commit

Permalink
(#1327) ispyb omega_start, axis_start now read from hardware for grid…
Browse files Browse the repository at this point in the history
…scans
  • Loading branch information
rtuck99 committed Jun 20, 2024
1 parent 920b079 commit 15313f8
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def populate_remaining_data_collection_info(
data_collection_info.parent_id = data_collection_group_id
data_collection_info.sample_id = params.sample_id
data_collection_info.detector_id = I03_EIGER_DETECTOR
data_collection_info.axis_start = data_collection_info.omega_start
data_collection_info.comments = comment
data_collection_info.detector_distance = params.detector_params.detector_distance
data_collection_info.exp_time = params.detector_params.exposure_time
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ def _handle_oav_grid_snapshot_triggered(self, doc) -> Sequence[ScanDataInfo]:
data_collection_id = self.ispyb_ids.data_collection_ids[
self._oav_snapshot_event_idx
]
self.populate_axis_info_for_snapshot(
data_collection_info, doc["data"]["smargon_omega"]
)

scan_data_info = ScanDataInfo(
data_collection_info=data_collection_info,
Expand Down Expand Up @@ -224,6 +227,12 @@ def _handle_ispyb_transmission_flux_read(self, doc) -> Sequence[ScanDataInfo]:
ISPYB_LOGGER.info("Updating ispyb data collection after flux read.")
return scan_data_infos

@abstractmethod
def populate_axis_info_for_snapshot(
self, data_collection_info: DataCollectionInfo, omega_start: float | None
):
pass

@abstractmethod
def populate_info_for_update(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ def activity_gated_start(self, doc: RunStart):
self.uid_to_finalize_on = doc.get("uid")
return super().activity_gated_start(doc)

def populate_axis_info_for_snapshot(
self, data_collection_info: DataCollectionInfo, omega_start: float | None
):
# TODO in subsequent PR which depends on rotation snapshots 349
pass

def populate_info_for_update(
self,
event_sourced_data_collection_info: DataCollectionInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def populate_data_collection_info_for_rotation(params: RotationScan):
data_collection_number=params.detector_params.run_number, # type:ignore # the validator always makes this int
n_images=params.num_images,
axis_range=params.rotation_increment_deg,
axis_start=params.omega_start_deg,
axis_end=(params.omega_start_deg + params.scan_width_deg),
kappa_start=params.kappa_start_deg,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@
StoreInIspyb,
)
from hyperion.log import ISPYB_LOGGER, set_dcgid_tag
from hyperion.parameters.components import DiffractionExperimentWithSample
from hyperion.parameters.constants import CONST
from hyperion.parameters.gridscan import (
GridCommon,
GridScanWithEdgeDetect,
ThreeDGridScan,
)

if TYPE_CHECKING:
Expand Down Expand Up @@ -163,11 +162,20 @@ def activity_gated_event(self, doc: Event):

return doc

def populate_axis_info_for_snapshot(
self, data_collection_info: DataCollectionInfo, omega_start: float | None
):
if omega_start is not None:
data_collection_info.omega_start = omega_start
data_collection_info.axis_start = omega_start
data_collection_info.axis_end = omega_start
data_collection_info.axis_range = 0

def populate_info_for_update(
self,
event_sourced_data_collection_info: DataCollectionInfo,
event_sourced_position_info: Optional[DataCollectionPositionInfo],
params: ThreeDGridScan | GridScanWithEdgeDetect,
params: DiffractionExperimentWithSample,
) -> Sequence[ScanDataInfo]:
assert (
self.ispyb_ids.data_collection_ids
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,16 @@ def populate_xz_data_collection_info(detector_params: DetectorParams):
detector_params.omega_start is not None
and detector_params.run_number is not None
), "StoreGridscanInIspyb failed to get parameters"
omega_start = detector_params.omega_start + 90
run_number = detector_params.run_number + 1
info = DataCollectionInfo(
omega_start=omega_start,
data_collection_number=run_number,
axis_range=0,
axis_end=omega_start,
)
return info


def populate_xy_data_collection_info(detector_params: DetectorParams):
return DataCollectionInfo(
omega_start=detector_params.omega_start,
data_collection_number=detector_params.run_number,
axis_range=0,
axis_end=detector_params.omega_start,
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -662,10 +662,10 @@ def test_ispyb_deposition_in_gridscan(
assert position_id is None
DC_EXPECTED_VALUES.update(
{
"axisstart": 90.0,
"axisend": 90.0,
"axisstart": -90.0,
"axisend": -90.0,
"datacollectionnumber": 2,
"omegastart": 90.0,
"omegastart": -90.0,
"filetemplate": "file_name_2_master.h5",
"numberofimages": 220,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import pytest
from bluesky.run_engine import RunEngine
from dodal.devices.aperturescatterguard import ApertureScatterguard
from dodal.devices.smargon import Smargon
from dodal.devices.synchrotron import SynchrotronMode
from dodal.devices.zebra import Zebra
from ophyd.status import Status
Expand Down
2 changes: 2 additions & 0 deletions tests/unit_tests/external_interaction/callbacks/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class TestData:
"oav_grid_snapshot_last_path_full_overlay": "test_1_y",
"oav_grid_snapshot_last_path_outer": "test_2_y",
"oav_grid_snapshot_last_saved_path": "test_3_y",
"smargon_omega": 0,
},
}
test_event_document_oav_snapshot_xz: Event = {
Expand All @@ -197,6 +198,7 @@ class TestData:
"oav_grid_snapshot_last_saved_path": "test_3_z",
"oav_grid_snapshot_microns_per_pixel_x": 1.25,
"oav_grid_snapshot_microns_per_pixel_y": 1.5,
"smargon_omega": -90,
},
}
test_event_document_pre_data_collection: Event = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
"parentid": TEST_DATA_COLLECTION_GROUP_ID,
"sampleid": TEST_SAMPLE_ID,
"detectorid": 78,
"axisstart": 0.0,
"axisrange": 0,
"axisend": 0,
"data_collection_number": 1,
"detector_distance": 100.0,
"exp_time": 0.1,
Expand All @@ -31,7 +28,6 @@
"imgsuffix": "h5",
"n_passes": 1,
"overlap": 0,
"omegastart": 0,
"start_image_number": 1,
"wavelength": None,
"xbeam": 150.0,
Expand All @@ -43,10 +39,6 @@
}

EXPECTED_DATA_COLLECTION_3D_XZ = EXPECTED_DATA_COLLECTION_3D_XY | {
"omegastart": 90,
"axis_range": 0,
"axisend": 90,
"axisstart": 90,
"data_collection_number": 2,
"filetemplate": "file_name_2_master.h5",
}
Expand Down Expand Up @@ -207,6 +199,10 @@ def test_activity_gated_event_oav_snapshot_triggered(self, mock_ispyb_conn):
"comments": "Hyperion: Xray centring - Diffraction grid scan of 40 by 20 "
"images in 100.0 um by 120.0 um steps. Top left (px): [50,100], "
"bottom right (px): [3250,1700].",
"axisstart": 0,
"omegastart": 0,
"axisend": 0,
"axisrange": 0,
},
)
assert_upsert_call_with(
Expand All @@ -222,6 +218,10 @@ def test_activity_gated_event_oav_snapshot_triggered(self, mock_ispyb_conn):
"comments": "Hyperion: Xray centring - Diffraction grid scan of 40 by 10 "
"images in 100.0 um by 120.0 um steps. Top left (px): [50,0], "
"bottom right (px): [3250,800].",
"axisstart": -90,
"omegastart": -90,
"axisend": -90,
"axisrange": 0,
},
)
assert_upsert_call_with(
Expand Down

0 comments on commit 15313f8

Please sign in to comment.