diff --git a/src/dls_tiled/visr.py b/src/dls_tiled/visr.py index b4504bd..1ea2352 100644 --- a/src/dls_tiled/visr.py +++ b/src/dls_tiled/visr.py @@ -196,7 +196,7 @@ def _channel_length(array: H5Dataset | numpy.ndarray | dict) -> int: def _axis_letter(name: object) -> str | None: - """Return "x", "y" or "z" if the axis name ends in one (e.g. "sample_stage-x").""" + """Return "x", "y" or "z" if the name ends in one (e.g. "spectroscopy_stage-x").""" if not isinstance(name, str): return None letter = re.split(r"[-_.]", name.lower())[-1] @@ -211,7 +211,7 @@ def _axis_name(axis: object) -> str | None: """The device name of a spec axis, or None if the spec doesn't carry one. A spec axis is whatever the plan passed in: a plain name, an ophyd-async - repr that carries the name (``Motor(name="sample_stage-x")``), or, in older + repr that carries the name (``Motor(name="spectroscopy_stage-x")``), or, in older runs, an object repr with no name (``<... Motor object at 0x7f...>``). """ if not isinstance(axis, str): @@ -486,11 +486,11 @@ async def get_setpoints(root, uid): async def _fetch_readback_x(root, uid) -> tuple[H5Dataset | numpy.ndarray, ScanType]: try: - x = await get_data(root, [uid, "primary", "internal", "sample_stage-x"]) + x = await get_data(root, [uid, "primary", "internal", "spectroscopy_stage-x"]) scan_type = ScanType.FlyScan except NoEntry: try: - x = await get_data(root, [uid, "primary", "sample_stage-x"]) + x = await get_data(root, [uid, "primary", "spectroscopy_stage-x"]) scan_type = ScanType.FlyScan except NoEntry: x = await get_data(root, [uid, "primary", "X"]) @@ -502,13 +502,17 @@ async def _fetch_readback_x(root, uid) -> tuple[H5Dataset | numpy.ndarray, ScanT async def _fetch_readback_yz(root, uid, scan_type, x_shape): if scan_type == ScanType.FlyScan: try: - y = await get_data(root, [uid, "primary", "internal", "sample_stage-y"]) + y = await get_data( + root, [uid, "primary", "internal", "spectroscopy_stage-y"] + ) except NoEntry: - y = await fill_data(root, [uid, "primary", "sample_stage-y"], x_shape) + y = await fill_data(root, [uid, "primary", "spectroscopy_stage-y"], x_shape) try: - z = await get_data(root, [uid, "primary", "internal", "sample_stage-z"]) + z = await get_data( + root, [uid, "primary", "internal", "spectroscopy_stage-z"] + ) except NoEntry: - z = await fill_data(root, [uid, "primary", "sample_stage-z"], x_shape) + z = await fill_data(root, [uid, "primary", "spectroscopy_stage-z"], x_shape) else: y = await fill_data(root, [uid, "primary", "Y"], x_shape) z = await fill_data(root, [uid, "primary", "Z"], x_shape) diff --git a/tests/test_visr.py b/tests/test_visr.py index e5231f3..7cd8077 100644 --- a/tests/test_visr.py +++ b/tests/test_visr.py @@ -167,7 +167,9 @@ async def lookup_adapter(path): def test_setpoints_follow_axis_names_not_dimension_order(): # Raster scan: y is the outer dimension, x the inner one. - spec = Line("sample_stage-y", 0, 1, 2) * Line("sample_stage-x", 0, 10, 3) + spec = Line("spectroscopy_stage-y", 0, 1, 2) * Line( + "spectroscopy_stage-x", 0, 10, 3 + ) x, y, z = _setpoints(spec) @@ -181,7 +183,7 @@ def test_setpoints_of_runs_with_repr_axes_use_the_motors_list(): "", 0, 10, 3 ) - x, y, _ = _setpoints(spec, motors=["sample_stage-y", "sample_stage-x"]) + x, y, _ = _setpoints(spec, motors=["spectroscopy_stage-y", "spectroscopy_stage-x"]) assert x.tolist() == [0, 5, 10, 0, 5, 10] assert y.tolist() == [0, 0, 0, 1, 1, 1] @@ -286,7 +288,9 @@ def _grid(spec, motors=None): def test_grid_edges_sit_halfway_between_setpoints(): - spec = Line("sample_stage-y", 0, 2, 3) * ~Line("sample_stage-x", 0, 10, 3) + spec = Line("spectroscopy_stage-y", 0, 2, 3) * ~Line( + "spectroscopy_stage-x", 0, 10, 3 + ) x_edges, y_edges, n_total, *_ = _grid(spec) @@ -300,7 +304,7 @@ def test_grid_of_runs_with_repr_axes_uses_the_motors_list(): "", 0, 10, 3 ) - x_edges, y_edges, *_ = _grid(spec, ["sample_stage-y", "sample_stage-x"]) + x_edges, y_edges, *_ = _grid(spec, ["spectroscopy_stage-y", "spectroscopy_stage-x"]) assert len(x_edges) == 4 and len(y_edges) == 4 @@ -733,11 +737,14 @@ def test_binned_etag_changes_when_the_image_does(client): @pytest.mark.parametrize( ("stored", "name"), [ - ("sample_stage-x", "sample_stage-x"), - ('Motor(name="sample_stage-x")', "sample_stage-x"), - ("Motor(name='sample_stage-y')", "sample_stage-y"), - ('Motor(device_name="stage", name="sample_stage-x")', "sample_stage-x"), - ('Motor(prefix="BL01:", name="sample_stage-x")', "sample_stage-x"), + ("spectroscopy_stage-x", "spectroscopy_stage-x"), + ('Motor(name="spectroscopy_stage-x")', "spectroscopy_stage-x"), + ("Motor(name='spectroscopy_stage-y')", "spectroscopy_stage-y"), + ( + 'Motor(device_name="stage", name="spectroscopy_stage-x")', + "spectroscopy_stage-x", + ), + ('Motor(prefix="BL01:", name="spectroscopy_stage-x")', "spectroscopy_stage-x"), ("", None), ], ) @@ -747,8 +754,8 @@ def test_axis_name_reads_the_name_out_of_the_forms_runs_store(stored, name): def test_setpoints_of_runs_with_named_reprs_need_no_motors_list(): # recent runs store Motor(name=...) and fly scans have no motors list - spec = Line('Motor(name="sample_stage-y")', 0, 1, 2) * Line( - 'Motor(name="sample_stage-x")', 0, 10, 3 + spec = Line('Motor(name="spectroscopy_stage-y")', 0, 1, 2) * Line( + 'Motor(name="spectroscopy_stage-x")', 0, 10, 3 ) x, y, _ = _setpoints(spec) @@ -758,8 +765,8 @@ def test_setpoints_of_runs_with_named_reprs_need_no_motors_list(): def test_grid_of_runs_with_named_reprs_needs_no_motors_list(): - spec = Line('Motor(name="sample_stage-y")', 0, 2, 3) * ~Line( - 'Motor(name="sample_stage-x")', 0, 10, 3 + spec = Line('Motor(name="spectroscopy_stage-y")', 0, 2, 3) * ~Line( + 'Motor(name="spectroscopy_stage-x")', 0, 10, 3 ) x_edges, y_edges, n_total, *_ = _grid(spec) @@ -906,7 +913,10 @@ def test_place_on_grid_without_points_is_the_bare_grid(): @pytest.mark.parametrize( "motors", - [["sample_stage-y", "sample_stage-x"], ["sample_stage-x", "sample_stage-y"]], + [ + ["spectroscopy_stage-y", "spectroscopy_stage-x"], + ["spectroscopy_stage-x", "spectroscopy_stage-y"], + ], ) def test_binned_lets_the_points_decide_x_and_y_when_only_the_motors_list_names_them( client, motors @@ -990,7 +1000,11 @@ def write_points( target = primary if where == "primary" else primary.create_container(where) names = {"X": "X", "Y": "Y", "Z": "Z"} if where != "primary" or channels == "named": - names = {"X": "sample_stage-x", "Y": "sample_stage-y", "Z": "sample_stage-z"} + names = { + "X": "spectroscopy_stage-x", + "Y": "spectroscopy_stage-y", + "Z": "spectroscopy_stage-z", + } target.write_array(numpy.asarray(x, dtype=float), key=names["X"]) target.write_array(numpy.asarray(y, dtype=float), key=names["Y"]) if z is not None: @@ -1121,7 +1135,8 @@ def test_binned_swapping_the_dimension_indices_transposes_the_image(client): @pytest.mark.parametrize("where", ["internal", "named"]) def test_binned_finds_positions_wherever_the_run_stores_them(client, where): - # older fly scans: primary/internal/sample_stage-x; others: primary/sample_stage-x + # older fly scans: primary/internal/spectroscopy_stage-x + # others: primary/spectroscopy_stage-x x, y = [0.0, 1.0, 0.0, 1.0], [0.0, 0.0, 1.0, 1.0] if where == "internal": write_points(client, where, x, y, where="internal") @@ -1284,8 +1299,8 @@ def test_binned_bins_a_step_scans_diodes_from_its_event_table(client): primary.write_dataframe( pandas.DataFrame( { - "sample_stage-x": SQUARE_X, - "sample_stage-y": SQUARE_Y, + "spectroscopy_stage-x": SQUARE_X, + "spectroscopy_stage-y": SQUARE_Y, **{f"spectroscopy_diodes-{c}": v for c, v in DIODES.items()}, } ),