In [13]:
%pylab inline
Populating the interactive namespace from numpy and matplotlib
In Condor the geometry of a spheroid is defined by two parameters: The average diameter $d$ and the flattening $f$. The average diameter can be understood as the diameter of a sphere of identical volume. The flattening $f$ is the ratio of the semi-axes $a$ and $c$, where $c$ is measured along the symmetry axis $z$.
For internal calculations in Condor the parameters $d$ and $f$ are translated into the semi-axes $a$ and $c$ for convenience:
In [1]:
import condor
In [8]:
S = condor.Source(wavelength=1.E-9, pulse_energy=1E-3, focus_diameter=1E-6)
P1 = condor.ParticleSpheroid(diameter=100E-9, flattening=0.5)
D = condor.Detector(nx=1000, ny=1000, distance=1., pixel_size=100E-6)
E = condor.Experiment(source=S, particles={"particle_spheroid": P}, detector=D)
In [9]:
res = E.propagate()
In [15]:
imshow(log10(res["entry_1"]["data_1"]["data"]))
Out[15]:
<matplotlib.image.AxesImage at 0x11c0e82d0>
In [16]:
help(condor.ParticleMap(geome))
Help on class ParticleMap in module condor.particle.particle_map:
class ParticleMap(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 :meth:`condor.particle.particle_abstract.AbstractContinuousParticle.set_diameter_variation` (default ``None``)
|
| :diameter_spread (float): See :meth:`condor.particle.particle_abstract.AbstractContinuousParticle.set_diameter_variation` (default ``None``)
|
| :diameter_variation_n (int): See :meth:`condor.particle.particle_abstract.AbstractContinuousParticle.set_diameter_variation` (default ``None``)
|
| :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 see :meth:`set_custom_geometry_by_h5file` or :meth:`set_custom_geometry_by_array` respectively (default ``None``)
|
| :map3d: See :meth:`set_custom_geometry_by_array` (default ``None``)
|
| :map3d_filename: See :meth:`set_custom_geometry_by_h5file` (default ``None``)
|
| :map3d_dataset: See :meth:`set_custom_geometry_by_h5file` (default ``None``)
|
| :emd_id: See :meth:`set_custom_geometry_by_emd_id` (default ``None``)
|
| :rotation_values (array): See :meth:`condor.particle.particle_abstract.AbstractParticle.set_alignment` (default ``None``)
|
| :rotation_formalism (str): See :meth:`condor.particle.particle_abstract.AbstractParticle.set_alignment` (default ``None``)
|
| :rotation_mode (str): See :meth:`condor.particle.particle_abstract.AbstractParticle.set_alignment` (default ``None``)
|
| :flattening (float): (Mean) value of :math:`a/c`, takes only effect if ``geometry='spheroid'`` (default ``0.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'``. If ``sync`` at every event the number of particles in the interaction volume equals the rounded value of ``number``. If ``'random'`` the number of particles is Poissonian and ``number`` is the expectation value. (default ``'synchronised'``)
|
| :position (array): See :class:`condor.particle.particle_abstract.AbstractParticle` (default ``None``)
|
| :position_variation (str): See :meth:`condor.particle.particle_abstract.AbstractParticle.set_position_variation` (default ``None``)
|
| :position_spread (float): See :meth:`condor.particle.particle_abstract.AbstractParticle.set_position_variation` (default ``None``)
|
| :position_variation_n (int): See :meth:`condor.particle.particle_abstract.AbstractParticle.set_position_variation` (default ``None``)
|
| :material_type (str): See :meth:`condor.particle.particle_abstract.AbstractContinuousParticle.set_material` (default ``'water'``)
|
| :massdensity (float): See :meth:`condor.particle.particle_abstract.AbstractContinuousParticle.set_material` (default ``None``)
|
| :atomic_composition (dict): See :meth:`condor.particle.particle_abstract.AbstractContinuousParticle.set_material` (default ``None``)
|
| :electron_density (float): See :meth:`condor.particle.particle_abstract.AbstractContinuousParticle.set_material` (default ``None``)
|
| Method resolution order:
| ParticleMap
| condor.particle.particle_abstract.AbstractContinuousParticle
| condor.particle.particle_abstract.AbstractParticle
|
| Methods defined here:
|
| __init__(self, 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)
|
| get_conf(self)
| Get configuration in form of a dictionary. Another identically configured ParticleMap instance can be initialised by:
|
| .. code-block:: python
|
| conf = P0.get_conf() # P0: already existing ParticleMap instance
| P1 = condor.ParticleMap(**conf) # P1: new ParticleMap instance with the same configuration as P0
|
| get_current_map(self)
| Return the current map
|
| get_new_dn_map(self, O, dx_required, dx_suggested, photon_wavelength)
| Return the a new refractive index map
|
| Args:
|
| :O (dict): Parameter dictionary as returned from :meth:`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(self, O, dx_required, dx_suggested)
| Return new map with given parameters
|
| Args:
|
| :O (dict): Parameter dictionary as returned from :meth:`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
|
| get_next(self)
| Iterate the parameters and return them as a dictionary
|
| get_original_map(self)
| Return the original map
|
| set_custom_geometry_by_array(self, map3d, dx)
| 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 is ``None``) 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(self, emd_id, offset=None, factor=None)
| 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(self, map3d_filename, map3d_dataset, dx)
| Load map from dataset in HDF5 file
|
| If a material is defined (``material_type`` is not ``None``) 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(self, filename, offset=None, factor=None)
| 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)
|
| ----------------------------------------------------------------------
| Methods inherited from condor.particle.particle_abstract.AbstractContinuousParticle:
|
| add_material(self, material_type, massdensity, atomic_composition, electron_density)
| Initialise and add the AtomDensityMaterial / ElectronDensityMaterial class instance to the particle
|
| Args:
| :material_type (str): See :class:`condor.utils.material.AtomDensityMaterial`
|
| :massdensity (float): See :class:`condor.utils.material.AtomDensityMaterial`
|
| :atomic_composition (dict): See :class:`condor.utils.material.AtomDensityMaterial`
|
| :electron_density (float): See :class:`condor.utils.material.ElectronDensityMaterial`
|
| set_diameter_variation(self, diameter_variation, diameter_spread, diameter_variation_n)
| 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 within ``diameter_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 if ``diameter_variation='range'``
|
| set_material(self, material_type, massdensity, atomic_composition, electron_density)
| Initialise and set the AtomDensityMaterial / ElectronDensityMaterial class instance of the particle
|
| Args:
| :material_type (str): See :class:`condor.utils.material.AtomDensityMaterial`
|
| :massdensity (float): See :class:`condor.utils.material.AtomDensityMaterial`
|
| :atomic_composition (dict): See :class:`condor.utils.material.AtomDensityMaterial`
|
| :electron_density (float): See :class:`condor.utils.material.ElectronDensityMaterial`
|
| ----------------------------------------------------------------------
| Methods inherited from condor.particle.particle_abstract.AbstractParticle:
|
| get_current_rotation(self)
| Return current orientation of the particle in form of an instance of :class:`condor.utils.rotation.Rotation`
|
| get_next_number_of_particles(self)
| Iterate the number of partices
|
| set_alignment(self, rotation_values, rotation_formalism, rotation_mode)
| 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 see :class:`condor.utils.rotation.Rotations` (default ``None``)
|
| :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(self, position_variation, position_spread, position_variation_n)
| 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 within ``position_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 with ``position_variation='range'``
In [ ]:
dx ©
condor.ParticleMap(geometry='custom', )
Content source: FXIhub/condor
Similar notebooks: