condor.particle package¶
Submodules¶
condor.particle.particle_abstract module¶
-
class
condor.particle.particle_abstract.
AbstractContinuousParticle
(diameter, diameter_variation=None, diameter_spread=None, diameter_variation_n=None, rotation_values=None, rotation_formalism=None, rotation_mode='extrinsic', number=1.0, arrival='synchronised', position=None, position_variation=None, position_spread=None, position_variation_n=None, material_type='water', massdensity=None, atomic_composition=None, electron_density=None)[source]¶ Bases:
condor.particle.particle_abstract.AbstractParticle
Base class for derived particle classes that make use of the continuum approximation (density instead of discrete atoms)
- Args:
diameter (float): (Mean) particle diameter in unit meter - Kwargs:
diameter_variation (str): See condor.particle.particle_abstract.AbstractContinuousParticle.set_diameter_variation()
(defaultNone
)diameter_spread (float): See condor.particle.particle_abstract.AbstractContinuousParticle.set_diameter_variation()
(defaultNone
)diameter_variation_n (int): See condor.particle.particle_abstract.AbstractContinuousParticle.set_diameter_variation()
(defaultNone
)rotation_values (array): See condor.particle.particle_abstract.AbstractParticle.set_alignment()
(defaultNone
)rotation_formalism (str): See condor.particle.particle_abstract.AbstractParticle.set_alignment()
(defaultNone
)rotation_mode (str): See condor.particle.particle_abstract.AbstractParticle.set_alignment()
(defaultNone
)number (float): Expectation value for the number of particles in the interaction volume. (defaukt 1.
)arrival (str): Arrival of particles at the interaction volume can be either 'random'
or'synchronised'
. Ifsync
at every event the number of particles in the interaction volume equals the rounded value ofnumber
. If'random'
the number of particles is Poissonian andnumber
is the expectation value. (default'synchronised'
)position (array): See condor.particle.particle_abstract.AbstractParticle
(defaultNone
)position_variation (str): See condor.particle.particle_abstract.AbstractParticle.set_position_variation()
(defaultNone
)position_spread (float): See condor.particle.particle_abstract.AbstractParticle.set_position_variation()
(defaultNone
)position_variation_n (int): See condor.particle.particle_abstract.AbstractParticle.set_position_variation()
(defaultNone
)material_type (str): See condor.particle.particle_abstract.AbstractContinuousParticle.set_material()
(default'water'
)massdensity (float): See condor.particle.particle_abstract.AbstractContinuousParticle.set_material()
(defaultNone
)atomic_composition (dict): See condor.particle.particle_abstract.AbstractContinuousParticle.set_material()
(defaultNone
)electron_density (float): See condor.particle.particle_abstract.AbstractContinuousParticle.set_material()
(defaultNone
)
-
add_material
(material_type, massdensity, atomic_composition, electron_density)[source]¶ Initialise and add the AtomDensityMaterial / ElectronDensityMaterial class instance to the particle
- Args:
material_type (str): See condor.utils.material.AtomDensityMaterial
massdensity (float): See condor.utils.material.AtomDensityMaterial
atomic_composition (dict): See condor.utils.material.AtomDensityMaterial
electron_density (float): See condor.utils.material.ElectronDensityMaterial
-
set_diameter_variation
(diameter_variation, diameter_spread, diameter_variation_n)[source]¶ Set the variation scheme of the particle diameter
- Args:
diameter_variation (str): Variation of the particle diameter
Choose one of the following options:
diameter_variation
Type of variation None
No diameter variation 'normal'
Normal (Gaussian) variation 'uniform'
Uniformly distributed diameters within spread limits 'range'
Equidistant sequence of diameter_variation_n
diameter samples withindiameter_spread
diameter_spread (float): Statistical spread
diameter_variation_n (int): Number of particle-diameter samples within the specified range
Note
The argument
diameter_variation_n
takes effect only ifdiameter_variation='range'
-
set_material
(material_type, massdensity, atomic_composition, electron_density)[source]¶ Initialise and set the AtomDensityMaterial / ElectronDensityMaterial class instance of the particle
- Args:
material_type (str): See condor.utils.material.AtomDensityMaterial
massdensity (float): See condor.utils.material.AtomDensityMaterial
atomic_composition (dict): See condor.utils.material.AtomDensityMaterial
electron_density (float): See condor.utils.material.ElectronDensityMaterial
-
class
condor.particle.particle_abstract.
AbstractParticle
(rotation_values=None, rotation_formalism=None, rotation_mode='extrinsic', number=1.0, arrival='synchronised', position=None, position_variation=None, position_spread=None, position_variation_n=None)[source]¶ Base class for every derived particle class
- Kwargs:
rotation_values: See condor.particle.particle_abstract.AbstractParticle.set_alignment()
(defaultNone
)rotation_formalism (str): See condor.particle.particle_abstract.AbstractParticle.set_alignment()
(defaultNone
)rotation_mode (str): See condor.particle.particle_abstract.AbstractParticle.set_alignment()
(defaultNone
)number (float): Expectation value for the number of particles in the interaction volume. (defaukt 1.
)arrival (str): Arrival of particles at the interaction volume can be either 'random'
or'synchronised'
. Ifsync
at every event the number of particles in the interaction volume equals the rounded value ofnumber
. If'random'
the number of particles is Poissonian andnumber
is the expectation value. (default'synchronised'
)position: (Mean) position vector [x, y, z] of the particle. If set to None
the particle is placed at the origin (defaultNone
)position_variation (str): See condor.particle.particle_abstract.AbstractParticle.set_position_variation()
(defaultNone
)position_spread (float): See condor.particle.particle_abstract.AbstractParticle.set_position_variation()
(defaultNone
)position_variation_n (int): See condor.particle.particle_abstract.AbstractParticle.set_position_variation()
(defaultNone
)
-
get_current_rotation
()[source]¶ Return current orientation of the particle in form of an instance of
condor.utils.rotation.Rotation
-
set_alignment
(rotation_values, rotation_formalism, rotation_mode)[source]¶ Set rotation scheme of the partice
- Args:
rotation_values: Array of rotation parameters. For simulating patterns of many shots this can be also a sequence of rotation parameters. Input None
for no rotation and for random rotation formalisms. For more documentation seecondor.utils.rotation.Rotations
(defaultNone
)rotation_mode (str): If the rotation shall be assigned to the particle choose 'extrinsic'
. Choose'intrinsic'
if the coordinate system shall be rotated (default'extrinsic'
)
-
set_position_variation
(position_variation, position_spread, position_variation_n)[source]¶ Set position variation scheme
- Args:
position_variation (str): Statistical variation of the particle position (default
None
)Choose one of the following options:
position_variation
Type of variation None
No positional variation 'normal'
Normal (Gaussian) variation 'uniform'
Uniformly distributed positions within spread limits 'range'
Equidistant sequence of position_variation_n
position samples withinposition_spread
position_spread (float): Statistical spread of the particle position
position_variation_n (int): Number of position samples within the specified range in each dimension
Note
The argument
position_variation_n
takes effect only in combination withposition_variation='range'
condor.particle.particle_map module¶
-
class
condor.particle.particle_map.
ParticleMap
(geometry, diameter=None, diameter_variation=None, diameter_spread=None, diameter_variation_n=None, dx=None, map3d=None, map3d_filename=None, map3d_dataset=None, emd_id=None, rotation_values=None, rotation_formalism=None, rotation_mode='extrinsic', flattening=0.75, number=1.0, arrival='synchronised', position=None, position_variation=None, position_spread=None, position_variation_n=None, material_type=None, massdensity=None, atomic_composition=None, electron_density=None)[source]¶ Bases:
condor.particle.particle_abstract.AbstractContinuousParticle
Class for a particle model
Model: Refractive index map sampled on a cubic grid (continuum approximation)
- Args:
geometry (str): Geometry type
Choose one of the following options:
'custom'
- provide map either with an HDF5 file (map3d_filename
,map3d_dataset
) or with a numpy array (map3d
)'icosahedron'
- create map of a uniformly filled icosahedron'cube'
- create map of a uniformly filled cube'sphere'
- create map of a uniformly filled sphere'spheroid'
- create map of a uniformly filled spheroid
diameter (float): Particle diameter (not map diameter)
- Kwargs:
diameter_variation (str): See condor.particle.particle_abstract.AbstractContinuousParticle.set_diameter_variation()
(defaultNone
)diameter_spread (float): See condor.particle.particle_abstract.AbstractContinuousParticle.set_diameter_variation()
(defaultNone
)diameter_variation_n (int): See condor.particle.particle_abstract.AbstractContinuousParticle.set_diameter_variation()
(defaultNone
)dx: Distance between grid points of the map. This needs to be specified only if geometry=`\custom''. Depending on whether the geometry is specified by file (``map3d_filename
,map3d_dataset
) or by numpy array (map3d
) for more documentation seeset_custom_geometry_by_h5file()
orset_custom_geometry_by_array()
respectively (defaultNone
)map3d: See set_custom_geometry_by_array()
(defaultNone
)map3d_filename: See set_custom_geometry_by_h5file()
(defaultNone
)map3d_dataset: See set_custom_geometry_by_h5file()
(defaultNone
)emd_id: See set_custom_geometry_by_emd_id()
(defaultNone
)rotation_values (array): See condor.particle.particle_abstract.AbstractParticle.set_alignment()
(defaultNone
)rotation_formalism (str): See condor.particle.particle_abstract.AbstractParticle.set_alignment()
(defaultNone
)rotation_mode (str): See condor.particle.particle_abstract.AbstractParticle.set_alignment()
(defaultNone
)flattening (float): (Mean) value of \(a/c\), takes only effect if geometry='spheroid'
(default0.75
)number (float): Expectation value for the number of particles in the interaction volume. (defaukt 1.
)arrival (str): Arrival of particles at the interaction volume can be either 'random'
or'synchronised'
. Ifsync
at every event the number of particles in the interaction volume equals the rounded value ofnumber
. If'random'
the number of particles is Poissonian andnumber
is the expectation value. (default'synchronised'
)position (array): See condor.particle.particle_abstract.AbstractParticle
(defaultNone
)position_variation (str): See condor.particle.particle_abstract.AbstractParticle.set_position_variation()
(defaultNone
)position_spread (float): See condor.particle.particle_abstract.AbstractParticle.set_position_variation()
(defaultNone
)position_variation_n (int): See condor.particle.particle_abstract.AbstractParticle.set_position_variation()
(defaultNone
)material_type (str): See condor.particle.particle_abstract.AbstractContinuousParticle.set_material()
(default'water'
)massdensity (float): See condor.particle.particle_abstract.AbstractContinuousParticle.set_material()
(defaultNone
)atomic_composition (dict): See condor.particle.particle_abstract.AbstractContinuousParticle.set_material()
(defaultNone
)electron_density (float): See condor.particle.particle_abstract.AbstractContinuousParticle.set_material()
(defaultNone
)
-
get_conf
()[source]¶ Get configuration in form of a dictionary. Another identically configured ParticleMap instance can be initialised by:
conf = P0.get_conf() # P0: already existing ParticleMap instance P1 = condor.ParticleMap(**conf) # P1: new ParticleMap instance with the same configuration as P0
-
get_new_dn_map
(O, dx_required, dx_suggested, photon_wavelength)[source]¶ Return the a new refractive index map
Args:
O (dict): Parameter dictionary as returned from condor.particle.particle_map.get_next()
dx_required (float): Required resolution (grid spacing) of the map. An error is raised if the resolution of the map has too low resolution dx_suggested (float): Suggested resolution (grid spacing) of the map. If the map has a very high resolution it will be interpolated to a the suggested resolution value photon_wavelength (float): Photon wavelength in unit meter
-
get_new_map
(O, dx_required, dx_suggested)[source]¶ Return new map with given parameters
Args:
O (dict): Parameter dictionary as returned from condor.particle.particle_map.get_next()
dx_required (float): Required resolution (grid spacing) of the map. An error is raised if the resolution of the map has too low resolution dx_suggested (float): Suggested resolution (grid spacing) of the map. If the map has a very high resolution it will be interpolated to a the suggested resolution value
-
set_custom_geometry_by_array
(map3d, dx)[source]¶ Set map from numpy array
- Args:
map3d (array): 4D numpy array (material index, z, y, x) of float values. If a material is defined (material not None
) the values of the map scale the complex refractive index of the material. If no material is defined (materials isNone
) the map will be casted to complex values and used without any rescaling.dx (float): Grid spacing in unit meter
-
set_custom_geometry_by_emd_id
(emd_id, offset=None, factor=None)[source]¶ Fetch map from the EMD by id code.
The map will be preprocessed by applying an offset and rescaling and by padding the water background with zeros.
Finally, the avereage value of the map will be rescaled by the refractive index of the associated material.
- Args:
emd_id (str): EMD ID code. offset (float): Offset value of the map (MAP = (EM_DATA + OFFSET) X FACTOR) factor (float): Rescale factor of the map (MAP = (EM_DATA + OFFSET) X FACTOR)
-
set_custom_geometry_by_h5file
(map3d_filename, map3d_dataset, dx)[source]¶ Load map from dataset in HDF5 file
If a material is defined (
material_type
is notNone
) the absolute values of the map will be rescaled by the complex refractive index of the material. If no material is defined (material_type=None
) the map will be casted to complex values and used without any rescaling.- Args:
map3d_filename (str): Location of the HDF5 file that contains the map data map3d_dataset (str): Dataset location in the file. The dataset must have three equal dimensions of float values. dx: Grid spacing in unit meter
-
set_custom_geometry_by_mrcfile
(filename, offset=None, factor=None)[source]¶ Read map from the MRC file (CCP4 file format, see http://www.ccp4.ac.uk/html/maplib.html).
The map will be preprocessed by applying an offset and rescaling and by padding the water background with zeros.
Finally, the avereage value of the map will be rescaled by the refractive index of the associated material.
- Args:
filename (str): Filename of MRC file. offset (float): Offset value of the map (MAP = (EM_DATA + OFFSET) X FACTOR) factor (float): Rescale factor of the map (MAP = (EM_DATA + OFFSET) X FACTOR)
condor.particle.particle_atoms module¶
-
class
condor.particle.particle_atoms.
ParticleAtoms
(pdb_filename=None, pdb_id=None, atomic_numbers=None, atomic_positions=None, rotation_values=None, rotation_formalism=None, rotation_mode='extrinsic', number=1.0, arrival='synchronised', position=None, position_variation=None, position_spread=None, position_variation_n=None)[source]¶ Bases:
condor.particle.particle_abstract.AbstractParticle
Class for a particle model
Model: Discrete atomic positions
- Kwargs:
pdb_filename (str): See set_atoms_from_pdb_file()
(defaultNone
)pdb_id (str): See set_atoms_from_pdb_id()
(defaultNone
)atomic_numbers (array): See set_atoms_from_arrays()
(defaultNone
)atomic_positions (array): See set_atoms_from_arrays()
(defaultNone
)Note
The atomic positions have to be specified either by a
pdb_filename
or byatomic_numbers
andatomic_positions
.rotation_values (array): See condor.particle.particle_abstract.AbstractParticle.set_alignment()
(defaultNone
)rotation_formalism (str): See condor.particle.particle_abstract.AbstractParticle.set_alignment()
(defaultNone
)rotation_mode (str): See condor.particle.particle_abstract.AbstractParticle.set_alignment()
(defaultNone
)number (float): Expectation value for the number of particles in the interaction volume. (defaukt 1.
)arrival (str): Arrival of particles at the interaction volume can be either 'random'
or'synchronised'
. Ifsync
at every event the number of particles in the interaction volume equals the rounded value ofnumber
. If'random'
the number of particles is Poissonian andnumber
is the expectation value. (default'synchronised'
)position (array): See condor.particle.particle_abstract.AbstractParticle
(defaultNone
)position_variation (str): See condor.particle.particle_abstract.AbstractParticle.set_position_variation()
(defaultNone
)position_spread (float): See condor.particle.particle_abstract.AbstractParticle.set_position_variation()
(defaultNone
)position_variation_n (int): See condor.particle.particle_abstract.AbstractParticle.set_position_variation()
(defaultNone
)
-
diameter_mean
¶ Return the two times the radius of gyration as an estimate for the extent (diameter) of the atomic structure
-
get_atomic_standard_weights
()[source]¶ Return the atomic standard weights in unified atomic mass unit (u)
-
get_center_of_mass
()[source]¶ Return the position of the center of mass \(\vec{r}_{\text{COM}}\)
Atomic structure of \(N\) atoms with masses \(m_i\) at the positions \(\vec{r}_i\)
\(\vec{r}_{\text{COM}} = \frac{\sum_{i=0}^N{m_i \, \vec{r}_i}}{\sum_{i=0}^N{m_i}}\)
-
get_conf
()[source]¶ Get configuration in form of a dictionary. Another identically configured ParticleAtoms instance can be initialised by:
conf = P0.get_conf() # P0: already existing ParticleAtoms instance P1 = condor.ParticleAtoms(**conf) # P1: new ParticleMolcule instance with the same configuration as P0
-
get_radius_of_gyration
()[source]¶ Return the radius of gyration \(R_g\)
Atomic structure of \(N\) atoms with masses \(m_i\) at the positions \(\vec{r}_i\)
\(R_g = \fract{ \sqrt{ \sum_{i=0}^N{ \vec{r}_i-\vec{r}_{\text{COM}} } } }{ \sum_{i=0}^N{ m_i }}\)
-
set_atoms_from_arrays
(atomic_numbers, atomic_positions)[source]¶ Specify atomic positions from atomic numbers and atomic positions
- Args:
atomic_numbers (array): Integer array of atomic numbers specifies the element species of each atom. Array shape: (\(N\),) with \(N\) denoting the number of atoms. atomic_position (array): Float array of atomic positions [\(x\), \(y\), \(z\)] in unit meter. Array shape: (\(N\), 3,) with \(N\) denoting the number of atoms
condor.particle.particle_sphere module¶
-
class
condor.particle.particle_sphere.
ParticleSphere
(diameter, diameter_variation=None, diameter_spread=None, diameter_variation_n=None, number=1.0, arrival='synchronised', position=None, position_variation=None, position_spread=None, position_variation_n=None, material_type=None, massdensity=None, atomic_composition=None, electron_density=None)[source]¶ Bases:
condor.particle.particle_abstract.AbstractContinuousParticle
Class for a particle model
Model: Uniformly filled spherical particle (continuum approximation)
- Args:
diameter (float): Sphere diameter - Kwargs:
diameter_variation (str): See condor.particle.particle_abstract.AbstractContinuousParticle.set_diameter_variation()
(defaultNone
)diameter_spread (float): See condor.particle.particle_abstract.AbstractContinuousParticle.set_diameter_variation()
(defaultNone
)diameter_variation_n (int): See condor.particle.particle_abstract.AbstractContinuousParticle.set_diameter_variation()
(defaultNone
)rotation_values (array): See condor.particle.particle_abstract.AbstractParticle.set_alignment()
(defaultNone
)rotation_formalism (str): See condor.particle.particle_abstract.AbstractParticle.set_alignment()
(defaultNone
)rotation_mode (str): See condor.particle.particle_abstract.AbstractParticle.set_alignment()
(defaultNone
)number (float): Expectation value for the number of particles in the interaction volume. (defaukt 1.
)arrival (str): Arrival of particles at the interaction volume can be either 'random'
or'synchronised'
. Ifsync
at every event the number of particles in the interaction volume equals the rounded value ofnumber
. If'random'
the number of particles is Poissonian andnumber
is the expectation value. (default'synchronised'
)position (array): See condor.particle.particle_abstract.AbstractParticle
(defaultNone
)position_variation (str): See condor.particle.particle_abstract.AbstractParticle.set_position_variation()
(defaultNone
)position_spread (float): See condor.particle.particle_abstract.AbstractParticle.set_position_variation()
(defaultNone
)position_variation_n (int): See condor.particle.particle_abstract.AbstractParticle.set_position_variation()
(defaultNone
)material_type (str): See condor.particle.particle_abstract.AbstractContinuousParticle.set_material()
(default'water'
)massdensity (float): See condor.particle.particle_abstract.AbstractContinuousParticle.set_material()
(defaultNone
)atomic_composition (dict): See condor.particle.particle_abstract.AbstractContinuousParticle.set_material()
(defaultNone
)electron_density (float): See condor.particle.particle_abstract.AbstractContinuousParticle.set_material()
(defaultNone
)
-
get_conf
(sef)[source]¶ Get configuration in form of a dictionary. Another identically configured ParticleMap instance can be initialised by:
conf = P0.get_conf() # P0: already existing ParticleSphere instance P1 = condor.ParticleSpheroid(**conf) # P1: new ParticleSphere instance with the same configuration as P0
condor.particle.particle_spheroid module¶
-
class
condor.particle.particle_spheroid.
ParticleSpheroid
(diameter, diameter_variation=None, diameter_spread=None, diameter_variation_n=None, flattening=0.75, flattening_variation=None, flattening_spread=None, flattening_variation_n=None, rotation_values=None, rotation_formalism=None, rotation_mode='extrinsic', number=1.0, arrival='synchronised', position=None, position_variation=None, position_spread=None, position_variation_n=None, material_type='water', massdensity=None, atomic_composition=None, electron_density=None)[source]¶ Bases:
condor.particle.particle_abstract.AbstractContinuousParticle
Class for a particle model
Model: Uniformly filled spheroid particle (continuum approximation)
\(a\): radius (semi-diameter) perpendicular to the rotation axis of the ellipsoid \(c\): radius (semi-diameter) along the rotation axis of the ellipsoid
Before applying rotations the rotation axis is parallel to the the y-axis
- Args:
diameter (float): Sphere diameter - Kwargs:
diameter_variation (str): See condor.particle.particle_abstract.AbstractContinuousParticle.set_diameter_variation()
(defaultNone
)diameter_spread (float): See condor.particle.particle_abstract.AbstractContinuousParticle.set_diameter_variation()
(defaultNone
)diameter_variation_n (int): See condor.particle.particle_abstract.AbstractContinuousParticle.set_diameter_variation()
(defaultNone
)flattening (float): (Mean) value of \(a/c\) (default 0.75
)flattening_variation (str): See condor.particle.particle_spheroid.set_flattening_variation()
(defaultNone
)flattening_spread (float): See condor.particle.particle_spheroid.set_flattening_variation()
(defaultNone
)flattening_variation_n (int): See condor.particle.particle_spheroid.set_flattening_variation()
(defaultNone
)rotation_values (array): See condor.particle.particle_abstract.AbstractParticle.set_alignment()
(defaultNone
)rotation_formalism (str): See condor.particle.particle_abstract.AbstractParticle.set_alignment()
(defaultNone
)rotation_mode (str): See condor.particle.particle_abstract.AbstractParticle.set_alignment()
(defaultNone
)number (float): Expectation value for the number of particles in the interaction volume. (defaukt 1.
)arrival (str): Arrival of particles at the interaction volume can be either 'random'
or'synchronised'
. Ifsync
at every event the number of particles in the interaction volume equals the rounded value ofnumber
. If'random'
the number of particles is Poissonian andnumber
is the expectation value. (default'synchronised'
)position (array): See condor.particle.particle_abstract.AbstractParticle
(defaultNone
)position_variation (str): See condor.particle.particle_abstract.AbstractParticle.set_position_variation()
(defaultNone
)position_spread (float): See condor.particle.particle_abstract.AbstractParticle.set_position_variation()
(defaultNone
)position_variation_n (int): See condor.particle.particle_abstract.AbstractParticle.set_position_variation()
(defaultNone
)material_type (str): See condor.particle.particle_abstract.AbstractContinuousParticle.set_material()
(default'water'
)massdensity (float): See condor.particle.particle_abstract.AbstractContinuousParticle.set_material()
(defaultNone
)atomic_composition (dict): See condor.particle.particle_abstract.AbstractContinuousParticle.set_material()
(defaultNone
)electron_density (float): See condor.particle.particle_abstract.AbstractContinuousParticle.set_material()
(defaultNone
)
-
get_conf
()[source]¶ Get configuration in form of a dictionary. Another identically configured ParticleMap instance can be initialised by:
conf = P0.get_conf() # P0: already existing ParticleSpheroid instance P1 = condor.ParticleSpheroid(**conf) # P1: new ParticleSpheroid instance with the same configuration as P0
-
set_flattening_variation
(flattening_variation, flattening_spread, flattening_variation_n)[source]¶ Set the variation scheme of the flattening parameter
- Args:
flattening_variation (str): Variation of the particle flattening
Choose one of the following options:
None
- No variation'normal'
- Normal (Gaussian) variation'uniform'
- Uniformly distributed flattenings'range'
- Equidistant sequence of particle-flattening samples within the spread limits.flattening_variation_n
defines the number of samples within the range
flattening_spread (float): Statistical spread of the parameter
flattening_variation_n (int): Number of particle-flattening samples within the specified range
Note
The argument
flattening_variation_n
takes effect only ifflattening_variation='range'