Source code for ewoksfluo.tests.tutorials.test_single_scan_single_detector
from typing import Any
from typing import Dict
from typing import List
from typing import Tuple
from . import assert_results
[docs]
def test_single_scan_single_detector_without_qt(tmp_path):
assert_results.assert_without_qt(
"mesh_single_scan_single_detector.ows",
get_inputs(tmp_path),
get_expected_outputs(tmp_path),
get_expected_hdf5(tmp_path),
)
[docs]
def test_single_scan_single_detector_with_qt(ewoks_orange_canvas, tmp_path):
assert_results.assert_with_qt(
ewoks_orange_canvas,
"mesh_single_scan_single_detector.ows",
get_inputs(tmp_path),
get_expected_outputs(tmp_path),
get_expected_hdf5(tmp_path),
)
[docs]
def get_inputs(tmp_path) -> List[Dict[str, Any]]:
return [
{
"label": "Mesh (single detector)",
"name": "output_filename",
"value": str(tmp_path / "input.h5"),
},
{
"label": "Fit scan (single detector)",
"name": "output_root_uri",
"value": str(tmp_path / "output.h5::/1.1"),
},
]
[docs]
def get_expected_outputs(tmp_path) -> Dict[str, Dict[str, Any]]:
bliss_scan_uri = str(tmp_path / "input.h5::/1.1")
output_root_uri = str(tmp_path / "output.h5::/1.1")
return {
"Mesh (single detector)": {
"config": str(tmp_path / "input.h5::/1.1/theory/configuration/data"),
"detector_name": "mca0",
"expo_time": 0.1,
"filename": str(tmp_path / "input.h5"),
"monitor_name": "I0",
"monitor_normalization_template": "1000000/<instrument/{}/data>",
"detector_normalization_template": "0.1/<instrument/{}/live_time>",
"scan_number": 1,
},
"Pick scan": {"bliss_scan_uri": bliss_scan_uri},
"Fit scan (single detector)": {
"xrf_results_uri": str(tmp_path / "output.h5::/1.1/fit/mca0/results"),
"bliss_scan_uri": bliss_scan_uri,
"detector_name": "mca0",
"output_root_uri": output_root_uri,
"output_root_group": None,
},
"Normalize": {
"xrf_results_uri": str(tmp_path / "output.h5::/1.1/norm/results"),
"bliss_scan_uri": bliss_scan_uri,
"output_root_uri": output_root_uri,
"output_root_group": None,
},
"Raw Counters": {
"xrf_results_uri": str(tmp_path / "output.h5::/1.1/merge/results"),
"bliss_scan_uri": bliss_scan_uri,
"output_root_uri": output_root_uri,
"output_root_group": None,
},
"Regrid": {
"xrf_results_uri": str(tmp_path / "output.h5::/1.1/regrid/results"),
"bliss_scan_uri": bliss_scan_uri,
"output_root_uri": output_root_uri,
"output_root_group": None,
},
}
[docs]
def get_expected_hdf5(tmp_path) -> Tuple[str, Dict[str, Any]]:
output_path = tmp_path / "output.h5"
expected = {
"@NX_class": "NXroot",
"@extra_attrs": {"default"},
"1.1": {
"@NX_class": "NXentry",
"@extra_attrs": {"default"},
"end_time@shape": (),
"fit": {
"@NX_class": "NXcollection",
"@extra_attrs": {"default"},
"mca0": {
"@NX_class": "NXprocess",
"@extra_attrs": {"default"},
"configuration": {
"@NX_class": "NXnote",
"data@shape": (),
"date@shape": (),
"type@shape": (),
},
"program@shape": (),
"results": {
"@NX_class": "NXcollection",
"@extra_attrs": {"default"},
"derivatives": {
"@NX_class": "NXdata",
"@axes": ["energy"],
"@signals": {
"Ce_L",
"Scatter_Compton000",
"Si_K",
"Ca_K",
"Scatter_Peak000",
"Fe_K",
},
"Ca_K@shape": (1024,),
"Ce_L@shape": (1024,),
"Fe_K@shape": (1024,),
"Scatter_Compton000@shape": (1024,),
"Scatter_Peak000@shape": (1024,),
"Si_K@shape": (1024,),
"energy@shape": (1024,),
"energy@units": "keV",
},
"diagnostics": {
"@NX_class": "NXdata",
"@signals": {"nFreeParameters", "nObservations"},
"nFreeParameters@shape": (3000,),
"nObservations@shape": (3000,),
},
"fit": {
"@NX_class": "NXdata",
"@axes": [".", "energy"],
"@signals": {"model", "data", "residuals"},
"data@shape": (3000, 1024),
"energy@shape": (1024,),
"energy@units": "keV",
"model@shape": (3000, 1024),
"residuals@shape": (3000, 1024),
},
"massfractions": {
"@NX_class": "NXdata",
"@signals": {"Ce_L", "Fe_K", "Ca_K", "Si_K"},
"Ca_K@shape": (3000,),
"Ce_L@shape": (3000,),
"Fe_K@shape": (3000,),
"Si_K@shape": (3000,),
},
"parameters": {
"@NX_class": "NXdata",
"@signals": {
"Ce_L",
"Scatter_Compton000",
"Si_K",
"Ca_K",
"Scatter_Peak000",
"Fe_K",
},
"Ca_K@shape": (3000,),
"Ce_L@shape": (3000,),
"Fe_K@shape": (3000,),
"Scatter_Compton000@shape": (3000,),
"Scatter_Peak000@shape": (3000,),
"Si_K@shape": (3000,),
},
"uncertainties": {
"@NX_class": "NXdata",
"@signals": {
"Ce_L",
"Scatter_Compton000",
"Si_K",
"Ca_K",
"Scatter_Peak000",
"Fe_K",
},
"Ca_K@shape": (3000,),
"Ce_L@shape": (3000,),
"Fe_K@shape": (3000,),
"Scatter_Compton000@shape": (3000,),
"Scatter_Peak000@shape": (3000,),
"Si_K@shape": (3000,),
},
},
"version@shape": (),
},
},
"merge": {
"@NX_class": "NXprocess",
"@extra_attrs": {"default"},
"configuration": {
"@NX_class": "NXnote",
"data@shape": (),
"date@shape": (),
"type@shape": (),
},
"program@shape": (),
"results": {
"@NX_class": "NXcollection",
"@extra_attrs": {"default"},
"massfractions": {
"@NX_class": "NXdata",
"@signals": {"Ce_L", "Fe_K", "Ca_K", "Si_K"},
"Ca_K@shape": (3000,),
"Ce_L@shape": (3000,),
"Fe_K@shape": (3000,),
"Si_K@shape": (3000,),
},
"parameters": {
"@NX_class": "NXdata",
"@signals": {
"Ce_L",
"Scatter_Compton000",
"Si_K",
"Ca_K",
"Scatter_Peak000",
"Fe_K",
},
"Ca_K@shape": (3000,),
"Ce_L@shape": (3000,),
"Fe_K@shape": (3000,),
"Scatter_Compton000@shape": (3000,),
"Scatter_Peak000@shape": (3000,),
"Si_K@shape": (3000,),
},
"rawcounters": {
"@NX_class": "NXdata",
"@signals": {
"mca0_events",
"mca0_live_time",
"mca0_elapsed_time",
"mca0_fractional_dead_time",
"mca0_trigger_live_time",
"mca0_roi2",
"I0",
"mca0_event_count_rate",
"mca0_roi1",
"mca0_triggers",
"sampz",
"sampy",
"mca0_trigger_count_rate",
},
"I0@shape": (3000,),
"mca0_elapsed_time@shape": (3000,),
"mca0_event_count_rate@shape": (3000,),
"mca0_events@shape": (3000,),
"mca0_fractional_dead_time@shape": (3000,),
"mca0_live_time@shape": (3000,),
"mca0_roi1@shape": (3000,),
"mca0_roi2@shape": (3000,),
"mca0_trigger_count_rate@shape": (3000,),
"mca0_trigger_live_time@shape": (3000,),
"mca0_triggers@shape": (3000,),
"sampy@shape": (3000,),
"sampy@units": "um",
"sampz@shape": (3000,),
"sampz@units": "um",
},
"uncertainties": {
"@NX_class": "NXdata",
"@signals": {
"Ce_L",
"Scatter_Compton000",
"Si_K",
"Ca_K",
"Scatter_Peak000",
"Fe_K",
},
"Ca_K@shape": (3000,),
"Ce_L@shape": (3000,),
"Fe_K@shape": (3000,),
"Scatter_Compton000@shape": (3000,),
"Scatter_Peak000@shape": (3000,),
"Si_K@shape": (3000,),
},
},
"version@shape": (),
},
"norm": {
"@NX_class": "NXprocess",
"@extra_attrs": {"default"},
"configuration": {
"@NX_class": "NXnote",
"data@shape": (),
"date@shape": (),
"type@shape": (),
},
"program@shape": (),
"results": {
"@NX_class": "NXcollection",
"@extra_attrs": {"default"},
"massfractions": {
"@NX_class": "NXdata",
"@signals": {"Ce_L", "Fe_K", "Ca_K", "Si_K"},
"Ca_K@shape": (3000,),
"Ce_L@shape": (3000,),
"Fe_K@shape": (3000,),
"Si_K@shape": (3000,),
},
"parameters": {
"@NX_class": "NXdata",
"@signals": {
"Ce_L",
"Scatter_Compton000",
"Si_K",
"Ca_K",
"Scatter_Peak000",
"Fe_K",
},
"Ca_K@shape": (3000,),
"Ce_L@shape": (3000,),
"Fe_K@shape": (3000,),
"Scatter_Compton000@shape": (3000,),
"Scatter_Peak000@shape": (3000,),
"Si_K@shape": (3000,),
},
"uncertainties": {
"@NX_class": "NXdata",
"@signals": {
"Ce_L",
"Scatter_Compton000",
"Si_K",
"Ca_K",
"Scatter_Peak000",
"Fe_K",
},
"Ca_K@shape": (3000,),
"Ce_L@shape": (3000,),
"Fe_K@shape": (3000,),
"Scatter_Compton000@shape": (3000,),
"Scatter_Peak000@shape": (3000,),
"Si_K@shape": (3000,),
},
},
"version@shape": (),
},
"regrid": {
"@NX_class": "NXprocess",
"@extra_attrs": {"default"},
"configuration": {
"@NX_class": "NXnote",
"data@shape": (),
"date@shape": (),
"type@shape": (),
},
"program@shape": (),
"results": {
"@NX_class": "NXcollection",
"@extra_attrs": {"default"},
"coordinates": {
"@NX_class": "NXcollection",
"closest_grid_distance": {
"@NX_class": "NXdata",
"@axes": ["sampy", "sampz"],
"@signals": {"distance"},
"distance@shape": (3000,),
"sampy@shape": (3000,),
"sampy@long_name": "sampy (um)",
"sampy@units": "um",
"sampz@shape": (3000,),
"sampz@long_name": "sampz (um)",
"sampz@units": "um",
"title@shape": (),
},
"closest_scatter_distance": {
"@NX_class": "NXdata",
"@axes": ["sampy", "sampz"],
"@signals": {"distance"},
"distance@shape": (3630,),
"sampy@shape": (3630,),
"sampy@long_name": "sampy (um)",
"sampy@units": "um",
"sampz@shape": (3630,),
"sampz@long_name": "sampz (um)",
"sampz@units": "um",
"title@shape": (),
},
"coordinates": {
"@NX_class": "NXdata",
"@axes": ["sampy", "sampz"],
"@signals": {"coordinate_type"},
"coordinate_type@shape": (6630,),
"sampy@shape": (6630,),
"sampy@long_name": "sampy (um)",
"sampy@units": "um",
"sampz@shape": (6630,),
"sampz@long_name": "sampz (um)",
"sampz@units": "um",
"title@shape": (),
},
"grid_coordinates": {
"@NX_class": "NXdata",
"@axes": ["sampy", "sampz"],
"@signals": {"has_data"},
"has_data@shape": (3630,),
"sampy@shape": (3630,),
"sampy@long_name": "sampy (um)",
"sampy@units": "um",
"sampz@shape": (3630,),
"sampz@long_name": "sampz (um)",
"sampz@units": "um",
"title@shape": (),
},
"scatter_coordinates": {
"@NX_class": "NXdata",
"@axes": ["sampy", "sampz"],
"@signals": {"indices"},
"indices@shape": (3000,),
"sampy@shape": (3000,),
"sampy@long_name": "sampy (um)",
"sampy@units": "um",
"sampz@shape": (3000,),
"sampz@long_name": "sampz (um)",
"sampz@units": "um",
"title@shape": (),
},
},
"massfractions": {
"@NX_class": "NXdata",
"@axes": ["sampz", "sampy"],
"@signals": {"Ce_L", "Fe_K", "Ca_K", "Si_K"},
"Ca_K@shape": (55, 66),
"Ce_L@shape": (55, 66),
"Fe_K@shape": (55, 66),
"Si_K@shape": (55, 66),
"sampy@shape": (66,),
"sampy@long_name": "sampy (um)",
"sampy@units": "um",
"sampy_indices@shape": (),
"sampz@shape": (55,),
"sampz@long_name": "sampz (um)",
"sampz@units": "um",
"sampz_indices@shape": (),
},
"parameters": {
"@NX_class": "NXdata",
"@axes": ["sampz", "sampy"],
"@signals": {
"Ce_L",
"Scatter_Compton000",
"Si_K",
"Ca_K",
"Scatter_Peak000",
"Fe_K",
},
"Ca_K@shape": (55, 66),
"Ce_L@shape": (55, 66),
"Fe_K@shape": (55, 66),
"Scatter_Compton000@shape": (55, 66),
"Scatter_Peak000@shape": (55, 66),
"Si_K@shape": (55, 66),
"sampy@shape": (66,),
"sampy@long_name": "sampy (um)",
"sampy@units": "um",
"sampy_indices@shape": (),
"sampz@shape": (55,),
"sampz@long_name": "sampz (um)",
"sampz@units": "um",
"sampz_indices@shape": (),
},
"rawcounters": {
"@NX_class": "NXdata",
"@axes": ["sampz", "sampy"],
"@signals": {
"mca0_events",
"mca0_live_time",
"mca0_elapsed_time",
"mca0_fractional_dead_time",
"mca0_trigger_live_time",
"mca0_roi2",
"I0",
"mca0_event_count_rate",
"mca0_roi1",
"mca0_triggers",
"mca0_trigger_count_rate",
},
"I0@shape": (55, 66),
"mca0_elapsed_time@shape": (55, 66),
"mca0_event_count_rate@shape": (55, 66),
"mca0_events@shape": (55, 66),
"mca0_fractional_dead_time@shape": (55, 66),
"mca0_live_time@shape": (55, 66),
"mca0_roi1@shape": (55, 66),
"mca0_roi2@shape": (55, 66),
"mca0_trigger_count_rate@shape": (55, 66),
"mca0_trigger_live_time@shape": (55, 66),
"mca0_triggers@shape": (55, 66),
"sampy@shape": (66,),
"sampy@long_name": "sampy (um)",
"sampy@units": "um",
"sampy_indices@shape": (),
"sampz@shape": (55,),
"sampz@long_name": "sampz (um)",
"sampz@units": "um",
"sampz_indices@shape": (),
},
"title@shape": (),
"uncertainties": {
"@NX_class": "NXdata",
"@axes": ["sampz", "sampy"],
"@signals": {
"Ce_L",
"Scatter_Compton000",
"Si_K",
"Ca_K",
"Scatter_Peak000",
"Fe_K",
},
"Ca_K@shape": (55, 66),
"Ce_L@shape": (55, 66),
"Fe_K@shape": (55, 66),
"Scatter_Compton000@shape": (55, 66),
"Scatter_Peak000@shape": (55, 66),
"Si_K@shape": (55, 66),
"sampy@shape": (66,),
"sampy@long_name": "sampy (um)",
"sampy@units": "um",
"sampy_indices@shape": (),
"sampz@shape": (55,),
"sampz@long_name": "sampz (um)",
"sampz@units": "um",
"sampz_indices@shape": (),
},
},
"version@shape": (),
},
"start_time@shape": (),
},
}
return output_path, expected