temet.tracer package

Submodules

temet.tracer.tracerEvo module

Analysis for evolution of tracer quantities in time (for cosmo boxes/zooms).

zoomDataDriver(sP, fields, snapStep=1)

Run and save data files for tracer evolution in several quantities of interest.

boxTracerDataCutout(snap=None)

Extract cutout tracer data for individual subhalos from a full box.

tracersTimeEvo(sP, fieldName, snapStep=None, all=True, pSplit=None)

Wrapper to handle zoom vs. box load.

tracersMetaOffsets(sP, all=None, parIDs=None, trIDs=None, getPath=False)

For a fullbox sP and either sP.haloInd or sP.subhaloInd specified, load and return the needed offsets to load a [halo/subhalo]-restricted part of any of the tracer_tracks data. If all == ‘Halo’ or ‘Subhalo’, then return all respective offsets and lengths. If parIDs or trIDs is not None, then a ptName to load and return these IDs for directly.

loadAllOrRestricted(sP, saveFilename, datasetName=None, indRange=None)

Load a single datasetName from a HDF5 tracer save file, either the entire dataset or restricted to a [halo/subhalo] subset if sP.haloInd or sP.subhaloInd is specified for a fullbox run.

accTime(sP, snapStep=1, rVirFac=1.0, pSplit=None, indRangeLoad=None)

Calculate accretion time for each tracer (and cache), as the earliest (highest redshift) crossing of rVirFac times the virial radius of the MPB halo. Uses the ‘rad_rvir’ field. Argument: rVirFac = what fraction of the virial radius denotes the accretion time?

redshiftsToClosestSnaps(data, redshifts, indsNotSnaps=False)

Return the nearest snapshot number to each redshifts using the data[‘redshifts’] and data[‘snaps’] mapping. By default, return simulation snapshot number, unless indsNotSnaps==True, in which case return the indices into the first dimension of data[field] for each tracer of the second dimension.

accMode(sP, snapStep=1, pSplit=None, indRangeLoad=None)

Derive an ‘accretion mode’ categorization for each tracer based on its group membership history. Specifically, separate all tracers into one of [smooth/merger/stripped] defined as: * smooth: child of MPB or no subhalo at all z>=z_acc * merger: child of subhalo other than the MPB at z=z_acc * stripped: child of MPB or no subhalo at z=z_acc, but child of non-MPB subhalo at any z>z_acc Where z_acc is the accretion redshift defined as the first (highest z) crossing of the virial radius.

valExtremum(sP, fieldName, snapStep=1, extType='max')

Calculate an extremum (e.g. min or max) or other single quantity (e.g. avg) for every tracer for a given property (e.g. temp). For [gas] values affected by the modified Utherm of the star-forming eEOS (temp, entr) we exclude times when SFR>0. This is then also consistent with what is done in the code for tracer_max* recorded values.

trValsAtRedshifts(sP, valName, redshifts, snapStep=1)

Return some property from the tracer evolution tracks (e.g. rad_rvir, temp, tracer_maxent) given by valName at the times in the simulation given by redshifts. Extracted from closest snapshot, no interpolation of property value.

trValsAtExtremumTimes(sP, valName, extName, extType='max', snapStep=1)

Wrap trValsAtRedshifts() to specifically give trVals at the redshifts corresponding to the extremum times corresponding to extName, extType.

trValsAtAccTimes(sP, valName, rVirFac=1.0, snapStep=1)

Wrap trValsAtRedshifts() to specifically give trVals at the redshifts corresponding to the accretion times determined as the first crossing of rVirFac times the virial radius.

mpbValsAtRedshifts(sP, valName, redshifts, snapStep=1)

Return some halo property, per tracer, from the main progenitor branch (MPB) (e.g. tvir, spin) given by valName at the times in the simulation given by redshifts.

mpbValsAtExtremumTimes(sP, valName, extName, extType='max', snapStep=1)

Wrap mpbValsAtRedshifts() to specifically give mpbVals at the redshifts corresponding to the extremum times corresponding to extName, extType.

mpbValsAtAccTimes(sP, valName, rVirFac=1.0, snapStep=1)

Wrap mpbValsAtRedshifts() to specifically give mpbVals at the redshifts corresponding to the accretion times determined as the first crossing of rVirFac times the virial radius.

temet.tracer.tracerMC module

Helper functions to efficiently work with the Monte Carlo tracers.

match(ar1, ar2, uniq=False)

My version of numpy.in1d with invert=False. Return is a ndarray of indices into ar1, corresponding to elements which exist in ar2. Meant to be used e.g. as ar1=all IDs in snapshot, and ar2=some IDs to search for, where ar2 could be e.g. ParentID from the tracers, in which case they are generally not unique (multiple tracers can exist in the same parent).

match2(ar1, ar2)

My alternative version of numpy.in1d with invert=False, which is more similar to calcMatch(). Return is two ndarrays. The first is indices into ar1, the second is indices into ar2, such that ar1[inds1] = ar2[inds2]. Both ar1 and ar2 are assumed to contain unique values. Can be used to e.g. crossmatch between two TracerID sets from different snapshots, or between some ParentIDs and ParticleIDs of other particle types. The approach is a concatenated mergesort of ar1,ar2 combined, therefore O( (N_ar1+N_ar2)*log(N_ar1+N_ar2) ) complexity.

match3(ar1, ar2, firstSorted=False, parallel=True)

Returns index arrays i1,i2 of the matching elements between ar1 and ar2. While the elements of ar1 must be unique, the elements of ar2 need not be. For every matched element of ar2, the return i1 gives the index in ar1 where it can be found. For every matched element of ar1, the return i2 gives the index in ar2 where it can be found. Therefore, ar1[i1] = ar2[i2]. The order of ar2[i2] preserves the order of ar2. Therefore, if all elements of ar2 are in ar1 (e.g. ar1=all TracerIDs in snap, ar2=set of TracerIDs to locate) then ar2[i2] = ar2. The approach is one sort of ar1 followed by bisection search for each element of ar2, therefore O(N_ar1*log(N_ar1) + N_ar2*log(N_ar1)) ~= O(N_ar1*log(N_ar1)) complexity so long as N_ar2 << N_ar1.

getTracerChildren(sP, parentSearchIDs, inds=False, ParentID=None, ParentIDSortInds=None)

For an input list of parent IDs (a UNIQUE list of an unknown mixture of gas/star/BH IDs), return the complete list of child MC tracers belonging to those parents (either their IDs or their global indices in the snap).

mapParentIDsToIndsByType(sP, parentIDs)

For an input list of parent IDs (an unknown mixture of possibly non-unique gas, star, and BH IDs), locate these cells/particles in the snapshot and return the by-type global snapshot indices (one per tracer, and so then possibly containing duplicates).

concatTracersByType(trIDsByParType, parPartTypes)

Collapse trIDsByParType dictionary into 1D tracer ID/index list. Ordering preserved according to the order of parPartTypes.

subhaloTracerChildren(sP, inds=False, haloID=None, subhaloID=None, parPartTypes=['gas', 'stars', 'bhs'], concatTypes=True, ParentID=None, ParentIDSortInds=None, doCache=True)

For a given haloID or subhaloID, return all the child tracers of parents in that object (their IDs or their global indices in the snap), by default for parents of all particle types, optionally restricted to input particle type(s).

globalTracerChildren(sP, inds=False, halos=False, subhalos=False, parPartTypes=['gas', 'stars', 'bhs'], concatTypes=True, ParentID=None, ParentIDSortInds=None)

For all subhalos or halos in a snapshot, return all the child tracers of parents in those objects (their IDs or their global indices in the snap), by default for parents of all particle types, optionally restricted to input particle type(s).

getEvoSnapList(sP, toRedshift=None, snapStep=1, reqFluidQuants=False)

Helper for below.

tracersTimeEvo(sP, tracerSearchIDs, trFields, parFields, toRedshift=None, snapStep=1, mpb=None, saveFilename=None, onlySnap=None, exitAfterOneSnap=False)

For a given set of tracerIDs at sP.redshift, walk through snapshots either forwards or backwards until reaching toRedshift. At each snapshot, re-locate the tracers and record trFields as a time sequence (from fluid_properties). Then, locate their parents at each snapshot and record parFields (from valid snapshot fields). For gas fields (e.g. temp), if the tracer is in a parent of a different type at that snapshot, record NaN. If the tracer is in a BH, set Velocity=0 as a flag. If saveFilename specified, then we save inside this function one snapshot at a time (avoid large memory allocation, and can be restarted). Otherwise, return for external save. If exitAfterOneSnap, then process only one snapshot and return, mostly for memory efficiency.

subhalosTracersTimeEvo(sP, subhaloIDs, toRedshift, trFields, parFields, parPartTypes, outPath, onlySnap=None)

For a set of subhaloIDs, determine all their child tracers at sP.redshift then record their properties back in time.

subhaloTracersTimeEvo(sP, subhaloID, fields, snapStep=1, toRedshift=10.0, fullHaloTracers=True)

For a single subhaloID, determine all its child tracers at sP.redshift and then record their properties back in time until the beginning of the simulation (‘tracks’). Note: Nearly identical to subhaloTracersTimeEvo() and can be merged in the future. Currently, here we do a separate snapshot loop for each quantity and save each quantity in a separate file. Memory load is smaller, run time is longer, parallelized to multiple quantities easily, and only one subhaloID supported at a time.

globalTracerLength(sP, halos=False, subhalos=False, haloTracerOffsets=None)

Return a 1D array of the number of tracers per halo or subhalo, for all in the snapshot, in direct analogy to LenType in the group catalogs. Compute the offsets as well.

globalTracerMPBMap(sP, halos=False, subhalos=False, trIDs=None, retMPBs=False, extraFields=None, indRange=None)

Load all MPBs of a global tracer set and create a mapping between unique MPBs and tracers. If indRange is not None (only so far when calling from accMode()), attempt to get halo_id’s using already computed parent_indextype tracer_tracks (for speed and efficiency only).

globalAllTracersTimeEvo(sP, field, halos=True, subhalos=False, indRange=None, toRedshift=None)

For all tracers in all FoFs at the simulation endtime, record time evolution tracks of one field for all snapshots (which contain tracers).

checkTracerMeta(sP)

Verify globalAllTracersTimeEvo() ordering.

temet.tracer.tracerPlot module

Plotting for evolution of tracer quantities in time (for cosmo boxes/zooms).

addRedshiftAgeImageAxes(ax, sP, snaps)

Add a redshift (bottom) and age (top) pair of axes for imshow plots. Top axis does not work when a colorbar is also added to the plot.

plotConfig(fieldName, extType='')

Store some common plot configuration parameters.

getEvo2D(sP, field, trIndRange=None, accTime=None, accMode=None)

Create and cache various permutations of the full 2D evolution tracks for all tracers.

plotEvo2D(ii)

Plot various full 2D blocks showing evolution of ‘all’ tracer tracks vs redshift/radius.

plotEvo1D()

Plot various 1D views showing evolution of tracer tracks vs redshift/radius.

getValHistos(sP, field, extType, accMode=None)

Calculate and cache 1D histograms of field/extType combinations from the full tracer tracks.

plotValHistos()

Plot (1D) histograms of extremum values, values at t_acc, or values at the extremum time of another value.

plotPosTempVsRedshift()

Plot trMC position (projected) and temperature evolution vs redshift.

plotStarFracVsRedshift()

Plot the fraction of tracers in stars vs. gas parents vs redshift.

Module contents

Monte Carlo tracer particles.