Interpolation

plonk.interpolate(*, snap, quantity, x='x', y='y', interp, weighted=False, slice_normal=None, slice_offset=None, extent, num_pixels=None)

Interpolate a quantity on the snapshot to a pixel grid.

Parameters
  • snap (SnapLike) – The Snap (or SubSnap) object.

  • quantity (str) – The quantity to visualize. Must be a string to pass to Snap,

  • x (str) – The x-coordinate for the visualization. Must be a string to pass to Snap. Default is ‘x’.

  • y (str) – The y-coordinate for the visualization. Must be a string to pass to Snap. Default is ‘y’.

  • interp (str) –

    The interpolation type. Default is ‘projection’.

    • ’projection’ : 2d interpolation via projection to xy-plane

    • ’slice’ : 3d interpolation via cross-section slice.

  • weighted (bool) – Use density weighted interpolation. Default is False.

  • slice_normal (Tuple[float, float, float]) – The normal vector to the plane in which to take the cross-section slice as an array (x, y, z).

  • slice_offset (Quantity) – The offset of the cross-section slice. Default is 0.0.

  • extent (Quantity) – The xy extent of the image as (xmin, xmax, ymin, ymax).

  • num_pixels (Tuple[float, float]) – The pixel grid to interpolate the scalar quantity to, as (npixx, npixy). Default is (512, 512).

Returns

The interpolated quantity on a pixel grid as a Pint Quantity. The shape for scalar data is (npixx, npixy), and for vector is (2, npixx, npixy).

Return type

Quantity

Examples

Interpolate density to grid.

>>> grid_data = plonk.interpolate(
...     snap=snap,
...     quantity='density',
...     interp='projection',
...     extent=(-100, 100, -100, 100),
... )
plonk.visualize.interpolation.scalar_interpolation(*, quantity, x_coordinate, y_coordinate, dist_from_slice=None, extent, smoothing_length, particle_mass, hfact, weighted=None, num_pixels=(512, 512))

Interpolate scalar quantity to a pixel grid.

Parameters
  • quantity (numpy.ndarray) – A scalar quantity on the particles to interpolate.

  • x_coordinate (numpy.ndarray) – Particle coordinate for x-axis in interpolation.

  • y_coordinate (numpy.ndarray) – Particle coordinate for y-axis in interpolation.

  • dist_from_slice (Optional[numpy.ndarray]) – The distance from the cross section slice. Only required for cross section interpolation.

  • extent (Tuple[float, float, float, float]) – The range in the x- and y-direction as (xmin, xmax, ymin, ymax).

  • smoothing_length (numpy.ndarray) – The smoothing length on each particle.

  • particle_mass (numpy.ndarray) – The particle mass on each particle.

  • hfact (float) – The smoothing length factor.

  • weighted (Optional[bool]) – Use density weighted interpolation. Default is off.

  • num_pixels (Tuple[float, float]) – The pixel grid to interpolate the scalar quantity to, as (npixx, npixy). Default is (512, 512).

Returns

An array of scalar quantities interpolated to a pixel grid with shape (npixx, npixy).

Return type

ndarray

plonk.visualize.interpolation.vector_interpolation(*, quantity_x, quantity_y, x_coordinate, y_coordinate, dist_from_slice=None, extent, smoothing_length, particle_mass, hfact, weighted=None, num_pixels=(512, 512))

Interpolate scalar quantity to a pixel grid.

Parameters
  • quantity_x (numpy.ndarray) – The x-component of a vector quantity to interpolate.

  • quantity_y (numpy.ndarray) – The y-component of a vector quantity to interpolate.

  • x_coordinate (numpy.ndarray) – Particle coordinate for x-axis in interpolation.

  • y_coordinate (numpy.ndarray) – Particle coordinate for y-axis in interpolation.

  • dist_from_slice (Optional[numpy.ndarray]) – The distance from the cross section slice. Only required for cross section interpolation.

  • extent (Tuple[float, float, float, float]) – The range in the x- and y-direction as (xmin, xmax, ymin, ymax).

  • smoothing_length (numpy.ndarray) – The smoothing length on each particle.

  • particle_mass (numpy.ndarray) – The particle mass on each particle.

  • hfact (float) – The smoothing length factor.

  • weighted (Optional[bool]) – Use density weighted interpolation. Default is off.

  • num_pixels (Tuple[float, float]) – The pixel grid to interpolate the scalar quantity to, as (npixx, npixy). Default is (512, 512).

Returns

An array of vector quantities interpolated to a pixel grid with shape (2, npixx, npixy).

Return type

ndarray