inertia_tensor_per_object

halotools.mock_observables.inertia_tensor_per_object(sample1, sample2, weights2, smoothing_scale, period=None, num_threads=1, approx_cell1_size=None, approx_cell2_size=None)[source]

For each point in sample1, identify all sample2 points within the input smoothing_scale; using those points together with the input weights2, the inertia_tensor_per_object function calculates the inertia tensor of the mass distribution surrounding each point in sample1.

For every pair of points, \(i, j\) in sample1, sample2, the contribution to the inertia tensor is:

\[\begin{split}\mathcal{I}_{\rm ij} = m_{\rm j}\begin{bmatrix} \delta x_{\rm ij}*\delta x_{\rm ij} & \delta x_{\rm ij}*\delta y_{\rm ij} & \delta x_{\rm ij}*\delta z_{\rm ij} \\ \delta y_{\rm ij}*\delta x_{\rm ij} & \delta y_{\rm ij}*\delta y_{\rm ij} & \delta y_{\rm ij}*\delta z_{\rm ij} \\ \delta z_{\rm ij}*\delta x_{\rm ij} & \delta z_{\rm ij}*\delta y_{\rm ij} & \delta z_{\rm ij}*\delta z_{\rm ij} \end{bmatrix}\end{split}\]

The \(\delta x_{\rm ij}\), \(\delta y_{\rm ij}\), and \(\delta z_{\rm ij}\) terms store the coordinate distances between the pair of points (optionally accounting for periodic boundary conditions), and \(m_{\rm j}\) stores the mass of the sample2 point.

To calculate the inertia tensor \(\mathcal{I}_{\rm i}\) for the \(i^{\rm th}\) point in sample1, the inertia_tensor_per_object function sums up the contributions \(\mathcal{I}_{\rm ij}\) for all \(j\) such that the distance between the two points \(D_{\rm ij}\) is less than the smoothing scale \(D_{\rm smooth}\):

\[\mathcal{I}_{\rm i} = \sum_{j}^{r_{\rm ij} < D_{\rm smooth}} \mathcal{I}_{\rm ij}\]
Parameters:
sample1array_like

Numpy array of shape (npts1, 3) storing 3-D positions of points.

See the Formatting your xyz coordinates for Mock Observables calculations documentation page, or the Examples section below, for instructions on how to transform your coordinate position arrays into the format accepted by the sample1 and sample2 arguments. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools.

sample2array_like

Numpy array of shape (npts2, 3) storing 3-D positions of the point masses used to calculate the inertia tensor of every sample1 point.

weights2array_like

Numpy array of shape (npts2,) storing the mass of each sample2 point used to calculate the inertia tensor of every sample1 point.

smoothing_scalefloat

Three-dimensional distance from each sample1 point defining which points in sample2 are used to compute the inertia tensor

periodarray_like, optional

Length-3 sequence defining the periodic boundary conditions in each dimension. If you instead provide a single scalar, Lbox, period is assumed to be the same in all Cartesian directions. Default is None, in which case no PBCs will be applied.

num_threadsint, optional

Number of threads to use in calculation, where parallelization is performed using the python multiprocessing module. Default is 1 for a purely serial calculation, in which case a multiprocessing Pool object will never be instantiated. A string ‘max’ may be used to indicate that the pair counters should use all available cores on the machine.

approx_cell1_sizearray_like, optional

Length-3 array serving as a guess for the optimal manner by how points will be apportioned into subvolumes of the simulation box.

The optimum choice unavoidably depends on the specs of your machine. Default choice is to use Lbox/10 in each dimension, which will return reasonable result performance for most use-cases. Performance can vary sensitively with this parameter, so it is highly recommended that you experiment with this parameter when carrying out performance-critical calculations.

approx_cell2_sizearray_like, optional

Analogous to approx_cell1_size, but for sample2. See comments for approx_cell1_size for details.

Returns:
inertia_tensorsndarray

Numpy array of shape (npts1, 3, 3) storing the inertia tensor for every object in sample1.

sum_of_massesndarray

Numpy array of shape (npts1, ) storing the sum of the masses of the sample2 points that fall within smoothing_scale of each sample1 point

Notes

There are several convenience functions available to derive quantities from the returned inertia tensors:

Examples

>>> npts1, npts2 = 50, 75
>>> sample1 = np.random.random((npts1, 3))
>>> sample2 = np.random.random((npts2, 3))
>>> weights2 = np.random.random(npts2)
>>> smoothing_scale = 0.1
>>> result = inertia_tensor_per_object(sample1, sample2, weights2, smoothing_scale)