Skip to content

Commit

Permalink
make nexus conversion test fail on undocumented or missing fields
Browse files Browse the repository at this point in the history
  • Loading branch information
rettigl committed Jul 13, 2024
1 parent 05fa998 commit d29f68c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
19 changes: 9 additions & 10 deletions specsscan/config/NXmpes_arpes_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"/@default": "entry",
"/ENTRY[entry]/@default": "data",
"/ENTRY[entry]/definition": "NXmpes_arpes",
"/ENTRY[entry]/definition/@version": "None",
"/ENTRY[entry]/title": "@attrs:metadata/entry_title",
"/ENTRY[entry]/start_time": "@attrs:metadata/timing/acquisition_start",
"/ENTRY[entry]/experiment_institution": "Fritz Haber Institute - Max Planck Society",
Expand All @@ -15,9 +14,9 @@
"/ENTRY[entry]/collection_time": "@attrs:metadata/timing/collection_time",
"/ENTRY[entry]/collection_time/@units": "s",
"/ENTRY[entry]/USER[user]": {
"name": "@attrs:metadata/user0/name",
"name": "!@attrs:metadata/user0/name",
"role": "@attrs:metadata/user0/role",
"affiliation": "@attrs:metadata/user0/affiliation",
"affiliation": "!@attrs:metadata/user0/affiliation",
"address": "@attrs:metadata/user0/address",
"email": "@attrs:metadata/user0/email"
},
Expand Down Expand Up @@ -70,19 +69,19 @@
"fast_axes": "@attrs:metadata/scan_info/fast_axes",
"slow_axes": "@attrs:metadata/scan_info/slow_axes",
"energy_resolution": {
"resolution": "@attrs:metadata/instrument/electronanalyser/energy_resolution",
"resolution": "!@attrs:metadata/instrument/electronanalyser/energy_resolution",
"resolution/@units": "meV",
"physical_quantity": "energy",
"type": "derived"
},
"angular_resolution": {
"resolution": "@attrs:metadata/instrument/electronanalyser/angular_resolution",
"resolution": "!@attrs:metadata/instrument/electronanalyser/angular_resolution",
"resolution/@units": "deg",
"physical_quantity": "angle",
"type": "derived"
},
"spatial_resolution": {
"resolution": "@attrs:metadata/instrument/electronanalyser/spatial_resolution",
"resolution": "!@attrs:metadata/instrument/electronanalyser/spatial_resolution",
"resolution/@units": "µm",
"physical_quantity": "length",
"type": "estimated"
Expand Down Expand Up @@ -169,7 +168,7 @@
"/ENTRY[entry]/INSTRUMENT[instrument]/beamTYPE[beam_probe]": {
"distance": 0.0,
"distance/@units": "mm",
"incident_energy": "@attrs:metadata/instrument/beam/probe/incident_energy",
"incident_energy": "!@attrs:metadata/instrument/beam/probe/incident_energy",
"incident_energy/@units": "eV",
"incident_energy_spread": "@attrs:metadata/instrument/beam/probe/incident_energy_spread",
"incident_energy_spread/@units": "eV",
Expand All @@ -193,7 +192,7 @@
"/ENTRY[entry]/INSTRUMENT[instrument]/beamTYPE[beam_pump]": {
"distance": 0.0,
"distance/@units": "mm",
"incident_energy": "@attrs:metadata/instrument/beam/pump/incident_energy",
"incident_energy": "!@attrs:metadata/instrument/beam/pump/incident_energy",
"incident_energy/@units": "eV",
"incident_energy_spread": "@attrs:metadata/instrument/beam/pump/incident_energy_spread",
"incident_energy_spread/@units": "eV",
Expand All @@ -217,7 +216,7 @@
"temperature_sensor": {
"name": "sample_temperature",
"measurement": "temperature",
"value": "@attrs:metadata/scan_info/trARPES:Carving:TEMP_RBV",
"value": "!@attrs:metadata/scan_info/trARPES:Carving:TEMP_RBV",
"value/@units": "K"
},
"sample_bias_voltmeter": {
Expand All @@ -229,7 +228,7 @@
"drain_current_amperemeter": {
"name": "drain_current",
"measurement": "current",
"value": "@attrs:metadata/scan_info/trARPES:Sample:Measure",
"value": "!@attrs:metadata/scan_info/trARPES:Sample:Measure",
"value/@units": "A"
},
"depends_on": "/entry/instrument/manipulator/transformations/trans_z",
Expand Down
11 changes: 8 additions & 3 deletions tests/test_specsscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import numpy as np
import pytest
from pynxtools.dataconverter.convert import ValidationFailed

import specsscan
from specsanalyzer.core import create_fft_params
Expand Down Expand Up @@ -323,8 +324,8 @@ def test_conversion_and_save_to_nexus():
sps.save("result.tiff")
sps.save("result.tiff", alias_dict={"X": "angular0", "Y": "angular1"})
sps.save("result.h5")
# with pytest.raises(LookupError):
# sps.save("result.nxs")
with pytest.raises(ValidationFailed):
sps.save("result.nxs", fail=True)

metadata = {}
# General
Expand All @@ -345,6 +346,10 @@ def test_conversion_and_save_to_nexus():
metadata["instrument"]["beam"]["probe"] = {}
metadata["instrument"]["beam"]["probe"]["incident_energy"] = 21.7

# sample
metadata["sample"] = {}
metadata["sample"]["name"] = "Name"

metadata["scan_info"] = {}
metadata["scan_info"]["trARPES:XGS600:PressureAC:P_RD"] = 2.5e-11
metadata["scan_info"]["trARPES:Carving:TEMP_RBV"] = 70
Expand All @@ -357,4 +362,4 @@ def test_conversion_and_save_to_nexus():
collect_metadata=True,
)

sps.save("result.nxs")
sps.save("result.nxs", fail=True)

0 comments on commit d29f68c

Please sign in to comment.