Skip to content

Commit

Permalink
Add tests for new eln data formalism
Browse files Browse the repository at this point in the history
  • Loading branch information
domna committed Aug 12, 2024
1 parent 1ab0d64 commit c92d0c1
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
8 changes: 7 additions & 1 deletion scripts/regenerate_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ function update_mpes_example {
dataconverter xarray_saved_small_calibration.h5 config_file.json --reader $READER --nxdl $NXDL --output example.nxs
}

function update_mpes_eln_example {
echo "Update mpes example with eln file"
dataconverter xarray_saved_small_calibration.h5 config_file.json eln_data.yaml --reader $READER --nxdl $NXDL --output example_eln.nxs
}

project_dir=$(dirname $(dirname $(realpath $0)))
cd $project_dir/tests/data

update_mpes_example
update_mpes_example
update_mpes_eln_example
2 changes: 1 addition & 1 deletion tests/data/config_file.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"/@default": "entry",
"/ENTRY/@default": "data",
"/ENTRY/definition": "NXmpes",
"/ENTRY/title": "@attrs:metadata/entry_title",
"/ENTRY/title": "['@eln:/ENTRY/title', '@attrs:metadata/entry_title']",
"/ENTRY/start_time": "@attrs:metadata/timing/acquisition_start",
"/ENTRY/experiment_institution": "Fritz Haber Institute - Max Planck Society",
"/ENTRY/experiment_facility": "Time Resolved ARPES",
Expand Down
2 changes: 1 addition & 1 deletion tests/data/eln_data.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
title: Valence Band Dynamics - 1030 nm linear p-polarized pump, 0.6 mJ/cm2 absorbed fluence
title: Title from ELN file
Instrument:
energy_resolution:
unit: meV
Expand Down
Binary file added tests/data/example_eln.nxs
Binary file not shown.
27 changes: 15 additions & 12 deletions tests/test_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
Basic example based test for the stm reader
"""

import os
from pathlib import Path

import pynxtools.dataconverter.convert as dataconverter
from pynxtools.testing.nexus_conversion import ReaderTest


Expand All @@ -30,18 +28,23 @@ def test_nexus_conversion(caplog, tmp_path):
test.check_reproducibility_of_nexus()


def test_eln_data(tmp_path):
"""Check if the subsections in the eln_data.yml file work."""
def test_conversion_w_eln_data(caplog, tmp_path):
"""
Tests the conversion with additional ELN data
"""
caplog.clear()
dir_path = Path(__file__).parent / "data"
dataconverter.convert(
input_file=(
test = ReaderTest(
nxdl="NXmpes",
reader_name="mpes",
files_or_dir=[
str(dir_path / "xarray_saved_small_calibration.h5"),
str(dir_path / "config_file.json"),
str(dir_path / "eln_data.yaml"),
),
reader="mpes",
nxdl="NXmpes",
output=os.path.join(tmp_path, "mpes.small_test.nxs"),
skip_verify=False,
ignore_undocumented=False,
str(dir_path / "example_eln.nxs"),
],
tmp_path=tmp_path,
caplog=caplog,
)
test.convert_to_nexus(caplog_level="WARNING", ignore_undocumented=False)
test.check_reproducibility_of_nexus()

0 comments on commit c92d0c1

Please sign in to comment.