pynbody.sph.renderers.HealpixRenderer#

class pynbody.sph.renderers.HealpixRenderer(snap: SimSnap)[source]#

Bases: ImageRenderer

Implementation for rendering a simulation snapshot to healpix

Attributes:
geometry
is_projected

Methods

copy([share_geometry])

Return a copy of this renderer.

render()

Render the image and return it as a numpy array or SimArray.

restrict_z_range()

Restrict the z range of the image to the same as the x range.

set_kernel([kernel_spec])

Set the kernel to be used for the image rendering.

set_output_units(units)

Set the output units of the image to be rendered.

set_particle_array_slice(slice)

Set the slice of particles to be rendered.

set_projection(is_projected)

Set whether the image is to be rendered as a projection or a slice.

set_quantity(qty)

Set the quantity to be rendered.

set_resolution(resolution)

Set the resolution of the image to be rendered.

set_smooth_floor([smooth_floor])

Set the minimum smoothing length to be used in the image rendering, in position units (not pixels).

set_smooth_range([smooth_min, smooth_max])

Set the range of smoothing lengths in image pixels to be used in the image rendering.

set_width(width)

Set the width of this renderer to the specified value.

with_approximate([levels, factor])

Return a version of this renderer that will use the specified number of approximation levels for rendering.

with_denoising([denoise])

Return a version of this renderer that may inclue a denoising step.

with_threading([num_threads])

Return a version of this renderer that will use the specified number of threads for rendering.

with_volume_weighted_projection()

Return a version of this renderer that will render a volume-weighted projection along the line of sight.

with_weighted_projection(weighting_array)

Return a version of this renderer that will render a weighted projection along the line of sight.

__init__(snap: SimSnap)[source]#
copy(share_geometry=False)#

Return a copy of this renderer.

If share_geometry is True, the geometry of the image is shared between the original and the copy. Otherwise, the geometry is copied as well.

render()#

Render the image and return it as a numpy array or SimArray.

restrict_z_range()#

Restrict the z range of the image to the same as the x range.

set_kernel(kernel_spec: str | type | KernelBase | None = None)#

Set the kernel to be used for the image rendering.

Parameters:

kernel_spec – The kernel to be used for the image rendering. This can be specified as a string, a kernel class, or a kernel instance. If None, the default kernel is assigned. For more information see pynbody.sph.kernels.create_kernel().

Notes

If a projected image is to be used, a 3D kernel should still be passed. The projection is handled internally.

set_output_units(units: str | UnitBase | None)#

Set the output units of the image to be rendered. This will also change the projection status of the image.

Parameters:

units (str | units.UnitBase) – The units to be used for the output image. These are checked for compatibility with the array to be rendered, either in projection or in slice. If the units are not compatible in either interpretation, a UnitsException is raised. If None, the output units are set to the units of the array to be rendered.

set_particle_array_slice(slice)#

Set the slice of particles to be rendered.

This is used by the threaded renderer to split the rendering across multiple threads.

Parameters:

slice (slice) – The slice of particles to be rendered.

set_projection(is_projected: bool)#

Set whether the image is to be rendered as a projection or a slice. This will also reset the output units.

set_quantity(qty)#

Set the quantity to be rendered.

Parameters:

qty (str | numpy.ndarray) – The quantity to be rendered. If a string, the quantity is taken from the simulation snapshot.

set_resolution(resolution: int)#

Set the resolution of the image to be rendered.

Parameters:

resolution (int) – The resolution of the image to be rendered.

set_smooth_floor(smooth_floor: float | str | UnitBase = 0.0)#

Set the minimum smoothing length to be used in the image rendering, in position units (not pixels).

Any particles with smoothing lengths below this value will have their smoothing lengths set to this value. The purpose is to exclude particles with very small smoothing lengths from the image rendering, which can cause excess noise e.g. in contoured images.

set_smooth_range(smooth_min: float = 0.0, smooth_max: float = None)#

Set the range of smoothing lengths in image pixels to be used in the image rendering.

Any particles with smoothing lengths outside this range will be ignored.

This is for use by the approximate renderer to render images at multiple resolutions.

Note that set_smoothing_floor() is a different method that does not exclude particles below the minimum, rather setting them to the minimum.

Parameters:
  • smooth_min (float, optional) – The minimum smoothing length to be used in the image rendering, specified in pixels. The default is zero.

  • smooth_max (float, optional) – The maximum smoothing length to be used in the image rendering, specified in pixels. If None (default), there is no maximum.

set_width(width: float | str | UnitBase)#

Set the width of this renderer to the specified value.

Parameters:

width (float, str, units.UnitBase) – The width of the image to be rendered. If a string or unit, the value will be converted to the units of the simulation snapshot.

with_approximate(levels: int | None = None, factor=8) ImageRendererBase[source]#

Return a version of this renderer that will use the specified number of approximation levels for rendering.

For more information, see ApproximateImageRenderer.

Note that if the number of levels is less than 2, the original renderer is returned.

Parameters:
  • levels (int, optional) – The number of approximation levels to use. If None, the number of levels is determined by the size of the image and the zoom factor.

  • factor (int, optional) – The zoom factor to use between levels of approximation. The default is 8.

with_denoising(denoise: bool | None = None) ImageRendererBase#

Return a version of this renderer that may inclue a denoising step.

Parameters:

denoise (bool | None) – Whether to include denoising in the rendering process. If None, denoising is applied only if the image is likely to benefit from it. If True, denoising is to be forced on the image; if that is actually impossible, this routine raises an exception. If False, denoising is never applied and the routine returns a straight-forward copy of the current renderer.

with_threading(num_threads: int | None = None) ImageRendererBase#

Return a version of this renderer that will use the specified number of threads for rendering.

If num_threads is None, the number of threads is determined by the configuration file.

with_volume_weighted_projection()#

Return a version of this renderer that will render a volume-weighted projection along the line of sight.

with_weighted_projection(weighting_array)#

Return a version of this renderer that will render a weighted projection along the line of sight.