flaminkit

A toolkit for the FLAMINGO cosmological hydrodynamical simulation suite

Submodules

Attributes

__version__

Functions

halofile(args[, info])

Name of file containing halo information, based on command-line arguments

infalling_groups(halofile[, cluster_mass_min, ...])

Find groups falling into a sample of clusters

particles_around(particle_file, coords, dmax, ...[, ...])

Find particles no further than a given distance from sets of coordinates

_find_particles_around(particle_coords, xyz, dmid, rng)

Helper function for particles_around

subhalos_in_clusters(halofile[, cluster_mask, ...])

Find subhalos within a given cluster population

subhalo_particle_statistic(particle_data, ...[, weights])

Calculate subhalo properties from the particle distribution

output_file(args, root[, ext])

parse_args([args])

Parse command-line arguments

read_args()

Set up the base command-line arguments

Package Contents

flaminkit.halofile(args, info=True)

Name of file containing halo information, based on command-line arguments

Parameters

args : output of parse_args

Returns

halofile: str

filename

flaminkit.infalling_groups(halofile, cluster_mass_min=0, cluster_mass_max=np.inf, clusters=None, distance_max=5, group_mass_min=0, n=None, overdensity='200_crit', so_cols=None, random_seed=None)

Find groups falling into a sample of clusters

This function looks for all clusters in the chosen mass range that are the most massive cluster within distance_max and then identifies all groups around them. Here, groups are defined simply by a lower mass cut. The cluster center is taken as the center of mass.

Parameters

halofilestr

hdf5 file name

cluster_mass_min, cluster_mass_maxfloat, optional

minimum and maximum spherical overdensity cluster mass, in solar masses

distance_maxfloat

maximum 3d distance around which to search for groups, in units of the SORadius specified by overdensity

group_mass_minfloat, optional

minimum infall group mass

nint, optional

number of clusters to return, chosen randomly given the mass range. If not specified all clusters are returned

overdensitystr

spherical overdensity as named in halofile

so_colslist, optional

list of spherical overdensity columns to include in addition to TotalMass – NOT YET IMPLEMENTED

random_seedint, optional

random seed used to select n clusters, if applicable.

Returns

main_clusters: pd.DataFrame

most massive clusters within their own distance_max * SORadius. If clusters is provided this will be a subset of it

infallerspd.DataFrame

infalling groups

flaminkit.particles_around(particle_file, coords, dmax, particle_type, dmin=0 * unyt.Mpc, squeeze=True, progress=True, nthreads=1)

Find particles no further than a given distance from sets of coordinates

Parameters

particle_file : str coords : unyt.unyt_array, shape: (N, 3)

coordinates of interest

dmaxunyt.unyt_quantity

maximum 3d distance to include particles

particle_typeiterable

items must be any subset of ("dm", "gas", "stars")

dminunyt.unyt_quantity, optional

minimum 3d distance

squeezebool

return squeezed array if only one particle type is provided

progressbool

whether to show a progress bar. Disabled if nthreads>1

nthreadsint

number of threads to use to match particles.

Returns

particlesswiftsimio.reader.SWIFTDataset or list

Loaded particles within cubical masks

matchinglist of np.ndarray, each with len = len(coords)

List of indices pointing to particles corresponding to all particles around each subhalo within the distance constraints

flaminkit._find_particles_around(particle_coords, xyz, dmid, rng, idx=None)

Helper function for particles_around

flaminkit.subhalos_in_clusters(halofile, cluster_mask=None, clusters=None, n=None, subhalo_mask=None, overdensity='200_crit', subhalo_cols=None, so_cols=None, random_seed=None, subsample_by=None)

Find subhalos within a given cluster population

Note

Only works with HBT+ catalogs for now

Parameters

halofilestr

hdf5 file name

cluster_mass_min, cluster_mass_maxfloat, optional

minimum and maximum spherical overdensity cluster mass, in Msun

cluster_maskdict, optional

minimum and maximum values for cluster propoerties. Each entry in the dictionary should correspond to a Dataset name in halofile, and its value correspond to an iterable with elements (vmin,vmax). The mask is applied as vmin <= x < vmax. Ignored if clusters is provided. For instance,

cluster_mask = {"SO/200_crit/TotalMass": (1e15, np.inf)}
clusterspd.DataFrame, optional

cluster sample. Must contain at least the columns (HostFOFId,CentreOfMass_x,CentreOfMass_y,CentreOfMass_z)

nint, optional

number of clusters to return, chosen randomly given the mass range. If not specified all clusters that comply with cluster_mask are returned

subhalo_maskdict, optional

minimum and maximum subhalo values, given as an iterable of (vmin, vmax) for each desired column. Dictionary keys can be any subset of columns from BoundSubhalo. The mask is applied as vmin <= x < vmax

overdensitystr

spherical overdensity as named in halofile

subhalo_colslist, optional

list of columns from BoundSubhalo to include in addition to (HostFOFId,TrackId,Depth). Because the object returned is a pd.DataFrame, columns with more than one dimension are not yet supported

so_colslist, optional

list of spherical overdensity columns to include in addition to TotalMass. Ignored if clusters is provided

random_seed : int, optional subsample_by : str, optional

if subsampling the catalog (for quick runs), specifies a column name, which must be present in the catalog, and the n first entries in that column will be used. Otherwise the subsampling will be random

Returns

cluster_galaxiespd.DataFrame

galaxies within clusters

flaminkit.subhalo_particle_statistic(particle_data, subhalo_particles, statistic, weights=None, **kwargs)

Calculate subhalo properties from the particle distribution

Parameters

particle_dataswiftsimio.objects.cosmo_array

particle property, i.e., column from a swiftsimio.reader.SWIFTDataset

subhalo_particlesnp.ndarray or ``list`, len: N

list of indices or masks relating elements of particle_data to each subhalo

statisticcallable

function to apply to the particles of each subhalo.

weightsswiftsimio.objects.cosmo_array or np.ndarray, optional

weights applied to obtain a weighted statistic

kwargsdict, optional

additional arguments passed to statistic. Note that if this includes another swiftsimio.objects.cosmo_array (e.g., as weights) it is recommended to give the ndarray_view to ensure proper behaviour

Returns

subhalo_propertynp.ndarray, shape: (N,)

subhalo property obtained from the particles

Notes

  • If a property has more than one dimension (e.g., a position or velocity) it is easiest to pass each array to this function separately as

    mean_velocity = [subhalo_particle_statistic(
        particles.velocities[:,i], subhalo_particles, np.mean)
        for i in range(3)]
    
flaminkit.output_file(args, root, ext=None)
flaminkit.parse_args(args=None)

Parse command-line arguments

Parameters

argslist-like, optional

additional arguments to include in the parser. Each element in args should contain two elements: the string(s) enabling the argument and the kwargs to add it to the parser. For instance,

args=(('--foo', {'type': int, 'default': 1}), ('--bar', {'action': 'store_true'}))

Returns

args : output of parser.parse_args

flaminkit.read_args()

Set up the base command-line arguments

Call this function from any program if there are additional command-line arguments in it (to be added manually from that program)

Note that any program might ignore any of these default command-line arguments if only a subset are relevant

Returns

parser : argparse.ArgumentParser object

flaminkit.__version__ = '0.0.7'