pynbody.filt.Cuboid#

class pynbody.filt.Cuboid(x1: float | str | UnitBase, y1: float | str | UnitBase = None, z1: float | str | UnitBase = None, x2: float | str | UnitBase = None, y2: float | str | UnitBase = None, z2: float | str | UnitBase = None)[source]#

Bases: Filter

A filter that selects particles within a cuboid defined by two opposite corners.

Methods

__call__(sim)

Return a boolean mask indicating which particles are in the filter.

cubic_cell_intersection(centroids)

Compute the intersection with cubic cells with the specified centroids.

where(sim)

Return the indices of particles that are in the filter.

__init__(x1: float | str | UnitBase, y1: float | str | UnitBase = None, z1: float | str | UnitBase = None, x2: float | str | UnitBase = None, y2: float | str | UnitBase = None, z2: float | str | UnitBase = None)[source]#

Create a cuboid filter.

If any of the cube coordinates x1, y1, z1, x2, y2, z2 are not specified they are determined as y1=x1; z1=x1; x2=-x1; y2=-y1; z2=-z1.

cubic_cell_intersection(centroids)[source]#

Compute the intersection with cubic cells with the specified centroids.

This is currently used by the swift loader to figure out which cells to load

where(sim)[source]#

Return the indices of particles that are in the filter.

This is a convenience method that is equivalent to np.where(f(sim)) but may be more efficient for some filters.