pompy.processors module

Helper classes to process outputs of models.

class pompy.processors.ConcentrationValueCalculator(puff_molecular_amount)[source]

Calculates odour concentration values in simulation region.

__init__(puff_molecular_amount)[source]
Parameters:puff_molecular_amount (float) – Molecular content of each puff (e.g. in moles or raw number of molecules). This is conserved as the puff is transported within the plume but the puff becomes increasingly diffuse as it’s radius grows due to diffusion.
calc_conc_point(puff_array, x, y, z=0)[source]

Calculate concentration at a single point.

Parameters:
  • puff_array (array) – 2D array of puff properties of shape (n_puffs, 4) with n_puffs being the number of puffs and the four columns of the array corresponding in order to the puff x-coordinates, y-coordinates, z-coordinates and squared radii.
  • x (float) – x-coordinate of point.
  • y (float) – y-coordinate of point.
  • z (float) – z-coordinate of point.
calc_conc_list(puff_array, x, y, z=0)[source]

Calculate concentrations across a 1D list of points in a xy-plane.

Parameters:
  • puff_array (array) – 2D array of puff properties of shape (n_puffs, 4) with n_puffs being the number of puffs and the four columns of the array corresponding in order to the puff x-coordinates, y-coordinates, z-coordinates and squared radii.
  • x (array) – 1D array of x-coordinates of points.
  • y (array) – 1D array of y-coordinates of points.
  • z (float) – z-coordinate (height) of plane.
calc_conc_grid(puff_array, x, y, z=0)[source]

Calculate concentrations across a 2D grid of points in a xy-plane.

Parameters:
  • puff_array (array) – 2D array of puff properties of shape (n_puffs, 4) with n_puffs being the number of puffs and the four columns of the array corresponding in order to the puff x-coordinates, y-coordinates, z-coordinates and squared radii.
  • x (array) – 2D array of x-coordinates of grid points.
  • y (array) – 2D array of y-coordinates of grid points.
  • z (float) – z-coordinate (height) of grid plane.
class pompy.processors.ConcentrationArrayGenerator(array_xy_region, array_z, n_x, n_y, puff_mol_amount, kernel_rad_mult=3)[source]

Produces odour concentration field arrays from puff property arrays.

Instances of this class can take single or multiple arrays of puff properties outputted from a PlumeModel and process them to produce an array of the concentration values across the a specified region using a Gaussian model for the individual puff concentration distributions.

Compared to the ConcentrationValueCalculator class, this class should be more efficient for calculating large concentration field arrays for real-time graphical display of odour concentration fields for example at the expense of less accurate values due to the truncation of spatial extent of each puff.

Notes

The returned array values correspond to the point concentration measurements across a regular grid of sampling points - i.e. the equivalent to convolving the true continuous concentration distribution with a regular 2D grid of Dirac delta / impulse functions. An improvement in some ways would be to instead calculate the integral of the concentration distribution over the (square) region around each grid point however this would be extremely computationally costly and due to the lack of a closed form solution for the integral of a Gaussian also potentially difficult to implement without introducing other numerical errors. An integrated field can be approximated with this class by generating an array at a higher resolution than required and then filtering with a suitable kernel and down-sampling.

This implementation estimates the concentration distribution puff kernels with sub-grid resolution, giving improved accuracy at the cost of increased computational cost versus using a precomputed radial field aligned with the grid to compute kernel values or using a library of precomputed kernels.

For cases where the array region cover the whole simulation region the computational cost could also be reduced by increasing the size of the region the array corresponds to outside of the simulation region such that when adding the puff concentration kernels to the concentration field array, checks do not need to be made to restrict to the overlapping region for puffs near the edges of the simulation region which have a concentration distribution which extends beyond its extents.

__init__(array_xy_region, array_z, n_x, n_y, puff_mol_amount, kernel_rad_mult=3)[source]
Parameters:
  • array_region (Rectangle) – Two-dimensional rectangular region defined in world coordinates over which to calculate the concentration field.
  • array_z (float) – Height on the vertical z-axis at which to calculate the concentration field over.
  • n_x (integer) – Number of grid points to sample at across x-dimension.
  • n_y (integer) – Number of grid points to sample at across y-dimension.
  • puff_mol_amount (float) – Molecular content of each puff (e.g. in moles or raw number of molecules). This is conserved as the puff is transported within the plume but the puff becomes increasingly diffuse as its radius grows due to diffusion. (dimensionality:molecular amount)
  • kernel_rad_mult (float) – Multiplier used to determine to within how many puff radii from the puff centre to truncate the concentration distribution kernel calculated to. The default value of 3 will truncate the Gaussian kernel at (or above) the point at which the concentration has dropped to 0.004 of the peak value at the puff centre.
generate_single_array(puff_array)[source]

Generates a single concentration field array from a puff array.

Parameters:puff_array (array) – 2D array of puff properties of shape (n_puffs, 4) with n_puffs being the number of puffs and the four columns of the array corresponding in order to the puff x-coordinates, y-coordinates, z-coordinates and squared radii.
Returns:conc_array – 2D array of shape (n_x, n_y) containing concentration field values at specified grid points.
Return type:array
generate_multiple_arrays(puff_arrays)[source]

Generates multiple concentration field arrays from puff arrays.

Parameters:puff_arrays (array iterable) – Iterable sequence of 2D arrays of puff properties, with each array of shape (n_puffs, 4) with n_puffs being the number of puffs and the four columns of the array corresponding in order to the puff x-coordinates, y-coordinates, z-coordinates and squared radii.
Returns:conc_arrays – List of 2D arrays of shape (n_x, n_y) containing concentration field values at specified grid points, with each array in list corresponding to the puff properties array at the corresponding index in puff_arrays.
Return type:array iterable