From ba111730d6f587f8884fd98a6f700dc1ea1c78bd Mon Sep 17 00:00:00 2001 From: Relm-Arrowny Date: Wed, 25 Sep 2024 12:01:27 +0000 Subject: [PATCH 01/11] added andor2 detectors --- src/dodal/beamlines/p99.py | 44 ++++- src/dodal/devices/areadetector/__init__.py | 2 + src/dodal/devices/areadetector/andor2.py | 51 ++++++ .../areadetector/andor2_epics/__init__.py | 4 + .../andor2_epics/andor2_controller.py | 79 +++++++++ .../areadetector/andor2_epics/andor2_io.py | 53 ++++++ .../unit_tests/areadetector/test_andor2.py | 151 ++++++++++++++++++ 7 files changed, 383 insertions(+), 1 deletion(-) create mode 100644 src/dodal/devices/areadetector/andor2.py create mode 100644 src/dodal/devices/areadetector/andor2_epics/__init__.py create mode 100644 src/dodal/devices/areadetector/andor2_epics/andor2_controller.py create mode 100644 src/dodal/devices/areadetector/andor2_epics/andor2_io.py create mode 100644 tests/devices/unit_tests/areadetector/test_andor2.py diff --git a/src/dodal/beamlines/p99.py b/src/dodal/beamlines/p99.py index fd8b9dfbfb..613c423cca 100644 --- a/src/dodal/beamlines/p99.py +++ b/src/dodal/beamlines/p99.py @@ -1,4 +1,13 @@ -from dodal.common.beamlines.beamline_utils import device_instantiation, set_beamline +from pathlib import Path + +from ophyd_async.core import AutoIncrementFilenameProvider, StaticPathProvider +from ophyd_async.epics.adcore import SingleTriggerDetector + +from dodal.common.beamlines.beamline_utils import ( + device_instantiation, + set_beamline, +) +from dodal.devices.areadetector import Andor2 from dodal.devices.motors import XYZPositioner from dodal.devices.p99.sample_stage import FilterMotor, SampleAngleStage from dodal.log import set_beamline as set_log_beamline @@ -59,3 +68,36 @@ def sample_lab_xyz_stage( wait=wait_for_connection, fake=fake_with_ophyd_sim, ) + + +andor_data_path = StaticPathProvider( + filename_provider=AutoIncrementFilenameProvider(base_filename="andor2"), + directory_path=Path("/dls/p99/data/2024/cm37284-2/processing/writenData"), +) + + +def andor2_det( + wait_for_connection: bool = True, fake_with_ophyd_mock: bool = False +) -> Andor2: + return device_instantiation( + Andor2, + prefix="-EA-DET-03:", + name="andor2_det", + path_provider=andor_data_path, + wait=wait_for_connection, + fake=fake_with_ophyd_mock, + ) + + +def andor2_point( + wait_for_connection: bool = True, fake_with_ophyd_mock: bool = False +) -> SingleTriggerDetector: + return device_instantiation( + SingleTriggerDetector, + drv=andor2_det().drv, + read_uncached=([andor2_det().drv.stat_mean]), + prefix="", + name="andor2_point", + wait=wait_for_connection, + fake=fake_with_ophyd_mock, + ) diff --git a/src/dodal/devices/areadetector/__init__.py b/src/dodal/devices/areadetector/__init__.py index 78171d5ef5..e3df576501 100644 --- a/src/dodal/devices/areadetector/__init__.py +++ b/src/dodal/devices/areadetector/__init__.py @@ -1,10 +1,12 @@ from .adaravis import AdAravisDetector from .adsim import AdSimDetector from .adutils import Hdf5Writer, SynchronisedAdDriverBase +from .andor2 import Andor2 __all__ = [ "AdSimDetector", "SynchronisedAdDriverBase", "Hdf5Writer", "AdAravisDetector", + "Andor2", ] diff --git a/src/dodal/devices/areadetector/andor2.py b/src/dodal/devices/areadetector/andor2.py new file mode 100644 index 0000000000..e506b7f4d4 --- /dev/null +++ b/src/dodal/devices/areadetector/andor2.py @@ -0,0 +1,51 @@ +from bluesky.protocols import Hints +from ophyd_async.core import PathProvider, StandardDetector +from ophyd_async.epics.adcore import ADBaseDatasetDescriber, ADHDFWriter, NDFileHDFIO + +from dodal.devices.areadetector.andor2_epics import Andor2Controller, Andor2DriverIO + + +class Andor2(StandardDetector): + """ + Andor 2 area detector device + + Parameters + ---------- + prefix: str + Epic Pv, + path_provider: PathProvider + Path provider for hdf writer + name: str + Name of the device + config_sigs: Sequence[SignalR] + optional config signal to be added + **scalar_sigs: str + Optional scalar signals + """ + + _controller: Andor2Controller + _writer: ADHDFWriter + + def __init__( + self, + prefix: str, + path_provider: PathProvider, + name: str, + ): + self.drv = Andor2DriverIO(prefix + "CAM:") + self.hdf = NDFileHDFIO(prefix + "HDF5:") + super().__init__( + Andor2Controller(self.drv), + ADHDFWriter( + self.hdf, + path_provider, + lambda: self.name, + ADBaseDatasetDescriber(self.drv), + ), + config_sigs=[self.drv.acquire_time], + name=name, + ) + + @property + def hints(self) -> Hints: + return self._writer.hints diff --git a/src/dodal/devices/areadetector/andor2_epics/__init__.py b/src/dodal/devices/areadetector/andor2_epics/__init__.py new file mode 100644 index 0000000000..5266370530 --- /dev/null +++ b/src/dodal/devices/areadetector/andor2_epics/__init__.py @@ -0,0 +1,4 @@ +from .andor2_controller import Andor2Controller +from .andor2_io import Andor2DriverIO, Andor2TriggerMode, ImageMode + +__all__ = ["Andor2Controller", "Andor2TriggerMode", "Andor2DriverIO", "ImageMode"] diff --git a/src/dodal/devices/areadetector/andor2_epics/andor2_controller.py b/src/dodal/devices/areadetector/andor2_epics/andor2_controller.py new file mode 100644 index 0000000000..3dbf07cfac --- /dev/null +++ b/src/dodal/devices/areadetector/andor2_epics/andor2_controller.py @@ -0,0 +1,79 @@ +import asyncio + +from ophyd_async.core import DetectorControl, DetectorTrigger +from ophyd_async.core._detector import TriggerInfo +from ophyd_async.epics import adcore +from ophyd_async.epics.adcore import ( + DEFAULT_GOOD_STATES, + DetectorState, + stop_busy_record, +) + +from .andor2_io import ( + Andor2DriverIO, + Andor2TriggerMode, + ImageMode, +) + + +class Andor2Controller(DetectorControl): + """ + Andor 2 controller + + """ + + _supported_trigger_types = { + DetectorTrigger.internal: Andor2TriggerMode.internal, + DetectorTrigger.constant_gate: Andor2TriggerMode.ext_trigger, + } + + def __init__( + self, + driver: Andor2DriverIO, + good_states: set[DetectorState] | None = None, + ) -> None: + if good_states is None: + good_states = set(DEFAULT_GOOD_STATES) + self._drv = driver + self.good_states = good_states + + def get_deadtime(self, exposure: float | None) -> float: + if exposure is None: + return 0.1 + return exposure + 0.1 + + async def prepare(self, trigger_info: TriggerInfo): + if trigger_info.livetime is not None: + await adcore.set_exposure_time_and_acquire_period_if_supplied( + self, self._drv, trigger_info.livetime + ) + await asyncio.gather( + self._drv.trigger_mode.set(self._get_trigger_mode(trigger_info.trigger)), + self._drv.num_images.set( + 999_999 if trigger_info.number == 0 else trigger_info.number + ), + self._drv.image_mode.set(ImageMode.multiple), + ) + + async def arm(self) -> None: + # Standard arm the detector and wait for the acquire PV to be True + self._arm_status = await adcore.start_acquiring_driver_and_ensure_status( + self._drv + ) + + async def wait_for_idle(self): + if self._arm_status: + await self._arm_status + + @classmethod + def _get_trigger_mode(cls, trigger: DetectorTrigger) -> Andor2TriggerMode: + if trigger not in cls._supported_trigger_types.keys(): + raise ValueError( + f"{cls.__name__} only supports the following trigger " + f"types: {cls._supported_trigger_types.keys()} but was asked to " + f"use {trigger}" + ) + return cls._supported_trigger_types[trigger] + + async def disarm(self): + await stop_busy_record(self._drv.acquire, False, timeout=1) diff --git a/src/dodal/devices/areadetector/andor2_epics/andor2_io.py b/src/dodal/devices/areadetector/andor2_epics/andor2_io.py new file mode 100644 index 0000000000..52c28a7288 --- /dev/null +++ b/src/dodal/devices/areadetector/andor2_epics/andor2_io.py @@ -0,0 +1,53 @@ +from enum import Enum + +from ophyd_async.epics.adcore._core_io import ADBaseIO +from ophyd_async.epics.signal import ( + epics_signal_r, + epics_signal_rw, + epics_signal_rw_rbv, +) + + +class Andor2TriggerMode(str, Enum): + internal = "Internal" + ext_trigger = "External" + ext_start = "External Start" + ext_exposure = "External Exposure" + ext_FVP = "External FVP" + soft = "Software" + + +class ImageMode(str, Enum): + single = "Single" + multiple = "Multiple" + continuous = "Continuous" + fast_kinetics = "Fast Kinetics" + + +class ADBaseDataType(str, Enum): + UInt16 = "UInt16" + UInt32 = "UInt32" + b1 = "" + b2 = "" + b3 = "" + b4 = "" + b5 = "" + b6 = "" + Float32 = "Float32" + Float64 = "Float64" + + +class Andor2DriverIO(ADBaseIO): + """ + Epics pv for andor model:DU897_BV as deployed on p99 + """ + + def __init__(self, prefix: str) -> None: + super().__init__(prefix) + self.trigger_mode = epics_signal_rw(Andor2TriggerMode, prefix + "TriggerMode") + self.data_type = epics_signal_r(ADBaseDataType, prefix + "DataType_RBV") + self.accumulate_period = epics_signal_r( + float, prefix + "AndorAccumulatePeriod_RBV" + ) + self.image_mode = epics_signal_rw_rbv(ImageMode, prefix + "ImageMode") + self.stat_mean = epics_signal_r(int, prefix[:-4] + "STAT:MeanValue_RBV") diff --git a/tests/devices/unit_tests/areadetector/test_andor2.py b/tests/devices/unit_tests/areadetector/test_andor2.py new file mode 100644 index 0000000000..38bc689ded --- /dev/null +++ b/tests/devices/unit_tests/areadetector/test_andor2.py @@ -0,0 +1,151 @@ +from collections import defaultdict +from pathlib import Path +from unittest.mock import Mock, patch + +import pytest +from bluesky.plans import count +from bluesky.run_engine import RunEngine +from ophyd_async.core import ( + DetectorTrigger, + DeviceCollector, + FilenameProvider, + StaticFilenameProvider, + StaticPathProvider, + TriggerInfo, + assert_emitted, + callback_on_mock_put, + set_mock_value, +) +from ophyd_async.epics.adcore._core_io import DetectorState + +from dodal.devices.areadetector import Andor2 +from dodal.devices.areadetector.andor2_epics import ( + Andor2DriverIO, + Andor2TriggerMode, + ImageMode, +) +from dodal.devices.areadetector.andor2_epics.andor2_controller import Andor2Controller + + +@pytest.fixture +def static_filename_provider(): + return StaticFilenameProvider("ophyd_async_tests") + + +@pytest.fixture +def static_path_provider_factory(tmp_path: Path): + def create_static_dir_provider_given_fp(fp: FilenameProvider): + return StaticPathProvider(fp, tmp_path) + + return create_static_dir_provider_given_fp + + +@pytest.fixture +def static_path_provider( + static_path_provider_factory, + static_filename_provider: FilenameProvider, +): + return static_path_provider_factory(static_filename_provider) + + +@pytest.fixture +async def Andor() -> Andor2Controller: + async with DeviceCollector(mock=True): + drv = Andor2DriverIO("DRIVER:") + controller = Andor2Controller(drv) + + return controller + + +async def test_Andor_controller(RE, Andor: Andor2Controller): + with patch("ophyd_async.core.wait_for_value", return_value=None): + await Andor.prepare(trigger_info=TriggerInfo(number=1, livetime=0.002)) + await Andor.arm() + + driver = Andor._drv + + set_mock_value(driver.accumulate_period, 1) + assert await driver.num_images.get_value() == 1 + assert await driver.image_mode.get_value() == ImageMode.multiple + assert await driver.trigger_mode.get_value() == Andor2TriggerMode.internal + assert await driver.acquire.get_value() is True + assert await driver.acquire_time.get_value() == 0.002 + assert Andor.get_deadtime(2) == 2 + 0.1 + assert Andor.get_deadtime(None) == 0.1 + + with patch("ophyd_async.core.wait_for_value", return_value=None): + await Andor.disarm() + + assert await driver.acquire.get_value() is False + + with patch("ophyd_async.core.wait_for_value", return_value=None): + await Andor.disarm() + with pytest.raises(ValueError): + Andor._get_trigger_mode(DetectorTrigger.edge_trigger) + + assert await driver.acquire.get_value() is False + + +# area detector that is use for testing +@pytest.fixture +async def andor2(static_path_provider: StaticPathProvider) -> Andor2: + async with DeviceCollector(mock=True): + andor2 = Andor2("p99", static_path_provider, "andor2") + + set_mock_value(andor2._controller._drv.array_size_x, 10) + set_mock_value(andor2._controller._drv.array_size_y, 20) + set_mock_value(andor2.hdf.file_path_exists, True) + set_mock_value(andor2.hdf.num_captured, 0) + set_mock_value(andor2.hdf.file_path, str(static_path_provider._directory_path)) + set_mock_value( + andor2.hdf.full_file_name, + str(static_path_provider._directory_path) + "/test-andor2-hdf0", + ) + + rbv_mocks = Mock() + rbv_mocks.get.side_effect = range(0, 10000) + callback_on_mock_put( + andor2._writer.hdf.capture, + lambda *_, **__: set_mock_value(andor2._writer.hdf.capture, value=True), + ) + + callback_on_mock_put( + andor2.drv.acquire, + lambda *_, **__: set_mock_value( + andor2._writer.hdf.num_captured, rbv_mocks.get() + ), + ) + + return andor2 + + +async def test_Andor2_RE( + RE: RunEngine, + andor2: Andor2, + static_path_provider: StaticPathProvider, +): + docs = defaultdict(list) + + def capture_emitted(name, doc): + docs[name].append(doc) + + RE.subscribe(capture_emitted) + set_mock_value(andor2.drv.detector_state, DetectorState.Idle) + RE(count([andor2], 10)) + assert ( + str(static_path_provider._directory_path) + == await andor2.hdf.file_path.get_value() + ) + assert ( + str(static_path_provider._directory_path) + "/test-andor2-hdf0" + == await andor2.hdf.full_file_name.get_value() + ) + assert_emitted( + docs, + start=1, + descriptor=1, + stream_resource=1, + stream_datum=10, + event=10, + stop=1, + ) From 9efbad09e56cbcc35cbc77530ee0feb3d315cbfe Mon Sep 17 00:00:00 2001 From: Relm-Arrowny Date: Wed, 25 Sep 2024 12:17:56 +0000 Subject: [PATCH 02/11] remove old docstring --- src/dodal/devices/areadetector/andor2.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/dodal/devices/areadetector/andor2.py b/src/dodal/devices/areadetector/andor2.py index e506b7f4d4..fcbfa580f5 100644 --- a/src/dodal/devices/areadetector/andor2.py +++ b/src/dodal/devices/areadetector/andor2.py @@ -17,10 +17,6 @@ class Andor2(StandardDetector): Path provider for hdf writer name: str Name of the device - config_sigs: Sequence[SignalR] - optional config signal to be added - **scalar_sigs: str - Optional scalar signals """ _controller: Andor2Controller @@ -37,10 +33,10 @@ def __init__( super().__init__( Andor2Controller(self.drv), ADHDFWriter( - self.hdf, - path_provider, - lambda: self.name, - ADBaseDatasetDescriber(self.drv), + hdf=self.hdf, + path_provider=path_provider, + name_provider=lambda: self.name, + dataset_describer=ADBaseDatasetDescriber(self.drv), ), config_sigs=[self.drv.acquire_time], name=name, From da4fb77930085095d974a4de846835654348568f Mon Sep 17 00:00:00 2001 From: Relm-Arrowny Date: Wed, 25 Sep 2024 12:25:18 +0000 Subject: [PATCH 03/11] correct connection mistakes --- src/dodal/beamlines/p99.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/dodal/beamlines/p99.py b/src/dodal/beamlines/p99.py index 613c423cca..15c5e85c73 100644 --- a/src/dodal/beamlines/p99.py +++ b/src/dodal/beamlines/p99.py @@ -50,7 +50,7 @@ def sample_xyz_stage( wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False ) -> XYZPositioner: return device_instantiation( - FilterMotor, + XYZPositioner, prefix="-MO-STAGE-02:", name="sample_xyz_stage", wait=wait_for_connection, @@ -62,7 +62,7 @@ def sample_lab_xyz_stage( wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False ) -> XYZPositioner: return device_instantiation( - FilterMotor, + XYZPositioner, prefix="-MO-STAGE-02:LAB:", name="sample_lab_xyz_stage", wait=wait_for_connection, @@ -77,7 +77,7 @@ def sample_lab_xyz_stage( def andor2_det( - wait_for_connection: bool = True, fake_with_ophyd_mock: bool = False + wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False ) -> Andor2: return device_instantiation( Andor2, @@ -85,12 +85,12 @@ def andor2_det( name="andor2_det", path_provider=andor_data_path, wait=wait_for_connection, - fake=fake_with_ophyd_mock, + fake=fake_with_ophyd_sim, ) def andor2_point( - wait_for_connection: bool = True, fake_with_ophyd_mock: bool = False + wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False ) -> SingleTriggerDetector: return device_instantiation( SingleTriggerDetector, @@ -99,5 +99,5 @@ def andor2_point( prefix="", name="andor2_point", wait=wait_for_connection, - fake=fake_with_ophyd_mock, + fake=fake_with_ophyd_sim, ) From e8deec9bd517e142fb57df5788909b0948a3402d Mon Sep 17 00:00:00 2001 From: Relm-Arrowny Date: Wed, 25 Sep 2024 12:50:24 +0000 Subject: [PATCH 04/11] test stuck CI --- src/dodal/beamlines/p99.py | 6 ++++-- src/dodal/devices/areadetector/andor2.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/dodal/beamlines/p99.py b/src/dodal/beamlines/p99.py index 15c5e85c73..867cab0dbf 100644 --- a/src/dodal/beamlines/p99.py +++ b/src/dodal/beamlines/p99.py @@ -94,8 +94,10 @@ def andor2_point( ) -> SingleTriggerDetector: return device_instantiation( SingleTriggerDetector, - drv=andor2_det().drv, - read_uncached=([andor2_det().drv.stat_mean]), + drv=andor2_det(wait_for_connection, fake_with_ophyd_sim).drv, + read_uncached=( + [andor2_det(wait_for_connection, fake_with_ophyd_sim).drv.stat_mean] + ), prefix="", name="andor2_point", wait=wait_for_connection, diff --git a/src/dodal/devices/areadetector/andor2.py b/src/dodal/devices/areadetector/andor2.py index fcbfa580f5..53e21923b7 100644 --- a/src/dodal/devices/areadetector/andor2.py +++ b/src/dodal/devices/areadetector/andor2.py @@ -7,7 +7,7 @@ class Andor2(StandardDetector): """ - Andor 2 area detector device + Andor 2 area detector device. Andor model:DU897_BV Parameters ---------- From c819404d260974b3562c3459653d92c54792a046 Mon Sep 17 00:00:00 2001 From: Relm-Arrowny Date: Fri, 27 Sep 2024 10:03:53 +0000 Subject: [PATCH 05/11] split and improve test --- src/dodal/devices/areadetector/andor2.py | 22 ++--- .../andor2_epics/andor2_controller.py | 18 ++-- .../areadetector/andor2_epics/andor2_io.py | 6 -- .../unit_tests/areadetector/test_andor2.py | 86 ++++++++++++++----- 4 files changed, 85 insertions(+), 47 deletions(-) diff --git a/src/dodal/devices/areadetector/andor2.py b/src/dodal/devices/areadetector/andor2.py index 53e21923b7..178629cde9 100644 --- a/src/dodal/devices/areadetector/andor2.py +++ b/src/dodal/devices/areadetector/andor2.py @@ -7,16 +7,8 @@ class Andor2(StandardDetector): """ - Andor 2 area detector device. Andor model:DU897_BV - - Parameters - ---------- - prefix: str - Epic Pv, - path_provider: PathProvider - Path provider for hdf writer - name: str - Name of the device + Andor 2 area detector device (CCD detector 56fps with full chip readout). + Andor model:DU897_BV. """ _controller: Andor2Controller @@ -28,6 +20,16 @@ def __init__( path_provider: PathProvider, name: str, ): + """ + Parameters + ---------- + prefix: str + Epic Pv, + path_provider: PathProvider + Path provider for hdf writer + name: str + Name of the device + """ self.drv = Andor2DriverIO(prefix + "CAM:") self.hdf = NDFileHDFIO(prefix + "HDF5:") super().__init__( diff --git a/src/dodal/devices/areadetector/andor2_epics/andor2_controller.py b/src/dodal/devices/areadetector/andor2_epics/andor2_controller.py index 3dbf07cfac..6567b220db 100644 --- a/src/dodal/devices/areadetector/andor2_epics/andor2_controller.py +++ b/src/dodal/devices/areadetector/andor2_epics/andor2_controller.py @@ -15,16 +15,14 @@ ImageMode, ) +MIN_DEAD_TIME = 0.1 +DEFAULT_MAX_NUM_IMAGE = 999_999 -class Andor2Controller(DetectorControl): - """ - Andor 2 controller - - """ +class Andor2Controller(DetectorControl): _supported_trigger_types = { DetectorTrigger.internal: Andor2TriggerMode.internal, - DetectorTrigger.constant_gate: Andor2TriggerMode.ext_trigger, + DetectorTrigger.edge_trigger: Andor2TriggerMode.ext_trigger, } def __init__( @@ -39,8 +37,8 @@ def __init__( def get_deadtime(self, exposure: float | None) -> float: if exposure is None: - return 0.1 - return exposure + 0.1 + return MIN_DEAD_TIME + return exposure + MIN_DEAD_TIME async def prepare(self, trigger_info: TriggerInfo): if trigger_info.livetime is not None: @@ -50,7 +48,9 @@ async def prepare(self, trigger_info: TriggerInfo): await asyncio.gather( self._drv.trigger_mode.set(self._get_trigger_mode(trigger_info.trigger)), self._drv.num_images.set( - 999_999 if trigger_info.number == 0 else trigger_info.number + DEFAULT_MAX_NUM_IMAGE + if trigger_info.number == 0 + else trigger_info.number ), self._drv.image_mode.set(ImageMode.multiple), ) diff --git a/src/dodal/devices/areadetector/andor2_epics/andor2_io.py b/src/dodal/devices/areadetector/andor2_epics/andor2_io.py index 52c28a7288..58596e2dd6 100644 --- a/src/dodal/devices/areadetector/andor2_epics/andor2_io.py +++ b/src/dodal/devices/areadetector/andor2_epics/andor2_io.py @@ -27,12 +27,6 @@ class ImageMode(str, Enum): class ADBaseDataType(str, Enum): UInt16 = "UInt16" UInt32 = "UInt32" - b1 = "" - b2 = "" - b3 = "" - b4 = "" - b5 = "" - b6 = "" Float32 = "Float32" Float64 = "Float64" diff --git a/tests/devices/unit_tests/areadetector/test_andor2.py b/tests/devices/unit_tests/areadetector/test_andor2.py index 38bc689ded..f2d8c70394 100644 --- a/tests/devices/unit_tests/areadetector/test_andor2.py +++ b/tests/devices/unit_tests/areadetector/test_andor2.py @@ -1,6 +1,6 @@ from collections import defaultdict from pathlib import Path -from unittest.mock import Mock, patch +from unittest.mock import Mock import pytest from bluesky.plans import count @@ -24,7 +24,11 @@ Andor2TriggerMode, ImageMode, ) -from dodal.devices.areadetector.andor2_epics.andor2_controller import Andor2Controller +from dodal.devices.areadetector.andor2_epics.andor2_controller import ( + DEFAULT_MAX_NUM_IMAGE, + MIN_DEAD_TIME, + Andor2Controller, +) @pytest.fixture @@ -49,44 +53,82 @@ def static_path_provider( @pytest.fixture -async def Andor() -> Andor2Controller: +async def andor_controller() -> Andor2Controller: async with DeviceCollector(mock=True): drv = Andor2DriverIO("DRIVER:") - controller = Andor2Controller(drv) - - return controller + andor_controller = Andor2Controller(drv) + return andor_controller -async def test_Andor_controller(RE, Andor: Andor2Controller): - with patch("ophyd_async.core.wait_for_value", return_value=None): - await Andor.prepare(trigger_info=TriggerInfo(number=1, livetime=0.002)) - await Andor.arm() - driver = Andor._drv +async def test_andor_controller_prepare_and_arm_with_TriggerInfo( + RE, andor_controller: Andor2Controller +): + await andor_controller.prepare(trigger_info=TriggerInfo(number=1, livetime=0.002)) + await andor_controller.arm() - set_mock_value(driver.accumulate_period, 1) + driver = andor_controller._drv assert await driver.num_images.get_value() == 1 assert await driver.image_mode.get_value() == ImageMode.multiple assert await driver.trigger_mode.get_value() == Andor2TriggerMode.internal assert await driver.acquire.get_value() is True assert await driver.acquire_time.get_value() == 0.002 - assert Andor.get_deadtime(2) == 2 + 0.1 - assert Andor.get_deadtime(None) == 0.1 - with patch("ophyd_async.core.wait_for_value", return_value=None): - await Andor.disarm() +async def test_andor_controller_prepare_and_arm_with_no_livetime( + RE, andor_controller: Andor2Controller +): + # get driver and set the current acquire time. + default_count_time = 2141 + driver = andor_controller._drv + set_mock_value(driver.acquire_time, default_count_time) + await andor_controller.prepare(trigger_info=TriggerInfo(number=5)) + await andor_controller.arm() + + assert await driver.num_images.get_value() == 5 + assert await driver.image_mode.get_value() == ImageMode.multiple + assert await driver.trigger_mode.get_value() == Andor2TriggerMode.internal + assert await driver.acquire.get_value() is True + assert await driver.acquire_time.get_value() == default_count_time + + +async def test_andor_controller_prepare_and_arm_with_trigger_number_of_zero( + RE, andor_controller: Andor2Controller +): + # get driver and set the current acquire time. + default_count_time = 1231 + driver = andor_controller._drv + set_mock_value(driver.acquire_time, default_count_time) + await andor_controller.prepare(trigger_info=TriggerInfo(number=0)) + await andor_controller.arm() + + assert await driver.num_images.get_value() == DEFAULT_MAX_NUM_IMAGE + assert await driver.image_mode.get_value() == ImageMode.multiple + assert await driver.trigger_mode.get_value() == Andor2TriggerMode.internal + assert await driver.acquire.get_value() is True + assert await driver.acquire_time.get_value() == default_count_time + + +async def test_andor_controller_disarm(RE, andor_controller: Andor2Controller): + await andor_controller.disarm() + driver = andor_controller._drv assert await driver.acquire.get_value() is False - with patch("ophyd_async.core.wait_for_value", return_value=None): - await Andor.disarm() + await andor_controller.disarm() + + +async def test_andor_incorrect_tigger_mode(RE, andor_controller: Andor2Controller): with pytest.raises(ValueError): - Andor._get_trigger_mode(DetectorTrigger.edge_trigger) + andor_controller._get_trigger_mode(DetectorTrigger.variable_gate) - assert await driver.acquire.get_value() is False + assert await andor_controller._drv.acquire.get_value() is False + + +async def test_andor_controller_deadtime(RE, andor_controller: Andor2Controller): + assert andor_controller.get_deadtime(2) == 2 + MIN_DEAD_TIME + assert andor_controller.get_deadtime(None) == MIN_DEAD_TIME -# area detector that is use for testing @pytest.fixture async def andor2(static_path_provider: StaticPathProvider) -> Andor2: async with DeviceCollector(mock=True): @@ -119,7 +161,7 @@ async def andor2(static_path_provider: StaticPathProvider) -> Andor2: return andor2 -async def test_Andor2_RE( +async def test_andor2_RE( RE: RunEngine, andor2: Andor2, static_path_provider: StaticPathProvider, From 122ec650e218ba6522bb6b73416603dc6b7dc80c Mon Sep 17 00:00:00 2001 From: Relm-Arrowny Date: Fri, 27 Sep 2024 11:05:40 +0000 Subject: [PATCH 06/11] change ADBaseDataType back with 6 blinks as it failed to connect with it --- src/dodal/beamlines/p99.py | 9 ++++++--- src/dodal/devices/areadetector/andor2_epics/andor2_io.py | 6 ++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/dodal/beamlines/p99.py b/src/dodal/beamlines/p99.py index 867cab0dbf..19bc5e9b94 100644 --- a/src/dodal/beamlines/p99.py +++ b/src/dodal/beamlines/p99.py @@ -21,7 +21,7 @@ def sample_angle_stage( wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False ) -> SampleAngleStage: - """Sample stage for p99""" + """sample angle stage (old currently on the side)""" return device_instantiation( SampleAngleStage, @@ -35,8 +35,6 @@ def sample_angle_stage( def sample_stage_filer( wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False ) -> FilterMotor: - """Sample stage for p99""" - return device_instantiation( FilterMotor, prefix="-MO-STAGE-02:MP:SELECT", @@ -92,6 +90,11 @@ def andor2_det( def andor2_point( wait_for_connection: bool = True, fake_with_ophyd_sim: bool = False ) -> SingleTriggerDetector: + """ + This is the same physical detector as andor2_det but it will not save + any image as we only care about the detector mean count. + This behave very much like a oversize/overpirce photo diode when use in this mode. + """ return device_instantiation( SingleTriggerDetector, drv=andor2_det(wait_for_connection, fake_with_ophyd_sim).drv, diff --git a/src/dodal/devices/areadetector/andor2_epics/andor2_io.py b/src/dodal/devices/areadetector/andor2_epics/andor2_io.py index 58596e2dd6..52c28a7288 100644 --- a/src/dodal/devices/areadetector/andor2_epics/andor2_io.py +++ b/src/dodal/devices/areadetector/andor2_epics/andor2_io.py @@ -27,6 +27,12 @@ class ImageMode(str, Enum): class ADBaseDataType(str, Enum): UInt16 = "UInt16" UInt32 = "UInt32" + b1 = "" + b2 = "" + b3 = "" + b4 = "" + b5 = "" + b6 = "" Float32 = "Float32" Float64 = "Float64" From f453fef9cbb0177d620370feef99f5f5f9b783c1 Mon Sep 17 00:00:00 2001 From: Relm-Arrowny Date: Tue, 8 Oct 2024 11:26:56 +0000 Subject: [PATCH 07/11] added empty string in ADBaseDateType to aviod type mismatch in enum. --- src/dodal/devices/areadetector/andor2_epics/andor2_io.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/dodal/devices/areadetector/andor2_epics/andor2_io.py b/src/dodal/devices/areadetector/andor2_epics/andor2_io.py index 52c28a7288..d5bcb8da26 100644 --- a/src/dodal/devices/areadetector/andor2_epics/andor2_io.py +++ b/src/dodal/devices/areadetector/andor2_epics/andor2_io.py @@ -27,14 +27,9 @@ class ImageMode(str, Enum): class ADBaseDataType(str, Enum): UInt16 = "UInt16" UInt32 = "UInt32" - b1 = "" - b2 = "" - b3 = "" - b4 = "" - b5 = "" - b6 = "" Float32 = "Float32" Float64 = "Float64" + _ = "" class Andor2DriverIO(ADBaseIO): From b51a4b9b99b704ebb716133b14272b0f42885072 Mon Sep 17 00:00:00 2001 From: Relm-Arrowny Date: Tue, 8 Oct 2024 11:32:28 +0000 Subject: [PATCH 08/11] added some comment. --- .ipynb_checkpoints/Untitled-checkpoint.ipynb | 6 + .ipynb_checkpoints/p-checkpoint.ipynbpydantic | 235 +++++++ p.ipynbpydantic | 177 +++++ .../Untitled-checkpoint.ipynb | 615 ++++++++++++++++++ src/Untitled.ipynb | 456 +++++++++++++ .../Id_play-checkpoint.ipynb | 387 +++++++++++ .../areadetector/andor2_epics/andor2_io.py | 4 + 7 files changed, 1880 insertions(+) create mode 100644 .ipynb_checkpoints/Untitled-checkpoint.ipynb create mode 100644 .ipynb_checkpoints/p-checkpoint.ipynbpydantic create mode 100644 p.ipynbpydantic create mode 100644 src/.ipynb_checkpoints/Untitled-checkpoint.ipynb create mode 100644 src/Untitled.ipynb create mode 100644 src/dodal/devices/.ipynb_checkpoints/Id_play-checkpoint.ipynb diff --git a/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/.ipynb_checkpoints/Untitled-checkpoint.ipynb new file mode 100644 index 0000000000..363fcab7ed --- /dev/null +++ b/.ipynb_checkpoints/Untitled-checkpoint.ipynb @@ -0,0 +1,6 @@ +{ + "cells": [], + "metadata": {}, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/.ipynb_checkpoints/p-checkpoint.ipynbpydantic b/.ipynb_checkpoints/p-checkpoint.ipynbpydantic new file mode 100644 index 0000000000..a0e8e02bd7 --- /dev/null +++ b/.ipynb_checkpoints/p-checkpoint.ipynbpydantic @@ -0,0 +1,235 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "id": "ef076421-53cc-4a5a-abd2-3133af676e78", + "metadata": {}, + "outputs": [], + "source": [ + "from pydantic import BaseModel\n", + "from dodal.devices.i10.id_apple2 import convert_csv_to_lookup\n", + "lut= convert_csv_to_lookup(file=\"/workspaces/dodal/tests/devices/i10/lookupTables/IDEnergy2GapCalibrations.csv\", source=(\"Source\",\"idu\"))" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "4df22e82-6817-470d-80da-dc7e8c356bd7", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'lh': {'Energies': {'255.3': {'Low': 255.3,\n", + " 'High': 513.28,\n", + " 'Poly': poly1d([ 4.33435e-08, -7.52562e-05, 6.41791e-02, 3.88755e+00])},\n", + " '513.28': {'Low': 513.28,\n", + " 'High': 771.545,\n", + " 'Poly': poly1d([ 1.04394e-08, -2.61385e-05, 3.93435e-02, 8.14960e+00])},\n", + " '771.545': {'Low': 771.545,\n", + " 'High': 1027.52,\n", + " 'Poly': poly1d([ 9.55013e-09, -2.51296e-05, 3.93892e-02, 7.92050e+00])},\n", + " '1027.52': {'Low': 1027.52,\n", + " 'High': 1282.59,\n", + " 'Poly': poly1d([ 1.04932e-08, -2.84144e-05, 4.30451e-02, 6.60845e+00])},\n", + " '1282.59': {'Low': 1282.59,\n", + " 'High': 1700.0,\n", + " 'Poly': poly1d([ 8.26909e-08, -3.14196e-04, 4.21009e-01, -1.60378e+02])}},\n", + " 'Limit': {'Minimum': 255.3, 'Maximum': 1700.0}},\n", + " 'lv': {'Energies': {'521.99': {'Low': 521.99,\n", + " 'High': 734.983,\n", + " 'Poly': poly1d([ 1.67544e-09, -6.57463e-06, 2.02971e-02, 6.96008e+00])},\n", + " '734.983': {'Low': 734.983,\n", + " 'High': 932.69,\n", + " 'Poly': poly1d([ 2.32314e-09, -5.82037e-06, 1.81492e-02, 7.87490e+00])},\n", + " '932.69': {'Low': 932.69,\n", + " 'High': 1129.16,\n", + " 'Poly': poly1d([ 8.33737e-09, -2.22386e-05, 3.31944e-02, 3.24578e+00])},\n", + " '1129.16': {'Low': 1129.16,\n", + " 'High': 1325.74,\n", + " 'Poly': poly1d([ 1.91056e-08, -6.01726e-05, 7.77255e-02, -1.41739e+01])},\n", + " '1325.74': {'Low': 1325.74,\n", + " 'High': 1700.0,\n", + " 'Poly': poly1d([ 8.03864e-08, -3.12082e-04, 4.23051e-01, -1.72027e+02])}},\n", + " 'Limit': {'Minimum': 521.99, 'Maximum': 1700.0}},\n", + " 'pc': {'Energies': {'418.566': {'Low': 418.566,\n", + " 'High': 637.695,\n", + " 'Poly': poly1d([ 1.35966e-08, -2.99885e-05, 3.68795e-02, 5.13046e+00])},\n", + " '637.695': {'Low': 637.695,\n", + " 'High': 855.483,\n", + " 'Poly': poly1d([ 6.54757e-09, -1.67934e-05, 2.85808e-02, 6.88328e+00])},\n", + " '855.483': {'Low': 855.483,\n", + " 'High': 1071.32,\n", + " 'Poly': poly1d([ 7.21330e-09, -1.90157e-05, 3.09807e-02, 6.03968e+00])},\n", + " '1071.32': {'Low': 1071.32,\n", + " 'High': 1287.03,\n", + " 'Poly': poly1d([ 1.57511e-08, -4.76693e-05, 6.30626e-02, -5.94187e+00])},\n", + " '1287.03': {'Low': 1287.03,\n", + " 'High': 1700.0,\n", + " 'Poly': poly1d([ 5.53938e-08, -2.04650e-04, 2.70486e-01, -9.73851e+01])}},\n", + " 'Limit': {'Minimum': 418.566, 'Maximum': 1700.0}},\n", + " 'nc': {'Energies': {'426.626': {'Low': 426.626,\n", + " 'High': 646.014,\n", + " 'Poly': poly1d([ 1.28076e-08, -2.86867e-05, 3.61496e-02, 5.26037e+00])},\n", + " '646.014': {'Low': 646.014,\n", + " 'High': 863.674,\n", + " 'Poly': poly1d([ 7.57955e-09, -1.92019e-05, 3.04420e-02, 6.39722e+00])},\n", + " '863.674': {'Low': 863.674,\n", + " 'High': 1079.84,\n", + " 'Poly': poly1d([ 5.92247e-09, -1.52587e-05, 2.73263e-02, 7.21445e+00])},\n", + " '1079.84': {'Low': 1079.84,\n", + " 'High': 1295.74,\n", + " 'Poly': poly1d([ 1.65398e-08, -5.06815e-05, 6.68457e-02, -7.52454e+00])},\n", + " '1295.74': {'Low': 1295.74,\n", + " 'High': 1700.0,\n", + " 'Poly': poly1d([ 5.77565e-08, -2.15111e-04, 2.85830e-01, -1.04872e+02])}},\n", + " 'Limit': {'Minimum': 426.626, 'Maximum': 1700.0}},\n", + " 'lh3': {'Energies': {'769.119': {'Low': 769.119,\n", + " 'High': 1028.01,\n", + " 'Poly': poly1d([ 3.62736e-09, -1.44570e-05, 2.74816e-02, 1.83429e+00])},\n", + " '1028.01': {'Low': 1028.01,\n", + " 'High': 1286.16,\n", + " 'Poly': poly1d([ 1.69557e-09, -8.56945e-06, 2.14904e-02, 3.87065e+00])},\n", + " '1286.16': {'Low': 1286.16,\n", + " 'High': 1544.17,\n", + " 'Poly': poly1d([ 5.94806e-10, -4.20572e-06, 1.57398e-02, 6.38981e+00])},\n", + " '1544.17': {'Low': 1544.17,\n", + " 'High': 1794.62,\n", + " 'Poly': poly1d([ 5.17381e-09, -2.58804e-05, 4.99948e-02, -1.16837e+01])},\n", + " '1794.62': {'Low': 1794.62,\n", + " 'High': 2100.0,\n", + " 'Poly': poly1d([ 2.32221e-08, -1.35379e-04, 2.68796e-01, -1.56010e+02])}},\n", + " 'Limit': {'Minimum': 769.119, 'Maximum': 2100.0}},\n", + " 'la': {'Energies': {'654': {'Low': 654.0,\n", + " 'High': 1700.0,\n", + " 'Poly': poly1d([ 5.1239781e-20, -3.6007756e-16, 1.0820994e-12, -1.7983774e-09,\n", + " 1.7879222e-06, -1.0666011e-03, 3.6850100e-01, -4.3829175e+01])}},\n", + " 'Limit': {'Minimum': 654.0, 'Maximum': 1700.0}}}" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "class lookuptable(BaseModel):\n", + " Value: str\n", + " Type: str" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "id": "4e56e0e6-80e0-4cb7-be99-788f60dac9e1", + "metadata": {}, + "outputs": [], + "source": [ + "class lookuptable(BaseModel):\n", + " model: str\n", + "\n", + "\n", + "class ConfStructure(BaseModel):\n", + " version: int\n", + " info: Info" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "id": "c6b856eb-4597-4d4c-928c-82e2a3c85032", + "metadata": {}, + "outputs": [], + "source": [ + "my_conf_wrong = {\n", + " 'version': 1,\n", + "\n", + " 'info': {\n", + " 'conf_one': 2.5,\n", + " 'conf_two': 'foo',\n", + " 'conf_three': False,\n", + " 'optional_conf': 'bar'\n", + " }\n", + "}\n", + "\n", + "my_conf_right = {\n", + " 'version': 10,\n", + "\n", + " 'info': {\n", + " 'conf_one': 14.5,\n", + " 'conf_two': 'something',\n", + " 'conf_three': False\n", + " }\n", + "}\n" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "id": "6694cd4a-22e3-4f5b-a363-616c1758beeb", + "metadata": {}, + "outputs": [], + "source": [ + "model = ConfStructure(**my_conf_right)" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "id": "60cc1988-281b-4971-8d6f-08358bb4e879", + "metadata": {}, + "outputs": [], + "source": [ + "res = ConfStructure(**my_conf_wrong)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6d669082-693a-40bb-82a4-e918fcb5221c", + "metadata": {}, + "outputs": [], + "source": [ + "'Low': 255.3,\n", + " 'High': 513.28,\n", + " 'Poly': poly1d([ 4.33435e-08, -7.52562e-05, 6.41791e-02, 3.88755e+00])}," + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b4ca9b09-7e63-4283-b434-99bddd74ae63", + "metadata": {}, + "outputs": [], + "source": [ + "class energies(BaseModel):\n", + " Low: float,\n", + " High: float,\n", + " Poly: np.poly1d\n", + " " + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.9" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/p.ipynbpydantic b/p.ipynbpydantic new file mode 100644 index 0000000000..6fe6cfeda5 --- /dev/null +++ b/p.ipynbpydantic @@ -0,0 +1,177 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 5, + "id": "ef076421-53cc-4a5a-abd2-3133af676e78", + "metadata": {}, + "outputs": [], + "source": [ + "from pydantic import BaseModel, ConfigDict\n", + "from dodal.devices.i10.id_apple2 import convert_csv_to_lookup\n", + "import numpy as np\n", + "lut= convert_csv_to_lookup(file=\"/workspaces/dodal/tests/devices/i10/lookupTables/IDEnergy2GapCalibrations.csv\", source=(\"Source\",\"idu\"))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4df22e82-6817-470d-80da-dc7e8c356bd7", + "metadata": {}, + "outputs": [], + "source": [ + "class lookuptable(BaseModel):\n", + " Value: str\n", + " Type: str" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4e56e0e6-80e0-4cb7-be99-788f60dac9e1", + "metadata": {}, + "outputs": [], + "source": [ + "class lookuptable(BaseModel):\n", + " model: str\n", + "\n", + "\n", + "class ConfStructure(BaseModel):\n", + " version: int\n", + " info: Info" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c6b856eb-4597-4d4c-928c-82e2a3c85032", + "metadata": {}, + "outputs": [], + "source": [ + "my_conf_wrong = {\n", + " 'version': 1,\n", + "\n", + " 'info': {\n", + " 'conf_one': 2.5,\n", + " 'conf_two': 'foo',\n", + " 'conf_three': False,\n", + " 'optional_conf': 'bar'\n", + " }\n", + "}\n", + "\n", + "my_conf_right = {\n", + " 'version': 10,\n", + "\n", + " 'info': {\n", + " 'conf_one': 14.5,\n", + " 'conf_two': 'something',\n", + " 'conf_three': False\n", + " }\n", + "}\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6694cd4a-22e3-4f5b-a363-616c1758beeb", + "metadata": {}, + "outputs": [], + "source": [ + "model = ConfStructure(**my_conf_right)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "60cc1988-281b-4971-8d6f-08358bb4e879", + "metadata": {}, + "outputs": [], + "source": [ + "res = ConfStructure(**my_conf_wrong)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6d669082-693a-40bb-82a4-e918fcb5221c", + "metadata": {}, + "outputs": [], + "source": [ + "'Low': 255.3,\n", + " 'High': 513.28,\n", + " 'Poly': poly1d([ 4.33435e-08, -7.52562e-05, 6.41791e-02, 3.88755e+00])}," + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "b4ca9b09-7e63-4283-b434-99bddd74ae63", + "metadata": {}, + "outputs": [ + { + "ename": "RuntimeError", + "evalue": "no validator found for , see `arbitrary_types_allowed` in Config", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[8], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mpydantic\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m BaseModel, ConfigDict, ValidationError\n\u001b[0;32m----> 2\u001b[0m \u001b[38;5;28;43;01mclass\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;21;43;01menergies\u001b[39;49;00m\u001b[43m(\u001b[49m\u001b[43mBaseModel\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[1;32m 3\u001b[0m \u001b[43m \u001b[49m\u001b[43mmodel_config\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mConfigDict\u001b[49m\u001b[43m(\u001b[49m\u001b[43marbitrary_types_allowed\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[1;32m 4\u001b[0m \u001b[43m \u001b[49m\u001b[43mLow\u001b[49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mfloat\u001b[39;49m\n", + "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/main.py:197\u001b[0m, in \u001b[0;36mpydantic.main.ModelMetaclass.__new__\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/fields.py:504\u001b[0m, in \u001b[0;36mpydantic.fields.ModelField.infer\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/fields.py:434\u001b[0m, in \u001b[0;36mpydantic.fields.ModelField.__init__\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/fields.py:555\u001b[0m, in \u001b[0;36mpydantic.fields.ModelField.prepare\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/fields.py:829\u001b[0m, in \u001b[0;36mpydantic.fields.ModelField.populate_validators\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/validators.py:765\u001b[0m, in \u001b[0;36mfind_validators\u001b[0;34m()\u001b[0m\n", + "\u001b[0;31mRuntimeError\u001b[0m: no validator found for , see `arbitrary_types_allowed` in Config" + ] + } + ], + "source": [ + "from pydantic import BaseModel, ConfigDict, ValidationError\n", + "class energies(BaseModel):\n", + " model_config = ConfigDict(arbitrary_types_allowed=True)\n", + " Low: float\n", + " High: float\n", + " Poly: np.poly1d\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bfb3148b-b695-4c96-b2bf-abb551c3bf27", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "47abe376-478e-4cb6-9889-d900a42881a7", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.9" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/src/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/src/.ipynb_checkpoints/Untitled-checkpoint.ipynb new file mode 100644 index 0000000000..5599d36b87 --- /dev/null +++ b/src/.ipynb_checkpoints/Untitled-checkpoint.ipynb @@ -0,0 +1,615 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 104, + "id": "b2b767b2-ac31-415d-871d-31e231aed824", + "metadata": {}, + "outputs": [], + "source": [ + "from dodal.devices.i10.id_apple2 import convert_csv_to_lookup\n", + "from typing import Any" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "9de0be36-54e9-4572-8878-461951aa8e2a", + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np" + ] + }, + { + "cell_type": "code", + "execution_count": 106, + "id": "801358db-d3b6-4118-b631-bf0182c86271", + "metadata": { + "scrolled": true + }, + "outputs": [], + "source": [ + "k= convert_csv_to_lookup(file=\"/workspaces/dodal/tests/devices/i10/lookupTables/IDEnergy2GapCalibrations.csv\", source=(\"Source\",\"idu\"))" + ] + }, + { + "cell_type": "code", + "execution_count": 112, + "id": "cfed326c-216b-43c1-905f-aa2471c6e9d9", + "metadata": {}, + "outputs": [], + "source": [ + "from pydantic import BaseModel, create_model,ConfigDict, ValidationError" + ] + }, + { + "cell_type": "code", + "execution_count": 107, + "id": "b8499431-6c1d-4c36-acc9-9e11623d8182", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'lh': {'Energies': {'255.3': {'Low': 255.3,\n", + " 'High': 513.28,\n", + " 'Poly': poly1d([ 4.33435e-08, -7.52562e-05, 6.41791e-02, 3.88755e+00])},\n", + " '513.28': {'Low': 513.28,\n", + " 'High': 771.545,\n", + " 'Poly': poly1d([ 1.04394e-08, -2.61385e-05, 3.93435e-02, 8.14960e+00])},\n", + " '771.545': {'Low': 771.545,\n", + " 'High': 1027.52,\n", + " 'Poly': poly1d([ 9.55013e-09, -2.51296e-05, 3.93892e-02, 7.92050e+00])},\n", + " '1027.52': {'Low': 1027.52,\n", + " 'High': 1282.59,\n", + " 'Poly': poly1d([ 1.04932e-08, -2.84144e-05, 4.30451e-02, 6.60845e+00])},\n", + " '1282.59': {'Low': 1282.59,\n", + " 'High': 1700.0,\n", + " 'Poly': poly1d([ 8.26909e-08, -3.14196e-04, 4.21009e-01, -1.60378e+02])}},\n", + " 'Limit': {'Minimum': 255.3, 'Maximum': 1700.0}},\n", + " 'lv': {'Energies': {'521.99': {'Low': 521.99,\n", + " 'High': 734.983,\n", + " 'Poly': poly1d([ 1.67544e-09, -6.57463e-06, 2.02971e-02, 6.96008e+00])},\n", + " '734.983': {'Low': 734.983,\n", + " 'High': 932.69,\n", + " 'Poly': poly1d([ 2.32314e-09, -5.82037e-06, 1.81492e-02, 7.87490e+00])},\n", + " '932.69': {'Low': 932.69,\n", + " 'High': 1129.16,\n", + " 'Poly': poly1d([ 8.33737e-09, -2.22386e-05, 3.31944e-02, 3.24578e+00])},\n", + " '1129.16': {'Low': 1129.16,\n", + " 'High': 1325.74,\n", + " 'Poly': poly1d([ 1.91056e-08, -6.01726e-05, 7.77255e-02, -1.41739e+01])},\n", + " '1325.74': {'Low': 1325.74,\n", + " 'High': 1700.0,\n", + " 'Poly': poly1d([ 8.03864e-08, -3.12082e-04, 4.23051e-01, -1.72027e+02])}},\n", + " 'Limit': {'Minimum': 521.99, 'Maximum': 1700.0}},\n", + " 'pc': {'Energies': {'418.566': {'Low': 418.566,\n", + " 'High': 637.695,\n", + " 'Poly': poly1d([ 1.35966e-08, -2.99885e-05, 3.68795e-02, 5.13046e+00])},\n", + " '637.695': {'Low': 637.695,\n", + " 'High': 855.483,\n", + " 'Poly': poly1d([ 6.54757e-09, -1.67934e-05, 2.85808e-02, 6.88328e+00])},\n", + " '855.483': {'Low': 855.483,\n", + " 'High': 1071.32,\n", + " 'Poly': poly1d([ 7.21330e-09, -1.90157e-05, 3.09807e-02, 6.03968e+00])},\n", + " '1071.32': {'Low': 1071.32,\n", + " 'High': 1287.03,\n", + " 'Poly': poly1d([ 1.57511e-08, -4.76693e-05, 6.30626e-02, -5.94187e+00])},\n", + " '1287.03': {'Low': 1287.03,\n", + " 'High': 1700.0,\n", + " 'Poly': poly1d([ 5.53938e-08, -2.04650e-04, 2.70486e-01, -9.73851e+01])}},\n", + " 'Limit': {'Minimum': 418.566, 'Maximum': 1700.0}},\n", + " 'nc': {'Energies': {'426.626': {'Low': 426.626,\n", + " 'High': 646.014,\n", + " 'Poly': poly1d([ 1.28076e-08, -2.86867e-05, 3.61496e-02, 5.26037e+00])},\n", + " '646.014': {'Low': 646.014,\n", + " 'High': 863.674,\n", + " 'Poly': poly1d([ 7.57955e-09, -1.92019e-05, 3.04420e-02, 6.39722e+00])},\n", + " '863.674': {'Low': 863.674,\n", + " 'High': 1079.84,\n", + " 'Poly': poly1d([ 5.92247e-09, -1.52587e-05, 2.73263e-02, 7.21445e+00])},\n", + " '1079.84': {'Low': 1079.84,\n", + " 'High': 1295.74,\n", + " 'Poly': poly1d([ 1.65398e-08, -5.06815e-05, 6.68457e-02, -7.52454e+00])},\n", + " '1295.74': {'Low': 1295.74,\n", + " 'High': 1700.0,\n", + " 'Poly': poly1d([ 5.77565e-08, -2.15111e-04, 2.85830e-01, -1.04872e+02])}},\n", + " 'Limit': {'Minimum': 426.626, 'Maximum': 1700.0}},\n", + " 'lh3': {'Energies': {'769.119': {'Low': 769.119,\n", + " 'High': 1028.01,\n", + " 'Poly': poly1d([ 3.62736e-09, -1.44570e-05, 2.74816e-02, 1.83429e+00])},\n", + " '1028.01': {'Low': 1028.01,\n", + " 'High': 1286.16,\n", + " 'Poly': poly1d([ 1.69557e-09, -8.56945e-06, 2.14904e-02, 3.87065e+00])},\n", + " '1286.16': {'Low': 1286.16,\n", + " 'High': 1544.17,\n", + " 'Poly': poly1d([ 5.94806e-10, -4.20572e-06, 1.57398e-02, 6.38981e+00])},\n", + " '1544.17': {'Low': 1544.17,\n", + " 'High': 1794.62,\n", + " 'Poly': poly1d([ 5.17381e-09, -2.58804e-05, 4.99948e-02, -1.16837e+01])},\n", + " '1794.62': {'Low': 1794.62,\n", + " 'High': 2100.0,\n", + " 'Poly': poly1d([ 2.32221e-08, -1.35379e-04, 2.68796e-01, -1.56010e+02])}},\n", + " 'Limit': {'Minimum': 769.119, 'Maximum': 2100.0}},\n", + " 'la': {'Energies': {'654': {'Low': 654.0,\n", + " 'High': 1700.0,\n", + " 'Poly': poly1d([ 5.1239781e-20, -3.6007756e-16, 1.0820994e-12, -1.7983774e-09,\n", + " 1.7879222e-06, -1.0666011e-03, 3.6850100e-01, -4.3829175e+01])}},\n", + " 'Limit': {'Minimum': 654.0, 'Maximum': 1700.0}}}" + ] + }, + "execution_count": 107, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "k" + ] + }, + { + "cell_type": "code", + "execution_count": 96, + "id": "5566431a-c3ff-499e-af27-f0a15ad6c336", + "metadata": {}, + "outputs": [], + "source": [ + " k={'la': {'Energies': {'654': {'Low': 654.0,'High': 1700.0}},\n", + " 'Limit': {'Minimum': 654.0, 'Maximum': 1700.0}}}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "285cae6f-4787-4213-ac55-d68c1015e545", + "metadata": {}, + "outputs": [], + "source": [ + "{'654': {'Low': 654.0,\n", + " 'High': 1700.0,\n", + " 'Poly': poly1d([ 5.1239781e-20, -3.6007756e-16, 1.0820994e-12, -1.7983774e-09,\n", + " 1.7879222e-06, -1.0666011e-03, 3.6850100e-01, -4.3829175e+01])}},\n", + " 'Limit': {'Minimum': 654.0, 'Maximum': 1700.0}}" + ] + }, + { + "cell_type": "code", + "execution_count": 89, + "id": "82335624-4c7f-4e67-8974-561bd8730257", + "metadata": {}, + "outputs": [], + "source": [ + " k={'la': {'Limits': {'Minimum': 654.0, 'Maximum': 1700.0}}}" + ] + }, + { + "cell_type": "code", + "execution_count": 82, + "id": "c649bb52-d6db-4351-96cb-63d58d32c787", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'Limit': {'Minimum': 654.0, 'Maximum': 1700.0}}" + ] + }, + "execution_count": 82, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "k[\"la\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 114, + "id": "35dabdc8-ae79-4cbb-9e20-c191321d8210", + "metadata": {}, + "outputs": [ + { + "ename": "RuntimeError", + "evalue": "no validator found for , see `arbitrary_types_allowed` in Config", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[114], line 9\u001b[0m\n\u001b[1;32m 7\u001b[0m Minimum: \u001b[38;5;28mfloat\u001b[39m\n\u001b[1;32m 8\u001b[0m Maximum: \u001b[38;5;28mfloat\u001b[39m\n\u001b[0;32m----> 9\u001b[0m \u001b[38;5;28;43;01mclass\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;21;43;01mLaa\u001b[39;49;00m\u001b[43m(\u001b[49m\u001b[43mBaseModel\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[1;32m 10\u001b[0m \u001b[43m \u001b[49m\u001b[43mmodel_config\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mConfigDict\u001b[49m\u001b[43m(\u001b[49m\u001b[43marbitrary_types_allowed\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[1;32m 11\u001b[0m \u001b[43m \u001b[49m\u001b[43mLow\u001b[49m\u001b[43m:\u001b[49m\u001b[38;5;28;43mfloat\u001b[39;49m\n", + "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/main.py:197\u001b[0m, in \u001b[0;36mpydantic.main.ModelMetaclass.__new__\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/fields.py:504\u001b[0m, in \u001b[0;36mpydantic.fields.ModelField.infer\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/fields.py:434\u001b[0m, in \u001b[0;36mpydantic.fields.ModelField.__init__\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/fields.py:555\u001b[0m, in \u001b[0;36mpydantic.fields.ModelField.prepare\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/fields.py:829\u001b[0m, in \u001b[0;36mpydantic.fields.ModelField.populate_validators\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/validators.py:765\u001b[0m, in \u001b[0;36mfind_validators\u001b[0;34m()\u001b[0m\n", + "\u001b[0;31mRuntimeError\u001b[0m: no validator found for , see `arbitrary_types_allowed` in Config" + ] + } + ], + "source": [ + "from typing import Dict\n", + "\n", + "from pydantic import BaseModel\n", + "from numpy.numpy.polynomial\n", + "poly1d = TypeVar (\"numpy\")\n", + "class min_max(BaseModel):\n", + " Minimum: float\n", + " Maximum: float\n", + "class Laa(BaseModel):\n", + " Low:float\n", + " High:float\n", + " Poly:np.poly1d\n", + " class Config:\n", + " arbitrary_types_allowed = True\n", + "class Cenergy(BaseModel):\n", + " __root__: Dict[str, Laa]\n", + "\n", + "class Entries (BaseModel):\n", + " Energies : Cenergy\n", + " Limit:min_max\n", + "class lookuptable(BaseModel):\n", + " model_config = ConfigDict(arbitrary_types_allowed=True)\n", + " __root__: Dict[str, Entries]\n", + "\n", + "good_data = {\n", + " 'g': { 'Value': 'va', 'Type': 'ta' },\n", + " 'b': { 'Value': 'vb', 'Type': 'tb' },\n", + "}\n", + "\n", + "bad_data = {\n", + " 'a': { 'Value': 'va', 'Type': 'ta' },\n", + " 'b': { 'Value': 'vb' },\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": 110, + "id": "ad3b3efd-572a-478a-9845-af0624020331", + "metadata": {}, + "outputs": [ + { + "ename": "ValidationError", + "evalue": "6 validation errors for lookuptable\n__root__ -> lh -> Limits\n field required (type=value_error.missing)\n__root__ -> lv -> Limits\n field required (type=value_error.missing)\n__root__ -> pc -> Limits\n field required (type=value_error.missing)\n__root__ -> nc -> Limits\n field required (type=value_error.missing)\n__root__ -> lh3 -> Limits\n field required (type=value_error.missing)\n__root__ -> la -> Limits\n field required (type=value_error.missing)", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mValidationError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[110], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mlookuptable\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mparse_obj\u001b[49m\u001b[43m(\u001b[49m\u001b[43mk\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/main.py:526\u001b[0m, in \u001b[0;36mpydantic.main.BaseModel.parse_obj\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/main.py:341\u001b[0m, in \u001b[0;36mpydantic.main.BaseModel.__init__\u001b[0;34m()\u001b[0m\n", + "\u001b[0;31mValidationError\u001b[0m: 6 validation errors for lookuptable\n__root__ -> lh -> Limits\n field required (type=value_error.missing)\n__root__ -> lv -> Limits\n field required (type=value_error.missing)\n__root__ -> pc -> Limits\n field required (type=value_error.missing)\n__root__ -> nc -> Limits\n field required (type=value_error.missing)\n__root__ -> lh3 -> Limits\n field required (type=value_error.missing)\n__root__ -> la -> Limits\n field required (type=value_error.missing)" + ] + } + ], + "source": [ + "lookuptable.parse_obj(k)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "5c911eb8-d0ad-4ca3-8b72-13a615cd4845", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'SR10I-MO-STAT-21:'" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "split_pv = \"SR10I-MO-SERVC-21:\".split(\"-\")\n", + "split_pv[0] + \"-\" +split_pv[1] + \"-STAT\"+\"-\"+split_pv[3]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d5d45ce2-c9e3-45e9-9164-d41739dc4d6c", + "metadata": {}, + "outputs": [], + "source": [ + "import csv\n", + "\n", + "\n", + "def load_lookup_table(filename):\n", + " '''read a CSV file storing lookup table and create a dictionar using values in the fisrt 4 columns as key and return both dictionary and header\n", + " '''\n", + " with open(filename) as csv_data:\n", + " reader = csv.reader(csv_data)\n", + " rows = [row for row in reader if row or not row.startswith('#')]\n", + " header = rows[0]\n", + "\n", + " lookuptable = {}\n", + " for row in rows[1:]:\n", + " # print row\n", + " lookuptable[(row[0], row[1], float(row[2]), float(row[3]))] = [float(item) for item in row[4:]]\n", + " return lookuptable, header" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ae6b413f-5c2b-45d8-9861-4ec3aae15456", + "metadata": {}, + "outputs": [], + "source": [ + "result=load_lookup_table(\"/workspaces/dodal/tests/devices/i10/lookupTables/IDEnergy2GapCalibrations.csv\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "49ff9c40-1e25-4e63-8faa-e036142c2c48", + "metadata": {}, + "outputs": [], + "source": [ + "with open(\"/workspaces/dodal/tests/devices/i10/lookupTables/IDEnergy2GapCalibrations.csv\", newline='') as csvfile:\n", + "\n", + " reader = csv.DictReader(csvfile)\n", + " result = sorted(reader, key=lambda d: float(d['MinEnergy']))\n", + " for row in result:\n", + " if(float(row[\"MaxEnergy\"])>600):\n", + " print(row[\"MaxEnergy\"])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "85a0c336-8e23-4913-9337-d6564e5f4c06", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9a2ea13b-1671-41f6-bc79-19b9288e2652", + "metadata": {}, + "outputs": [], + "source": [ + "k = {\"idd\":{\"pc\":{1},\"nc\":{2}},\n", + " \"idu\":{\"pc\":{1},\"nc\":{2}}}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "017804f2-a1a1-423c-bcd9-6c9a76a8caa9", + "metadata": {}, + "outputs": [], + "source": [ + "k[\"idd\"][\"pc\"]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fc9fa2c7-ad13-440d-ab39-e30716ca581e", + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "20fd5287-ee7e-42fa-9dfa-2a9dc175e2d3", + "metadata": {}, + "outputs": [], + "source": [ + "df = pd.read_csv(\"/workspaces/dodal/src/lookupTables/IDEnergy2GapCalibrations.csv\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "86b36042-db8d-4b14-89f9-677cba0b342e", + "metadata": {}, + "outputs": [], + "source": [ + "source = (\"Source\",\"idd\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ef671a59-02cb-43c1-ace3-9755591dbf18", + "metadata": {}, + "outputs": [], + "source": [ + "idd = df[df[source[0]] == source[1]]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d39fbf11-51c9-47e7-9f28-a1cbf4bb8d6f", + "metadata": {}, + "outputs": [], + "source": [ + "idd = idd.drop(source[0], axis=1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "231e9a70-709a-4606-861d-616a86cf9e51", + "metadata": {}, + "outputs": [], + "source": [ + "idd" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0ae8975f-beba-46c1-9ced-9c6195b7e5dd", + "metadata": {}, + "outputs": [], + "source": [ + "temp_df: pd.DataFrame = df[df[\"Mode\"] == \"lv\"].drop(\"Mode\", axis=1).sort_values(by=\"MaxEnergy\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "97dc0e29-90c3-4062-b620-17245e2741b2", + "metadata": {}, + "outputs": [], + "source": [ + "temp_df" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ee9957ba-7e09-41bf-b543-d6c050f6cab6", + "metadata": {}, + "outputs": [], + "source": [ + "iddict = {}\n", + "for i in id_modes:\n", + " temp_df = idd[idd[\"Mode\"]==i].drop(\"Mode\", axis=1)\n", + " iddict[i]= {}\n", + " ecounter = 0\n", + " for __, row in temp_df.iterrows():\n", + " poly = np.poly1d(row.values[::-1])\n", + " print(row.values[::-1])\n", + " iddict[i][f\"Energy{ecounter}\"]= {\"min\":row.values[0],\"max\":row.values[1],\"poly\":poly}\n", + " ecounter+=1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f5d1f275-2292-473b-bb65-9ec6c9d9ae52", + "metadata": {}, + "outputs": [], + "source": [ + "iddict.keys()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "28b5d8b7-e35e-4e59-92a7-ef064d7bb335", + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e9fbc1c4-e633-4b00-94fb-87a049d68392", + "metadata": {}, + "outputs": [], + "source": [ + "w[w.MaxEnergy<500]" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "fa4d89bd-4e74-49d5-bbc5-e7e5e87e519c", + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "e1b12e56-e79a-4343-ae67-28130a1a64aa", + "metadata": {}, + "outputs": [], + "source": [ + "x = np.arange(610,1200)\n", + "y = [1400.13845, -13.0099589\t,0.0518055008,\t-0.000113471444\t,1.47749738E-07,\t-1.14420814E-10,\t4.88195989E-14,\t-8.85680201E-18]\n", + "fit = np.poly1d(y[::-1])" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "c77d79ca-297c-4746-9cbe-5fc269fe6c83", + "metadata": {}, + "outputs": [], + "source": [ + "import matplotlib.pyplot as plt" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "6da755bb-59c2-4c96-870e-ed3ea054ad0d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[]" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAh8AAAGdCAYAAACyzRGfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAyJklEQVR4nO3deXyU9b3//fdMJjNZZ7KRlYRNZC/ihlC1cooix4OoPcfKbSnVnrv16KPWY29EHhZ7PGrR9ty97WLtcnqqrUur56fUpWoVUaQiyurOIiEEQggEksk6SWa+9x+TGQiEJTC5rllez8djHkmu68rkM9/HkLz5bpfDGGMEAABgEafdBQAAgNRC+AAAAJYifAAAAEsRPgAAgKUIHwAAwFKEDwAAYCnCBwAAsBThAwAAWMpldwFHCoVCqqurU25urhwOh93lAACAk2CMUUtLi8rLy+V0Hr9vI+7CR11dnSorK+0uAwAAnILa2loNHTr0uNfEXfjIzc2VFC7e6/XaXA0AADgZfr9flZWV0b/jxxN34SMy1OL1egkfAAAkmJOZMsGEUwAAYCnCBwAAsB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//OHqsqanJeDwe89RTTxljjPnkk0+MJPP+++9Hr3n55ZeNw+Ewu3fvHrzi48R3v/tdM2rUKBMKhUxTU5NJT083zzzzTPT8p59+aiSZ1atXG2PCb2in02nq6+uj1zzyyCPG6/WaQCBgef2D7YorrjA33nhjn2PXXHONuf76640xvMf6097ebtLS0syLL77Y5/jZZ59t7rrrLtrsCEf+YYhV+/zyl780+fn5ff5dLlq0yIwZM2aQX9Hg6i98RFRXV/cbPlL9d9vx2izivffeM5JMTU2NMcbe91jcD7s8//zzOvfcc/Uv//IvKi4u1pQpU/Tb3/42er66ulr19fWaOXNm9JjP59PUqVO1evVqSdLq1auVl5enc889N3rNzJkz5XQ6tWbNGutejA26urr0+OOP68Ybb5TD4dC6devU3d3dp73Gjh2rqqqqPu01adIklZSURK+ZNWuW/H6/Pv74Y8tfw2CbPn26li9fri1btkiSNm3apFWrVmn27NmSeI/1p6enR8FgUBkZGX2OZ2ZmatWqVbTZCcSqfVavXq2LL75Ybrc7es2sWbO0efNmHTx40KJXEx/43XZizc3NcjgcysvLk2Tveyzuw8f27dv1yCOPaPTo0Xr11Vf1b//2b7r11lv12GOPSZLq6+slqc+bKfJ15Fx9fb2Ki4v7nHe5XCooKIhek6yWLVumpqYmfeMb35AUbgu32x1980Uc2V79tWfkXLK58847dd1112ns2LFKT0/XlClTdNttt+n666+XxHusP7m5uZo2bZruvfde1dXVKRgM6vHHH9fq1au1Z88e2uwEYtU+qfZv9Xj43XZ8nZ2dWrRokebNmxe9kZyd77G4u6vtkUKhkM4991z98Ic/lCRNmTJFH330kX71q19pwYIFNlcX/373u99p9uzZKi8vt7uUuPX000/riSee0JNPPqkJEyZo48aNuu2221ReXs577Dj++Mc/6sYbb1RFRYXS0tJ09tlna968eVq3bp3dpQE4THd3t6699loZY/TII4/YXY6kBOj5KCsr0/jx4/scGzdunHbu3ClJKi0tlaSjZjTv3bs3eq60tFQNDQ19zvf09OjAgQPRa5JRTU2NXn/9df3rv/5r9Fhpaam6urrU1NT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mNM7Npn06ZN5sILLzQej8dUVFSYBx54wKqXGFMnaq/f//73/Z7/wQ9+EH2OVPvddrw2iyxJ7u8R2fPJGPveYw5jDtvGEQAAYJDF/ZwPAACQXAgfAADAUoQPAABgKcIHAACwFOEDAABYivABAAAsRfgAAACWInwAAABLET4AAIClCB8AAMBShA8AAGApwgcAALDU/w8Iohv8+mBE9wAAAABJRU5ErkJggg==", + "text/plain": [ + "
" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "plt.plot(x,fit(x))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "12ebf92b-bdbe-4414-8264-11dd2a6dc168", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.9" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/src/Untitled.ipynb b/src/Untitled.ipynb new file mode 100644 index 0000000000..ae219e11db --- /dev/null +++ b/src/Untitled.ipynb @@ -0,0 +1,456 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "b2b767b2-ac31-415d-871d-31e231aed824", + "metadata": {}, + "outputs": [], + "source": [ + "from dodal.devices.i10.id_apple2 import convert_csv_to_lookup\n", + "from typing import Any\n", + "from pydantic import BaseModel, create_model,ConfigDict, ValidationError" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "9de0be36-54e9-4572-8878-461951aa8e2a", + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "801358db-d3b6-4118-b631-bf0182c86271", + "metadata": { + "scrolled": true + }, + "outputs": [], + "source": [ + "k= convert_csv_to_lookup(file=\"/workspaces/dodal/tests/devices/i10/lookupTables/IDEnergy2GapCalibrations.csv\", source=(\"Source\",\"idu\"))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cfed326c-216b-43c1-905f-aa2471c6e9d9", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b8499431-6c1d-4c36-acc9-9e11623d8182", + "metadata": {}, + "outputs": [], + "source": [ + "k" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "5566431a-c3ff-499e-af27-f0a15ad6c336", + "metadata": {}, + "outputs": [], + "source": [ + " w={'la': {'Energies': {'654': {'Low': 654.0,'High': 1700.0, 'Poly':np.poly1d([ 5.1239781e-20, -3.6007756e-16, 1.0820994e-12, -1.7983774e-09,\n", + " 1.7879222e-06, -1.0666011e-03, 3.6850100e-01, -4.3829175e+01])}},\n", + " 'Limits': {'Minimum': 654.0, 'Maximum': 1700.0}}}" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "285cae6f-4787-4213-ac55-d68c1015e545", + "metadata": {}, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "closing parenthesis ')' does not match opening parenthesis '{' on line 1 (3614237539.py, line 4)", + "output_type": "error", + "traceback": [ + "\u001b[0;36m Cell \u001b[0;32mIn[8], line 4\u001b[0;36m\u001b[0m\n\u001b[0;31m 1.7879222e-06, -1.0666011e-03, 3.6850100e-01, -4.3829175e+01])}},\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m closing parenthesis ')' does not match opening parenthesis '{' on line 1\n" + ] + } + ], + "source": [ + "{'654': {'Low': 654.0,\n", + " 'High': 1700.0,\n", + " 'Poly': [ 5.1239781e-20, -3.6007756e-16, 1.0820994e-12, -1.7983774e-09,\n", + " 1.7879222e-06, -1.0666011e-03, 3.6850100e-01, -4.3829175e+01])}},\n", + " 'Limit': {'Minimum': 654.0, 'Maximum': 1700.0}}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "82335624-4c7f-4e67-8974-561bd8730257", + "metadata": {}, + "outputs": [], + "source": [ + " k={'la': {'Limits': {'Minimum': 654.0, 'Maximum': 1700.0}}}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c649bb52-d6db-4351-96cb-63d58d32c787", + "metadata": {}, + "outputs": [], + "source": [ + "k[\"la\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "35dabdc8-ae79-4cbb-9e20-c191321d8210", + "metadata": {}, + "outputs": [], + "source": [ + "from typing import Dict\n", + "\n", + "from pydantic import BaseModel\n", + "\n", + "class min_max(BaseModel):\n", + " Minimum: float\n", + " Maximum: float\n", + "class Laa(BaseModel):\n", + " Low:float\n", + " High:float\n", + " Poly:np.poly1d\n", + " class Config:\n", + " arbitrary_types_allowed = True\n", + "class Cenergy(BaseModel):\n", + " __root__: Dict[str, Laa]\n", + "\n", + "class Entries (BaseModel):\n", + " Energies : Cenergy\n", + " Limit:min_max\n", + "class lookuptable(BaseModel):\n", + " __root__: Dict[str, Entries]\n" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "ad3b3efd-572a-478a-9845-af0624020331", + "metadata": {}, + "outputs": [ + { + "ename": "ValidationError", + "evalue": "1 validation error for lookuptable\n__root__ -> la -> Limit\n field required (type=value_error.missing)", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mValidationError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[10], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mlookuptable\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mparse_obj\u001b[49m\u001b[43m(\u001b[49m\u001b[43mw\u001b[49m\u001b[43m)\u001b[49m\n", + "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/main.py:526\u001b[0m, in \u001b[0;36mpydantic.main.BaseModel.parse_obj\u001b[0;34m()\u001b[0m\n", + "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/main.py:341\u001b[0m, in \u001b[0;36mpydantic.main.BaseModel.__init__\u001b[0;34m()\u001b[0m\n", + "\u001b[0;31mValidationError\u001b[0m: 1 validation error for lookuptable\n__root__ -> la -> Limit\n field required (type=value_error.missing)" + ] + } + ], + "source": [ + "lookuptable.parse_obj(w)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5c911eb8-d0ad-4ca3-8b72-13a615cd4845", + "metadata": {}, + "outputs": [], + "source": [ + "split_pv = \"SR10I-MO-SERVC-21:\".split(\"-\")\n", + "split_pv[0] + \"-\" +split_pv[1] + \"-STAT\"+\"-\"+split_pv[3]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d5d45ce2-c9e3-45e9-9164-d41739dc4d6c", + "metadata": {}, + "outputs": [], + "source": [ + "import csv\n", + "\n", + "\n", + "def load_lookup_table(filename):\n", + " '''read a CSV file storing lookup table and create a dictionar using values in the fisrt 4 columns as key and return both dictionary and header\n", + " '''\n", + " with open(filename) as csv_data:\n", + " reader = csv.reader(csv_data)\n", + " rows = [row for row in reader if row or not row.startswith('#')]\n", + " header = rows[0]\n", + "\n", + " lookuptable = {}\n", + " for row in rows[1:]:\n", + " # print row\n", + " lookuptable[(row[0], row[1], float(row[2]), float(row[3]))] = [float(item) for item in row[4:]]\n", + " return lookuptable, header" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ae6b413f-5c2b-45d8-9861-4ec3aae15456", + "metadata": {}, + "outputs": [], + "source": [ + "result=load_lookup_table(\"/workspaces/dodal/tests/devices/i10/lookupTables/IDEnergy2GapCalibrations.csv\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "49ff9c40-1e25-4e63-8faa-e036142c2c48", + "metadata": {}, + "outputs": [], + "source": [ + "with open(\"/workspaces/dodal/tests/devices/i10/lookupTables/IDEnergy2GapCalibrations.csv\", newline='') as csvfile:\n", + "\n", + " reader = csv.DictReader(csvfile)\n", + " result = sorted(reader, key=lambda d: float(d['MinEnergy']))\n", + " for row in result:\n", + " if(float(row[\"MaxEnergy\"])>600):\n", + " print(row[\"MaxEnergy\"])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "85a0c336-8e23-4913-9337-d6564e5f4c06", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9a2ea13b-1671-41f6-bc79-19b9288e2652", + "metadata": {}, + "outputs": [], + "source": [ + "k = {\"idd\":{\"pc\":{1},\"nc\":{2}},\n", + " \"idu\":{\"pc\":{1},\"nc\":{2}}}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "017804f2-a1a1-423c-bcd9-6c9a76a8caa9", + "metadata": {}, + "outputs": [], + "source": [ + "k[\"idd\"][\"pc\"]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fc9fa2c7-ad13-440d-ab39-e30716ca581e", + "metadata": {}, + "outputs": [], + "source": [ + "import pandas as pd" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "20fd5287-ee7e-42fa-9dfa-2a9dc175e2d3", + "metadata": {}, + "outputs": [], + "source": [ + "df = pd.read_csv(\"/workspaces/dodal/src/lookupTables/IDEnergy2GapCalibrations.csv\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "86b36042-db8d-4b14-89f9-677cba0b342e", + "metadata": {}, + "outputs": [], + "source": [ + "source = (\"Source\",\"idd\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ef671a59-02cb-43c1-ace3-9755591dbf18", + "metadata": {}, + "outputs": [], + "source": [ + "idd = df[df[source[0]] == source[1]]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d39fbf11-51c9-47e7-9f28-a1cbf4bb8d6f", + "metadata": {}, + "outputs": [], + "source": [ + "idd = idd.drop(source[0], axis=1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "231e9a70-709a-4606-861d-616a86cf9e51", + "metadata": {}, + "outputs": [], + "source": [ + "idd" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0ae8975f-beba-46c1-9ced-9c6195b7e5dd", + "metadata": {}, + "outputs": [], + "source": [ + "temp_df: pd.DataFrame = df[df[\"Mode\"] == \"lv\"].drop(\"Mode\", axis=1).sort_values(by=\"MaxEnergy\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "97dc0e29-90c3-4062-b620-17245e2741b2", + "metadata": {}, + "outputs": [], + "source": [ + "temp_df" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ee9957ba-7e09-41bf-b543-d6c050f6cab6", + "metadata": {}, + "outputs": [], + "source": [ + "iddict = {}\n", + "for i in id_modes:\n", + " temp_df = idd[idd[\"Mode\"]==i].drop(\"Mode\", axis=1)\n", + " iddict[i]= {}\n", + " ecounter = 0\n", + " for __, row in temp_df.iterrows():\n", + " poly = np.poly1d(row.values[::-1])\n", + " print(row.values[::-1])\n", + " iddict[i][f\"Energy{ecounter}\"]= {\"min\":row.values[0],\"max\":row.values[1],\"poly\":poly}\n", + " ecounter+=1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f5d1f275-2292-473b-bb65-9ec6c9d9ae52", + "metadata": {}, + "outputs": [], + "source": [ + "iddict.keys()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "28b5d8b7-e35e-4e59-92a7-ef064d7bb335", + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e9fbc1c4-e633-4b00-94fb-87a049d68392", + "metadata": {}, + "outputs": [], + "source": [ + "w[w.MaxEnergy<500]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fa4d89bd-4e74-49d5-bbc5-e7e5e87e519c", + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e1b12e56-e79a-4343-ae67-28130a1a64aa", + "metadata": {}, + "outputs": [], + "source": [ + "x = np.arange(610,1200)\n", + "y = [1400.13845, -13.0099589\t,0.0518055008,\t-0.000113471444\t,1.47749738E-07,\t-1.14420814E-10,\t4.88195989E-14,\t-8.85680201E-18]\n", + "fit = np.poly1d(y[::-1])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c77d79ca-297c-4746-9cbe-5fc269fe6c83", + "metadata": {}, + "outputs": [], + "source": [ + "import matplotlib.pyplot as plt" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6da755bb-59c2-4c96-870e-ed3ea054ad0d", + "metadata": {}, + "outputs": [], + "source": [ + "plt.plot(x,fit(x))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "12ebf92b-bdbe-4414-8264-11dd2a6dc168", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.9" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/src/dodal/devices/.ipynb_checkpoints/Id_play-checkpoint.ipynb b/src/dodal/devices/.ipynb_checkpoints/Id_play-checkpoint.ipynb new file mode 100644 index 0000000000..31bf9c98d0 --- /dev/null +++ b/src/dodal/devices/.ipynb_checkpoints/Id_play-checkpoint.ipynb @@ -0,0 +1,387 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "id": "b13dab05-d065-4b74-8401-74b84695b8d3", + "metadata": {}, + "outputs": [], + "source": [ + "import asyncio\n", + "\n", + "from apple2_undulator import (\n", + " UndulatorPhaseAxes,\n", + " UndulatorGap,\n", + " UndulatorJawPhase\n", + ")\n", + "from bluesky import RunEngine\n", + "from bluesky.callbacks.best_effort import BestEffortCallback\n", + "from pgm import PGM\n", + "\n", + "from dodal.devices.i10.i10_apple2 import I10Apple2, I10Apple2PGM, I10Apple2Pol \n", + "\n", + "RE = RunEngine({})\n", + "bec = BestEffortCallback()\n", + "from pathlib import Path\n", + "import bluesky.plan_stubs as bps\n", + "from ophyd_async.core import DeviceCollector\n", + "\n", + "from dodal.devices.i10.i10_setting_data import I10Grating" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "8280232e-edb6-465f-b9f1-e9452fb38623", + "metadata": {}, + "outputs": [], + "source": [ + "with DeviceCollector():\n", + " i10PGM = PGM(prefix=\"BL10I-OP-PGM-01:\", grating=I10Grating, gratingPv=\"NLINES2\")\n", + " i10_id_gap = UndulatorGap(\"SR10I-MO-SERVC-21:\")\n", + " i10_id_phase = UndulatorPhaseAxes(prefix=\"SR10I-MO-SERVC-21:\",top_outer= \"RPQ1\",top_inner= \"RPQ2\",btm_outer= \"RPQ4\",btm_inner= \"RPQ3\")\n", + " i10_id_jaw = UndulatorJawPhase(prefix=\"SR10I-MO-SERVC-21:\", move_pv=\"RPQ1\", jawPhase=\"JAW\")\n", + " id10 = I10Apple2(id_gap=i10_id_gap, id_phase=i10_id_phase,\n", + " energy_gap_table_path = Path(\"/workspaces/dodal/tests/devices/i10/lookupTables/IDEnergy2GapCalibrations.csv\",),\n", + " energy_phase_table_path= Path(\"/workspaces/dodal/tests/devices/i10/lookupTables/IDEnergy2PhaseCalibrations.csv\",),\n", + " id_jaw_phase= i10_id_jaw,\n", + " source =(\"Source\",\"idu\"))\n", + " i10_energy = I10Apple2PGM(id=id10, pgm= i10PGM)\n", + " i10_pol = I10Apple2Pol(id=id10)\n", + " # upa21 = UndulatorPhaseAxes(prefix = 'SR21I-MO-SERVC-01:',\n", + " # top_outer= \"PUO\",\n", + " # top_inner= \"PUI\",\n", + " # btm_outer= \"PLO\",\n", + " # btm_inner= \"PLI\"\n", + " # )" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8d2d8870-3c41-44cd-ab69-dffbae96e71f", + "metadata": {}, + "outputs": [], + "source": [ + "result = await i10_id_phase.top_inner.high_limit_travel.get_value()\n", + "print(await id10.polarisation.get_value())" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "77bce90a-f5eb-4383-b27c-c15e0c9b1e0c", + "metadata": {}, + "outputs": [], + "source": [ + "RE(bps.abs_set(id10, 500))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "715eb79c-ea44-44db-ba70-c771b4918cac", + "metadata": {}, + "outputs": [], + "source": [ + "result =await id10.read()\n", + "print(result)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0e14809a-512c-4826-a418-8f6e782927ce", + "metadata": {}, + "outputs": [], + "source": [ + "print(id10.pol)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "32c97a3b-153e-4bc8-9885-838f00e9cf45", + "metadata": {}, + "outputs": [], + "source": [ + "result =await i10_energy.read()\n", + "print(result)\n", + "result =await i10_pol.read()\n", + "print(result)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7f56526a-8a8d-400e-a89d-082c075fa600", + "metadata": {}, + "outputs": [], + "source": [ + "result[\"id10-gap-user_readback\"][\"value\"]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0c5549b6-d272-41c9-b1ed-dab96705dd16", + "metadata": {}, + "outputs": [], + "source": [ + "result = asyncio.gather(id10.read_configuration())#,upa21.read_configuration(), upa09.read_configuration())" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "274c1968-93a6-44b8-89d3-ddaf0cb6fc2d", + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "\n", + "\n", + "async def test():\n", + " return np.max(await asyncio.gather(id10.gap.get_timeout(), id10.phase.get_timeout()))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4c36d5f7-b662-4b27-ba00-4ccfcb7e5ec9", + "metadata": {}, + "outputs": [], + "source": [ + "k=asyncio.gather(test())" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a8af9acb-729c-4b82-aca9-9db5aa30a1fc", + "metadata": {}, + "outputs": [], + "source": [ + "k" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6fad6337-7b66-4f2c-968c-647f9000fedb", + "metadata": {}, + "outputs": [], + "source": [ + "i10_phase_axis_pv.read_pv" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "88de1b1f-cfa6-412d-ba48-ce76eff88da3", + "metadata": {}, + "outputs": [], + "source": [ + "upa10 = UndulatorPhaseAxes(prefix = 'SR10I-MO-', top_outer= top_outer,top_inner= top_inner, btm_outer= btm_outer, btm_inter= btm_inter)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ca7f8fc7-1708-497c-8574-a9538790e1ac", + "metadata": {}, + "outputs": [], + "source": [ + "RE(bps.abs_set(ug1, \"23.1\"))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0c97cc57-e160-4ab0-bee0-4c6d79b81e2f", + "metadata": {}, + "outputs": [], + "source": [ + "from epics import caget" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7d10b5a1-1e72-454e-8b18-839d4e5663ca", + "metadata": {}, + "outputs": [], + "source": [ + "caget(\"SR10I-MO-STAT-21:ANYFAULT\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8bfd191b-f583-4eaa-ae55-e0c00b26e176", + "metadata": {}, + "outputs": [], + "source": [ + "caget(\"SR21I-MO-SERVC-01:BLGAPMTR.HLM\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b2921e6c-e5fd-4276-bebd-8c703d85216b", + "metadata": {}, + "outputs": [], + "source": [ + "def new_pos():\n", + " output = range(0, 11, 1)\n", + " for i in output:\n", + " yield i" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4a24bb25-318f-4d98-b791-443a706415eb", + "metadata": {}, + "outputs": [], + "source": [ + "k= new_pos()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1c6e80f4-d746-49a0-839a-60ba93fd1896", + "metadata": {}, + "outputs": [], + "source": [ + "next(k)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a31af988-d39e-4490-87f4-187abd253c45", + "metadata": {}, + "outputs": [], + "source": [ + "result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c1036834-831a-4769-b78e-671dae96c8d0", + "metadata": {}, + "outputs": [], + "source": [ + "from ophyd_async.epics.motion import Motor\n", + "\n", + "i10motor = Motor(prefix=\"SR10I-MO-SERVC-01:BLRPQ1MTR\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f47a617b-d837-49b6-9596-3dcc7e20aee3", + "metadata": {}, + "outputs": [], + "source": [ + "result = asyncio.gather(i10motor.connect())" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "536dc75e-6478-43cd-a410-8a1c7a295506", + "metadata": {}, + "outputs": [], + "source": [ + "result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e7924dcc-c266-4409-9ed6-98c1263b8e50", + "metadata": {}, + "outputs": [], + "source": [ + "result = asyncio.gather(i10motor.user_setpoint.get_value(), i10motor.user_readback.get_value())" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "24b95866-2262-4eb6-bede-7090656f8d7a", + "metadata": {}, + "outputs": [], + "source": [ + "result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cbbed4fa-9df5-4d29-a5d8-d0c37d43746f", + "metadata": {}, + "outputs": [], + "source": [ + "sp = (2,4,6)\n", + "x= (1,5,7)\n", + "y = (2,6,9)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e0c2bd91-0c69-4ed7-99a5-8ed3a4237c4b", + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np\n", + "\n", + "result = np.abs(np.divide(tuple(np.subtract(x, y)), sp))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5a8808e6-70ff-4531-8729-d9cf09f9149f", + "metadata": {}, + "outputs": [], + "source": [ + "result.min()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b29f3abd-29a2-4659-aaf3-73383a1873f0", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.9" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/src/dodal/devices/areadetector/andor2_epics/andor2_io.py b/src/dodal/devices/areadetector/andor2_epics/andor2_io.py index d5bcb8da26..42e1236a34 100644 --- a/src/dodal/devices/areadetector/andor2_epics/andor2_io.py +++ b/src/dodal/devices/areadetector/andor2_epics/andor2_io.py @@ -30,6 +30,10 @@ class ADBaseDataType(str, Enum): Float32 = "Float32" Float64 = "Float64" _ = "" + """ + #This is needed due to all empty enum from epics will reduce to a single + "" and throw a typeerror as the blank "" is unmatched. + """ class Andor2DriverIO(ADBaseIO): From 89405cd02682602ba114c1de72bfa860e6b99107 Mon Sep 17 00:00:00 2001 From: Relm-Arrowny Date: Tue, 8 Oct 2024 11:39:34 +0000 Subject: [PATCH 09/11] remove junk that got added --- .ipynb_checkpoints/Untitled-checkpoint.ipynb | 6 - .ipynb_checkpoints/p-checkpoint.ipynbpydantic | 235 ------- .../Untitled-checkpoint.ipynb | 615 ------------------ src/Untitled.ipynb | 456 ------------- .../Id_play-checkpoint.ipynb | 387 ----------- 5 files changed, 1699 deletions(-) delete mode 100644 .ipynb_checkpoints/Untitled-checkpoint.ipynb delete mode 100644 .ipynb_checkpoints/p-checkpoint.ipynbpydantic delete mode 100644 src/.ipynb_checkpoints/Untitled-checkpoint.ipynb delete mode 100644 src/Untitled.ipynb delete mode 100644 src/dodal/devices/.ipynb_checkpoints/Id_play-checkpoint.ipynb diff --git a/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/.ipynb_checkpoints/Untitled-checkpoint.ipynb deleted file mode 100644 index 363fcab7ed..0000000000 --- a/.ipynb_checkpoints/Untitled-checkpoint.ipynb +++ /dev/null @@ -1,6 +0,0 @@ -{ - "cells": [], - "metadata": {}, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/.ipynb_checkpoints/p-checkpoint.ipynbpydantic b/.ipynb_checkpoints/p-checkpoint.ipynbpydantic deleted file mode 100644 index a0e8e02bd7..0000000000 --- a/.ipynb_checkpoints/p-checkpoint.ipynbpydantic +++ /dev/null @@ -1,235 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 2, - "id": "ef076421-53cc-4a5a-abd2-3133af676e78", - "metadata": {}, - "outputs": [], - "source": [ - "from pydantic import BaseModel\n", - "from dodal.devices.i10.id_apple2 import convert_csv_to_lookup\n", - "lut= convert_csv_to_lookup(file=\"/workspaces/dodal/tests/devices/i10/lookupTables/IDEnergy2GapCalibrations.csv\", source=(\"Source\",\"idu\"))" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "4df22e82-6817-470d-80da-dc7e8c356bd7", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'lh': {'Energies': {'255.3': {'Low': 255.3,\n", - " 'High': 513.28,\n", - " 'Poly': poly1d([ 4.33435e-08, -7.52562e-05, 6.41791e-02, 3.88755e+00])},\n", - " '513.28': {'Low': 513.28,\n", - " 'High': 771.545,\n", - " 'Poly': poly1d([ 1.04394e-08, -2.61385e-05, 3.93435e-02, 8.14960e+00])},\n", - " '771.545': {'Low': 771.545,\n", - " 'High': 1027.52,\n", - " 'Poly': poly1d([ 9.55013e-09, -2.51296e-05, 3.93892e-02, 7.92050e+00])},\n", - " '1027.52': {'Low': 1027.52,\n", - " 'High': 1282.59,\n", - " 'Poly': poly1d([ 1.04932e-08, -2.84144e-05, 4.30451e-02, 6.60845e+00])},\n", - " '1282.59': {'Low': 1282.59,\n", - " 'High': 1700.0,\n", - " 'Poly': poly1d([ 8.26909e-08, -3.14196e-04, 4.21009e-01, -1.60378e+02])}},\n", - " 'Limit': {'Minimum': 255.3, 'Maximum': 1700.0}},\n", - " 'lv': {'Energies': {'521.99': {'Low': 521.99,\n", - " 'High': 734.983,\n", - " 'Poly': poly1d([ 1.67544e-09, -6.57463e-06, 2.02971e-02, 6.96008e+00])},\n", - " '734.983': {'Low': 734.983,\n", - " 'High': 932.69,\n", - " 'Poly': poly1d([ 2.32314e-09, -5.82037e-06, 1.81492e-02, 7.87490e+00])},\n", - " '932.69': {'Low': 932.69,\n", - " 'High': 1129.16,\n", - " 'Poly': poly1d([ 8.33737e-09, -2.22386e-05, 3.31944e-02, 3.24578e+00])},\n", - " '1129.16': {'Low': 1129.16,\n", - " 'High': 1325.74,\n", - " 'Poly': poly1d([ 1.91056e-08, -6.01726e-05, 7.77255e-02, -1.41739e+01])},\n", - " '1325.74': {'Low': 1325.74,\n", - " 'High': 1700.0,\n", - " 'Poly': poly1d([ 8.03864e-08, -3.12082e-04, 4.23051e-01, -1.72027e+02])}},\n", - " 'Limit': {'Minimum': 521.99, 'Maximum': 1700.0}},\n", - " 'pc': {'Energies': {'418.566': {'Low': 418.566,\n", - " 'High': 637.695,\n", - " 'Poly': poly1d([ 1.35966e-08, -2.99885e-05, 3.68795e-02, 5.13046e+00])},\n", - " '637.695': {'Low': 637.695,\n", - " 'High': 855.483,\n", - " 'Poly': poly1d([ 6.54757e-09, -1.67934e-05, 2.85808e-02, 6.88328e+00])},\n", - " '855.483': {'Low': 855.483,\n", - " 'High': 1071.32,\n", - " 'Poly': poly1d([ 7.21330e-09, -1.90157e-05, 3.09807e-02, 6.03968e+00])},\n", - " '1071.32': {'Low': 1071.32,\n", - " 'High': 1287.03,\n", - " 'Poly': poly1d([ 1.57511e-08, -4.76693e-05, 6.30626e-02, -5.94187e+00])},\n", - " '1287.03': {'Low': 1287.03,\n", - " 'High': 1700.0,\n", - " 'Poly': poly1d([ 5.53938e-08, -2.04650e-04, 2.70486e-01, -9.73851e+01])}},\n", - " 'Limit': {'Minimum': 418.566, 'Maximum': 1700.0}},\n", - " 'nc': {'Energies': {'426.626': {'Low': 426.626,\n", - " 'High': 646.014,\n", - " 'Poly': poly1d([ 1.28076e-08, -2.86867e-05, 3.61496e-02, 5.26037e+00])},\n", - " '646.014': {'Low': 646.014,\n", - " 'High': 863.674,\n", - " 'Poly': poly1d([ 7.57955e-09, -1.92019e-05, 3.04420e-02, 6.39722e+00])},\n", - " '863.674': {'Low': 863.674,\n", - " 'High': 1079.84,\n", - " 'Poly': poly1d([ 5.92247e-09, -1.52587e-05, 2.73263e-02, 7.21445e+00])},\n", - " '1079.84': {'Low': 1079.84,\n", - " 'High': 1295.74,\n", - " 'Poly': poly1d([ 1.65398e-08, -5.06815e-05, 6.68457e-02, -7.52454e+00])},\n", - " '1295.74': {'Low': 1295.74,\n", - " 'High': 1700.0,\n", - " 'Poly': poly1d([ 5.77565e-08, -2.15111e-04, 2.85830e-01, -1.04872e+02])}},\n", - " 'Limit': {'Minimum': 426.626, 'Maximum': 1700.0}},\n", - " 'lh3': {'Energies': {'769.119': {'Low': 769.119,\n", - " 'High': 1028.01,\n", - " 'Poly': poly1d([ 3.62736e-09, -1.44570e-05, 2.74816e-02, 1.83429e+00])},\n", - " '1028.01': {'Low': 1028.01,\n", - " 'High': 1286.16,\n", - " 'Poly': poly1d([ 1.69557e-09, -8.56945e-06, 2.14904e-02, 3.87065e+00])},\n", - " '1286.16': {'Low': 1286.16,\n", - " 'High': 1544.17,\n", - " 'Poly': poly1d([ 5.94806e-10, -4.20572e-06, 1.57398e-02, 6.38981e+00])},\n", - " '1544.17': {'Low': 1544.17,\n", - " 'High': 1794.62,\n", - " 'Poly': poly1d([ 5.17381e-09, -2.58804e-05, 4.99948e-02, -1.16837e+01])},\n", - " '1794.62': {'Low': 1794.62,\n", - " 'High': 2100.0,\n", - " 'Poly': poly1d([ 2.32221e-08, -1.35379e-04, 2.68796e-01, -1.56010e+02])}},\n", - " 'Limit': {'Minimum': 769.119, 'Maximum': 2100.0}},\n", - " 'la': {'Energies': {'654': {'Low': 654.0,\n", - " 'High': 1700.0,\n", - " 'Poly': poly1d([ 5.1239781e-20, -3.6007756e-16, 1.0820994e-12, -1.7983774e-09,\n", - " 1.7879222e-06, -1.0666011e-03, 3.6850100e-01, -4.3829175e+01])}},\n", - " 'Limit': {'Minimum': 654.0, 'Maximum': 1700.0}}}" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "class lookuptable(BaseModel):\n", - " Value: str\n", - " Type: str" - ] - }, - { - "cell_type": "code", - "execution_count": 40, - "id": "4e56e0e6-80e0-4cb7-be99-788f60dac9e1", - "metadata": {}, - "outputs": [], - "source": [ - "class lookuptable(BaseModel):\n", - " model: str\n", - "\n", - "\n", - "class ConfStructure(BaseModel):\n", - " version: int\n", - " info: Info" - ] - }, - { - "cell_type": "code", - "execution_count": 41, - "id": "c6b856eb-4597-4d4c-928c-82e2a3c85032", - "metadata": {}, - "outputs": [], - "source": [ - "my_conf_wrong = {\n", - " 'version': 1,\n", - "\n", - " 'info': {\n", - " 'conf_one': 2.5,\n", - " 'conf_two': 'foo',\n", - " 'conf_three': False,\n", - " 'optional_conf': 'bar'\n", - " }\n", - "}\n", - "\n", - "my_conf_right = {\n", - " 'version': 10,\n", - "\n", - " 'info': {\n", - " 'conf_one': 14.5,\n", - " 'conf_two': 'something',\n", - " 'conf_three': False\n", - " }\n", - "}\n" - ] - }, - { - "cell_type": "code", - "execution_count": 42, - "id": "6694cd4a-22e3-4f5b-a363-616c1758beeb", - "metadata": {}, - "outputs": [], - "source": [ - "model = ConfStructure(**my_conf_right)" - ] - }, - { - "cell_type": "code", - "execution_count": 39, - "id": "60cc1988-281b-4971-8d6f-08358bb4e879", - "metadata": {}, - "outputs": [], - "source": [ - "res = ConfStructure(**my_conf_wrong)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "6d669082-693a-40bb-82a4-e918fcb5221c", - "metadata": {}, - "outputs": [], - "source": [ - "'Low': 255.3,\n", - " 'High': 513.28,\n", - " 'Poly': poly1d([ 4.33435e-08, -7.52562e-05, 6.41791e-02, 3.88755e+00])}," - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "b4ca9b09-7e63-4283-b434-99bddd74ae63", - "metadata": {}, - "outputs": [], - "source": [ - "class energies(BaseModel):\n", - " Low: float,\n", - " High: float,\n", - " Poly: np.poly1d\n", - " " - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.9" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/src/.ipynb_checkpoints/Untitled-checkpoint.ipynb b/src/.ipynb_checkpoints/Untitled-checkpoint.ipynb deleted file mode 100644 index 5599d36b87..0000000000 --- a/src/.ipynb_checkpoints/Untitled-checkpoint.ipynb +++ /dev/null @@ -1,615 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 104, - "id": "b2b767b2-ac31-415d-871d-31e231aed824", - "metadata": {}, - "outputs": [], - "source": [ - "from dodal.devices.i10.id_apple2 import convert_csv_to_lookup\n", - "from typing import Any" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "id": "9de0be36-54e9-4572-8878-461951aa8e2a", - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np" - ] - }, - { - "cell_type": "code", - "execution_count": 106, - "id": "801358db-d3b6-4118-b631-bf0182c86271", - "metadata": { - "scrolled": true - }, - "outputs": [], - "source": [ - "k= convert_csv_to_lookup(file=\"/workspaces/dodal/tests/devices/i10/lookupTables/IDEnergy2GapCalibrations.csv\", source=(\"Source\",\"idu\"))" - ] - }, - { - "cell_type": "code", - "execution_count": 112, - "id": "cfed326c-216b-43c1-905f-aa2471c6e9d9", - "metadata": {}, - "outputs": [], - "source": [ - "from pydantic import BaseModel, create_model,ConfigDict, ValidationError" - ] - }, - { - "cell_type": "code", - "execution_count": 107, - "id": "b8499431-6c1d-4c36-acc9-9e11623d8182", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'lh': {'Energies': {'255.3': {'Low': 255.3,\n", - " 'High': 513.28,\n", - " 'Poly': poly1d([ 4.33435e-08, -7.52562e-05, 6.41791e-02, 3.88755e+00])},\n", - " '513.28': {'Low': 513.28,\n", - " 'High': 771.545,\n", - " 'Poly': poly1d([ 1.04394e-08, -2.61385e-05, 3.93435e-02, 8.14960e+00])},\n", - " '771.545': {'Low': 771.545,\n", - " 'High': 1027.52,\n", - " 'Poly': poly1d([ 9.55013e-09, -2.51296e-05, 3.93892e-02, 7.92050e+00])},\n", - " '1027.52': {'Low': 1027.52,\n", - " 'High': 1282.59,\n", - " 'Poly': poly1d([ 1.04932e-08, -2.84144e-05, 4.30451e-02, 6.60845e+00])},\n", - " '1282.59': {'Low': 1282.59,\n", - " 'High': 1700.0,\n", - " 'Poly': poly1d([ 8.26909e-08, -3.14196e-04, 4.21009e-01, -1.60378e+02])}},\n", - " 'Limit': {'Minimum': 255.3, 'Maximum': 1700.0}},\n", - " 'lv': {'Energies': {'521.99': {'Low': 521.99,\n", - " 'High': 734.983,\n", - " 'Poly': poly1d([ 1.67544e-09, -6.57463e-06, 2.02971e-02, 6.96008e+00])},\n", - " '734.983': {'Low': 734.983,\n", - " 'High': 932.69,\n", - " 'Poly': poly1d([ 2.32314e-09, -5.82037e-06, 1.81492e-02, 7.87490e+00])},\n", - " '932.69': {'Low': 932.69,\n", - " 'High': 1129.16,\n", - " 'Poly': poly1d([ 8.33737e-09, -2.22386e-05, 3.31944e-02, 3.24578e+00])},\n", - " '1129.16': {'Low': 1129.16,\n", - " 'High': 1325.74,\n", - " 'Poly': poly1d([ 1.91056e-08, -6.01726e-05, 7.77255e-02, -1.41739e+01])},\n", - " '1325.74': {'Low': 1325.74,\n", - " 'High': 1700.0,\n", - " 'Poly': poly1d([ 8.03864e-08, -3.12082e-04, 4.23051e-01, -1.72027e+02])}},\n", - " 'Limit': {'Minimum': 521.99, 'Maximum': 1700.0}},\n", - " 'pc': {'Energies': {'418.566': {'Low': 418.566,\n", - " 'High': 637.695,\n", - " 'Poly': poly1d([ 1.35966e-08, -2.99885e-05, 3.68795e-02, 5.13046e+00])},\n", - " '637.695': {'Low': 637.695,\n", - " 'High': 855.483,\n", - " 'Poly': poly1d([ 6.54757e-09, -1.67934e-05, 2.85808e-02, 6.88328e+00])},\n", - " '855.483': {'Low': 855.483,\n", - " 'High': 1071.32,\n", - " 'Poly': poly1d([ 7.21330e-09, -1.90157e-05, 3.09807e-02, 6.03968e+00])},\n", - " '1071.32': {'Low': 1071.32,\n", - " 'High': 1287.03,\n", - " 'Poly': poly1d([ 1.57511e-08, -4.76693e-05, 6.30626e-02, -5.94187e+00])},\n", - " '1287.03': {'Low': 1287.03,\n", - " 'High': 1700.0,\n", - " 'Poly': poly1d([ 5.53938e-08, -2.04650e-04, 2.70486e-01, -9.73851e+01])}},\n", - " 'Limit': {'Minimum': 418.566, 'Maximum': 1700.0}},\n", - " 'nc': {'Energies': {'426.626': {'Low': 426.626,\n", - " 'High': 646.014,\n", - " 'Poly': poly1d([ 1.28076e-08, -2.86867e-05, 3.61496e-02, 5.26037e+00])},\n", - " '646.014': {'Low': 646.014,\n", - " 'High': 863.674,\n", - " 'Poly': poly1d([ 7.57955e-09, -1.92019e-05, 3.04420e-02, 6.39722e+00])},\n", - " '863.674': {'Low': 863.674,\n", - " 'High': 1079.84,\n", - " 'Poly': poly1d([ 5.92247e-09, -1.52587e-05, 2.73263e-02, 7.21445e+00])},\n", - " '1079.84': {'Low': 1079.84,\n", - " 'High': 1295.74,\n", - " 'Poly': poly1d([ 1.65398e-08, -5.06815e-05, 6.68457e-02, -7.52454e+00])},\n", - " '1295.74': {'Low': 1295.74,\n", - " 'High': 1700.0,\n", - " 'Poly': poly1d([ 5.77565e-08, -2.15111e-04, 2.85830e-01, -1.04872e+02])}},\n", - " 'Limit': {'Minimum': 426.626, 'Maximum': 1700.0}},\n", - " 'lh3': {'Energies': {'769.119': {'Low': 769.119,\n", - " 'High': 1028.01,\n", - " 'Poly': poly1d([ 3.62736e-09, -1.44570e-05, 2.74816e-02, 1.83429e+00])},\n", - " '1028.01': {'Low': 1028.01,\n", - " 'High': 1286.16,\n", - " 'Poly': poly1d([ 1.69557e-09, -8.56945e-06, 2.14904e-02, 3.87065e+00])},\n", - " '1286.16': {'Low': 1286.16,\n", - " 'High': 1544.17,\n", - " 'Poly': poly1d([ 5.94806e-10, -4.20572e-06, 1.57398e-02, 6.38981e+00])},\n", - " '1544.17': {'Low': 1544.17,\n", - " 'High': 1794.62,\n", - " 'Poly': poly1d([ 5.17381e-09, -2.58804e-05, 4.99948e-02, -1.16837e+01])},\n", - " '1794.62': {'Low': 1794.62,\n", - " 'High': 2100.0,\n", - " 'Poly': poly1d([ 2.32221e-08, -1.35379e-04, 2.68796e-01, -1.56010e+02])}},\n", - " 'Limit': {'Minimum': 769.119, 'Maximum': 2100.0}},\n", - " 'la': {'Energies': {'654': {'Low': 654.0,\n", - " 'High': 1700.0,\n", - " 'Poly': poly1d([ 5.1239781e-20, -3.6007756e-16, 1.0820994e-12, -1.7983774e-09,\n", - " 1.7879222e-06, -1.0666011e-03, 3.6850100e-01, -4.3829175e+01])}},\n", - " 'Limit': {'Minimum': 654.0, 'Maximum': 1700.0}}}" - ] - }, - "execution_count": 107, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "k" - ] - }, - { - "cell_type": "code", - "execution_count": 96, - "id": "5566431a-c3ff-499e-af27-f0a15ad6c336", - "metadata": {}, - "outputs": [], - "source": [ - " k={'la': {'Energies': {'654': {'Low': 654.0,'High': 1700.0}},\n", - " 'Limit': {'Minimum': 654.0, 'Maximum': 1700.0}}}" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "285cae6f-4787-4213-ac55-d68c1015e545", - "metadata": {}, - "outputs": [], - "source": [ - "{'654': {'Low': 654.0,\n", - " 'High': 1700.0,\n", - " 'Poly': poly1d([ 5.1239781e-20, -3.6007756e-16, 1.0820994e-12, -1.7983774e-09,\n", - " 1.7879222e-06, -1.0666011e-03, 3.6850100e-01, -4.3829175e+01])}},\n", - " 'Limit': {'Minimum': 654.0, 'Maximum': 1700.0}}" - ] - }, - { - "cell_type": "code", - "execution_count": 89, - "id": "82335624-4c7f-4e67-8974-561bd8730257", - "metadata": {}, - "outputs": [], - "source": [ - " k={'la': {'Limits': {'Minimum': 654.0, 'Maximum': 1700.0}}}" - ] - }, - { - "cell_type": "code", - "execution_count": 82, - "id": "c649bb52-d6db-4351-96cb-63d58d32c787", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'Limit': {'Minimum': 654.0, 'Maximum': 1700.0}}" - ] - }, - "execution_count": 82, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "k[\"la\"]" - ] - }, - { - "cell_type": "code", - "execution_count": 114, - "id": "35dabdc8-ae79-4cbb-9e20-c191321d8210", - "metadata": {}, - "outputs": [ - { - "ename": "RuntimeError", - "evalue": "no validator found for , see `arbitrary_types_allowed` in Config", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[114], line 9\u001b[0m\n\u001b[1;32m 7\u001b[0m Minimum: \u001b[38;5;28mfloat\u001b[39m\n\u001b[1;32m 8\u001b[0m Maximum: \u001b[38;5;28mfloat\u001b[39m\n\u001b[0;32m----> 9\u001b[0m \u001b[38;5;28;43;01mclass\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;21;43;01mLaa\u001b[39;49;00m\u001b[43m(\u001b[49m\u001b[43mBaseModel\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[1;32m 10\u001b[0m \u001b[43m \u001b[49m\u001b[43mmodel_config\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mConfigDict\u001b[49m\u001b[43m(\u001b[49m\u001b[43marbitrary_types_allowed\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[1;32m 11\u001b[0m \u001b[43m \u001b[49m\u001b[43mLow\u001b[49m\u001b[43m:\u001b[49m\u001b[38;5;28;43mfloat\u001b[39;49m\n", - "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/main.py:197\u001b[0m, in \u001b[0;36mpydantic.main.ModelMetaclass.__new__\u001b[0;34m()\u001b[0m\n", - "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/fields.py:504\u001b[0m, in \u001b[0;36mpydantic.fields.ModelField.infer\u001b[0;34m()\u001b[0m\n", - "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/fields.py:434\u001b[0m, in \u001b[0;36mpydantic.fields.ModelField.__init__\u001b[0;34m()\u001b[0m\n", - "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/fields.py:555\u001b[0m, in \u001b[0;36mpydantic.fields.ModelField.prepare\u001b[0;34m()\u001b[0m\n", - "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/fields.py:829\u001b[0m, in \u001b[0;36mpydantic.fields.ModelField.populate_validators\u001b[0;34m()\u001b[0m\n", - "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/validators.py:765\u001b[0m, in \u001b[0;36mfind_validators\u001b[0;34m()\u001b[0m\n", - "\u001b[0;31mRuntimeError\u001b[0m: no validator found for , see `arbitrary_types_allowed` in Config" - ] - } - ], - "source": [ - "from typing import Dict\n", - "\n", - "from pydantic import BaseModel\n", - "from numpy.numpy.polynomial\n", - "poly1d = TypeVar (\"numpy\")\n", - "class min_max(BaseModel):\n", - " Minimum: float\n", - " Maximum: float\n", - "class Laa(BaseModel):\n", - " Low:float\n", - " High:float\n", - " Poly:np.poly1d\n", - " class Config:\n", - " arbitrary_types_allowed = True\n", - "class Cenergy(BaseModel):\n", - " __root__: Dict[str, Laa]\n", - "\n", - "class Entries (BaseModel):\n", - " Energies : Cenergy\n", - " Limit:min_max\n", - "class lookuptable(BaseModel):\n", - " model_config = ConfigDict(arbitrary_types_allowed=True)\n", - " __root__: Dict[str, Entries]\n", - "\n", - "good_data = {\n", - " 'g': { 'Value': 'va', 'Type': 'ta' },\n", - " 'b': { 'Value': 'vb', 'Type': 'tb' },\n", - "}\n", - "\n", - "bad_data = {\n", - " 'a': { 'Value': 'va', 'Type': 'ta' },\n", - " 'b': { 'Value': 'vb' },\n", - "}" - ] - }, - { - "cell_type": "code", - "execution_count": 110, - "id": "ad3b3efd-572a-478a-9845-af0624020331", - "metadata": {}, - "outputs": [ - { - "ename": "ValidationError", - "evalue": "6 validation errors for lookuptable\n__root__ -> lh -> Limits\n field required (type=value_error.missing)\n__root__ -> lv -> Limits\n field required (type=value_error.missing)\n__root__ -> pc -> Limits\n field required (type=value_error.missing)\n__root__ -> nc -> Limits\n field required (type=value_error.missing)\n__root__ -> lh3 -> Limits\n field required (type=value_error.missing)\n__root__ -> la -> Limits\n field required (type=value_error.missing)", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mValidationError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[110], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mlookuptable\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mparse_obj\u001b[49m\u001b[43m(\u001b[49m\u001b[43mk\u001b[49m\u001b[43m)\u001b[49m\n", - "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/main.py:526\u001b[0m, in \u001b[0;36mpydantic.main.BaseModel.parse_obj\u001b[0;34m()\u001b[0m\n", - "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/main.py:341\u001b[0m, in \u001b[0;36mpydantic.main.BaseModel.__init__\u001b[0;34m()\u001b[0m\n", - "\u001b[0;31mValidationError\u001b[0m: 6 validation errors for lookuptable\n__root__ -> lh -> Limits\n field required (type=value_error.missing)\n__root__ -> lv -> Limits\n field required (type=value_error.missing)\n__root__ -> pc -> Limits\n field required (type=value_error.missing)\n__root__ -> nc -> Limits\n field required (type=value_error.missing)\n__root__ -> lh3 -> Limits\n field required (type=value_error.missing)\n__root__ -> la -> Limits\n field required (type=value_error.missing)" - ] - } - ], - "source": [ - "lookuptable.parse_obj(k)" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "id": "5c911eb8-d0ad-4ca3-8b72-13a615cd4845", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'SR10I-MO-STAT-21:'" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "split_pv = \"SR10I-MO-SERVC-21:\".split(\"-\")\n", - "split_pv[0] + \"-\" +split_pv[1] + \"-STAT\"+\"-\"+split_pv[3]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "d5d45ce2-c9e3-45e9-9164-d41739dc4d6c", - "metadata": {}, - "outputs": [], - "source": [ - "import csv\n", - "\n", - "\n", - "def load_lookup_table(filename):\n", - " '''read a CSV file storing lookup table and create a dictionar using values in the fisrt 4 columns as key and return both dictionary and header\n", - " '''\n", - " with open(filename) as csv_data:\n", - " reader = csv.reader(csv_data)\n", - " rows = [row for row in reader if row or not row.startswith('#')]\n", - " header = rows[0]\n", - "\n", - " lookuptable = {}\n", - " for row in rows[1:]:\n", - " # print row\n", - " lookuptable[(row[0], row[1], float(row[2]), float(row[3]))] = [float(item) for item in row[4:]]\n", - " return lookuptable, header" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ae6b413f-5c2b-45d8-9861-4ec3aae15456", - "metadata": {}, - "outputs": [], - "source": [ - "result=load_lookup_table(\"/workspaces/dodal/tests/devices/i10/lookupTables/IDEnergy2GapCalibrations.csv\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "49ff9c40-1e25-4e63-8faa-e036142c2c48", - "metadata": {}, - "outputs": [], - "source": [ - "with open(\"/workspaces/dodal/tests/devices/i10/lookupTables/IDEnergy2GapCalibrations.csv\", newline='') as csvfile:\n", - "\n", - " reader = csv.DictReader(csvfile)\n", - " result = sorted(reader, key=lambda d: float(d['MinEnergy']))\n", - " for row in result:\n", - " if(float(row[\"MaxEnergy\"])>600):\n", - " print(row[\"MaxEnergy\"])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "85a0c336-8e23-4913-9337-d6564e5f4c06", - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "9a2ea13b-1671-41f6-bc79-19b9288e2652", - "metadata": {}, - "outputs": [], - "source": [ - "k = {\"idd\":{\"pc\":{1},\"nc\":{2}},\n", - " \"idu\":{\"pc\":{1},\"nc\":{2}}}" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "017804f2-a1a1-423c-bcd9-6c9a76a8caa9", - "metadata": {}, - "outputs": [], - "source": [ - "k[\"idd\"][\"pc\"]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "fc9fa2c7-ad13-440d-ab39-e30716ca581e", - "metadata": {}, - "outputs": [], - "source": [ - "import pandas as pd" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "20fd5287-ee7e-42fa-9dfa-2a9dc175e2d3", - "metadata": {}, - "outputs": [], - "source": [ - "df = pd.read_csv(\"/workspaces/dodal/src/lookupTables/IDEnergy2GapCalibrations.csv\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "86b36042-db8d-4b14-89f9-677cba0b342e", - "metadata": {}, - "outputs": [], - "source": [ - "source = (\"Source\",\"idd\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ef671a59-02cb-43c1-ace3-9755591dbf18", - "metadata": {}, - "outputs": [], - "source": [ - "idd = df[df[source[0]] == source[1]]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "d39fbf11-51c9-47e7-9f28-a1cbf4bb8d6f", - "metadata": {}, - "outputs": [], - "source": [ - "idd = idd.drop(source[0], axis=1)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "231e9a70-709a-4606-861d-616a86cf9e51", - "metadata": {}, - "outputs": [], - "source": [ - "idd" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "0ae8975f-beba-46c1-9ced-9c6195b7e5dd", - "metadata": {}, - "outputs": [], - "source": [ - "temp_df: pd.DataFrame = df[df[\"Mode\"] == \"lv\"].drop(\"Mode\", axis=1).sort_values(by=\"MaxEnergy\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "97dc0e29-90c3-4062-b620-17245e2741b2", - "metadata": {}, - "outputs": [], - "source": [ - "temp_df" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ee9957ba-7e09-41bf-b543-d6c050f6cab6", - "metadata": {}, - "outputs": [], - "source": [ - "iddict = {}\n", - "for i in id_modes:\n", - " temp_df = idd[idd[\"Mode\"]==i].drop(\"Mode\", axis=1)\n", - " iddict[i]= {}\n", - " ecounter = 0\n", - " for __, row in temp_df.iterrows():\n", - " poly = np.poly1d(row.values[::-1])\n", - " print(row.values[::-1])\n", - " iddict[i][f\"Energy{ecounter}\"]= {\"min\":row.values[0],\"max\":row.values[1],\"poly\":poly}\n", - " ecounter+=1" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "f5d1f275-2292-473b-bb65-9ec6c9d9ae52", - "metadata": {}, - "outputs": [], - "source": [ - "iddict.keys()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "28b5d8b7-e35e-4e59-92a7-ef064d7bb335", - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "e9fbc1c4-e633-4b00-94fb-87a049d68392", - "metadata": {}, - "outputs": [], - "source": [ - "w[w.MaxEnergy<500]" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "id": "fa4d89bd-4e74-49d5-bbc5-e7e5e87e519c", - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "id": "e1b12e56-e79a-4343-ae67-28130a1a64aa", - "metadata": {}, - "outputs": [], - "source": [ - "x = np.arange(610,1200)\n", - "y = [1400.13845, -13.0099589\t,0.0518055008,\t-0.000113471444\t,1.47749738E-07,\t-1.14420814E-10,\t4.88195989E-14,\t-8.85680201E-18]\n", - "fit = np.poly1d(y[::-1])" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "id": "c77d79ca-297c-4746-9cbe-5fc269fe6c83", - "metadata": {}, - "outputs": [], - "source": [ - "import matplotlib.pyplot as plt" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "id": "6da755bb-59c2-4c96-870e-ed3ea054ad0d", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[]" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAh8AAAGdCAYAAACyzRGfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAyJklEQVR4nO3deXyU9b3//fdMJjNZZ7KRlYRNZC/ihlC1cooix4OoPcfKbSnVnrv16KPWY29EHhZ7PGrR9ty97WLtcnqqrUur56fUpWoVUaQiyurOIiEEQggEksk6SWa+9x+TGQiEJTC5rllez8djHkmu68rkM9/HkLz5bpfDGGMEAABgEafdBQAAgNRC+AAAAJYifAAAAEsRPgAAgKUIHwAAwFKEDwAAYCnCBwAAsBThAwAAWMpldwFHCoVCqqurU25urhwOh93lAACAk2CMUUtLi8rLy+V0Hr9vI+7CR11dnSorK+0uAwAAnILa2loNHTr0uNfEXfjIzc2VFC7e6/XaXA0AADgZfr9flZW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16tTn//PPNOeec0+c57HqPxX34WLRokbnwwguPeT4UCpnS0lLz4x//OHqsqanJeDwe89RTTxljjPnkk0+MJPP+++9Hr3n55ZeNw+Ewu3fvHrzi48R3v/tdM2rUKBMKhUxTU5NJT083zzzzTPT8p59+aiSZ1atXG2PCb2in02nq6+uj1zzyyCPG6/WaQCBgef2D7YorrjA33nhjn2PXXHONuf76640xvMf6097ebtLS0syLL77Y5/jZZ59t7rrrLtrsCEf+YYhV+/zyl780+fn5ff5dLlq0yIwZM2aQX9Hg6i98RFRXV/cbPlL9d9vx2izivffeM5JMTU2NMcbe91jcD7s8//zzOvfcc/Uv//IvKi4u1pQpU/Tb3/42er66ulr19fWaOXNm9JjP59PUqVO1evVqSdLq1auVl5enc889N3rNzJkz5XQ6tWbNGutejA26urr0+OOP68Ybb5TD4dC6devU3d3dp73Gjh2rqqqqPu01adIklZSURK+ZNWuW/H6/Pv74Y8tfw2CbPn26li9fri1btkiSNm3apFWrVmn27NmSeI/1p6enR8FgUBkZGX2OZ2ZmatWqVbTZCcSqfVavXq2LL75Ybrc7es2sWbO0efNmHTx40KJXEx/43XZizc3NcjgcysvLk2Tveyzuw8f27dv1yCOPaPTo0Xr11Vf1b//2b7r11lv12GOPSZLq6+slqc+bKfJ15Fx9fb2Ki4v7nHe5XCooKIhek6yWLVumpqYmfeMb35AUbgu32x1980Uc2V79tWfkXLK58847dd1112ns2LFKT0/XlClTdNttt+n666+XxHusP7m5uZo2bZruvfde1dXVKRgM6vHHH9fq1au1Z88e2uwEYtU+qfZv9Xj43XZ8nZ2dWrRokebNmxe9kZyd77G4u6vtkUKhkM4991z98Ic/lCRNmTJFH330kX71q19pwYIFNlcX/373u99p9uzZKi8vt7uUuPX000/riSee0JNPPqkJEyZo48aNuu2221ReXs577Dj++Mc/6sYbb1RFRYXS0tJ09tlna968eVq3bp3dpQE4THd3t6699loZY/TII4/YXY6kBOj5KCsr0/jx4/scGzdunHbu3ClJKi0tlaSjZjTv3bs3eq60tFQNDQ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xo/35z382I0eONG6325SWlppbbrnFNDU1Rc+neputWLHCSDrqsWDBAmNM7Npn06ZN5sILLzQej8dUVFSYBx54wKqXGFMnaq/f//73/Z7/wQ9+EH2OVPvddrw2iyxJ7u8R2fPJGPveYw5jDtvGEQAAYJDF/ZwPAACQXAgfAADAUoQPAABgKcIHAACwFOEDAABYivABAAAsRfgAAACWInwAAABLET4AAIClCB8AAMBShA8AAGApwgcAALDU/w8Iohv8+mBE9wAAAABJRU5ErkJggg==", - "text/plain": [ - "
" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "plt.plot(x,fit(x))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "12ebf92b-bdbe-4414-8264-11dd2a6dc168", - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.9" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/src/Untitled.ipynb b/src/Untitled.ipynb deleted file mode 100644 index ae219e11db..0000000000 --- a/src/Untitled.ipynb +++ /dev/null @@ -1,456 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "id": "b2b767b2-ac31-415d-871d-31e231aed824", - "metadata": {}, - "outputs": [], - "source": [ - "from dodal.devices.i10.id_apple2 import convert_csv_to_lookup\n", - "from typing import Any\n", - "from pydantic import BaseModel, create_model,ConfigDict, ValidationError" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "9de0be36-54e9-4572-8878-461951aa8e2a", - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "id": "801358db-d3b6-4118-b631-bf0182c86271", - "metadata": { - "scrolled": true - }, - "outputs": [], - "source": [ - "k= convert_csv_to_lookup(file=\"/workspaces/dodal/tests/devices/i10/lookupTables/IDEnergy2GapCalibrations.csv\", source=(\"Source\",\"idu\"))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "cfed326c-216b-43c1-905f-aa2471c6e9d9", - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "b8499431-6c1d-4c36-acc9-9e11623d8182", - "metadata": {}, - "outputs": [], - "source": [ - "k" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "id": "5566431a-c3ff-499e-af27-f0a15ad6c336", - "metadata": {}, - "outputs": [], - "source": [ - " w={'la': {'Energies': {'654': {'Low': 654.0,'High': 1700.0, 'Poly':np.poly1d([ 5.1239781e-20, -3.6007756e-16, 1.0820994e-12, -1.7983774e-09,\n", - " 1.7879222e-06, -1.0666011e-03, 3.6850100e-01, -4.3829175e+01])}},\n", - " 'Limits': {'Minimum': 654.0, 'Maximum': 1700.0}}}" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "id": "285cae6f-4787-4213-ac55-d68c1015e545", - "metadata": {}, - "outputs": [ - { - "ename": "SyntaxError", - "evalue": "closing parenthesis ')' does not match opening parenthesis '{' on line 1 (3614237539.py, line 4)", - "output_type": "error", - "traceback": [ - "\u001b[0;36m Cell \u001b[0;32mIn[8], line 4\u001b[0;36m\u001b[0m\n\u001b[0;31m 1.7879222e-06, -1.0666011e-03, 3.6850100e-01, -4.3829175e+01])}},\u001b[0m\n\u001b[0m ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m closing parenthesis ')' does not match opening parenthesis '{' on line 1\n" - ] - } - ], - "source": [ - "{'654': {'Low': 654.0,\n", - " 'High': 1700.0,\n", - " 'Poly': [ 5.1239781e-20, -3.6007756e-16, 1.0820994e-12, -1.7983774e-09,\n", - " 1.7879222e-06, -1.0666011e-03, 3.6850100e-01, -4.3829175e+01])}},\n", - " 'Limit': {'Minimum': 654.0, 'Maximum': 1700.0}}" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "82335624-4c7f-4e67-8974-561bd8730257", - "metadata": {}, - "outputs": [], - "source": [ - " k={'la': {'Limits': {'Minimum': 654.0, 'Maximum': 1700.0}}}" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "c649bb52-d6db-4351-96cb-63d58d32c787", - "metadata": {}, - "outputs": [], - "source": [ - "k[\"la\"]" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "id": "35dabdc8-ae79-4cbb-9e20-c191321d8210", - "metadata": {}, - "outputs": [], - "source": [ - "from typing import Dict\n", - "\n", - "from pydantic import BaseModel\n", - "\n", - "class min_max(BaseModel):\n", - " Minimum: float\n", - " Maximum: float\n", - "class Laa(BaseModel):\n", - " Low:float\n", - " High:float\n", - " Poly:np.poly1d\n", - " class Config:\n", - " arbitrary_types_allowed = True\n", - "class Cenergy(BaseModel):\n", - " __root__: Dict[str, Laa]\n", - "\n", - "class Entries (BaseModel):\n", - " Energies : Cenergy\n", - " Limit:min_max\n", - "class lookuptable(BaseModel):\n", - " __root__: Dict[str, Entries]\n" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "id": "ad3b3efd-572a-478a-9845-af0624020331", - "metadata": {}, - "outputs": [ - { - "ename": "ValidationError", - "evalue": "1 validation error for lookuptable\n__root__ -> la -> Limit\n field required (type=value_error.missing)", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mValidationError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[10], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mlookuptable\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mparse_obj\u001b[49m\u001b[43m(\u001b[49m\u001b[43mw\u001b[49m\u001b[43m)\u001b[49m\n", - "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/main.py:526\u001b[0m, in \u001b[0;36mpydantic.main.BaseModel.parse_obj\u001b[0;34m()\u001b[0m\n", - "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/main.py:341\u001b[0m, in \u001b[0;36mpydantic.main.BaseModel.__init__\u001b[0;34m()\u001b[0m\n", - "\u001b[0;31mValidationError\u001b[0m: 1 validation error for lookuptable\n__root__ -> la -> Limit\n field required (type=value_error.missing)" - ] - } - ], - "source": [ - "lookuptable.parse_obj(w)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "5c911eb8-d0ad-4ca3-8b72-13a615cd4845", - "metadata": {}, - "outputs": [], - "source": [ - "split_pv = \"SR10I-MO-SERVC-21:\".split(\"-\")\n", - "split_pv[0] + \"-\" +split_pv[1] + \"-STAT\"+\"-\"+split_pv[3]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "d5d45ce2-c9e3-45e9-9164-d41739dc4d6c", - "metadata": {}, - "outputs": [], - "source": [ - "import csv\n", - "\n", - "\n", - "def load_lookup_table(filename):\n", - " '''read a CSV file storing lookup table and create a dictionar using values in the fisrt 4 columns as key and return both dictionary and header\n", - " '''\n", - " with open(filename) as csv_data:\n", - " reader = csv.reader(csv_data)\n", - " rows = [row for row in reader if row or not row.startswith('#')]\n", - " header = rows[0]\n", - "\n", - " lookuptable = {}\n", - " for row in rows[1:]:\n", - " # print row\n", - " lookuptable[(row[0], row[1], float(row[2]), float(row[3]))] = [float(item) for item in row[4:]]\n", - " return lookuptable, header" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ae6b413f-5c2b-45d8-9861-4ec3aae15456", - "metadata": {}, - "outputs": [], - "source": [ - "result=load_lookup_table(\"/workspaces/dodal/tests/devices/i10/lookupTables/IDEnergy2GapCalibrations.csv\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "49ff9c40-1e25-4e63-8faa-e036142c2c48", - "metadata": {}, - "outputs": [], - "source": [ - "with open(\"/workspaces/dodal/tests/devices/i10/lookupTables/IDEnergy2GapCalibrations.csv\", newline='') as csvfile:\n", - "\n", - " reader = csv.DictReader(csvfile)\n", - " result = sorted(reader, key=lambda d: float(d['MinEnergy']))\n", - " for row in result:\n", - " if(float(row[\"MaxEnergy\"])>600):\n", - " print(row[\"MaxEnergy\"])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "85a0c336-8e23-4913-9337-d6564e5f4c06", - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "9a2ea13b-1671-41f6-bc79-19b9288e2652", - "metadata": {}, - "outputs": [], - "source": [ - "k = {\"idd\":{\"pc\":{1},\"nc\":{2}},\n", - " \"idu\":{\"pc\":{1},\"nc\":{2}}}" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "017804f2-a1a1-423c-bcd9-6c9a76a8caa9", - "metadata": {}, - "outputs": [], - "source": [ - "k[\"idd\"][\"pc\"]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "fc9fa2c7-ad13-440d-ab39-e30716ca581e", - "metadata": {}, - "outputs": [], - "source": [ - "import pandas as pd" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "20fd5287-ee7e-42fa-9dfa-2a9dc175e2d3", - "metadata": {}, - "outputs": [], - "source": [ - "df = pd.read_csv(\"/workspaces/dodal/src/lookupTables/IDEnergy2GapCalibrations.csv\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "86b36042-db8d-4b14-89f9-677cba0b342e", - "metadata": {}, - "outputs": [], - "source": [ - "source = (\"Source\",\"idd\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ef671a59-02cb-43c1-ace3-9755591dbf18", - "metadata": {}, - "outputs": [], - "source": [ - "idd = df[df[source[0]] == source[1]]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "d39fbf11-51c9-47e7-9f28-a1cbf4bb8d6f", - "metadata": {}, - "outputs": [], - "source": [ - "idd = idd.drop(source[0], axis=1)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "231e9a70-709a-4606-861d-616a86cf9e51", - "metadata": {}, - "outputs": [], - "source": [ - "idd" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "0ae8975f-beba-46c1-9ced-9c6195b7e5dd", - "metadata": {}, - "outputs": [], - "source": [ - "temp_df: pd.DataFrame = df[df[\"Mode\"] == \"lv\"].drop(\"Mode\", axis=1).sort_values(by=\"MaxEnergy\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "97dc0e29-90c3-4062-b620-17245e2741b2", - "metadata": {}, - "outputs": [], - "source": [ - "temp_df" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ee9957ba-7e09-41bf-b543-d6c050f6cab6", - "metadata": {}, - "outputs": [], - "source": [ - "iddict = {}\n", - "for i in id_modes:\n", - " temp_df = idd[idd[\"Mode\"]==i].drop(\"Mode\", axis=1)\n", - " iddict[i]= {}\n", - " ecounter = 0\n", - " for __, row in temp_df.iterrows():\n", - " poly = np.poly1d(row.values[::-1])\n", - " print(row.values[::-1])\n", - " iddict[i][f\"Energy{ecounter}\"]= {\"min\":row.values[0],\"max\":row.values[1],\"poly\":poly}\n", - " ecounter+=1" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "f5d1f275-2292-473b-bb65-9ec6c9d9ae52", - "metadata": {}, - "outputs": [], - "source": [ - "iddict.keys()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "28b5d8b7-e35e-4e59-92a7-ef064d7bb335", - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "e9fbc1c4-e633-4b00-94fb-87a049d68392", - "metadata": {}, - "outputs": [], - "source": [ - "w[w.MaxEnergy<500]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "fa4d89bd-4e74-49d5-bbc5-e7e5e87e519c", - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "e1b12e56-e79a-4343-ae67-28130a1a64aa", - "metadata": {}, - "outputs": [], - "source": [ - "x = np.arange(610,1200)\n", - "y = [1400.13845, -13.0099589\t,0.0518055008,\t-0.000113471444\t,1.47749738E-07,\t-1.14420814E-10,\t4.88195989E-14,\t-8.85680201E-18]\n", - "fit = np.poly1d(y[::-1])" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "c77d79ca-297c-4746-9cbe-5fc269fe6c83", - "metadata": {}, - "outputs": [], - "source": [ - "import matplotlib.pyplot as plt" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "6da755bb-59c2-4c96-870e-ed3ea054ad0d", - "metadata": {}, - "outputs": [], - "source": [ - "plt.plot(x,fit(x))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "12ebf92b-bdbe-4414-8264-11dd2a6dc168", - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.9" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} diff --git a/src/dodal/devices/.ipynb_checkpoints/Id_play-checkpoint.ipynb b/src/dodal/devices/.ipynb_checkpoints/Id_play-checkpoint.ipynb deleted file mode 100644 index 31bf9c98d0..0000000000 --- a/src/dodal/devices/.ipynb_checkpoints/Id_play-checkpoint.ipynb +++ /dev/null @@ -1,387 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "id": "b13dab05-d065-4b74-8401-74b84695b8d3", - "metadata": {}, - "outputs": [], - "source": [ - "import asyncio\n", - "\n", - "from apple2_undulator import (\n", - " UndulatorPhaseAxes,\n", - " UndulatorGap,\n", - " UndulatorJawPhase\n", - ")\n", - "from bluesky import RunEngine\n", - "from bluesky.callbacks.best_effort import BestEffortCallback\n", - "from pgm import PGM\n", - "\n", - "from dodal.devices.i10.i10_apple2 import I10Apple2, I10Apple2PGM, I10Apple2Pol \n", - "\n", - "RE = RunEngine({})\n", - "bec = BestEffortCallback()\n", - "from pathlib import Path\n", - "import bluesky.plan_stubs as bps\n", - "from ophyd_async.core import DeviceCollector\n", - "\n", - "from dodal.devices.i10.i10_setting_data import I10Grating" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "id": "8280232e-edb6-465f-b9f1-e9452fb38623", - "metadata": {}, - "outputs": [], - "source": [ - "with DeviceCollector():\n", - " i10PGM = PGM(prefix=\"BL10I-OP-PGM-01:\", grating=I10Grating, gratingPv=\"NLINES2\")\n", - " i10_id_gap = UndulatorGap(\"SR10I-MO-SERVC-21:\")\n", - " i10_id_phase = UndulatorPhaseAxes(prefix=\"SR10I-MO-SERVC-21:\",top_outer= \"RPQ1\",top_inner= \"RPQ2\",btm_outer= \"RPQ4\",btm_inner= \"RPQ3\")\n", - " i10_id_jaw = UndulatorJawPhase(prefix=\"SR10I-MO-SERVC-21:\", move_pv=\"RPQ1\", jawPhase=\"JAW\")\n", - " id10 = I10Apple2(id_gap=i10_id_gap, id_phase=i10_id_phase,\n", - " energy_gap_table_path = Path(\"/workspaces/dodal/tests/devices/i10/lookupTables/IDEnergy2GapCalibrations.csv\",),\n", - " energy_phase_table_path= Path(\"/workspaces/dodal/tests/devices/i10/lookupTables/IDEnergy2PhaseCalibrations.csv\",),\n", - " id_jaw_phase= i10_id_jaw,\n", - " source =(\"Source\",\"idu\"))\n", - " i10_energy = I10Apple2PGM(id=id10, pgm= i10PGM)\n", - " i10_pol = I10Apple2Pol(id=id10)\n", - " # upa21 = UndulatorPhaseAxes(prefix = 'SR21I-MO-SERVC-01:',\n", - " # top_outer= \"PUO\",\n", - " # top_inner= \"PUI\",\n", - " # btm_outer= \"PLO\",\n", - " # btm_inner= \"PLI\"\n", - " # )" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "8d2d8870-3c41-44cd-ab69-dffbae96e71f", - "metadata": {}, - "outputs": [], - "source": [ - "result = await i10_id_phase.top_inner.high_limit_travel.get_value()\n", - "print(await id10.polarisation.get_value())" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "77bce90a-f5eb-4383-b27c-c15e0c9b1e0c", - "metadata": {}, - "outputs": [], - "source": [ - "RE(bps.abs_set(id10, 500))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "715eb79c-ea44-44db-ba70-c771b4918cac", - "metadata": {}, - "outputs": [], - "source": [ - "result =await id10.read()\n", - "print(result)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "0e14809a-512c-4826-a418-8f6e782927ce", - "metadata": {}, - "outputs": [], - "source": [ - "print(id10.pol)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "32c97a3b-153e-4bc8-9885-838f00e9cf45", - "metadata": {}, - "outputs": [], - "source": [ - "result =await i10_energy.read()\n", - "print(result)\n", - "result =await i10_pol.read()\n", - "print(result)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "7f56526a-8a8d-400e-a89d-082c075fa600", - "metadata": {}, - "outputs": [], - "source": [ - "result[\"id10-gap-user_readback\"][\"value\"]" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "0c5549b6-d272-41c9-b1ed-dab96705dd16", - "metadata": {}, - "outputs": [], - "source": [ - "result = asyncio.gather(id10.read_configuration())#,upa21.read_configuration(), upa09.read_configuration())" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "274c1968-93a6-44b8-89d3-ddaf0cb6fc2d", - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np\n", - "\n", - "\n", - "async def test():\n", - " return np.max(await asyncio.gather(id10.gap.get_timeout(), id10.phase.get_timeout()))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "4c36d5f7-b662-4b27-ba00-4ccfcb7e5ec9", - "metadata": {}, - "outputs": [], - "source": [ - "k=asyncio.gather(test())" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "a8af9acb-729c-4b82-aca9-9db5aa30a1fc", - "metadata": {}, - "outputs": [], - "source": [ - "k" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "6fad6337-7b66-4f2c-968c-647f9000fedb", - "metadata": {}, - "outputs": [], - "source": [ - "i10_phase_axis_pv.read_pv" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "88de1b1f-cfa6-412d-ba48-ce76eff88da3", - "metadata": {}, - "outputs": [], - "source": [ - "upa10 = UndulatorPhaseAxes(prefix = 'SR10I-MO-', top_outer= top_outer,top_inner= top_inner, btm_outer= btm_outer, btm_inter= btm_inter)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ca7f8fc7-1708-497c-8574-a9538790e1ac", - "metadata": {}, - "outputs": [], - "source": [ - "RE(bps.abs_set(ug1, \"23.1\"))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "0c97cc57-e160-4ab0-bee0-4c6d79b81e2f", - "metadata": {}, - "outputs": [], - "source": [ - "from epics import caget" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "7d10b5a1-1e72-454e-8b18-839d4e5663ca", - "metadata": {}, - "outputs": [], - "source": [ - "caget(\"SR10I-MO-STAT-21:ANYFAULT\")\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "8bfd191b-f583-4eaa-ae55-e0c00b26e176", - "metadata": {}, - "outputs": [], - "source": [ - "caget(\"SR21I-MO-SERVC-01:BLGAPMTR.HLM\")\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "b2921e6c-e5fd-4276-bebd-8c703d85216b", - "metadata": {}, - "outputs": [], - "source": [ - "def new_pos():\n", - " output = range(0, 11, 1)\n", - " for i in output:\n", - " yield i" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "4a24bb25-318f-4d98-b791-443a706415eb", - "metadata": {}, - "outputs": [], - "source": [ - "k= new_pos()\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "1c6e80f4-d746-49a0-839a-60ba93fd1896", - "metadata": {}, - "outputs": [], - "source": [ - "next(k)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "a31af988-d39e-4490-87f4-187abd253c45", - "metadata": {}, - "outputs": [], - "source": [ - "result" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "c1036834-831a-4769-b78e-671dae96c8d0", - "metadata": {}, - "outputs": [], - "source": [ - "from ophyd_async.epics.motion import Motor\n", - "\n", - "i10motor = Motor(prefix=\"SR10I-MO-SERVC-01:BLRPQ1MTR\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "f47a617b-d837-49b6-9596-3dcc7e20aee3", - "metadata": {}, - "outputs": [], - "source": [ - "result = asyncio.gather(i10motor.connect())" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "536dc75e-6478-43cd-a410-8a1c7a295506", - "metadata": {}, - "outputs": [], - "source": [ - "result" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "e7924dcc-c266-4409-9ed6-98c1263b8e50", - "metadata": {}, - "outputs": [], - "source": [ - "result = asyncio.gather(i10motor.user_setpoint.get_value(), i10motor.user_readback.get_value())" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "24b95866-2262-4eb6-bede-7090656f8d7a", - "metadata": {}, - "outputs": [], - "source": [ - "result" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "cbbed4fa-9df5-4d29-a5d8-d0c37d43746f", - "metadata": {}, - "outputs": [], - "source": [ - "sp = (2,4,6)\n", - "x= (1,5,7)\n", - "y = (2,6,9)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "e0c2bd91-0c69-4ed7-99a5-8ed3a4237c4b", - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np\n", - "\n", - "result = np.abs(np.divide(tuple(np.subtract(x, y)), sp))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "5a8808e6-70ff-4531-8729-d9cf09f9149f", - "metadata": {}, - "outputs": [], - "source": [ - "result.min()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "b29f3abd-29a2-4659-aaf3-73383a1873f0", - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.9" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} From 60c11a374989c7a5419e18405a6ec95f8fec59d8 Mon Sep 17 00:00:00 2001 From: Relm-Arrowny Date: Tue, 8 Oct 2024 11:40:46 +0000 Subject: [PATCH 10/11] remove more junk --- p.ipynbpydantic | 177 ------------------------------------------------ 1 file changed, 177 deletions(-) delete mode 100644 p.ipynbpydantic diff --git a/p.ipynbpydantic b/p.ipynbpydantic deleted file mode 100644 index 6fe6cfeda5..0000000000 --- a/p.ipynbpydantic +++ /dev/null @@ -1,177 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 5, - "id": "ef076421-53cc-4a5a-abd2-3133af676e78", - "metadata": {}, - "outputs": [], - "source": [ - "from pydantic import BaseModel, ConfigDict\n", - "from dodal.devices.i10.id_apple2 import convert_csv_to_lookup\n", - "import numpy as np\n", - "lut= convert_csv_to_lookup(file=\"/workspaces/dodal/tests/devices/i10/lookupTables/IDEnergy2GapCalibrations.csv\", source=(\"Source\",\"idu\"))" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "4df22e82-6817-470d-80da-dc7e8c356bd7", - "metadata": {}, - "outputs": [], - "source": [ - "class lookuptable(BaseModel):\n", - " Value: str\n", - " Type: str" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "4e56e0e6-80e0-4cb7-be99-788f60dac9e1", - "metadata": {}, - "outputs": [], - "source": [ - "class lookuptable(BaseModel):\n", - " model: str\n", - "\n", - "\n", - "class ConfStructure(BaseModel):\n", - " version: int\n", - " info: Info" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "c6b856eb-4597-4d4c-928c-82e2a3c85032", - "metadata": {}, - "outputs": [], - "source": [ - "my_conf_wrong = {\n", - " 'version': 1,\n", - "\n", - " 'info': {\n", - " 'conf_one': 2.5,\n", - " 'conf_two': 'foo',\n", - " 'conf_three': False,\n", - " 'optional_conf': 'bar'\n", - " }\n", - "}\n", - "\n", - "my_conf_right = {\n", - " 'version': 10,\n", - "\n", - " 'info': {\n", - " 'conf_one': 14.5,\n", - " 'conf_two': 'something',\n", - " 'conf_three': False\n", - " }\n", - "}\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "6694cd4a-22e3-4f5b-a363-616c1758beeb", - "metadata": {}, - "outputs": [], - "source": [ - "model = ConfStructure(**my_conf_right)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "60cc1988-281b-4971-8d6f-08358bb4e879", - "metadata": {}, - "outputs": [], - "source": [ - "res = ConfStructure(**my_conf_wrong)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "6d669082-693a-40bb-82a4-e918fcb5221c", - "metadata": {}, - "outputs": [], - "source": [ - "'Low': 255.3,\n", - " 'High': 513.28,\n", - " 'Poly': poly1d([ 4.33435e-08, -7.52562e-05, 6.41791e-02, 3.88755e+00])}," - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "id": "b4ca9b09-7e63-4283-b434-99bddd74ae63", - "metadata": {}, - "outputs": [ - { - "ename": "RuntimeError", - "evalue": "no validator found for , see `arbitrary_types_allowed` in Config", - "output_type": "error", - "traceback": [ - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[0;31mRuntimeError\u001b[0m Traceback (most recent call last)", - "Cell \u001b[0;32mIn[8], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mpydantic\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m BaseModel, ConfigDict, ValidationError\n\u001b[0;32m----> 2\u001b[0m \u001b[38;5;28;43;01mclass\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;21;43;01menergies\u001b[39;49;00m\u001b[43m(\u001b[49m\u001b[43mBaseModel\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[1;32m 3\u001b[0m \u001b[43m \u001b[49m\u001b[43mmodel_config\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mConfigDict\u001b[49m\u001b[43m(\u001b[49m\u001b[43marbitrary_types_allowed\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m)\u001b[49m\n\u001b[1;32m 4\u001b[0m \u001b[43m \u001b[49m\u001b[43mLow\u001b[49m\u001b[43m:\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mfloat\u001b[39;49m\n", - "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/main.py:197\u001b[0m, in \u001b[0;36mpydantic.main.ModelMetaclass.__new__\u001b[0;34m()\u001b[0m\n", - "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/fields.py:504\u001b[0m, in \u001b[0;36mpydantic.fields.ModelField.infer\u001b[0;34m()\u001b[0m\n", - "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/fields.py:434\u001b[0m, in \u001b[0;36mpydantic.fields.ModelField.__init__\u001b[0;34m()\u001b[0m\n", - "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/fields.py:555\u001b[0m, in \u001b[0;36mpydantic.fields.ModelField.prepare\u001b[0;34m()\u001b[0m\n", - "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/fields.py:829\u001b[0m, in \u001b[0;36mpydantic.fields.ModelField.populate_validators\u001b[0;34m()\u001b[0m\n", - "File \u001b[0;32m/venv/lib/python3.11/site-packages/pydantic/validators.py:765\u001b[0m, in \u001b[0;36mfind_validators\u001b[0;34m()\u001b[0m\n", - "\u001b[0;31mRuntimeError\u001b[0m: no validator found for , see `arbitrary_types_allowed` in Config" - ] - } - ], - "source": [ - "from pydantic import BaseModel, ConfigDict, ValidationError\n", - "class energies(BaseModel):\n", - " model_config = ConfigDict(arbitrary_types_allowed=True)\n", - " Low: float\n", - " High: float\n", - " Poly: np.poly1d\n", - " " - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "bfb3148b-b695-4c96-b2bf-abb551c3bf27", - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "47abe376-478e-4cb6-9889-d900a42881a7", - "metadata": {}, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.11.9" - } - }, - "nbformat": 4, - "nbformat_minor": 5 -} From 1f196334e5ab9fe2844121c3019f11748432d1e8 Mon Sep 17 00:00:00 2001 From: Relm-Arrowny Date: Tue, 15 Oct 2024 08:57:49 +0000 Subject: [PATCH 11/11] catch up to ophyd 0.7 --- .../areadetector/andor2_epics/andor2_controller.py | 8 ++++---- tests/devices/unit_tests/areadetector/test_andor2.py | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/dodal/devices/areadetector/andor2_epics/andor2_controller.py b/src/dodal/devices/areadetector/andor2_epics/andor2_controller.py index 6567b220db..ca904c303d 100644 --- a/src/dodal/devices/areadetector/andor2_epics/andor2_controller.py +++ b/src/dodal/devices/areadetector/andor2_epics/andor2_controller.py @@ -1,6 +1,6 @@ import asyncio -from ophyd_async.core import DetectorControl, DetectorTrigger +from ophyd_async.core import DetectorController, DetectorTrigger from ophyd_async.core._detector import TriggerInfo from ophyd_async.epics import adcore from ophyd_async.epics.adcore import ( @@ -19,7 +19,7 @@ DEFAULT_MAX_NUM_IMAGE = 999_999 -class Andor2Controller(DetectorControl): +class Andor2Controller(DetectorController): _supported_trigger_types = { DetectorTrigger.internal: Andor2TriggerMode.internal, DetectorTrigger.edge_trigger: Andor2TriggerMode.ext_trigger, @@ -49,8 +49,8 @@ async def prepare(self, trigger_info: TriggerInfo): self._drv.trigger_mode.set(self._get_trigger_mode(trigger_info.trigger)), self._drv.num_images.set( DEFAULT_MAX_NUM_IMAGE - if trigger_info.number == 0 - else trigger_info.number + if trigger_info.total_number_of_triggers == 0 + else trigger_info.total_number_of_triggers ), self._drv.image_mode.set(ImageMode.multiple), ) diff --git a/tests/devices/unit_tests/areadetector/test_andor2.py b/tests/devices/unit_tests/areadetector/test_andor2.py index f2d8c70394..76127bc3e9 100644 --- a/tests/devices/unit_tests/areadetector/test_andor2.py +++ b/tests/devices/unit_tests/areadetector/test_andor2.py @@ -64,7 +64,9 @@ async def andor_controller() -> Andor2Controller: async def test_andor_controller_prepare_and_arm_with_TriggerInfo( RE, andor_controller: Andor2Controller ): - await andor_controller.prepare(trigger_info=TriggerInfo(number=1, livetime=0.002)) + await andor_controller.prepare( + trigger_info=TriggerInfo(number_of_triggers=1, livetime=0.002) + ) await andor_controller.arm() driver = andor_controller._drv @@ -82,7 +84,7 @@ async def test_andor_controller_prepare_and_arm_with_no_livetime( default_count_time = 2141 driver = andor_controller._drv set_mock_value(driver.acquire_time, default_count_time) - await andor_controller.prepare(trigger_info=TriggerInfo(number=5)) + await andor_controller.prepare(trigger_info=TriggerInfo(number_of_triggers=5)) await andor_controller.arm() assert await driver.num_images.get_value() == 5 @@ -99,7 +101,7 @@ async def test_andor_controller_prepare_and_arm_with_trigger_number_of_zero( default_count_time = 1231 driver = andor_controller._drv set_mock_value(driver.acquire_time, default_count_time) - await andor_controller.prepare(trigger_info=TriggerInfo(number=0)) + await andor_controller.prepare(trigger_info=TriggerInfo(number_of_triggers=0)) await andor_controller.arm() assert await driver.num_images.get_value() == DEFAULT_MAX_NUM_IMAGE