pycosmommf package¶
Copyright (c) 2024 James Sunseri. All rights reserved.
pycosmommf: A package for identifying structures in the cosmic web.
Submodules¶
pycosmommf.filter module¶
- pycosmommf.filter.kspace_gaussian_filter(R_S, kv)¶
create a Gaussian filter in k-space.
- pycosmommf.filter.kspace_top_hat_filter(R_S, kv)¶
create a top-hat filter in k-space.
- pycosmommf.filter.smooth_gauss(f, R_S, kv)¶
apply a Gaussian filter to a field f.
- pycosmommf.filter.smooth_loggauss(f, R_S, kv)¶
apply a Gaussian filter to the log of a field f.
- pycosmommf.filter.smooth_top_hat(f, R_S, kv)¶
apply a top-hat filter to a field f.
- pycosmommf.filter.wavevectors3D(dims, box_size=(6.283185307179586, 6.283185307179586, 6.283185307179586))¶
Returns the wavevectors for a 3D grid of dimensions
dimsand box sizebox_size.- Parameters:
- Returns:
- a tuple containing:
kx (
np.ndarray): The wavevector in the x-direction.ky (
np.ndarray): The wavevector in the y-direction.kz (
np.ndarray): The wavevector in the z-direction.
- Return type:
(tuple)
pycosmommf.hessian module¶
- pycosmommf.hessian.fast_hessian_from_smoothed(f_Rn, R_S, kv)¶
Compute the hessian matrix of the smoothed field f_Rn.
- Parameters:
- Returns:
The hessian matrix of the smoothed field. The shape is
(nx, ny, nz, 6), wherenx, ny, nzare the dimensions off_Rn.- Return type:
(
4D float np.ndarray)
pycosmommf.signatures module¶
- pycosmommf.signatures.maximum_signature(Rs, density_cube, algorithm='NEXUSPLUS', eps=1e-16)¶
Compute the maximum signatures across all scales Rs.
- Parameters:
Rs (
listoffloat) – List of smoothing scales in units of voxels.density_cube (
3D float np.ndarray) – The 3D density field to analyze.algorithm (
str, optional) – The algorithm to use for smoothing. Can be either “NEXUS” or “NEXUSPLUS”. Defaults to “NEXUSPLUS”.eps (
float, optional) – Small value to avoid division by zero. Defaults to1e-16.
- Returns:
An array of signatures with shape
(nx, ny, nz, 3), wherenx, ny, nzare the dimensions of the inputdensity_cube. The last dimension contains the signatures for clusters, filaments, and walls respectively.- Return type:
(
4D float np.ndarray)
- pycosmommf.signatures.signatures_from_hessian(hessian)¶
Function to calculate the signatures from a given hessian.
- Parameters:
hessian (
4D float np.ndarray) – The hessian matrix of the smoothed field, with shape(nx, ny, nz, 6).- Returns:
- The signatures array with shape
(nx, ny, nz, 3). Each signature corresponds to a different type of structure: sigs[..., 0]: Cluster signaturesigs[..., 1]: Filament signaturesigs[..., 2]: Wall signature
- The signatures array with shape
- Return type:
(
4D float np.ndarray)
pycosmommf.tagging module¶
- pycosmommf.tagging.calc_mass_change(sig_vec, density_vec, Smin, Smax)¶
Calculate the mass change curve for a given structure type.
- Parameters:
- Returns:
- a tuple containing:
S (
1D float np.ndarray): the signature valuesΔΜ_2 (
1D float np.ndarray): the mass change curve
- Return type:
(tuple)
- pycosmommf.tagging.calc_structure_bools(density_cube, max_sigs, verbose_flag, clusbool=None, Smin=-3, Smax=2, overdensity_threshold=370)¶
Calculate the boolean filters for clusters, filaments, walls, and voids.
- Parameters:
density_cube (
3D float np.ndarray) – the (δ+1 = ρ/<ρ>)density_cube, this is NOT (δ = ρ/<ρ> - 1).max_sigs (
4D float np.ndarray) – the maximum signatures array from CosmoMMF.maximum_signature()verbose_flag (
bool) – a flag to allow the function to be more helpful and verbose.clusbool (
bool np.ndarray, optional) – the cluster boolean filterSmin (
float, optional) – the minimum signature valueSmax (
float, optional) – the maximum signature valueoverdensity_threshold (
int, optional) – the overdensity parameter threshold for determining virialization
- Returns:
- a tuple containing:
clusbool (
3D bool np.ndarray): the cluster boolean filterfilbool (
3D bool np.ndarray): the filament boolean filterwallbool (
3D bool np.ndarray): the wall boolean filtervoidbool (
3D bool np.ndarray): the void boolean filter- summary_data (
dict): a dictionary returned only whenverbose_flag = True, it contains the following keys: S_clus (
1D float np.ndarray): the signature values for clustersf_vir_clus (
1D float np.ndarray): the virialization fraction for clustersS_fil (
1D float np.ndarray): the signature values for filamentsdM2_fil (
1D float np.ndarray): the mass change curve for filamentsS_fil_thresh (
float): the threshold value for filamentsS_wall (
1D float np.ndarray): the signature values for wallsdM2_wall (
1D float np.ndarray): the mass change curve for wallsS_wall_thresh (
float): the threshold value for wallsmass_fractions (
1D float np.ndarray): a list of mass fractions for clusters, filaments, walls, and voidsvolume_fractions (
1D float np.ndarray): a list of volume fractions for clusters, filaments, walls, and voids
- summary_data (
- Return type:
(tuple)
- pycosmommf.tagging.make_the_clusbool(delta, max_sigs, overdensity_threshold)¶
A function that creates a bool Filter which selects only the clusters in a given cosmological δ field. This function accomplishes this by finding a threshold value for 𝒮_cluster by looking at the change in virialization fraction as a function of 𝒮_cluster.
- Parameters:
delta (
3D float np.ndarray) – delta refers to the (δ = ρ / <ρ> - 1) field, this is NOT the (δ + 1 = ρ / <ρ>) field.max_sigs (
4D float np.ndarray) – the maximum signatures array from themaximum_signature()function.verbose_flag (
bool) – a flag to allow the function to be more helpful and verbose.overdensity_threshold (
float) – The overdensity parameter threshold for determining virialization. Commonly used values that are physically motivated can be 370, 200, or 500.
- Returns:
- a tuple containing:
clusbool (
3D bool np.ndarray): a boolean filter that selects only the clusters in a given cosmological δ field.S_th (
float): the threshold value for 𝒮_cluster.signature_thresholds (
1D float np.ndarray): an array of threshold values for 𝒮_cluster.virialized_fractions (
1D float np.ndarray): an array of virialized fractions as a function of 𝒮_cluster.
- Return type:
(tuple)
pycosmommf.utils module¶
- pycosmommf.utils.cylinder(n, r)¶
Returns an nxnxn array with a cylinder in the center with radius r. All points within the radius are set to 10, the rest are set to 0.
- pycosmommf.utils.shrink(data, new_size)¶
A simple function to shrink a 3D array by summing over blocks of new_size.
- Parameters:
data (
3D float np.ndarray) – The input 3D array to be shrunk.new_size (
int) – The new size for each dimension after shrinking.
- Returns:
The shrunk 3D array.
- Return type:
(
3D float np.ndarray)
- pycosmommf.utils.sphere(n, r)¶
Returns an nxnxn array with a sphere in the center with radius r. All points within the radius are set to 10, the rest are set to 0.