condor package

Submodules

condor.experiment module

class condor.experiment.Experiment(source, particles, detector)[source]

Class for X-ray diffraction experiment

Args:

source:Source instance
particles:Dictionary of particle instances
detector:Detector instance
get_conf()[source]

Get configuration in form of a dictionary. Another identically configured Experiment instance can be initialised by:

conf = E0.get_conf()                         # E0: already existing Experiment instance
E1 = condor.experiment_from_configdict(conf) # E1: new Experiment instance with the same configuration as E0  
get_fresnel_number(wavelength)[source]
get_linear_sampling_ratio(wavelength=None, particle_diameter=None, particle_key=None)[source]

Returns the linear sampling ratio \(o\) of the diffraction pattern:

\(o=\frac{D\lambda}{dp}\)
\(D\): Detector distance
\(p\): Detector pixel size (edge length)
\(\lambda\): Photon wavelength
\(d\): Particle diameter
get_qmap(*args, **keyArgs)
get_qmap_from_cache()[source]
get_resolution(wavelength=None, cx=None, cy=None, pos='corner', convention='full_period')[source]
propagate(*args, **keyArgs)
propagate3d(qn=None, qmax=None)[source]
condor.experiment.experiment_from_configdict(configdict)[source]

Initialise Experiment instance from a dictionary

See also:

condor.experiment.experiment_from_configfile(configfile)[source]

Initialise Experiment instance from configuration file

See also:

condor.experiment.remove_from_dict(D, startswith='_')[source]

condor.source module

class condor.source.Source(wavelength, focus_diameter, pulse_energy, profile_model=None, pulse_energy_variation=None, pulse_energy_spread=None, pulse_energy_variation_n=None, polarization='ignore')[source]

Class for an X-ray source

Args:
wavelength (float):
 X-ray wavelength in unit meter
focus_diameter (float):
 Focus diameter (characteristic transverse dimension) in unit meter
pulse_energy (float):
 (Statistical mean of) pulse energy in unit Joule
Kwargs:
profile_model (str):
 Model for the spatial illumination profile (default None)

Note

The (keyword) arguments focus_diameter and profile_model are passed on to the constructor of condor.utils.profile.Profile. For more detailed information read the documentation of the initialisation function.

pulse_energy_variation (str):
 Statistical variation of the pulse energy (default None)
pulse_energy_spread (float):
 Statistical spread of the pulse energy in unit Joule (default None)
pulse_energy_variation_n (int):
 Number of samples within the specified range (default None)
polarization (str):
 Type of polarization can be either vertical, horizontal, unpolarized, or ignore (default ignore)

Note

The keyword arguments pulse_energy_variation, pulse_energy_spread, and pulse_energy_variation_n are passed on to condor.source.Source.set_pulse_energy_variation() during initialisation. For more detailed information read the documentation of the method.

get_conf()[source]

Get configuration in form of a dictionary. Another identically configured Source instance can be initialised by:

conf = S0.get_conf()         # S0: already existing Source instance
S1 = condor.Source(**conf)   # S1: new Source instance with the same configuration as S0
get_intensity(position, unit='ph/m2', pulse_energy=None)[source]

Calculate the intensity at a given position in the focus

Args:
position:Coordinates [x, y, z] of the position where the intensity shall be calculated
Kwargs:
unit (str):

Intensity unit (default 'ph/m2')

Choose one of the following options:

  • 'ph/m2'
  • 'J/m2'
  • 'J/um2'
  • 'mJ/um2'
  • 'ph/um2'
pulse_energy (float):
 Pulse energy of that particular pulse in unit Joule. If None the mean of the pulse energy will be used (default None)
get_next()[source]

Iterate the parameters of the Source instance and return them as a dictionary

set_pulse_energy_variation(pulse_energy_variation=None, pulse_energy_spread=None, pulse_energy_variation_n=None)[source]

Set variation of the pulse energy

Kwargs:
pulse_energy_variation (str):
 

Statistical variation of the pulse energy (default None)

Choose one of the following options:

  • 'normal' - random normal (Gaussian) distribution
  • 'uniform' - random uniform distribution
  • 'range' - equispaced pulse energies around pulse_energy
  • None - no variation of the pulse energy
pulse_energy_spread (float):
 

Statistical spread of the pulse energy in unit Joule (default None)

pulse_energy_variation_n (int):
 

Number of samples within the specified range

Note

The argument pulse_energy_variation_n takes effect only in combination with pulse_energy_variation='range'

condor.detector module

class condor.detector.Detector(distance, pixel_size, x_gap_size_in_pixel=0, y_gap_size_in_pixel=0, hole_diameter_in_pixel=0, cx_hole=None, cy_hole=None, noise=None, noise_spread=None, noise_variation_n=None, noise_filename=None, noise_dataset=None, cx=None, cy=None, center_variation=None, center_spread_x=None, center_spread_y=None, center_variation_n=None, saturation_level=None, mask=None, mask_filename=None, mask_dataset=None, mask_is_cxi_bitmask=False, solid_angle_correction=True, nx=None, ny=None, binning=None)[source]

Class for a photon area-detector

_images/detector_schematic.jpg

Arguments:

distance (float):
 Distance from interaction point to detector plane
pixel_size (float):
 Edge length of detector pixel (square shape)

Keyword arguments:

cx (float):

Horizontal beam position in unit pixel. If cx=None beam will be positioned in the center (default None)

cy (float):

Vertical beam position in unit pixel If cy=None beam will be positioned in the center (default None)

center_variation (str):
 

See condor.detector.Detector.set_center_variation() (default None)

center_spread_x (float):
 

See condor.detector.Detector.set_center_variation() (default None)

center_spread_y (float):
 

See condor.detector.Detector.set_center_variation() (default None)

center_variation_n (int):
 

See condor.detector.Detector.set_center_variation() (default None)

noise (str):

See condor.detector.Detector.set_noise() (default None)

noise_spread (float):
 

See condor.detector.Detector.set_noise() (default None)

noise_filename (str):
 

See condor.detector.Detector.set_noise() (default None)

noise_dataset (str):
 

See condor.detector.Detector.set_noise() (default None)

saturation_level (float):
 

Value at which detector pixels satutrate (default None)

binning (int):

Pixel binning factor, intensies are integrated over square patches that have an area of binning x binning pixels (default None)

mask_CXI_bitmask (bool):
 

If True the provided mask (mask_dataset or mask) is a CXI bitmask. For documentation on the implementation of CXI bitmasks see condor.utils.pixelmask.PixelMask (default False)

solid_angle_correction (bool):
 

Whether or not solid angle correction shall be applied (default True)

Choose one of the following options:

mask_CXI_bitmask valid pixels
False 1
True (pixels & condor.utils.pixelmask.PixelMask.PIXEL_IS_IN_MASK_DEFAULT) == 0

There are 3 alternative options to specify shape and mask of the detector

A) Parameters

nx (int):Number of pixels in x direction (not including a potential gap or hole) (default None)
ny (int):Number of pixels in y direction (not including a potential gap or hole) (default None)
x_gap_size_in_pixel (int):
 Size of central gap along x in unit pixel (default None)
y_gap_size_in_pixel (int):
 Size of central gap along y in unit pixel (default None)
hole_diameter_in_pixel (int):
 Diameter of central hole in unit pixel (default None)

B) HDF5 dataset for mask

mask_filename (str):
 Location of HDF5 file that contains dataset for mask (default None)
mask_dataset (str):
 HDF5 dataset (in the file specified by the argument mask_filename) that contains the mask data. Toggle the option mask_CXI_bitmask for decoding options (default None)

C) Numpy array for mask

mask (array):2D numpy integer array that defines the mask. Toggle mask_CXI_bitmask for decoding options (default None)
bin_photons(I_det, M_det)[source]

Return the tuple of binned diffraction pattern and mask. If binning has not been specified a tuple (None, None) is returned

Args:
I_det (array):Intensity pattern (before binning) represented by a 2D array
M_det (array):CXI bitmask (before binning) represented by a 2D array (see also condor.utils.pixelmask.PixelMask)
calculate_polarization_factors(cx=None, cy=None, polarization='ignore')[source]
detect_photons(I)[source]

Return measurement of intensities from an array of expectation values of intensities. This method also returns the mask of the pattern

Args:
I (array):Intensity pattern represented as 2D array
generate_qmap(wavelength, cx=None, cy=None, extrinsic_rotation=None, order='xyz')[source]
generate_qmap_3d(wavelength, qn=None, qmax=None, extrinsic_rotation=None, order='xyz')[source]
generate_xypix(cx=None, cy=None)[source]
get_all_pixel_solid_angles(cx, cy)[source]

Return the solid angles of all detector pixels assuming a beam center at position (cx, cy).

Args:
cx (float):x-coordinate of the center position in unit pixel
cy (float):y-coordinate of the center position in unit pixel
get_conf()[source]

Get configuration in form of a dictionary. Another identically configured Detector instance can be initialised by:

conf = D0.get_conf()         # D0: already existing Detector instance
D1 = condor.Detector(**conf) # D1: new Detector instance with the same configuration as D0  
get_cx_mean_value()[source]

Return x-coordinate of the mean beam center position

get_cy_mean_value()[source]

Return y-coordinate of the mean beam center position

get_mask(intensities=None, boolmask=False)[source]

Return mask. The mask has information about the status of each individual detector pixel. The output can be either a CXI bitmask (default) or a boolean mask

For further information and the full bitcode go to condor.utils.pixelmask.PixelMask

Kwargs:
intensities:Numpy array of photon intensities for masking saturated pixels (default None)
boolmask (bool):
 If True the output will be a boolean array. Mask values are converted to True if no bit is set and to False otherwise
get_max_resolution(wavelength, cx=None, cy=None, center_variation=False)[source]

Return maximum resolution as a 3D vector (i.e. maximum resolution / momentum transfer in x, y and z)

Args:
wavelength (float):
 Photon wavelength in meters
Kwargs:
cx (float):x-coordinate of the center position in unit pixel (default None)
cy (float):y-coordinate of the center position in unit pixel (default None)
center_variation (bool):
 If True the beam center variation is taken into account. With respect to the mean position a maximum deviation of factor/2 times the variational spread is assumed. The factor is 3 for Gaussian distributed centers and 1 for others (default False)
get_next()[source]

Iterate the parameters of the Detector instance and return them as a dictionary

get_p_max_dist(cx=None, cy=None, pos='corner', center_variation=False)[source]

Return 3D position vector of the pixel furthest away from the beam center. If each of the given center position coordinates (cx, cy) is None the beam center is assumed to be located at its mean position

Kwargs:
cx (float):x-coordinate of the center position in unit pixel (default None)
cy (float):y-coordinate of the center position in unit pixel (default None)
pos (str):Position constraint can be either pos='corner' or pos='edge'. (default 'corner')
center_variation (bool):
 If True the beam center variation is taken into account. With respect to the mean position a maximum deviation of factor/2 times the variational spread is assumed. The factor is 3 for Gaussian distributed centers and 1 for others (default False)
get_pixel_solid_angle(x_off=0.0, y_off=0.0)[source]

Get the solid angle for a pixel at position x_off, y_off with respect to the beam center

Kwargs:
x_off:x-coordinate of the pixel position (center) in unit pixel with respect to the beam center (default 0.)
y_off:y-coordinate of the pixel position (center) in unit pixel with respect to the beam center (default 0.)
get_q_max(wavelength, cx=None, cy=None, pos='corner', center_variation=False)[source]

Return q-vector of maximal lenght

Args:
wavelength (float):
 Photon wavelength in meters
Kwargs:
cx (float):x-coordinate of the center position in unit pixel (default None)
cy (float):y-coordinate of the center position in unit pixel (default None)
get_resolution_element_r(wavelength, cx=None, cy=None, center_variation=False)[source]

Return resolution at the furthes corner position in 1/meters

Args:
wavelength (float):
 Photon wavelength in meters
Kwargs:
cx (float):x-coordinate of the center position in unit pixel (default None)
cy (float):y-coordinate of the center position in unit pixel (default None)
center_variation (bool):
 If True the beam center variation is taken into account. With respect to the mean position a maximum deviation of factor/2 times the variational spread is assumed. The factor is 3 for Gaussian distributed centers and 1 for others (default False)
get_resolution_element_x(wavelength, cx=None, cy=None, center_variation=False)[source]

Return resolution in x in 1/meters

Args:
wavelength (float):
 Photon wavelength in meters
Kwargs:
cx (float):x-coordinate of the center position in unit pixel (default None)
cy (float):y-coordinate of the center position in unit pixel (default None)
center_variation (bool):
 If True the beam center variation is taken into account. With respect to the mean position a maximum deviation of factor/2 times the variational spread is assumed. The factor is 3 for Gaussian distributed centers and 1 for others (default False)
get_resolution_element_y(wavelength, cx=None, cy=None, center_variation=False)[source]

Return resolution in y in 1/meters

Args:
wavelength (float):
 Photon wavelength in meters
Kwargs:
cx (float):x-coordinate of the center position in unit pixel (default None)
cy (float):y-coordinate of the center position in unit pixel (default None)
center_variation (bool):
 If True the beam center variation is taken into account. With respect to the mean position a maximum deviation of factor/2 times the variational spread is assumed. The factor is 3 for Gaussian distributed centers and 1 for others (default False)
set_center_variation(center_variation=None, center_spread_x=None, center_spread_y=None, center_variation_n=None)[source]

Set the variation of the beam center position (this method is called during initialisation)

Kwargs:
center_variation(str):
 

Variation of the beam center position (default None)

Choose one of the following options:

center_variation Variation model
None No variation
'normal' Normal (Gaussian) random distribution
'uniform' Uniform random distribution
'range' Equispaced grid around mean center position
center_spread_x (float):
 

Width of the distribution of center position in x [pixel] (default None)

center_spread_y (float):
 

Width of the distribution of center position in y [pixel] (default None)

Note

The arguments center_spread_y and center_spread_x take effect only in combination with center_variation='normal', 'uniform' or 'range'

center_variation_n (int):
 

Number of samples within the specified range (default None)

Note

The argument center_variation_n takes effect only in combination with center_variation='range'

set_noise(noise=None, noise_spread=None, noise_variation_n=None, noise_filename=None, noise_dataset=None)[source]

Set detector noise type and parameters (this method is called during initialisation)

Kwargs:
noise (str):

Noise added to the predicted intensities (default None)

Choose one of the following options:

noise Noise model
None No noise
'poisson' Poisson noise (shot noise)
'normal' Normal (Gaussian) noise
'uniform' Uniformly distributed values within spread limits
'normal_poisson' Normal (Gaussian) noise on top of Poisson noise (shot noise)
'file' Noise data from file
'file_poisson' Noise data from file on top of Poisson noise (shot noise)
noise_spread (float):
 

Width (full width at half maximum) of the Gaussian or uniform noise distribution (default None)

Note

The argument noise_spread takes only effect in combination with noise='normal', 'uniform' or 'normal_poisson'

noise_filename (str):
 

Location of the HDF5 file that contains the noise data (default None)

noise_dataset (str):
 

HDF5 dataset (in the file specified by the argument noise_filename) that contains the noise data (default None)

Note

The arguments noise_filename and noise_dataset takes effect only in combination with noise='file' or 'file_poisson'

condor.particle module

Module contents