SimEx.Analysis package¶
SimEx.Analysis.AbstractAnalysis module¶
- module AbstractAnalysis
Hosts the abstract base class for all analysis classes.
-
class
SimEx.Analysis.AbstractAnalysis.AbstractAnalysis(input_path=None)[source]¶ Bases:
object- Class AbstractAnalysis
Abstract base class for all data analysis classes.
- Parameters
input_path (str) – Path to hdf5 file holding the data to analyze. Single file or directory.
-
classmethod
dumpLoader(fname)[source]¶ Creates calculator object from a dump file
- Parameters
fname – path to the dump file.
- Returns
Created calculator object.
- Raises
RuntimeError – if cannot create object.
-
property
input_path¶ Query for the input file path(s).
-
SimEx.Analysis.AbstractAnalysis.checkAndSetBaseCalculator(var=None, default=None)[source]¶ Check if passed object is an AbstractAnalysis instance. If non is given, set to given default.
- Parameters
var – The object to check.
default – The default to use.
- Returns
The checked object.
- Raises
RuntimeError – if no valid Analysis object was given.
SimEx.Analysis.DiffractionAnalysis module¶
- module DiffractionAnalysis
Module that hosts the DiffractionAnalysis class.
-
class
SimEx.Analysis.DiffractionAnalysis.DiffractionAnalysis(input_path=None, pattern_indices=None, poissonize=True, mask=None)[source]¶ Bases:
SimEx.Analysis.AbstractAnalysis.AbstractAnalysis- Class DiffractionAnalysis
Class that implements common data analysis tasks for diffraction data.
- Parameters
input_path (str) – Name of file or directory that contains data to analyse.
pattern_indices (int || sequence of int || "all") – Identify which patterns to include in the analysis (default “all”).
poissonize (bool) – Whether to add Poisson noise to the integer photon numbers (default True).
mask (numpy.array) – Mask to multiply on each pattern.
- Example pattern_indices
pattern_indices=1
pattern_indices=[1,2,3]
pattern_indices=range(1,10)
pattern_indices=”all”
-
animatePatterns(output_path=None, logscale=False, offset=0.1)[source]¶ Make an animated gif out of the given patterns.
-
property
mask¶ Query the mask.
-
property
npattern¶ get the number of the selected patterns in this analysis object
-
numpyPattern(operation=None)[source]¶ Return the pattern after opentation over the patterns defined in DiffractionAnalysis class.
- Parameters
operation (python function) – Operation to apply to selected patterns (default none).
- Note operation
Operation must accept a 3D numpy.array as first input argument and the “axis” keyword-argument. Operation must return a 2D numpy.array. Axis will always be chosen as axis=0.
- Example operation
numpy.mean, numpy.std, numpy.sum
-
property
parameters¶
-
patternGenerator()[source]¶ Yield an iterator over a given pattern sequence from a diffraction file.
-
property
pattern_indices¶ Query pattern indices attribute.
-
property
patterns_iterator¶
-
plotPattern(operation=None, logscale=False, offset=0.1, symlog=False, *argv, **kwargs)[source]¶ Plot a pattern.
- Parameters
- Note operation
Operation must accept a 3D numpy.array as first input argument and the “axis” keyword-argument. Operation must return a 2D numpy.array. Axis will always be chosen as axis=0.
- Example operation
numpy.mean, numpy.std, numpy.sum
-
plotRadialProjection(operation=None, logscale=False, offset=1e-05, unit='q_nm^-1')[source]¶ Plot the radial projection of a pattern.
- Parameters
operation (python function) – Operation to apply to selected patterns (default numpy.sum).
logscale (bool) – Whether to plot the intensity on a logarithmic scale (z-axis) (default False).
- Note operation
Operation must accept a 3D numpy.array as first input argument and the “axis” keyword-argument. Operation must return a 2D numpy.array. Axis will always be chosen as axis=0.
- Example operation
numpy.mean, numpy.std, numpy.sum
:param unit:can be “q_nm^-1”, “q_A^-1”, “2th_deg”, “2th_rad”, “r_mm”. :type unit: str
-
property
poissonize¶ Query whether to read data with (True) or without (False) Poisson noise.
-
property
qMap¶ q of each pixel
-
shannonPixelPhoton(resolution)[source]¶ Get the average number of photons per shannon pixel
- Parameters
resolution (float) – The full periodic resolution (A) for shannon pixels
-
property
solidAngles¶ Solid angle of each pixel
-
SimEx.Analysis.DiffractionAnalysis.azimuthalIntegration(pattern, parameters, unit='q_nm^-1')[source]¶
-
SimEx.Analysis.DiffractionAnalysis.diffractionParameters(path)[source]¶ Extract beam parameters and geometry from given file or directory.
- Parameters
path (str) – Path to file that holds the parameters to extract.
-
SimEx.Analysis.DiffractionAnalysis.plotImage(pattern, logscale=False, offset=0.1, symlog=False, *argv, **kwargs)[source]¶ Workhorse function to plot an image
- Parameters
- Returns
the handles of figure and axis
- Return type
figure,axis
-
SimEx.Analysis.DiffractionAnalysis.plotRadialProjection(pattern, parameters, logscale=True, offset=1e-05, unit='q_nm^-1')[source]¶ Perform integration over azimuthal angle and plot as function of radius.
:param unit:can be “q_nm^-1”, “q_A^-1”, “2th_deg”, “2th_rad”, “r_mm”. :type unit: str
SimEx.Analysis.XFELPhotonAnalysis module¶
- module XFELPhotonAnalysis
Module that hosts the XFELPhotonAnalysis class.
-
class
SimEx.Analysis.XFELPhotonAnalysis.XFELPhotonAnalysis(input_path=None)[source]¶ Bases:
SimEx.Analysis.AbstractAnalysis.AbstractAnalysis- Class XFELPhotonAnalysis
Class that implements common data analysis tasks for wavefront (radiation field) data.
- Parameters
input_path (str) – Name of file or directory that contains data to analyse.
-
property
intensity¶ Query for the intensity.
-
plotIntensityMap(qspace=False, logscale=False)[source]¶ Plot the integrated intensity as function of x,y or qx, qy on a colormap.
-
plotOnAxisPowerDensity(spectrum=False)[source]¶ Method to plot the on-axis power density.
- Parameters
spectrum (bool) – Whether to plot the power density in energy domain (True) or time domain (False, default).
-
plotTotalPower(spectrum=False)[source]¶ Method to plot the total power.
- Parameters
spectrum (bool) – Whether to plot the power density in energy domain (True) or time domain (False, default).
-
property
wavefront¶ Query for the wavefront.
-
SimEx.Analysis.XFELPhotonAnalysis.calculate_fwhm(wfr)[source]¶ Calculate FWHM of the beam calculating number of point bigger then max/2 throuhgt center of the image
- Parameters
wfr – wavefront
- Returns
{‘fwhm_x’:fwhm_x, ‘fwhm_y’: fwhm_y} in [m]
-
SimEx.Analysis.XFELPhotonAnalysis.mask_nans(a, replacement=0.0)[source]¶ Find nans in an array and replace. :param a: Array to mask. :type a: numpy.array
- Parameters
replacement (numeric) – The value to replace nans.
- Returns
The array of booleans indicating which values of a are nan, numpy.isnan(a)
- Return type
numpy.array(dtype=bool)
SimEx.Analysis.XMDYNPhotonMatterAnalysis module¶
- module XMDYNPhotonMatterAnalysis
Hosting utilities to analyse and visualize photon-matter trajectories generated by XMDYN.
-
class
SimEx.Analysis.XMDYNPhotonMatterAnalysis.XMDYNPhotonMatterAnalysis(input_path=None, snapshot_indices=None, elements=None, sample_path=None)[source]¶ Bases:
SimEx.Analysis.AbstractAnalysis.AbstractAnalysis- Class XMDYNPhotonMatterAnalysis
Class to encapsulate diagnostics of photon matter interaction trajectories.
- Parameters
-
property
elements¶ Query the elements to include.
-
property
input_path¶ Query the input path.
-
plot_charge()[source]¶ Plot the average number of electrons per atom per atomic species as function of time.
-
property
sample_path¶ Query the sample path.
-
property
snapshot_indices¶ Query the snapshot indices.
-
SimEx.Analysis.XMDYNPhotonMatterAnalysis.calculate_displacement(snapshot, r0, sample)[source]¶ Calculate the average displacement per atomic species in a snapshot.
- Parameters
snapshot (dict) – The snapshot to analyze
r0 (numpy.array (shape=(Natoms, 3))) – Unperturbed positions of the sample atoms.
### CHECKME: Can’t we read r0 from the sample dict?
- Parameters
sample (dict) – Sample data
-
SimEx.Analysis.XMDYNPhotonMatterAnalysis.calculate_ion_charge(snapshot, sample)[source]¶ Calculate the remaining electric charge per atomic species of a given snapshot.