PyNXPhaser#
- class cdiutils.process.PyNXPhaser(iobs, mask=None, operators=None, **params)[source]#
Bases:
objectA class for using PyNX’s phasing algorithms without worrying too much about the initialisation and the parameters. This class uses generic PyNX parameters but they can also be provided upon instanciation.
Phase Retrieval
This class is deprecated. Use the BcdiPipeline.phase_retrieval() method instead, which handles PyNX execution automatically.
See the BcdiPipeline documentation for current phase retrieval workflows.
- __init__(iobs, mask=None, operators=None, **params)[source]#
Initialisation method.
- Parameters:
iobs (np.ndarray) – the observed intensity.
mask (np.ndarray, optional) – the mask, can include detector gap mask/hot pixels/aliens. Defaults to None.
operators (dict, optional) – the operators you might want to use. If not provided, ER, HIO and RAAR will be initialised anyway. Defaults to None.
params (dict, optional) – the PyNX parameters. If not provided, will use some generic parameters.
- Raises:
ModuleNotFoundError – if PyNX is not installed, this class is of no use.
- init_cdi(verbose=True, init_main_cdi=True, **params)[source]#
Initialise the CDI object.
- Parameters:
verbose (bool, optional) – whether to print the initialisation steps. Defaults to True.
init_main_cdi (bool, optional) – whether to set the cdi attribute or not. Defaults to True.
**params (optional) – the parameters to update the default ones with.
- Returns:
the initialised CDI object.
- Return type:
CDI_Type
- run(recipe, cdi=None, init_cdi=True)[source]#
Run the reconstruction algorithm.
- Parameters:
recipe (str) – the instruction to run, i.e. the sequence of projection algorithms (ex: “ER**200, HIO**400, RAAR**800”)
cdi (CDI_Type, optional) – a cdi object you might to work on, if not provided, will used the attribute self.cdi. Defaults to None.
init_cdi (bool, optional) – whether to initialise the cdi object or not. Defaults to True.
- Raises:
ValueError – if instruction is not authorised.
ValueError – if instruction is invalid
- run_multiple_instances(run_nb, recipe, init_cdi=True)[source]#
Run several reconstructions.
- Parameters:
run_nb (int) – the number of reconstructions
recipe (str) – the instruction to run, i.e. the sequence of projection algorithms (ex: “ER**200, HIO**400, RAAR**800”)
init_cdi (bool, optional) – whether to initialise the cdi object or not. Defaults to True.
- Raises:
ValueError – if init_cdi is False but no initialisation was done with the init_cdi() method beforehand.
- genetic_phasing(run_nb, genetic_pass_nb, recipe, selection_method='sharpness', init_cdi=True)[source]#
Run ‘genetic’-like phasing. It runs a number of reconstruction independently (defined by the recipe). The support of the best result based on the selection_method is used to replace other reconstruction support. This is repeated genetic_pass_nb number of times.
- Parameters:
run_nb (int) – the number of reconstructions.
genetic_pass_nb (int) – the number of genetic pass, i.e. the number of times the recipe is applied.
recipe (str) – the instruction to run, i.e. the sequence of projection algorithms (ex: “ER**200, HIO**400, RAAR**800”)
selection_method (str, optional) – The metric used to select the best reconstruction. Defaults to “sharpness”.
init_cdi (bool, optional) – whether to initialise the cdi object or not. Defaults to True.
- Raises:
ValueError – if init_cdi is False but no initialisation was done with the init_cdi() method beforehand.
ValueError – selection method is unknown/invalid.
- static plot_cdi(cdi, spaces='both', axis=0, title=None, axes=None)[source]#
A staticmethod to plot cdi object main quantity.
See ShowCDI operator to see how Vincent plots CDI objects. https://gitlab.esrf.fr/favre/PyNX/-/blob/master/pynx/cdi/cpu_operator.py?ref_type=heads
- Parameters:
cdi (CDI_Type) – the cdi object to plot the quantity from.
spaces (str, optional) – Whether reciprocal or direct space. Defaults to “both”.
axis (int, optional) – What slice to plot. Defaults to 0.
title (str, optional) – A title for the plot. Defaults to None.
Examples#
Phase retrieval should be performed using BcdiPipeline:
from cdiutils.pipeline import BcdiPipeline
# Create pipeline with configuration
pipeline = BcdiPipeline(param_file_path="config.yml")
# Preprocess detector data
pipeline.preprocess()
# Run phase retrieval with PyNX
pipeline.phase_retrieval()
See Also#
PhasingResultAnalyser : Detailed analysis of phasing results
BcdiPipeline : Complete pipeline using PyNXPhaser