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] [edit on github]¶ For each point in
sample1
, identify allsample2
points within the inputsmoothing_scale
; using those points together with the inputweights2
, theinertia_tensor_per_object
function calculates the inertia tensor of the mass distribution surrounding each point insample1
.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
, theinertia_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:  sample1 : array_like
Numpy array of shape (npts1, 3) storing 3D 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
andsample2
arguments. Length units are comoving and assumed to be in Mpc/h, here and throughout Halotools. sample2 : array_like
Numpy array of shape (npts2, 3) storing 3D positions of the point masses used to calculate the inertia tensor of every
sample1
point. weights2 : array_like
Numpy array of shape (npts2,) storing the mass of each
sample2
point used to calculate the inertia tensor of everysample1
point. smoothing_scale : float
Threedimensional distance from each
sample1
point defining which points insample2
are used to compute the inertia tensor period : array_like, optional
Length3 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_threads : int, 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_size : array_like, optional
Length3 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 usecases. Performance can vary sensitively with this parameter, so it is highly recommended that you experiment with this parameter when carrying out performancecritical calculations.
 approx_cell2_size : array_like, optional
Analogous to
approx_cell1_size
, but for sample2. See comments forapprox_cell1_size
for details.
Returns:  inertia_tensors : ndarray
Numpy array of shape (npts1, 3, 3) storing the inertia tensor for every object in
sample1
. sum_of_masses : ndarray
Numpy array of shape (npts1, ) storing the sum of the masses of the
sample2
points that fall withinsmoothing_scale
of eachsample1
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)