Commit ca1ae9d4 authored by Wout De Nolf's avatar Wout De Nolf Committed by Valentin Valls
Browse files

[test] add test for NXdata from plotselect

parent d11ba39a
......@@ -67,15 +67,7 @@ def validate_scan_data(
:param bool save_images: save lima images
"""
# Parse arguments
if config:
save_options = config_options()
else:
save_options = base_options()
if alt:
save_options = {k: not v for k, v in save_options.items()}
# Forced in confdtest.py::writer_options
save_options["copy_non_external"] = True
save_options["allow_external_hdf5"] = True
save_options = get_save_options(config=config, alt=alt)
variable_length = not all(scan_shape)
if not positioners:
positioners = []
......@@ -155,6 +147,65 @@ def validate_scan_data(
validate_notes(nxentry, notes)
def assert_scan_nxdata(
scan,
plots,
subscan=1,
positioners=None,
master_name="timer",
scan_shape=tuple(),
config=True,
alt=False,
save_images=True,
**kw,
):
"""
:param bliss.scanning.scan.Scan scan:
:param dict plots:
:param int subscan:
:param list positioners: fast axis first
:param str master_name: chain master name
:param tuple scan_shape: fast axis first 0D scan by default
:param bool config: configurable writer
:param bool alt: alternative writer options
:param bool save_images: save lima images
"""
save_options = get_save_options(config=config, alt=alt)
if not positioners:
positioners = []
uri = scan_utils.scan_uri(scan, subscan=subscan)
with nexus.uriContext(uri) as nxentry:
for name, info in plots.items():
validate_nxdata(
nxentry[name],
info["ndim"],
info["type"],
info["signals"],
scan_shape=scan_shape,
positioners=positioners,
master_name=master_name,
save_options=save_options,
save_images=save_images,
)
def get_save_options(config=True, alt=False):
"""
:param bool config: configurable writer
:param bool alt: alternative writer options
"""
if config:
save_options = config_options()
else:
save_options = base_options()
if alt:
save_options = {k: not v for k, v in save_options.items()}
# Forced in confdtest.py::writer_options
save_options["copy_non_external"] = True
save_options["allow_external_hdf5"] = True
return save_options
def validate_scangroup_data(sequence, config=True, **kwargs):
"""
:param bliss.scanning.scan.Scan sequence:
......
# -*- 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
import nxw_test_utils
import nxw_test_data
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
scan_display = session.scan_display
scan_saving.technique = ""
detectors = [env_dict[name] for name in ["diode3", "diode4", "diode5"]]
names = [env_dict[name].fullname for name in ["diode3", "diode4"]]
scan_display._plotselect(names)
plots = {}
plots["plotselect"] = {"ndim": 0, "type": "grid", "signals": ["diode3", "diode4"]}
scan_shape = (10,)
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
)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment