sarracen.ptmass.classify_bound_particles

sarracen.ptmass.classify_bound_particles(sdf: SarracenDataFrame, sdf_sinks: SarracenDataFrame) Series

Determines to which sink each SPH particle is gravitationally bound.

Returns a pandas Series that classifies particles by the sink to which they are bound, or -1 if they are not bound to any sink.

Parameters:
Returns:

A pandas Series with the sink classification for each particle.

Return type:

Series

Raises:

ValueError – If the particle SarracenDataFrame does not contain particle mass.

Notes

The index of the Series will match the index of the input SarracenDataFrame. The sinks are classified according to their index in the sdf_sinks.

Examples

Here is a set of SPH particles and sink particles. There are 4 sink particles.

>>> sdf, sdf_sinks = sarracen.read_phantom('dumpfile')
>>> len(sdf_sinks)
4
>>> sdf.head()
          x         y        z      vx      vy      vz       h
0   24.0711   34.7009  -9.7994 -0.1229  0.0843  0.0012  1.2793
1  -16.8095   39.8220  10.3250 -0.1356 -0.0585 -0.0010  1.3448
2  -31.4485  143.1688  33.4715 -0.0747 -0.0158  0.0002  3.1289
3   -2.0287 -149.1813 -35.7251  0.0749 -0.0012 -0.0011  3.2898
4  -93.4897   85.5293   2.2384 -0.0559 -0.0629  0.0006  1.9655

A pandas Series is returned that classifies which sink particle each SPH particle is bound to.

>>> bound_to_sink = sarracen.ptmass.classify_sink(sdf, sdf_sinks)
>>> sdf['sink'] = bound_to_sink
>>> sdf.head()
           x         y       z      vx      vy      vz       h  sink
0   24.0711   34.7009  -9.7994 -0.1229  0.0843  0.0012  1.2793     0
1  -16.8095   39.8220  10.3250 -0.1356 -0.0585 -0.0010  1.3448     0
2  -31.4485  143.1688  33.4715 -0.0747 -0.0158  0.0002  3.1289     3
3   -2.0287 -149.1813 -35.7251  0.0749 -0.0012 -0.0011  3.2898     2
4  -93.4897   85.5293   2.2384 -0.0559 -0.0629  0.0006  1.9655     0