pynbody.filt.And#

class pynbody.filt.And(f1, f2)[source]#

Bases: Filter

A filter that selects particles that are in both of two other filters.

You can construct this filter conveniently using the & operator, i.e.

>>> f = f1 & f2

returns a filter that selects particles that are in both f1 and f2.

Methods

__call__(sim)

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

cubic_cell_intersection(centroids[, deltax, ...])

Compute the intersection with cubic cells with the specified centroids.

where(sim)

Return the indices of particles that are in the filter.

__init__(f1, f2)[source]#
cubic_cell_intersection(centroids, deltax=None, boxsize=None)[source]#

Compute the intersection with cubic cells with the specified centroids.

Returns a boolean array, True for each cell that the filter’s region may intersect (it may be True for some cells that it does not). This is used by the swift and ramses loaders to figure out which cells to load.

Parameters:
  • centroids (array-like) – The centres of the cells, shape (N, 3), in the snapshot’s position units.

  • deltax (float, optional) – The side length of the cells, which must all be the same size. If given, the centroids can be any set of such cells: for example, those of one level of an AMR hierarchy, or a sparse selection of cells. If not given, the centroids must instead form a complete uniform grid filling a periodic box, and both the side length and the box size are inferred from them.

  • boxsize (float, optional) – The size of the periodic box, used only if deltax is given (None, the default, for no periodic wrapping). Without deltax, it is inferred from the grid.

where(sim: snapshot.SimSnap)#

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.