oap_model.psd module
- class oap_model.psd.CompositePSD(psds: list[oap_model.psd.PSD], bins: list[float] = None)[source]
Bases:
PSDA composite particle size distribution object.
Contains the distribution parameters, and binning information.
- Parameters
psds (list[PSD]) – The list of PSDs to combine.
bins (np.ndarray, optional) – The bin edges in metres. Defaults to 100 bins between \(1 imes10^{-7}\) and \(1 imes10^{-7}\).
- dn_dd(d: Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]) ndarray[source]
Calculate the particle size distribution value given diameters.
- generate_diameters(n_particles) tuple[list[float], list[oap_model.ast_model.ASTModel]][source]
Generate a particle diameter from the PSD.
- class oap_model.psd.CrystalModel(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
EnumEnum for crystal types.
- COL_AR5_ROT = 4
- RECT_AR5 = 2
- RECT_AR5_ROT = 5
- ROS_6 = 3
- SPHERE = 1
- class oap_model.psd.GammaPSD(intercept: float, slope: float, shape: float, bins: list[float] = None, model: CrystalModel = CrystalModel.SPHERE)[source]
Bases:
PSDGamma particle size distribution object.
Contains the distribution parameters, and binning information.
\[n_N(r) = N_0 \left(\frac{r}{\text{1 m}}\right)^\mu \mathrm{e}^{-\Lambda r}.\]- Parameters
intercept (float) – \(N_0\) in \(\mathrm{m^{-3}}\).
slope (float) – \(\Lambda\) in \(\mathrm{m^{-1}}\).
shape (float) – \(\mu\).
bins (np.ndarray, optional) – The bin edges in metres. Defaults to 100 bins between \(1\times10^{-7}\) and \(1\times10^{-7}\).
- dn_dd(d: Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]) ndarray[source]
Calculate the particle size distribution value given diameters.
- classmethod from_concentration(number_concentration, slope, shape, **kwargs)[source]
Calculate the number density per field.
- Parameters
number_concentration (float) – The number concentration in \(\mathrm{m^{-3}}\).
slope (float) – \(\Lambda\) in \(\mathrm{m^{-1}}\).
shape (float) – \(\mu\).
- Returns
The number density per field.
- Return type
float
- classmethod from_litres_microns(intercept_per_litre_per_micron, slope_per_micron, shape, **kwargs)[source]
- classmethod from_mean_variance(number_concentration, mean, variance, **kwargs)[source]
Create a GammaPSD object from the mean and variance of the particle diameter.
- property mean
Calculate the mean particle diameter.
- property variance
Calculate the variance of the particle diameter.
- class oap_model.psd.OSheaGammaPSD(intercept: float, slope: float, shape: float, bins: list[float] = None, model: CrystalModel = CrystalModel.SPHERE)[source]
Bases:
GammaPSD
- class oap_model.psd.PSD(bins: list[float] = None, model: CrystalModel = CrystalModel.SPHERE)[source]
Bases:
ABCBase class for particle size distribution objects.
- property binned_distribution
Calculate the binned particle size distribution.
- Returns
The number of particles in each bin.
- Return type
np.ndarray
- abstract dn_dd(d: Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]]) ndarray[source]
Calculate the particle size distribution value given diameters.
- generate_diameters(n_particles) tuple[list[float], list[oap_model.ast_model.ASTModel]][source]
Generate a particle diameter from the PSD.
- property max_dn_dd
Calculate the maximum value of the particle size distribution.
- property midpoints
Calculate the binned particle size distribution.
- Returns
The number of particles in each bin.
- Return type
np.ndarray
- property total_number_density: float
Calculate the total number density of particles.
- class oap_model.psd.Particle(diameter, angle, model)
Bases:
tuple- angle
Alias for field number 1
- diameter
Alias for field number 0
- model
Alias for field number 2
- class oap_model.psd.PositionedParticle(diameter, angle, model, position)
Bases:
tuple- angle
Alias for field number 1
- diameter
Alias for field number 0
- model
Alias for field number 2
- position
Alias for field number 3
- class oap_model.psd.SamplingModel(psd: GammaPSD, z_dist: callable = None, inlet_length: float = 0.00735)[source]
Bases:
objectParticle size distribution model.
A modelling class that contains a PSD object, and simulates particle measurement from it. Particles are assumed to be distributed uniformly across the inlet. Particle size is assumed to be independent of position along the inlet.
- Parameters
psd (PSD) – The particle size distribution function, dN/dr in \(\mathrm{m^{-3}}\).
z_dist (callable, optional, unimplimented) – The probability distribution of particles along the z-axis, normalised to 1 when integrated wrt z, in m^-1. Defaults to uniform across array.
inlet_length (float, optional) – The length of the inlet in metres.
- generate(n_particles: int) ndarray[source]
Generate a sample of particles from the PSD, at random z positions.
- Parameters
n_particles (int) – The number of particles to generate.
- Returns
The particles represented by tuples of (diameter, z).
- Return type
np.ndarray
- simulate_distribution(n_particles: int, single_particle: bool = False, keep_models=False) ndarray[source]
Simulate the observation of spherical particles.
Generates a sample of spherical particles and then simulates the observation of the particles by producing new AST models.
- Parameters
n_particles (int) – The number of particles to generate.
single_particle (bool, optional) – Whether to consider only the largest particle in each diffraction pattern. Defaults to False.
keep_models (bool, optional) – Whether to keep the AST models after simulation. Warning: this will use a lot of memory. Defaults to False.
- Returns
The measured particle diameters.
- Return type
np.ndarray
- simulate_distribution_from_scaling(n_particles: int, single_particle: bool = False, base_model: ASTModel = None, keep_models=False) ndarray[source]
Simulate the observation of similar particles.
Generates a sample of particles, produces new AST models by scaling a base model, and then simulates the observation of the particles.
- Parameters
n_particles (int) – The number of particles to generate.
single_particle (bool, optional) – Whether to consider only the largest particle in each diffraction pattern. Defaults to False.
base_model (ASTModel, optional) – The base model to scale. Should have a high resolution relative to typical particle sizes. Defaults to a 1000 nm diameter particle.
keep_models (bool, optional) – Whether to keep the AST models after simulation. Warning: this will use a lot of memory. Defaults to False.
- Returns
The measured particle diameters.
- Return type
np.ndarray
- class oap_model.psd.TwoMomentGammaPSD(m2, m3, bins: list[float] = None, model: CrystalModel = CrystalModel.SPHERE)[source]
Bases:
PSD- property characteristic_diameter
- oap_model.psd.rejection_sampler(p, xbounds, pmax)[source]
Returns a value sampled from a bounded probability distribution.
- Parameters
p (callable) – The probability distribution function.
xbounds (list) – The bounds of the distribution.
pmax (float) – The maximum value of the probability distribution.