|
2 | 2 | import os
|
3 | 3 | import unittest
|
4 | 4 | import uuid
|
| 5 | +from pathlib import Path |
5 | 6 |
|
6 | 7 | import bluesky.plan_stubs as bps
|
7 | 8 | import bluesky.plans as bp
|
| 9 | +import matplotlib |
8 | 10 | from bluesky.callbacks import LiveTable
|
9 | 11 | from bluesky.preprocessors import subs_decorator
|
10 | 12 | from bluesky.run_engine import RunEngine, RunEngineResult
|
11 | 13 | from genie_python import genie as g # type: ignore
|
| 14 | +from ibex_bluesky_core.callbacks import ISISCallbacks |
| 15 | +from ibex_bluesky_core.callbacks.fitting.fitting_utils import Linear |
12 | 16 | from ibex_bluesky_core.devices import get_pv_prefix
|
13 | 17 | from ibex_bluesky_core.devices.block import block_r, block_rw_rbv
|
14 | 18 | from ibex_bluesky_core.devices.simpledae import SimpleDae
|
|
20 | 24 | GoodFramesNormalizer,
|
21 | 25 | PeriodGoodFramesNormalizer,
|
22 | 26 | )
|
23 |
| -from ibex_bluesky_core.devices.simpledae.waiters import GoodFramesWaiter, PeriodGoodFramesWaiter |
| 27 | +from ibex_bluesky_core.devices.simpledae.waiters import ( |
| 28 | + GoodFramesWaiter, |
| 29 | + PeriodGoodFramesWaiter, |
| 30 | +) |
24 | 31 | from ibex_bluesky_core.log import set_bluesky_log_levels
|
25 | 32 | from ibex_bluesky_core.run_engine import get_run_engine
|
26 | 33 | from ophyd_async.plan_stubs import ensure_connected
|
|
30 | 37 | set_genie_python_raises_exceptions,
|
31 | 38 | )
|
32 | 39 |
|
| 40 | +matplotlib.use("qtagg") |
33 | 41 | RE: RunEngine = get_run_engine()
|
34 | 42 |
|
35 | 43 | P3_INIT_VALUE: float = 123.456
|
@@ -147,6 +155,29 @@ def _plan():
|
147 | 155 | self.assertTrue(any("| 123.456 | -10.00000 |" in line for line in livetable_lines))
|
148 | 156 | self.assertTrue(any("| 123.456 | 10.00000 |" in line for line in livetable_lines))
|
149 | 157 |
|
| 158 | + def test_scan_with_standard_callbacks(self) -> None: |
| 159 | + icc = ISISCallbacks( |
| 160 | + x="p5", |
| 161 | + y="p3", |
| 162 | + fit=Linear().fit(), |
| 163 | + human_readable_file_output_dir=Path(LOG_FOLDER) / "output_files", |
| 164 | + live_fit_logger_output_dir=Path(LOG_FOLDER) / "fitting", |
| 165 | + ) |
| 166 | + |
| 167 | + @icc |
| 168 | + def _plan(): |
| 169 | + p3 = block_r(float, "p3") |
| 170 | + p5 = block_rw_rbv(float, "p5") |
| 171 | + yield from ensure_connected(p3, p5) |
| 172 | + yield from bp.scan([p3], p5, -10, 10, num=10) |
| 173 | + |
| 174 | + RE(_plan()) |
| 175 | + |
| 176 | + self.assertAlmostEqual(icc.peak_stats["com"], 0) |
| 177 | + print(icc.live_fit.result.params["c0"]) |
| 178 | + print(icc.live_fit.result.fit_report()) |
| 179 | + self.assertAlmostEqual(icc.live_fit.result.params["c0"], P3_INIT_VALUE) |
| 180 | + |
150 | 181 | def test_count_simple_dae(self) -> None:
|
151 | 182 | start_run_number = int(g.get_runnumber())
|
152 | 183 |
|
@@ -211,7 +242,9 @@ def test_GIVEN_logging_is_requested_THEN_the_log_file_exists(self) -> None:
|
211 | 242 | )
|
212 | 243 | self.assertTrue(os.path.exists(self.qualified_log_filename))
|
213 | 244 |
|
214 |
| - def test_GIVEN_logging_is_requested_THEN_the_log_file_contains_the_message(self) -> None: |
| 245 | + def test_GIVEN_logging_is_requested_THEN_the_log_file_contains_the_message( |
| 246 | + self, |
| 247 | + ) -> None: |
215 | 248 | # Log invocation.
|
216 | 249 | bluesky_message = LOG_MESSAGE + str(uuid.uuid4())
|
217 | 250 | other_message = LOG_MESSAGE + str(uuid.uuid4())
|
@@ -240,7 +273,9 @@ def test_GIVEN_logging_is_configured_at_info_level_THEN_debug_messages_do_not_go
|
240 | 273 | self.assertNotIn(debug_msg, content)
|
241 | 274 | self.assertIn(info_msg, content)
|
242 | 275 |
|
243 |
| - def test_GIVEN_logging_is_configured_at_debug_level_THEN_debug_messages_do_go_to_log_file(self): |
| 276 | + def test_GIVEN_logging_is_configured_at_debug_level_THEN_debug_messages_do_go_to_log_file( |
| 277 | + self, |
| 278 | + ): |
244 | 279 | debug_msg = LOG_MESSAGE + str(uuid.uuid4())
|
245 | 280 | info_msg = LOG_MESSAGE + str(uuid.uuid4())
|
246 | 281 |
|
|
0 commit comments