SAXS/WAXS tasks#

How to use

These tasks come from ewokspdf ewoksxrpd. It can be installed with

pip install ewokspdf ewoksxrpd

ℹ️ These tasks are used at the following ESRF beamlines: BM02, ID06, ID09, ID11, ID13, ID16B, ID31

SaveAsciiPattern1D#

Save single diffractogram in ASCII format

Identifier:
ewoksxrpd.tasks.ascii.SaveAsciiPattern1D
Task type:
class
Inputs:
filename*
x*
xunits*
y*
header
metadata
yerror
Outputs:
saved

SaveAsciiMultiPattern1D#

Identifier:
ewoksxrpd.tasks.ascii.SaveAsciiMultiPattern1D
Task type:
class
Inputs:
filenames*
x_list*
xunits_list*
y_list*
header_list
metadata_list
yerror_list
Outputs:
saved

SaveNexusPatternsAsAscii#

Convert azimuthal integration results from NeXus to ASCII files

One ASCII file is created for each integration pattern in nxdata_url. ASCII files are named from the output_filename_template and the pattern index.

If output_archive_filename is provided, all ASCII files are stored in a single ZIP file. In this case, output_filename_template is the template path of ASCII files inside the ZIP file.

Required inputs:

  • nxdata_url (str): The url of the NXData group storing the azimuthal integration results

  • output_filename_template (str): A string template containing one ‘%d’ field. It is used to generate the filename from the frame number.

Optional inputs:

  • header (dict): Information to store in ASCII file header (default: {})

  • enabled (bool): True to enable saving as ASCII files, False to skip task (default: True)

  • output_archive_filename (str): Filename of the ZIP file containing all ASCII files. If this is None (default) or the empty string, ZIP compression is disabled.

  • overwrite (bool): True to allow overwriting existing ASCII/ZIP files (default: False)

  • sector_suffix_template (str): A string template containing one ‘%d’ field. Used to generate the string appended at the end of the filename showing the sector number. Defaults to “sector%04d”. Only used if 2D integrated patterns are present.

  • counter_urls (list[str]): Urls to datasets with counter values to save in the file header. The dataset should be scalar or have a length equal to the number of integrated frames from the nxdata_url. If this is None (default), no counter value is added to the header.

Outputs:

  • filenames (tuple[str]): The names of the created ASCII files or ZIP file

Identifier:
ewoksxrpd.tasks.ascii.SaveNexusPatternsAsAscii
Task type:
class
Inputs:
nxdata_url*
output_filename_template*
counter_urls
enabled
header
lima_url_template
lima_url_template_args
output_archive_filename
overwrite
prioritize_non_native_h5items
retry_period
retry_timeout
sector_suffix_template
Outputs:
filenames

SubtractBackground#

Background removal with normalization

.. code:

Icor = I  - B / Bmon * Imon
Identifier:
ewoksxrpd.tasks.background.SubtractBackground
Task type:
class
Inputs:
background*
background_monitor*
image*
monitor*
lima_url_template
lima_url_template_args
prioritize_non_native_h5items
retry_period
retry_timeout
Outputs:
image
monitor

LastLimaImage#

Get the last Lima image from Redis

Identifier:
ewoksxrpd.tasks.bliss.LastLimaImage
Task type:
class
Inputs:
db_name*
demo
Outputs:
image

CalibrateSingle#

Single distance and energy calibration. Accepts multiple values for max_rings for sequential refinement.

Identifier:
ewoksxrpd.tasks.calibrate.CalibrateSingle
Task type:
class
Inputs:
calibrant*
detector*
energy*
geometry*
image*
detector_config
fixed
lima_url_template
lima_url_template_args
max_rings
prioritize_non_native_h5items
retry_period
retry_timeout
ring_detector
robust
Outputs:
chi2
detector
detector_config
energy
geometry
rings

CalibrateMulti#

Single energy, multi distance calibration with 1 distance motor.

The images and positions are the diffraction patterns and the motor positions at which those were measured.

The reference_position is the detector position that corresponds to geometry (positions[0] by default).

The sample_position is the position where sample and detector would theoretically coincide (0 by default).

The output energy and geometry correspond to sample_position.

The units of positions, sample_position and reference_position are defined by positionunits_in_meter (1e-3 by default which means the unit is in millimeter).

The parametrization allow deriving energy+geometry from the detector position.

.. code-block:: python

energy, geometry = parametrization(parameters, position)
Identifier:
ewoksxrpd.tasks.calibrate.CalibrateMulti
Task type:
class
Inputs:
calibrant*
detector*
energy*
geometry*
images*
positions*
detector_config
fixed
lima_url_template
lima_url_template_args
max_rings
positionunits_in_meter
prioritize_non_native_h5items
reference_position
retry_period
retry_timeout
robust
sample_position
Outputs:
chi2
detector
detector_config
energy
geometry
parameters
parametrization
rings

CalculateGeometry#

Calculate energy and geometry from pyFAI parametrization

Identifier:
ewoksxrpd.tasks.calibrate.CalculateGeometry
Task type:
class
Inputs:
parameters*
parametrization*
position*
lima_url_template
lima_url_template_args
prioritize_non_native_h5items
retry_period
retry_timeout
Outputs:
energy
geometry

DiagnoseCalibrateSingleResults#

Quality of a single-distance pyFAI calibration

Identifier:
ewoksxrpd.tasks.diagnostics.DiagnoseCalibrateSingleResults
Task type:
class
Inputs:
calibrant*
detector*
energy*
geometry*
image*
detector_config
dpi
figsize
filename
fontsize
lima_url_template
lima_url_template_args
pause
prioritize_non_native_h5items
retry_period
retry_timeout
rings
scaling
show
Outputs:
saved

DiagnoseCalibrateMultiResults#

Quality of a multi-distance pyFAI calibration

Identifier:
ewoksxrpd.tasks.diagnostics.DiagnoseCalibrateMultiResults
Task type:
class
Inputs:
calibrant*
detector*
images*
parameters*
parametrization*
positions*
detector_config
dpi
figsize
filename
fontsize
lima_url_template
lima_url_template_args
pause
prioritize_non_native_h5items
retry_period
retry_timeout
rings
scaling
show
Outputs:
saved

DiagnoseIntegrate1D#

Quality of a pyFAI integration

Identifier:
ewoksxrpd.tasks.diagnostics.DiagnoseIntegrate1D
Task type:
class
Inputs:
x*
xunits*
y*
calibrant
dpi
energy
figsize
filename
fontsize
lima_url_template
lima_url_template_args
pause
prioritize_non_native_h5items
retry_period
retry_timeout
scaling
show
yerror
Outputs:
saved

IntegrateSinglePattern#

1D or 2D integration of a single diffraction pattern.

Identifier:
ewoksxrpd.tasks.integrate.IntegrateSinglePattern
Task type:
class
Inputs:
detector*
energy*
geometry*
image*
darkcurrent
demo
detector_config
fixed_integration_options
flatfield
frame_band_index
integration_options
lima_url_template
lima_url_template_args
mask
maximum_persistent_workers
monitor
monitors
prioritize_non_native_h5items
reference
references
retry_period
retry_timeout
Outputs:
azimuthal
azimuthal_units
info
intensity
intensity_error
radial
radial_units

Integrate1D#

DEPRECATED. Use IntegrateSinglePattern instead.

Identifier:
ewoksxrpd.tasks.integrate.Integrate1D
Task type:
class
Inputs:
detector*
energy*
geometry*
image*
darkcurrent
demo
detector_config
fixed_integration_options
flatfield
frame_band_index
integration_options
lima_url_template
lima_url_template_args
mask
maximum_persistent_workers
monitor
monitors
prioritize_non_native_h5items
reference
references
retry_period
retry_timeout
Outputs:
azimuthal
azimuthal_units
info
intensity
intensity_error
radial
radial_units
x
xunits
y
yerror

Integrate1DList#

1D integration of a list of diffraction patterns.

Identifier:
ewoksxrpd.tasks.integrate.Integrate1DList
Task type:
class
Inputs:
detector*
energy*
geometry*
images*
output_file*
darkcurrent
demo
detector_config
entry_name
fixed_integration_options
flatfield
flush_period
frame_band_index
integration_options
lima_url_template
lima_url_template_args
mask
maximum_persistent_workers
monitors
prioritize_non_native_h5items
reference
retry_period
retry_timeout
Outputs:
output_uri

IntegrateBlissScan#

1D or 2D integration of a single detector in a single Bliss scan with saving.

Identifier:
ewoksxrpd.tasks.integrate.IntegrateBlissScan
Task type:
class
Inputs:
detector*
detector_name*
energy*
filename*
geometry*
output_filename*
scan*
counter_names
darkcurrent
demo
detector_config
external_output_filename
fixed_integration_options
flatfield
flush_period
frame_band_index
integration_options
lima_url_template
lima_url_template_args
mask
maximum_persistent_workers
monitor_name
monitors
nxmeasurement_name
nxprocess_as_default
nxprocess_name
overwrite
prioritize_non_native_h5items
reference
references
retry_period
retry_timeout
scan_memory_url
subscan
Outputs:
info
nxdata_url

IntegrateBlissScanWithoutSaving#

1D or 2D integration of a single detector in a single Bliss scan without saving.

Identifier:
ewoksxrpd.tasks.integrate.IntegrateBlissScanWithoutSaving
Task type:
class
Inputs:
detector*
detector_name*
energy*
filename*
geometry*
scan*
counter_names
darkcurrent
demo
detector_config
fixed_integration_options
flatfield
frame_band_index
integration_options
lima_url_template
lima_url_template_args
mask
maximum_persistent_workers
monitor_name
monitors
prioritize_non_native_h5items
reference
references
retry_period
retry_timeout
scan_memory_url
subscan
Outputs:
azimuthal
azimuthal_units
info
intensity
intensity_error
radial
radial_units

MultiConfigIntegrateSinglePattern#

Multiple integrations of a single diffraction pattern with different configurations

Identifier:
ewoksxrpd.tasks.integrate.MultiConfigIntegrateSinglePattern
Task type:
class
Inputs:
configs*
detector*
energy*
geometry*
image*
darkcurrent
demo
detector_config
fixed_integration_options
flatfield
frame_band_index
integration_options
lima_url_template
lima_url_template_args
mask
maximum_persistent_workers
monitor
monitors
prioritize_non_native_h5items
reference
references
retry_period
retry_timeout
Outputs:
azimuthal
azimuthal_units
info
intensity
intensity_error
radial
radial_units

MultiConfigIntegrate1D#

DEPRECATED. Use MultiConfigIntegrateSinglePattern instead.

Identifier:
ewoksxrpd.tasks.integrate.MultiConfigIntegrate1D
Task type:
class
Inputs:
configs*
detector*
energy*
geometry*
image*
darkcurrent
demo
detector_config
fixed_integration_options
flatfield
frame_band_index
integration_options
lima_url_template
lima_url_template_args
mask
maximum_persistent_workers
monitor
monitors
prioritize_non_native_h5items
reference
references
retry_period
retry_timeout
Outputs:
azimuthal
azimuthal_units
info
intensity
intensity_error
radial
radial_units
x
xunits
y
yerror

MaskDetection#

The pixels with the same ratio as the monitor ratio within an error margin are considered “good pixels”. The others are masked off.

The error margin monitor_ratio_margin is a fraction of the monitor ratio (0.1 by default).

Masked pixels have value 1. The mask can be smoothed with smooth > 0 to avoid border effects.

.. code:

monitor_ratio = monitor_high / monitor_low
image_ratio = image_high / image_low

bad = abs(image_ratio - monitor_ratio) > monitor_ratio * monitor_ratio_margin
Identifier:
ewoksxrpd.tasks.mask.MaskDetection
Task type:
class
Inputs:
image1*
image2*
monitor1*
monitor2*
lima_url_template
lima_url_template_args
monitor_ratio_margin
prioritize_non_native_h5items
retry_period
retry_timeout
smooth
Outputs:
mask

Integrate2DMultiGeometry#

Identifier:
ewoksxrpd.tasks.multi_geometry_integrate.Integrate2DMultiGeometry
Task type:
class
Inputs:
goniometer_file*
images*
positions*
darkcurrent
fixed_integration_options
flatfield
integration_options
lima_url_template
lima_url_template_args
mask
prioritize_non_native_h5items
retry_period
retry_timeout
Outputs:
azimuthal
azimuthal_units
info
intensity
intensity_error
radial
radial_units

SaveNexusPattern1D#

Save single diffractogram in HDF5/NeXus format

Identifier:
ewoksxrpd.tasks.nexus.SaveNexusPattern1D
Task type:
class
Inputs:
url*
x*
xunits*
y*
bliss_scan_url
external_url
header
lima_url_template
lima_url_template_args
metadata
nxmeasurement_name
nxprocess_as_default
nxprocess_name
prioritize_non_native_h5items
retry_period
retry_timeout
yerror
Outputs:
saved

SaveNexusIntegrated#

Save 1D or 2D integration diffraction patterns in HDF5/NeXus format

Identifier:
ewoksxrpd.tasks.nexus.SaveNexusIntegrated
Task type:
class
Inputs:
intensity*
radial*
radial_units*
url*
azimuthal
azimuthal_units
bliss_scan_url
external_url
info
intensity_error
lima_url_template
lima_url_template_args
metadata
nxmeasurement_name
nxprocess_as_default
nxprocess_name
prioritize_non_native_h5items
retry_period
retry_timeout
Outputs:
saved

SaveNexusMultiPattern1D#

Identifier:
ewoksxrpd.tasks.nexus.SaveNexusMultiPattern1D
Task type:
class
Inputs:
url*
x_list*
xunits*
y_list*
bliss_scan_url
external_url
header_list
lima_url_template
lima_url_template_args
metadata
nxmeasurement_name
nxprocess_as_default
nxprocess_name
prioritize_non_native_h5items
retry_period
retry_timeout
yerror_list
Outputs:
saved

PyFaiConfig#

Parse pyFAI calibration and integration parameters.

Optional inputs:

  • energy (float|None): Energy in KeV (priority 1)

  • geometry (dict|None): pyFAI geometry information (priority 1)

  • detector (str|None): Name of the detector (priority 1)

  • detector_config (dict|None): Configuration of the detector (priority 1)

  • mask (str|numpy.ndarray|None): Filename or data of the detector mask (priority 1)

  • flatfield (str|numpy.ndarray|None): Filename or data of the detector flat-field (priority 1)

  • darkcurrent (str|numpy.ndarray|None): Filename or data of the detector dark-current (priority 1)

  • integration_options (dict|None): Extra pyFAI worker or integration parameters (priority 2)

  • filenames (Sequence[str]|None): PyFAI poni or json file name (priority 3, last file has highest priority)

  • filename (str|None): PyFAI poni or json file name (priority 4)

  • calibrant (str|None): Calibrant name

  • darkflatmethod (str|None): Dark and flat-field correction method

Outputs:

  • energy (float): Energy in KeV

  • geometry (dict): pyFAI geometry information

  • detector (str): Name of the detector

  • detector_config (dict): Configuration of the detector

  • mask (str|numpy.ndarray|None): Filename or data of the detector mask

  • flatfield (str|numpy.ndarray|None): Filename or data of the detector flat-field

  • darkcurrent (str|numpy.ndarray|None): Filename or data of the detector dark-current

  • integration_options (dict): Extra pyFAI worker or integration parameters

  • calibrant (str|None): Calibrant name

Identifier:
ewoksxrpd.tasks.pyfaiconfig.PyFaiConfig
Task type:
class
Inputs:
calibrant
darkcurrent
darkflatmethod
detector
detector_config
energy
filename
filenames
flatfield
geometry
integration_options
mask
show_merge_warnings
Outputs:
calibrant
darkcurrent
detector
detector_config
energy
flatfield
geometry
integration_options
mask

SavePyFaiConfig#

Save inputs as pyFAI calibration and integration configuration file (.json)

The configuration is saved as a JSON file following pyFAI configuration format.

Required inputs:

  • output_filename (str): Name of the file where to save pyFAI configuration. Must include the extension

  • energy (float): Energy in KeV

  • geometry (dict): pyFAI geometry information (poni)

  • detector (str): Name of the detector

Optional inputs:

  • mask (str): Filename of the mask to used

  • detector_config (dict): Configuration of the detector

  • integration_options (dict): Extra configuration fields

Outputs:

  • filename (str): Saved filename, same as output_filename

Identifier:
ewoksxrpd.tasks.pyfaiconfig.SavePyFaiConfig
Task type:
class
Inputs:
detector*
energy*
geometry*
output_filename*
detector_config
integration_options
mask
Outputs:
filename

SavePyFaiPoniFile#

Save inputs as pyFAI PONI file

Required inputs:

  • output_filename (str): Name of the file where to save pyFAI PONI. Must include extension.

  • energy (float): Energy in KeV

  • geometry (dict): pyFAI geometry information (poni)

  • detector (str): Name of the detector

Optional inputs:

  • detector_config (dict): Configuration of the detector

Outputs:

  • filename (str): Saved filename, same as output_filename

Identifier:
ewoksxrpd.tasks.pyfaiconfig.SavePyFaiPoniFile
Task type:
class
Inputs:
detector*
energy*
geometry*
output_filename*
detector_config
Outputs:
filename

SaveImages#

Save images with monitor and other metadata

Identifier:
ewoksxrpd.tasks.save_images.SaveImages
Task type:
class
Inputs:
image_uris*
output_dir*
ext
Outputs:
output_paths

SubtractBackgroundPattern#

Subtract an integrated pattern from patterns stored in NeXus and saves the result in a new NeXus process group

.. code:

I_pattern_corrected = I_pattern - (I_background_pattern * background_factor)

If errors are available in the background and in the input data, errors are propagated and saved as well.

.. code:

E_I_pattern_corrected = \sqrt{E_I_pattern^2 + (E_I_background_pattern * background_factor)^2}
Identifier:
ewoksxrpd.tasks.subtract_pattern.SubtractBackgroundPattern
Task type:
class
Inputs:
background_nxdata_url*
nxdata_url*
output_nxprocess_url*
background_factor
enabled
external_nxprocess_url
lima_url_template
lima_url_template_args
prioritize_non_native_h5items
retry_period
retry_timeout
Outputs:
nxdata_url

SumBlissScanImages#

Sum images of a single camera of a single Bliss scan

Identifier:
ewoksxrpd.tasks.sum.SumBlissScanImages
Task type:
class
Inputs:
detector_name*
filename*
output_filename*
scan*
background_step
lima_url_template
lima_url_template_args
monitor_name
output_process
prioritize_non_native_h5items
retry_period
retry_timeout
scan_memory_url
subscan
Outputs:
monitor
output_uri

SumImages#

Sum images of a single camera from a Bliss scan file

For each scan, images are added in blocks of block_size images (one block with all images by default).

The result contains: * the block sums when sum_type=per_scan or sum_type=both * the sum of the block sums when sum_type=all_scans or sum_type=both

Identifier:
ewoksxrpd.tasks.sum.SumImages
Task type:
class
Inputs:
detector_name*
filename*
output_filename*
block_size
end_image
end_scan
monitor_name
output_entry
output_process
start_image
start_scan
sum_type
Outputs:
monitor_uris
output_uris

PdfGetXAverage#

Average a list of 1D XRPD patterns from provided output of IntegrateBlissScan

Inputs: - nxdata_url: .h5 path with NXData url - average_every: how many rows to average over; - ‘all’ for all rows, - ‘1’ for no averaging, - or any integer divisor of the total number of rows Outputs: - radial: 1D array - intensity: 1D or 2D array based on average_every - info: dict with radial_units and wavelength

Identifier:
ewokspdf.tasks.average.PdfGetXAverage
Task type:
class
Inputs:
nxdata_url*
average_every
Outputs:
info
intensity
radial

PdfGetXConfig#

Parse pdfgetx config parameters

Identifier:
ewokspdf.tasks.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 or 2D array - info: dict with unit, wavelength, and nb_avg - pdfgetx_options: PDFConfig object Outputs: - results: List od PDFGetter object with attributes defined by outputtype. Attributes are tuples with [0] X (radial) and [1] Y (intensity) - info: dict with unit, wavelength, and nb_avg - pdfgetx_options: PDFConfig object

Identifier:
ewokspdf.tasks.processor.PdfGetXProcessor
Task type:
class
Inputs:
info*
intensity*
pdfgetx_options*
radial*
Outputs:
info
pdfgetx_options
results

PdfGetXSaveAscii#

Saves the PDF result (iq, sq, fq, gr) in separate ASCII files

Inputs: - filename: Path to the base file used to save data. - results: List of PDFGetter objects with attributes for output types. - info: dict with unit, wavelength, and nb_avg Outputs: - saved: True if files are saved successfully. - filenames: List of saved filenames.

Identifier:
ewokspdf.tasks.save_ascii.PdfGetXSaveAscii
Task type:
class
Inputs:
filename*
info*
results*
Outputs:
filenames
saved

PdfGetXSaveNexus#

Saves the PDF results (iq, sq, fq, gr) in a NeXus file

Inputs: - nxdata_url: .h5 path with NXData url in which the data will be saved - results: List of PDFGetter object with attributes defined by outputtype. Attributes are tuples with [0] X (radial) and [1] Y (intensity) Outputs: - pdfgetx_options: pdfgetx.PDFConfig object containing the configuration

Identifier:
ewokspdf.tasks.save_nexus.PdfGetXSaveNexus
Task type:
class
Inputs:
info*
nxdata_url*
pdfgetx_options*
results*
lima_url_template
lima_url_template_args
prioritize_non_native_h5items
retry_period
retry_timeout
subscan
Outputs:
output_url