Custom SAXS/WAXS tasks#
How to use
These tasks come from ewoksbm29 ewoksid02 ewoksid11 ewoksid22 ewoksid31 ewoksoptics. It can be installed with
pip install ewoksbm29 ewoksid02 ewoksid11 ewoksid22 ewoksid31 ewoksoptics
ℹ️ These tasks are used at the following ESRF beamlines: BM05, BM29, ID02, ID06, ID11, ID22, ID31
DahuHplcSummary#
Rebuild the complete chromatogram with basic analysis.
In addition to the inputs from DahuJobWithIspybUpload:
Required inputs:
integrated_files (List[str]): Azimuthally integrated SAXS data.
Optional inputs:
hplc_summary_parameters (dict): Extra subtract parameters (see
HplcSummaryParameters).
- Identifier:
ewoksbm29.tasks.hplc_summary.DahuHplcSummary- Task type:
- class
- Inputs:
- integrated_files*
- config_directory
- dahu_job_index
- dahu_parameter_file
- dahu_url
- extra_dahu_parameters
- hplc_summary_parameters
- ispyb_metadata
- ispyb_url
- nobackup
- timeout
- Outputs:
- dahu_job_id
- dahu_job_index
- dahu_result
DahuIntegrate#
Azimuthal integration of BM29 SAXS data.
In addition to the inputs from DahuJobWithIspybUpload:
Required inputs:
scan_data_slice (dict): Subset of parameters related to the scan data (see
IntegrateParameters).
Optional inputs:
integrate_parameters (dict): Extra integrate parameters (see
IntegrateParameters).
- Identifier:
ewoksbm29.tasks.integrate.DahuIntegrate- Task type:
- class
- Inputs:
- scan_data_slice*
- config_directory
- dahu_job_index
- dahu_parameter_file
- dahu_url
- extra_dahu_parameters
- integrate_parameters
- ispyb_metadata
- ispyb_url
- nobackup
- timeout
- Outputs:
- dahu_job_id
- dahu_job_index
- dahu_result
ReadScanDataSlice#
Return a subset of IntegrateParameters for a SAXS scan index range covered
by the lima file with index lima_file_index.
Optional inputs (online & offline):
lima_file_index (int): Lima file index that determines the scan slice.
dahu_to_counter_name (dict): Map counter names to
IntegrateParameterskeys.storage_ring_current (float): Storage ring current in mA.
exposure_time (float): Scan point exposure time in s.
Optional inputs (online):
scan_key (str): Blissdata scan key (tries offline when fails).
retry_timeout (float): Timeout when trying to access the Lima image dataset or wait for the scan to be PREPARED.
retry_period (float): Period in retry loops.
Optional inputs (offline):
scan_file_path (str): Bliss scan file name.
scan_number (str): Bliss scan number.
Outputs:
scan_data_slice (dict): Subset of
IntegrateParametersrelated to the scan data.has_data (bool):
scan_data_slicecontains a non-empty scan data slice.lima_file_index (int): The lime file index to which
scan_data_slicebelongs.next_lima_file_index (int): The next Lima file index.
- Identifier:
ewoksbm29.tasks.read.ReadScanDataSlice- Task type:
- class
- Inputs:
- dahu_to_counter_name
- exposure_time
- lima_file_index
- retry_period
- retry_timeout
- scan_file_path
- scan_key
- scan_number
- storage_ring_current
- Outputs:
- has_data
- lima_file_index
- next_lima_file_index
- scan_data_slice
AccumulateDahuJobResults#
Accumulate Dahu job results with the job index as a key.
.. code: python
dahu_results[dahu_job_index] = {"dahu_job_id": dahu_job_id, "dahu_result": dahu_result}
Required inputs:
dahu_job_index (int): Dahu job index for ordering results.
dahu_job_id (Optional[int]): Dahu job id (
Nonemeans no Dahu job was executed).dahu_result (Optional[dict]): Dahu result (
Nonemeans no Dahu job was executed).
Outputs:
dahu_results (Dict[int, dict]): Add the Dahu result to results from previous executions within the same workflow.
- Identifier:
ewoksbm29.tasks.results.AccumulateDahuJobResults- Task type:
- class
- Inputs:
- dahu_job_id*
- dahu_job_index*
- dahu_result*
- Outputs:
- dahu_results
DahuSubtract#
Subtract average integrated buffer signal from the sample signal.
In addition to the inputs from DahuJobWithIspybUpload:
Required inputs:
sample_file (str): Azimuthally integrated SAXS data.
buffer_files (List[str]): Azimuthally integrated SAXS data of the buffer.
Optional inputs:
subtract_parameters (dict): Extra subtract parameters (see
SubtractParameters).
- Identifier:
ewoksbm29.tasks.subtract.DahuSubtract- Task type:
- class
- Inputs:
- buffer_files*
- sample_file*
- config_directory
- dahu_job_index
- dahu_parameter_file
- dahu_url
- extra_dahu_parameters
- ispyb_metadata
- ispyb_url
- nobackup
- subtract_parameters
- timeout
- Outputs:
- dahu_job_id
- dahu_job_index
- dahu_result
AverageGenericTask#
The AverageTask class is responsible for calculating the average of datasets in the ID02 SAXS pipeline.
It extends the ID02ProcessingTask class and provides additional functionality for handling averaging-specific
inputs and processing logic. If azimuth_range is not provided, a full average will be performed.
Optional Inputs:
- dataset_sum_signal (numpy.ndarray): Sum of signal, non-normalized from an ai.integrate2d result.
- dataset_sum_normalization (numpy.ndarray): Sum of normalized pixels, from an ai.integrate2d result. If NormalizationTask was performed, norm == count
- dataset_sum_variance (numpy.ndarray): Sum of variance, from an ai.integrate2d result. Variance of sum_signal.
- unit1 (str): Unit for the axis 1 (normally it’s chi_deg, azimuthal axis).
- unit1_array (numpy.ndarray): Axis 1 array (e.g., chi_deg array).
- unit1_range (list of tuples): Ranges for averaging axis 1 of dataset (e.g., [(0, 90), (270, 360)] for azimuthal average).
- unit2 (str): Unit for the axis 2 (normally it’s q_nm^-1, radial axis).
- unit2_array (numpy.ndarray): Axis 2 array (e.g., q_nm^-1 array).
- unit2_range (list of tuples): Ranges for averaging axis 2 of dataset (e.g., [(1,3), (4,5)] for radial average).
- axis_average (int): The axis along which to perform the average. Possible values: 1, 2.
- Dummy (float): Value to replace invalid pixels in the dataset.
- pca_parameters (dict): Parameters for Principal Component Analysis (PCA) if applicable.
Outputs Parameters:
- dataset_average_signal_norm (numpy.ndarray): Normalized average signal dataset.
- Identifier:
ewoksid02.tasks.averagetask.AverageGenericTask- Task type:
- class
- Inputs:
- Dummy
- axis_average
- continue_pipeline
- dataset_sigma
- dataset_signal
- dataset_sum_normalization
- dataset_sum_signal
- dataset_sum_variance
- dataset_variance
- datatype
- detector_name
- do_process
- do_save
- filename_data
- filename_db
- filename_lima
- gc_collect
- headers
- index_node
- index_range
- index_range_last
- info_history
- lima_url_template
- lima_url_template_args
- log_level
- loop_nb
- nb_frames_total
- nb_nodes
- pca_parameters
- processing_filename
- processing_subtitle
- processing_type
- reading_mode
- save_azim_averaged
- save_metadata
- save_sigma
- save_variance
- scan_memory_url
- scan_nb
- scan_number_format
- streams_subscan1
- streams_subscan2
- subtitle
- unit1
- unit1_array
- unit1_range
- unit2
- unit2_array
- unit2_range
- Outputs:
- continue_pipeline
- dataset_sigma
- dataset_signal
- dataset_variance
- detector_name
- filename_data
- filename_lima
- headers
- index_range_last
- info_history
- lima_url_template
- lima_url_template_args
- loop_nb
- nb_frames_total
- scan_memory_url
- scan_nb
- scan_number_format
- streams_subscan1
- streams_subscan2
AverageTask#
- Identifier:
ewoksid02.tasks.averagetask.AverageTask- Task type:
- class
- Inputs:
- Dummy
- axis_average
- azimuth_array
- azimuthal_range
- azimuthal_unit
- continue_pipeline
- dataset_sigma
- dataset_signal
- dataset_sum_normalization
- dataset_sum_signal
- dataset_sum_variance
- dataset_variance
- datatype
- detector_name
- do_process
- do_save
- filename_data
- filename_db
- filename_lima
- gc_collect
- headers
- index_node
- index_range
- index_range_last
- info_history
- lima_url_template
- lima_url_template_args
- log_level
- loop_nb
- nb_frames_total
- nb_nodes
- pca_parameters
- processing_filename
- processing_subtitle
- processing_type
- radial_array
- radial_range
- radial_unit
- reading_mode
- save_azim_averaged
- save_metadata
- save_sigma
- save_variance
- scan_memory_url
- scan_nb
- scan_number_format
- streams_subscan1
- streams_subscan2
- subtitle
- unit1
- unit1_array
- unit1_range
- unit2
- unit2_array
- unit2_range
- Outputs:
- continue_pipeline
- dataset_sigma
- dataset_signal
- dataset_variance
- detector_name
- filename_data
- filename_lima
- headers
- index_range_last
- info_history
- lima_url_template
- lima_url_template_args
- loop_nb
- nb_frames_total
- scan_memory_url
- scan_nb
- scan_number_format
- streams_subscan1
- streams_subscan2
AzimuthalTask#
The AzimuthalTask class is responsible for performing azimuthal integration on datasets in the ID02 SAXS pipeline.
It extends the ID02ProcessingTask class and provides additional functionality for handling azimuthal integration-specific
inputs and processing logic using the pyFAI library.
Optional Inputs:
- filename_mask_azimuthal (str): Path to the mask file for masking invalid pixels.
- filename_dark_azimuthal (str): Path to the file with a dark-current correction.
- npt2_rad (int): Number of radial bins for the integration.
- npt2_azim (int): Number of azimuthal bins for the integration.
- unit (str): Unit for the radial axis (e.g., “q_nm^-1”).
- Dummy (float): Value to replace invalid pixels in the dataset.
- DDummy (float): Tolerance for dummy pixel replacement.
- Center_1 (float): Beam center in the first dimension.
- Center_2 (float): Beam center in the second dimension.
- PSize_1 (float): Pixel size 1.
- PSize_2 (float): Pixel size 2.
- BSize_1 (float): Pixel binning 1.
- BSize_2 (float): Pixel binning 2.
- SampleDistance (float): Sample to detector distance in meters.
- WaveLength (float): Wavelength of beam in meters.
- DetectorRotation_1 (float): rot2 of pyFAI.
- DetectorRotation_2 (float): rot1 of pyFAI.
- DetectorRotation_3 (float): rot3 of pyFAI.
- method (str): Integration method to be used by pyFAI (e.g., “bbox”, “csr”).
- method_opencl_target_type (str): OpenCL target type (“gpu”, “cpu”, …). Default is “gpu”.
- method_opencl_target (str): OpenCL target, “auto” to pick a GPU at random. Default is “auto”.
- integration_options (dict): Additional options for pyFAI integration.
- do_variance_formula (bool): Flag to enable variance calculation using a formula. Default is False.
- variance_formula (str): Formula for calculating variance in the dataset.
- save_sum (bool): To save or not the arrays sum_signal, sum_normalization and sum_variance.
Outputs:
- dataset_sum_signal (numpy.ndarray): Summed signal dataset after azimuthal integration.
- dataset_sum_normalization (numpy.ndarray): Summed normalization dataset after azimuthal integration.
- dataset_sum_variance (numpy.ndarray): Summed variance dataset after azimuthal integration.
- radial_array (numpy.ndarray): Radial axis array for the integrated data.
- azimuth_array (numpy.ndarray): Azimuthal axis array for the integrated data.
- Identifier:
ewoksid02.tasks.azimuthaltask.AzimuthalTask- Task type:
- class
- Inputs:
- BSize_1
- BSize_2
- Center_1
- Center_2
- DDummy
- DetectorRotation_1
- DetectorRotation_2
- DetectorRotation_3
- Dummy
- PSize_1
- PSize_2
- SampleDistance
- WaveLength
- continue_pipeline
- dataset_sigma
- dataset_signal
- dataset_variance
- datatype
- detector_name
- do_process
- do_save
- filename_dark_azimuthal
- filename_data
- filename_db
- filename_lima
- filename_mask_azimuthal
- gc_collect
- headers
- index_node
- index_range
- index_range_last
- info_history
- integration_options
- lima_url_template
- lima_url_template_args
- log_level
- loop_nb
- method_algorithm
- method_implementation
- method_opencl_target
- method_opencl_target_type
- method_pixelsplit
- nb_frames_total
- nb_nodes
- npt2_azim
- npt2_rad
- processing_filename
- processing_subtitle
- processing_type
- reading_mode
- save_metadata
- save_sigma
- save_sum
- save_variance
- scan_memory_url
- scan_nb
- scan_number_format
- streams_subscan1
- streams_subscan2
- subtitle
- unit
- Outputs:
- azimuth_array
- continue_pipeline
- dataset_sigma
- dataset_signal
- dataset_sum_normalization
- dataset_sum_signal
- dataset_sum_variance
- dataset_variance
- detector_name
- filename_data
- filename_lima
- headers
- index_range_last
- info_history
- lima_url_template
- lima_url_template_args
- loop_nb
- nb_frames_total
- radial_array
- scan_memory_url
- scan_nb
- scan_number_format
- streams_subscan1
- streams_subscan2
CavingTask#
The CavingTask class is responsible for applying a “caving” operation to datasets in the ID02 SAXS pipeline.
The caving is applied to those pixels whose intensity matches with a dummy value + those pixels provided by a mask file.
Optional Inputs: - Dummy (float): Value to replace invalid pixels in the dataset. - Center_1 (float): Beam center in the first dimension. - Center_2 (float): Beam center in the second dimension. - filename_mask_static (str): Path to the mask file used for the caving operation. - filename_mask_reference (str): Path to the reference mask file (kind of a negative mask). - flip_caving (bool): Cave the image with its flipped projection, both horizontal and vertical. WARNING: it is physically not correct! - algorithm (str): Implementation to perform the caving (numpy or cupy).
- Identifier:
ewoksid02.tasks.cavingtask.CavingTask- Task type:
- class
- Inputs:
- Center_1
- Center_2
- Dummy
- algorithm
- continue_pipeline
- dataset_sigma
- dataset_signal
- dataset_variance
- datatype
- detector_name
- do_process
- do_save
- filename_data
- filename_db
- filename_lima
- filename_mask_reference
- filename_mask_static
- flip_caving
- gc_collect
- headers
- index_node
- index_range
- index_range_last
- info_history
- lima_url_template
- lima_url_template_args
- log_level
- loop_nb
- nb_frames_total
- nb_nodes
- processing_filename
- processing_subtitle
- processing_type
- reading_mode
- save_metadata
- save_sigma
- save_variance
- scan_memory_url
- scan_nb
- scan_number_format
- streams_subscan1
- streams_subscan2
- subtitle
- Outputs:
- continue_pipeline
- dataset_sigma
- dataset_signal
- dataset_variance
- detector_name
- filename_data
- filename_lima
- headers
- index_range_last
- info_history
- lima_url_template
- lima_url_template_args
- loop_nb
- nb_frames_total
- scan_memory_url
- scan_nb
- scan_number_format
- streams_subscan1
- streams_subscan2
CavingGapsTask#
The CavingGapsTask inherits ‘CavingTask’.
Here, it will take the parameters from the headers to perform the caving operation
and cover the gaps in the dataset and avoid the beamstop. Hence, no explicit mask filenames are needed.
- Identifier:
ewoksid02.tasks.cavingtask.CavingGapsTask- Task type:
- class
- Inputs:
- Center_1
- Center_2
- Dummy
- algorithm
- continue_pipeline
- dataset_sigma
- dataset_signal
- dataset_variance
- datatype
- detector_name
- do_process
- do_save
- filename_data
- filename_db
- filename_lima
- filename_mask_reference
- filename_mask_static
- flip_caving
- gc_collect
- headers
- index_node
- index_range
- index_range_last
- info_history
- lima_url_template
- lima_url_template_args
- log_level
- loop_nb
- nb_frames_total
- nb_nodes
- processing_filename
- processing_subtitle
- processing_type
- reading_mode
- save_metadata
- save_sigma
- save_variance
- scan_memory_url
- scan_nb
- scan_number_format
- streams_subscan1
- streams_subscan2
- subtitle
- Outputs:
- continue_pipeline
- dataset_sigma
- dataset_signal
- dataset_variance
- detector_name
- filename_data
- filename_lima
- headers
- index_range_last
- info_history
- lima_url_template
- lima_url_template_args
- loop_nb
- nb_frames_total
- scan_memory_url
- scan_nb
- scan_number_format
- streams_subscan1
- streams_subscan2
CavingBeamstopTask#
The CavingBeamstopTask inherits ‘CavingTask’.
Here, it will take the parameters from the headers to perform the caving operation
and cover the beamstop. Hence, no explicit mask filename is needed.
- Identifier:
ewoksid02.tasks.cavingtask.CavingBeamstopTask- Task type:
- class
- Inputs:
- Center_1
- Center_2
- Dummy
- algorithm
- continue_pipeline
- dataset_sigma
- dataset_signal
- dataset_variance
- datatype
- detector_name
- do_process
- do_save
- filename_data
- filename_db
- filename_lima
- filename_mask_reference
- filename_mask_static
- flip_caving
- gc_collect
- headers
- index_node
- index_range
- index_range_last
- info_history
- lima_url_template
- lima_url_template_args
- log_level
- loop_nb
- nb_frames_total
- nb_nodes
- processing_filename
- processing_subtitle
- processing_type
- reading_mode
- save_metadata
- save_sigma
- save_variance
- scan_memory_url
- scan_nb
- scan_number_format
- streams_subscan1
- streams_subscan2
- subtitle
- Outputs:
- continue_pipeline
- dataset_sigma
- dataset_signal
- dataset_variance
- detector_name
- filename_data
- filename_lima
- headers
- index_range_last
- info_history
- lima_url_template
- lima_url_template_args
- loop_nb
- nb_frames_total
- scan_memory_url
- scan_nb
- scan_number_format
- streams_subscan1
- streams_subscan2
SingleDetector#
Trigger DAHU in the workflow.
- Identifier:
ewoksid02.tasks.dahuprocessingtask.SingleDetector- Task type:
- class
- Inputs:
- parameters*
- Outputs:
- files
- logging
- runtime
SaveGalleryTask#
- Identifier:
ewoksid02.tasks.gallerytask.SaveGalleryTask- Task type:
- class
- Inputs:
- nxdata_url*
- do_save
- Outputs:
- filename_png
ID02ProcessingTask#
Processes one slice of frames and appends it to a PROCESSED_DATA file.
A child implements :meth:process – which reads self.dataset_signal,
self.dataset_variance and self.dataset_sigma and publishes the result
on self.outputs – and :meth:get_processing_parameters, the parameters
that processing was run with. Everything else (the benchmarks, the file
creation, the metadata, the ewoks history) is done here. The child must
also be registered in PROCESSING_TYPE_TASK, otherwise the task refuses
to run: the key is what names the process in the output file.
The datasets come from the loop and are never read from the source here:
when there is no signal to process, the node stops the pipeline
(continue_pipeline goes to False) rather than trying to read more.
The context inputs it reads through its parent – detector_name,
scan_nb, filename_data, filename_lima, headers, the counter
streams, the loop position – are documented on
- class:
~ewoksid02.tasks.id02task.ID02Task.
Optional Inputs:
- dataset_signal (numpy.ndarray): Slice of frames to process.
- dataset_variance (numpy.ndarray): Variance of that slice, when the source has one.
- dataset_sigma (numpy.ndarray): Sigma of that slice, when the source has one.
- datatype (str): Dtype the 2D data is written with. Default and recommended is “float32”.
- processing_filename (str): Full path to the (new) output file. Required to save.
- processing_subtitle (str): Additional subtitle for the processing task.
- subtitle (str): Subtitle for the processing task to be added to the output filename.
- do_process (bool): Whether to process the slice at all. Default is True.
- do_save (bool): Whether to write the result. Default is True.
- save_variance (bool): Whether to write the variance dataset. Default is False.
- save_sigma (bool): Whether to write the sigma dataset. Default is True.
- save_metadata (bool): Whether to write the counters and the metadata of the slice. Default is True.
- filename_db (str): Path to a SQLite file where processing/saving benchmarks are recorded. Recorded independently of do_save; if not set, benchmarks are not persisted to a database.
- continue_pipeline (bool): Loop-control flag coming from the reading node, propagated untouched.
Outputs:
- dataset_signal (numpy.ndarray): Processed signal dataset.
- dataset_variance (numpy.ndarray): Processed variance dataset.
- dataset_sigma (numpy.ndarray): Processed sigma dataset.
- continue_pipeline (bool): False when there was nothing to process.
- info_history (dict): The ewoks history, with this node appended to it on the first loop.
- Identifier:
ewoksid02.tasks.id02processingtask.ID02ProcessingTask- Task type:
- class
- Inputs:
- continue_pipeline
- dataset_sigma
- dataset_signal
- dataset_variance
- datatype
- detector_name
- do_process
- do_save
- filename_data
- filename_db
- filename_lima
- gc_collect
- headers
- index_node
- index_range
- index_range_last
- info_history
- lima_url_template
- lima_url_template_args
- log_level
- loop_nb
- nb_frames_total
- nb_nodes
- processing_filename
- processing_subtitle
- processing_type
- reading_mode
- save_metadata
- save_sigma
- save_variance
- scan_memory_url
- scan_nb
- scan_number_format
- streams_subscan1
- streams_subscan2
- subtitle
- Outputs:
- continue_pipeline
- dataset_sigma
- dataset_signal
- dataset_variance
- detector_name
- filename_data
- filename_lima
- headers
- index_range_last
- info_history
- lima_url_template
- lima_url_template_args
- loop_nb
- nb_frames_total
- scan_memory_url
- scan_nb
- scan_number_format
- streams_subscan1
- streams_subscan2
ID02ReaderTask#
Entry/exit valve of the ID02 loop: reads the next slice of frames.
Every execution is a new cycle: loop_nb is incremented, the next slice
is read and handed to the processing chain. When there is nothing left to
read, continue_pipeline goes to False, which is what makes the loop
exit towards the “end” node instead of going round again.
The datasets coming back around the loop are not inputs: a reading node always reads a fresh slice, so whatever the last processing node produced is dropped here.
Either scan_memory_url (online) or filename_data (offline) must be
given – see :meth:_get_reading_mode, which also enforces what each mode
needs (a detector_name online, a detector_name and a scan_nb for a
RAW_DATA file). Every other input is optional.
The context inputs it reads through its parent – detector_name,
scan_nb, filename_data, filename_lima, headers, the counter
streams, the loop position – are documented on
- class:
~ewoksid02.tasks.id02task.ID02Task.
Optional Inputs: - reading_stream (str): Blissdata stream to slice data from. Only valid for online processing. - variance_formula (str): Formula to compute the variance out of the signal. Used when the source carries no variance of its own, which is the case online and for a RAW_DATA file. - Dummy (float): Value marking invalid pixels, used to compute the sigma out of the variance. Falls back to the headers. - datatype (str): Dtype the frames are handed over with. Defaults to “float32”, the type the processed files are written with. Set to None to keep the type they were read with.
Outputs:
- dataset_signal (numpy.ndarray): The slice that was just read. Empty when the source is exhausted.
- dataset_variance / dataset_sigma (numpy.ndarray): Read alongside the signal from a PROCESSED_DATA file, computed out of the signal otherwise.
- index_range_last (list): Range of frames the slice covers. Fed back to the next cycle so it knows where to resume.
- loop_nb (int): Cycle number, incremented by this node and by no other.
- continue_pipeline (bool): False when there is nothing left to read.
- Identifier:
ewoksid02.tasks.id02readertask.ID02ReaderTask- Task type:
- class
- Inputs:
- Dummy
- datatype
- detector_name
- filename_data
- filename_lima
- gc_collect
- headers
- index_node
- index_range
- index_range_last
- info_history
- lima_url_template
- lima_url_template_args
- log_level
- loop_nb
- max_slice_size
- nb_frames_total
- nb_nodes
- processing_type
- reading_mode
- reading_stream
- scan_memory_url
- scan_nb
- scan_number_format
- streams_subscan1
- streams_subscan2
- variance_formula
- Outputs:
- continue_pipeline
- dataset_sigma
- dataset_signal
- dataset_variance
- detector_name
- filename_data
- filename_lima
- headers
- index_range_last
- info_history
- lima_url_template
- lima_url_template_args
- loop_nb
- nb_frames_total
- scan_memory_url
- scan_nb
- scan_number_format
- streams_subscan1
- streams_subscan2
ID02Task#
Common machinery of the ID02 loop nodes: identity, logging and context.
A child is expected to call, in this order:
- meth:
_set_task– PID, logger and the common inputs.
- meth:
_set_context– reading mode, then whatever of the context is still unresolved, then the headers and the counter streams.
and then do its own work (read a slice, or process and save one).
- Identifier:
ewoksid02.tasks.id02task.ID02Task- Task type:
- class
- Inputs:
- detector_name
- filename_data
- filename_lima
- gc_collect
- headers
- index_node
- index_range
- index_range_last
- info_history
- lima_url_template
- lima_url_template_args
- log_level
- loop_nb
- nb_frames_total
- nb_nodes
- processing_type
- reading_mode
- scan_memory_url
- scan_nb
- scan_number_format
- streams_subscan1
- streams_subscan2
- Outputs:
- detector_name
- filename_data
- filename_lima
- headers
- index_range_last
- info_history
- lima_url_template
- lima_url_template_args
- loop_nb
- nb_frames_total
- scan_memory_url
- scan_nb
- scan_number_format
- streams_subscan1
- streams_subscan2
LLMTask#
Ask a language model with the prompt of a skill, and keep its JSON reply.
Used as is with skill (a skill of tasks/llm/), request (sent
as JSON) and name. A subclass sets SKILL and builds the request, the
name and the checks of the reply itself. The reply is written to
<output_dir>/<name>.json with the model and the date, and returned.
When the model was asked, the file also keeps the request as sent
(request) and which prompt went with it (prompt: skill, SHA-256 of
the system prompt, reply schema).
Any OpenAI-compatible server (vLLM, Ollama, …). Server and model come
from the inputs, else from EWOKSID02_LLM_URL and EWOKSID02_LLM_MODEL.
The key comes from the file named by EWOKSID02_LLM_ENV_FILE (a line
EWOKSID02_LLM_API_KEY=...), else from EWOKSID02_LLM_API_KEY.
A subclass with REPLY (a pydantic model) sends its JSON schema: the
server must reply in that shape (structured outputs). A server that
refuses it is asked again for any JSON object.
- Identifier:
ewoksid02.tasks.llm.llmtask.LLMTask- Task type:
- class
- Inputs:
- output_dir*
- base_url
- model
- name
- request
- skill
- timeout
- Outputs:
- filename_reply
- reply
InterpretNameTask#
Ask a language model what a collection name, or a scan title, says about the sample.
Writes the reply to <output_dir>/<collection>.json (the journal gives
JOURNAL/samples) and returns it as reply; BLISS writes the journal
line. A name that cannot say anything gets no model call, unless the
users’ notes (JOURNAL/NOTES.md) name it. Prompt in
skills/name-interpretation/, followed by its glossaries.
With scan_title, the title of a scan is interpreted instead, the
collection being its context: some users measure several samples in one
collection and name each in the title. The reply file is then name.
dataset is context, sent only when it is not the default timestamp.
- Identifier:
ewoksid02.tasks.llm.interpretnametask.InterpretNameTask- Task type:
- class
- Inputs:
- collection*
- output_dir*
- base_url
- collection_summary
- dataset
- model
- name
- other_collections
- other_titles
- proposal_abstract
- request
- scan_command
- scan_nb
- scan_title
- skill
- timeout
- user_notes
- Outputs:
- filename_reply
- reply
CheckProcessingInputsTask#
Ask a language model whether the processing inputs of a scan are right: calibration files, geometry, normalization, step chain.
request: the inputs summary of the scan (scan, flags, files,
headers, steps) and history, as the prompt of its skill describes;
the task adds precomputed. Writes the reply to
<output_dir>/<name>.json and returns it as reply; BLISS prints and
notes what looks wrong.
- Identifier:
ewoksid02.tasks.llm.checkprocessinginputstask.CheckProcessingInputsTask- Task type:
- class
- Inputs:
- name*
- output_dir*
- request*
- base_url
- model
- name
- request
- skill
- timeout
- Outputs:
- filename_reply
- reply
NormalizationTask#
The NormalizationTask class is responsible for normalizing datasets in the ID02 SAXS pipeline.
It extends the ID02ProcessingTask class and provides additional functionality to apply a standard pyFAI normalization:
Methods to read monitor values from the metadata file or from blissdata
Methods to read normalization parameters from the metadata file or from the headers
Methods to cache pyFAI azimuthal integrator and apply normalization
Applies corrections such as masking, dark frame subtraction, flat field correction, and polarization adjustments.
Optional Inputs: - filename_mask (str): Path to the mask file for correcting detector gaps or bad pixels. - filename_dark (str): Path to the file for dark current correction. - filename_flat (str): Path to the file for flat field correction. - Dummy (float): Value to replace invalid pixels in the dataset. - DDummy (float): Tolerance for dummy pixel replacement. - NormalizationFactor (float): Factor for normalizing the dataset. - correct_mask (bool): Whether to apply the mask. - correct_flatfield (bool): Whether to apply flat field correction. - correct_solidangle (bool): Whether to apply solid angle correction. - correct_polarization (bool): Whether to apply polarization correction. - PolarizationFactor (float): Factor for polarization correction. - PolarizationAxisOffset (float): Axis for polarization correction. - Center_1 (float): Beam center in the first dimension. - Center_2 (float): Beam center in the second dimension. - PSize_1 (float): Pixel size 1. - PSize_2 (float): Pixel size 2. - BSize_1 (float): Pixel binning 1. - BSize_2 (float): Pixel binning 2. - SampleDistance (float): Sample to detector distance in meters. - WaveLength (float): Wavelength of beam in meters. - DetectorRotation_1 (float): rot2 of pyFAI. - DetectorRotation_2 (float): rot1 of pyFAI. - DetectorRotation_3 (float): rot3 of pyFAI. - pin_monitor (str): Pin to the monitor stream. - header_pin_monitor (str): Header key used to monitor values. - algorithm (str): Implementation to perform the normalization (numpy or cupy). - dark_filter (str): Filter to use in case the dark-current file is a multi-frame scan file. - dark_filter_quantil_lower (str): In case the dark_filter is quantil, lower limit. - dark_filter_quantil_upper (str): In case the dark_filter is quantil, upper limit.
- Identifier:
ewoksid02.tasks.normalizationtask.NormalizationTask- Task type:
- class
- Inputs:
- BSize_1
- BSize_2
- Center_1
- Center_2
- DDummy
- DetectorRotation_1
- DetectorRotation_2
- DetectorRotation_3
- Dummy
- NormalizationFactor
- PSize_1
- PSize_2
- PolarizationAxisOffset
- PolarizationFactor
- SampleDistance
- WaveLength
- algorithm
- continue_pipeline
- correct_dark
- correct_flatfield
- correct_mask
- correct_polarization
- correct_solidangle
- dark_filter
- dark_filter_quantil_lower
- dark_filter_quantil_upper
- dataset_sigma
- dataset_signal
- dataset_variance
- datatype
- detector_name
- do_process
- do_save
- filename_dark
- filename_data
- filename_db
- filename_flat
- filename_lima
- filename_mask
- gc_collect
- header_pin_monitor
- headers
- index_node
- index_range
- index_range_last
- info_history
- lima_url_template
- lima_url_template_args
- log_level
- loop_nb
- nb_frames_total
- nb_nodes
- pin_monitor
- processing_filename
- processing_subtitle
- processing_type
- reading_mode
- save_metadata
- save_normalization
- save_sigma
- save_variance
- scan_memory_url
- scan_nb
- scan_number_format
- streams_subscan1
- streams_subscan2
- subtitle
- Outputs:
- continue_pipeline
- dataset_sigma
- dataset_signal
- dataset_variance
- detector_name
- filename_data
- filename_lima
- headers
- index_range_last
- info_history
- lima_url_template
- lima_url_template_args
- loop_nb
- nb_frames_total
- scan_memory_url
- scan_nb
- scan_number_format
- streams_subscan1
- streams_subscan2
SAXSAnalysisTask#
Measure the averaged curve of an _ave.h5, without background.
nxdata_url: <file>::<NXdata>, as for the gallery. operations: names
of saxsanalysis.OPERATIONS, all by default. No
language model: the skill saxs-interpretation reads the numbers later. The
measurements (saxsanalysis) are also written to
.saxs_analysis/<stem>_saxsanalysis.json, in the folder of the file
(filename_saxsanalysis).
Never fails: the last node of the online workflow must not turn a
successful reduction into a failure. An error makes every operation
invalid, with the error as reason.
- Identifier:
ewoksid02.tasks.saxsanalysistask.SAXSAnalysisTask- Task type:
- class
- Inputs:
- nxdata_url*
- operations
- Outputs:
- filename_saxsanalysis
- saxsanalysis
ScalersTask#
The ScalersTask class is responsible for creating a scalers file, that contains a large chunk of the metadata for reprocessing.
It extends the ID02ProcessingTask class and provides additional functionality to apply a standard pyFAI normalization:
Methods to read monitor values from the metadata file or from blissdata
Methods to read normalization parameters from the metadata file or from the headers
Methods to cache pyFAI azimuthal integrator and apply normalization
- Identifier:
ewoksid02.tasks.scalerstask.ScalersTask- Task type:
- class
- Inputs:
- Dummy
- continue_pipeline
- dataset_sigma
- dataset_signal
- dataset_variance
- datatype
- detector_name
- do_process
- do_save
- filename_data
- filename_db
- filename_lima
- gc_collect
- headers
- index_node
- index_range
- index_range_last
- info_history
- lima_url_template
- lima_url_template_args
- log_level
- loop_nb
- nb_frames_total
- nb_nodes
- processing_filename
- processing_subtitle
- processing_type
- reading_mode
- save_metadata
- save_sigma
- save_variance
- scan_memory_url
- scan_nb
- scan_number_format
- streams_subscan1
- streams_subscan2
- subtitle
- Outputs:
- continue_pipeline
- dataset_sigma
- dataset_signal
- dataset_variance
- detector_name
- filename_data
- filename_lima
- headers
- index_range_last
- info_history
- lima_url_template
- lima_url_template_args
- loop_nb
- nb_frames_total
- scan_memory_url
- scan_nb
- scan_number_format
- streams_subscan1
- streams_subscan2
SecondaryScatteringTask#
The SecondaryScatteringTask class is responsible for calculating and correcting the scattering coming from
the window that separates the wagon from the flying tube.
It can be used to correct any scattering source that is close to the detector.
Optional Inputs:
- filename_window_wagon (str): Path to the mask file used for defining the scattering window WAXS pattern.
- WindowRoiSize (float): Distance parameter for subdata extraction during secondary scattering correction.
- Dummy (float): Value to perform a pre-caving step (to mask the detector gaps)
- Center_1 (float): Beam center in the first dimension.
- Center_2 (float): Beam center in the second dimension.
- algorithm (str): Implementation to perform the secondary scattering correction and pre-caving (numpy or cupy).
- pre_caving (bool): To perform a caving step before the correction.
- filename_mask_static (str): Path to the mask file used for the caving operation.
- filename_mask_reference (str): Path to the reference mask file (kind of a negative mask).
- flip_caving (bool): Cave the image with its flipped projection, both horizontal and vertical. WARNING: it is physically not correct!
- save_secondary_scattering (bool): Flag to save the secondary scattering dataset. Default is False.
- BSize_1 (float): Pixel binning 1.
- BSize_2 (float): Pixel binning 2.
Outputs:
- secondary_scattering (numpy.ndarray): Dataset with the calculated secondary scattering.
- Identifier:
ewoksid02.tasks.secondaryscatteringtask.SecondaryScatteringTask- Task type:
- class
- Inputs:
- BSize_1
- BSize_2
- Center_1
- Center_2
- Dummy
- WindowRoiSize
- algorithm
- continue_pipeline
- dataset_sigma
- dataset_signal
- dataset_variance
- datatype
- detector_name
- do_process
- do_save
- filename_data
- filename_db
- filename_lima
- filename_mask_reference
- filename_mask_static
- filename_window_wagon
- flip_caving
- gc_collect
- headers
- index_node
- index_range
- index_range_last
- info_history
- lima_url_template
- lima_url_template_args
- log_level
- loop_nb
- nb_frames_total
- nb_nodes
- pre_caving
- processing_filename
- processing_subtitle
- processing_type
- reading_mode
- save_metadata
- save_secondary_scattering
- save_sigma
- save_variance
- scan_memory_url
- scan_nb
- scan_number_format
- streams_subscan1
- streams_subscan2
- subtitle
- Outputs:
- continue_pipeline
- dataset_sigma
- dataset_signal
- dataset_variance
- detector_name
- filename_data
- filename_lima
- headers
- index_range_last
- info_history
- lima_url_template
- lima_url_template_args
- loop_nb
- nb_frames_total
- scan_memory_url
- scan_nb
- scan_number_format
- streams_subscan1
- streams_subscan2
PdfGetXAverage#
Average a list of 1D XRPD patterns from provided output of IntegrateBlissScan
Inputs: - nxdata_url: .h5 path with NXData url Outputs: - radial: 1D array - intensity: 1D array - info: dict with radial_units and wavelength
- Identifier:
ewoksid11.pdfgetx_average.PdfGetXAverage- Task type:
- class
- Inputs:
- nxdata_url*
- Outputs:
- info
- intensity
- radial
PdfGetXConfig#
Parse pdfgetx config parameters
- Identifier:
ewoksid11.pdfgetx_config.PdfGetXConfig- Task type:
- class
- Inputs:
- filename
- pdfgetx_options_dict
- Outputs:
- pdfgetx_options
PdfGetXProcessor#
Extracts the PDF signal from provided intensities and radial
Inputs: - radial: 1D array - intensity: 1D array - info: dict with unit and wavelength - pdfgetx_options: PDFConfig object Outputs: - result: PDFGetter object with attributes defined by outputtype. Attributes are tuples with [0] X (radial) and [1] Y (intensity) - pdfgetx_options: PDFConfig object
- Identifier:
ewoksid11.pdfgetx_processor.PdfGetXProcessor- Task type:
- class
- Inputs:
- info*
- intensity*
- pdfgetx_options*
- radial*
- Outputs:
- pdfgetx_options
- result
PdfGetXSaveAscii#
Saves the PDF result (iq, sq, fq, gr) in separate ASCII files
Inputs: - filename: h5file name that would have been used to save data from XrpdProcessor - result: PDFGetter object with attributes defined by outputtype. Attributes are tuples with [0] X (radial) and [1] Y (intensity) Outputs: - saved: True if saved - filename: list of saved filenames
- Identifier:
ewoksid11.pdfgetx_save_ascii.PdfGetXSaveAscii- Task type:
- class
- Inputs:
- filename*
- result*
- Outputs:
- filenames
- saved
PdfGetXSaveNexus#
Saves the PDF result (iq, sq, fq, gr) in a NeXus file
Inputs: - output_filename: h5file name where the data must be saved - scan: scan number - detector name: name of the detector - result: PDFGetter object with attributes defined by outputtype. Attributes are tuples with [0] X (radial) and [1] Y (intensity) Outputs: - output_url: URL of the NXprocess containing the saved data
- Identifier:
ewoksid11.pdfgetx_save_nexus.PdfGetXSaveNexus- Task type:
- class
- Inputs:
- detector_name*
- output_filename*
- pdfgetx_options*
- result*
- scan*
- lima_url_template
- lima_url_template_args
- prioritize_non_native_h5items
- retry_period
- retry_timeout
- subscan
- Outputs:
- output_url
CalibAverage#
Average a list of 2D images from bliss data url
Inputs: - bliss_data_url: format like /data/visitor/maXXXX/idXX/20240101/sample/dataset/dataset.h5::1.1/measurement/detector Outputs: - image: 2D image averaged from list of 2D images
- Identifier:
ewoksid11.pyfai_calib_average.CalibAverage- Task type:
- class
- Inputs:
- bliss_data_url*
- Outputs:
- image
CalibSave#
Saves the geometry from calibration result in output_path. By default, the geometry file will be: {calibrant}_YYYYMMDD_hhmm.poni
Inputs: - geometry: dictionnary, result of CalibrateSingle - calibrant: string with calibrant name used in CalibrateSingle - detector: string, default is detector - detector_config: dict with key splineFile - output_path: list of strings, where the poni will be saved - energy: float, in keV
Outputs: - output_path: list of strings, path of the poni files saved
- Identifier:
ewoksid11.pyfai_calib_save.CalibSave- Task type:
- class
- Inputs:
- calibrant*
- detector*
- detector_config*
- energy*
- geometry*
- output_path*
- Outputs:
- output_path
ID22H5ToSpec#
- Identifier:
ewoksid22.convert.ID22H5ToSpec- Task type:
- class
- Inputs:
- filename*
- ascii_extension
- entries
- outdirs
- outprefix
- primary_outdir
- rebin_filename
- retry_timeout
- Outputs:
- entries
- outfile
ID22TopasExtract#
- Identifier:
ewoksid22.extract.ID22TopasExtract- Task type:
- class
- Inputs:
- filename*
- inp_file*
- entries
- full_tth
- inp_step
- outdirs
- outprefix
- primary_outdir
- startp
- tth_max
- tth_min
ID22Rebin#
- Identifier:
ewoksid22.rebin.ID22Rebin- Task type:
- class
- Inputs:
- filename*
- parsfile*
- debug
- delta2theta
- device
- endp
- energy
- entries
- iter
- outdirs
- outprefix
- phi
- pixel
- primary_outdir
- range
- retry_timeout
- startp
- step
- unscramble_method
- wavelength
- width
- Outputs:
- entries
- outfile
ID22Sum#
- Identifier:
ewoksid22.sum.ID22Sum- Task type:
- class
- Inputs:
- binsize*
- filename*
- advanced
- ascii_extension
- entries
- lowtth
- outdirs
- outprefix
- primary_outdir
- raw_filename
- resfile
- scaling
- sum_all
- sum_single
- Outputs:
- outfile
WaitScansFinished#
- Identifier:
ewoksid22.wait.WaitScansFinished- Task type:
- class
- Inputs:
- filename*
- entries
- retry_timeout
- Outputs:
- entries
- filename
FlatFieldFromEnergy#
Interpolate an energy-stack of flat-field images.
The resulting flat-field image can be used as follows to correct diffraction patterns for flat field:
.. code::
Icor = I / flatfield
Output:
flatfield: 2D numpy.ndarray
- Identifier:
ewoksid31.tasks.flatfield.FlatFieldFromEnergy- Task type:
- class
- Inputs:
- newflat* :
str Filename of ID31 P3 detector flatfield
Examples:'/data/id31/inhouse/P3/flats.mat'- oldflat* :
str Filename of ID31 P3 detector ‘old’ flatfield
Examples:'/data/id31/inhouse/P3/flats_old.mat'- energy* :
float | str X-ray energy in KeV or URL of hdf5 dataset storing its value
Examples:75.0'/path/to/file.f5::/2.1/instrument/positioners/energy'
- enabled :
bool= True
- newflat* :
- Outputs:
- flatfield
SaveNexusPatternsAsId31TomoHdf5#
Save integrated XRD patterns into an HDF5 file compatible with ID31 tomography workflow.
Output:
filename (str): Path to the written HDF5 file, or empty string if skipped.
- Identifier:
ewoksid31.tasks.tomo.SaveNexusPatternsAsId31TomoHdf5- Task type:
- class
- Inputs:
- scan_entry_url* :
str HDF5 URL to the NXentry group containing the ‘measurement’ group
Examples:'/path/to/raw_data/file.f5::/2.1'- rot_name* :
str Dataset name in ‘measurement’ for rotation angles
Examples:'nth'- y_name* :
str Dataset name in ‘measurement’ for horizontal positions
Examples:'ny'- nxdata_url* :
str HDF5 URL to the NXdata group containing integrated patterns
Examples:'/path/to/processed_data/file.f5::/2.1/p4_integrate/integrated'
- output_filename* :
str Path to the output HDF5 file
Examples:'/path/to/processed_data/tomo.f5'- enabled :
bool= True - overwrite :
bool= False - retry_timeout :
float | None= None Duration in seconds for which to try to open HDF5 files
- retry_period :
float | None= None Amount of time in seconds between each attempt to open HDF5 files
- scan_entry_url* :
- Outputs:
- filename
GenerateIniFile#
Generate the ini file needed for the detector distorsion. Save it in output_file. Inputs: - template_file: string, path of the ini template file - mapping_data: dict[str, any], A dictionary of key-value pairs used for substitution in the template file - output_file: string, the full path (including filename) where the ini file will be saved Outputs: - output_file: string, the full path (including filename) where the ini file is saved
- Identifier:
ewoksoptics.tasks.generate_ini_file.GenerateIniFile- Task type:
- class
- Inputs:
- mapping_data*
- output_file*
- template_file*
- Outputs:
- output_file