test_nxw_plotselect.py 1.93 KB
Newer Older
1
2
3
4
5
6
7
8
# -*- coding: utf-8 -*-
#
# This file is part of the bliss project
#
# Copyright (c) 2015-2020 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.

from bliss.common import scans
Wout De Nolf's avatar
fixup    
Wout De Nolf committed
9
from bliss.common.plot import plotselect, plotinit
10
11
from tests.nexus_writer.helpers import nxw_test_utils
from tests.nexus_writer.helpers import nxw_test_data
12
13
14
15
16
17
18
19
20
21
22
23


def test_nxw_plotselect(nexus_writer_config):
    _test_nxw_plotselect(**nexus_writer_config)


@nxw_test_utils.writer_stdout_on_exception
def _test_nxw_plotselect(
    session=None, tmpdir=None, writer=None, save_images=True, **kwargs
):
    scan_saving = session.scan_saving
    env_dict = session.env_dict
24
    scan_saving.dataset.all.definition = "none"
25
26
    detectors = [env_dict[name] for name in ["diode3", "diode4", "diode5"]]
    scan_shape = (10,)
Wout De Nolf's avatar
fixup    
Wout De Nolf committed
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48

    plotselect("diode4", "diode5")

    # Overwrite plotselect for one scan
    plotinit("diode3", "diode4")
    plots = {"plotselect": {"ndim": 0, "type": "grid", "signals": ["diode3", "diode4"]}}
    scan = scans.loopscan(
        scan_shape[0], .1, *detectors, run=False, save_images=save_images
    )
    nxw_test_utils.run_scan(scan)
    nxw_test_utils.wait_scan_data_finished([scan], writer=writer)
    nxw_test_data.assert_scan_nxdata(
        scan,
        plots,
        scan_shape=scan_shape,
        positioners=[["elapsed_time", "epoch"]],
        save_images=save_images,
        **kwargs
    )

    # Fall back to plotselect
    plots = {"plotselect": {"ndim": 0, "type": "grid", "signals": ["diode4", "diode5"]}}
49
50
51
52
53
54
55
56
57
58
59
60
61
    scan = scans.loopscan(
        scan_shape[0], .1, *detectors, run=False, save_images=save_images
    )
    nxw_test_utils.run_scan(scan)
    nxw_test_utils.wait_scan_data_finished([scan], writer=writer)
    nxw_test_data.assert_scan_nxdata(
        scan,
        plots,
        scan_shape=scan_shape,
        positioners=[["elapsed_time", "epoch"]],
        save_images=save_images,
        **kwargs
    )