Execute a darfix workflow without GUI#
[1]:
import os
from orangecontrib.darfix import tutorials
from CLI using ewoks#
You can execute darfix workflows as any ewoks workflow using the ewoks execute command. Parameter values can be provided with the --parameter options (or the -p alias). For example, we want to execute a workflow named my_darfix_workflow.ows by setting two parameters: the detector HDF5 dataset and the HDF5 positioner dataset (aka metadata). For this, we can use the following command:
ewoks execute src/orangecontrib/darfix/tutorials/darfix_example1.ows --parameter raw_input_file=/data/scisoft/darfix/datasets/bliss_hdf5/Silicon_111_reflection_0003/Silicon_111_reflection_0003.h5 --parameter raw_detector_data_path=/1.1/instrument/pco_ff/data --parameter raw_metadata_path=/1.1/instrument/positioners
Warning: the HDF5 dataset must be provided as silx URL
From Python#
step 1: Define task arguments which are not defined in the workflow#
in this example we will focus about HDF5 dataset.
[2]:
root_dir = "/tmp/darfix"
os.makedirs(root_dir, exist_ok=True)
hdf5_file = os.path.join(tutorials.__path__[0], "hdf5_dataset", "strain.hdf5")
assert os.path.exists(hdf5_file)
step2: Execute the workflow#
For more information on executing ewoks workflows: https://workflow.gitlab-pages.esrf.fr/ewoks/ewoks/
[3]:
from ewoks import execute_graph
graph = os.path.join(tutorials.__path__[0], "darfix_example_hdf.ows")
results = execute_graph(
graph,
inputs=[
{
"name": "raw_input_file",
"value": hdf5_file,
},
{
"name": "raw_detector_data_path",
"value": "/1.1/instrument/my_detector/data",
},
{"name": "raw_metadata_path", "value": "/1.1/instrument/positioners"},
],
output_tasks=True,
)
WARNING:/home/docs/checkouts/readthedocs.org/user_builds/darfix/envs/stable/lib/python3.12/site-packages/darfix/tasks/roi.py:Cannot apply a ROI if origin ([]) or size ([]) is empty. Dataset is unchanged.
Noise removal operation: 100%|██████████| 2/2 [00:00<00:00, 26800.66it/s]
Compute Skewness and Kurtosis...: 100%|██████████| 3/3 [00:04<00:00, 1.48s/it]
Inspect the results#
[4]:
for node_id, task in results.items():
assert task.succeeded, f"task {node_id} failed"
print(task.get_output_values())
{'dataset': <darfix.dtypes.Dataset object at 0x7443c7cfa510>}
{}
{'dataset': <darfix.dtypes.Dataset object at 0x7443c76473e0>}
{'dataset': <darfix.dtypes.Dataset object at 0x7443c7647bc0>}
{'dataset': <darfix.dtypes.Dataset object at 0x7443c7647bc0>}
{'dataset': <darfix.dtypes.Dataset object at 0x7443c7647bc0>}
{'zsum': array([[[178, 214, 218, ..., 217, 208, 221],
[215, 219, 212, ..., 227, 225, 222],
[377, 223, 221, ..., 217, 217, 211],
...,
[167, 188, 197, ..., 191, 199, 190],
[185, 184, 181, ..., 178, 183, 191],
[176, 198, 203, ..., 181, 195, 187]]],
shape=(1, 512, 512), dtype=uint64)}
{'dataset': <darfix.dtypes.Dataset object at 0x7443c7647bc0>}
[ ]: