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/latest/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, 17734.90it/s]
Compute Skewness and Kurtosis...: 100%|██████████| 3/3 [00:05<00:00, 1.80s/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.core.dataset.Dataset object at 0x7c7423e98ec0>}
{}
{'dataset': <darfix.core.dataset.Dataset object at 0x7c7423e98ec0>}
{'dataset': <darfix.core.dataset.Dataset object at 0x7c7423e98ec0>}
{'dataset': <darfix.core.dataset.Dataset object at 0x7c7423e98ec0>}
{'dataset': <darfix.core.dataset.Dataset object at 0x7c7423e98ec0>}
{'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)}
{'grain_properties': GrainProperties(dims=[<darfix.core.dimension.Dimension object at 0x7c7423ebbdd0>], moments_dims={'obpitch': {<MomentType.COM: 'Center of mass'>: array([[25.10235023, 25.10235023, 25.10235023, ..., 25.10235046,
25.10235046, 25.10235071],
[25.10235023, 25.10235023, 25.10235023, ..., 25.10235046,
25.10235046, 25.10235071],
[25.10235277, 25.10235137, 25.10235001, ..., 25.10235001,
25.10235045, 25.10235023],
...,
[25.10234697, 25.10234646, 25.10234545, ..., 25.10234634,
25.10234686, 25.10234617],
[25.10234601, 25.1023451 , 25.10234377, ..., 25.10234634,
25.10234626, 25.10234626],
[25.1023446 , 25.1023446 , 25.10234377, ..., 25.10234617,
25.10234626, 25.10234626]], shape=(512, 512)), <MomentType.FWHM: 'FWHM'>: array([[0.00011678, 0.00011678, 0.00011678, ..., 0.00011678, 0.00011677,
0.00011675],
[0.00011663, 0.00011676, 0.00011676, ..., 0.00011678, 0.00011675,
0.00011675],
[0.00011656, 0.00011663, 0.00011675, ..., 0.00011677, 0.00011675,
0.00011675],
...,
[0.00011652, 0.00011644, 0.00011623, ..., 0.00011642, 0.00011651,
0.00011639],
[0.00011635, 0.00011615, 0.00011578, ..., 0.00011642, 0.0001164 ,
0.0001164 ],
[0.00011602, 0.00011602, 0.00011578, ..., 0.00011639, 0.0001164 ,
0.0001164 ]], shape=(512, 512)), <MomentType.SKEWNESS: 'Skewness'>: array([[ 0. , 0. , 0. , ..., -0.00921669,
-0.00921669, -0.01923166],
[ 0. , 0. , 0. , ..., -0.00921669,
-0.00921669, -0.01923166],
[-0.10245977, -0.04567401, 0.00904987, ..., 0.00921669,
-0.00881066, 0. ],
...,
[ 0.13202324, 0.15272764, 0.19379685, ..., 0.15755468,
0.13644206, 0.16448792],
[ 0.17083257, 0.20801257, 0.26311741, ..., 0.15755468,
0.16094643, 0.16094643],
[ 0.22875451, 0.22875451, 0.26311741, ..., 0.16448792,
0.16094643, 0.16094643]], shape=(512, 512)), <MomentType.KURTOSIS: 'Kurtosis'>: array([[-2. , -2. , -2. , ..., -1.99991505,
-1.99963014, -1.99795149],
[-1.989502 , -1.9985755 , -1.99865286, ..., -1.99990842,
-1.99802372, -1.99787523],
[-1.98525346, -1.989502 , -1.99791389, ..., -1.9996155 ,
-1.99802372, -1.99787523],
...,
[-1.98256986, -1.97667427, -1.96244278, ..., -1.97517652,
-1.98138356, -1.97294372],
[-1.97081623, -1.95673077, -1.93076923, ..., -1.97517652,
-1.97409625, -1.97409625],
[-1.94767138, -1.94767138, -1.93076923, ..., -1.97294372,
-1.97409625, -1.97409625]], shape=(512, 512))}}, transformation=None, constants={'auxx': np.int64(500), 'auxy': np.int64(600), 'auxz': np.int64(1300), 'bstop': np.float32(-1.83986e-05), 'cdpitch': np.float32(-404.727), 'cdx': np.int64(118), 'cdy': np.float32(-18.72), 'cdyaw': np.int64(0), 'cdz': np.float32(-5.7646), 'chi': np.float32(2.79004), 'corx': np.float32(1.9877), 'corz': np.float32(0.4099121), 'dcx': np.int64(561), 'dcy': np.int64(0), 'dcz': np.int64(-310), 'delIsp': np.int64(0), 'delVsp': np.float32(6.00113), 'detx': np.float32(91.867), 'dety': np.int64(1900), 'detz': np.float32(9.15), 'diffry': np.float32(-23.176), 'diffrz': np.float32(-1.38401e-06), 'diffty': np.float32(-6.6015625), 'difftz': np.int64(0), 'euro_sp': np.int64(410), 'fffoc': np.float32(-440.5), 'ffpitch': np.int64(0), 'ffrotc': np.float32(-0.151027), 'ffy': np.int64(0), 'ffz': np.float32(2257.86), 'furny': np.float32(45.0609), 'furnz': np.float32(-53.6341), 'hfoc': np.float32(-380.427), 'hrotc': np.float32(10.4341), 'htth': np.float32(14.73), 'hxpitch': np.float32(0.01499939), 'hxroll': np.float32(-0.0015001297), 'hxx': np.float32(-0.012496948), 'hxy': np.float32(0.3798828), 'hxyaw': np.float32(-0.21899414), 'hxz': np.float32(3.763), 'icx': np.int64(50), 'lenssel': np.float32(4.6210938), 'mainx': np.int64(-4850), 'mono': np.float32(5.67781), 'nffoc': np.float32(-12.28), 'nfrotc': np.float32(-0.0485141), 'nfrz': np.int64(0), 'nfx': np.int64(110), 'nfy': np.int64(99), 'nfz': np.float32(51.15), 'obx': np.float32(332.232), 'oby': np.float32(0.6972), 'obyaw': np.float32(-0.00459375), 'obz': np.float32(155.258), 'phi': np.float32(2.8300781), 's3hg': np.int64(4), 's3ho': np.float32(-2.3005), 's3vg': np.int64(4), 's3vo': np.float32(0.45996094), 's4hg': np.int64(1), 's4ho': np.float32(0.157396), 's4vg': np.int64(1), 's4vo': np.float32(1.09653), 's5hg': np.int64(2), 's5ho': np.float32(-0.0606673), 's5vg': np.int64(2), 's5vo': np.float32(2.67886), 's6hg': np.int64(3), 's6ho': np.float32(0.00199669), 's6vg': np.int64(7), 's6vo': np.float32(2.42334), 's7hg': np.int64(3), 's7ho': np.float32(3.4803e-10), 's7vg': np.int64(7), 's7vo': np.float32(-2.42334), 'smfoc': np.float32(-3.49836), 'smx': np.float32(-0.35009766), 'smy': np.float32(-3.5292969), 'smz': np.float32(1.21064), 'trash': np.int64(2), 'x2z': np.float32(7.26697)}, title='', 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=(512, 512), dtype=uint64), xysum=array([26573995, 45618620], dtype=uint64), dir='/home/docs/checkouts/readthedocs.org/user_builds/darfix/checkouts/latest/doc/archives', _source_dataset=<darfix.core.dataset.Dataset object at 0x7c7423e98ec0>)}
[ ]: