hbtp

HBTReader module.

Python module containing HBTReader class, used for analysis of HBT+ halo finder output.

Example:

class hbtp.ConfigReader(config_file)

Bases: object

Class to read the config files (i.e. Parameters.log).

class hbtp.HBTReader(subhalo_path)

Bases: object

Class to read the HBTPlus outputs.

To use it, initialize the reader with the directory in which Parameters.log is stored - it is written by HBT during runtime.

Parameters:subhalo_path (str) – directory with config files
GetExclusiveParticles(isnap=-1)

Loads an exclusive set of particles for subhaloes at isnap

Duplicate particles are assigned to the lowest mass subhaloes.

GetFileName(isnap, ifile=0, filetype='Sub')

Returns filename of an HBT snapshot

Parameters:
  • isnap (int) – snapshot of the file
  • ifile (int) – (default=0) index for sub-snapshots
  • filetype (str) – (default=’Sub’) ‘Src’, ‘Sub’ or ‘HaloSize’
Returns:

HBT snaphost filename

Return type:

(str)

GetHostHalo(HostHaloId, isnap=-1)

Returns spatial information of a specific FoF group.

Parameters:
  • HostHaloId (int) – host halo id
  • isnap (int) – snapshot number
Returns:

(numpy.ndarray) single FoF group in a structured array

GetHostMergerTree(HostHaloId, isnap=-1, file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)

Builds a FoF merger tree starting at a host halo ID.

Prints a graph which can be consumed by [Dot](graphviz.org] software.

Parameters:
  • HostHaloId (int) – a halo at which to root a tree
  • isnap (int) – (default = -1) snapshot number
  • file (File) – (default=sys.stdout) default output for a Dot diagram
Returns:

multiply embedded list with a tree, i.e. [1, [2, 3]]

Return type:

(list)

GetNumberOfSubhalos(isnap=-1)

Retunrs number of subhaloes in a snapshot.

Parameters:isnap (int) – (default = -1) snapshot number
GetParticleProperties(subindex, isnap=-1)

Returns subhalo particle properties for subhalo with index subindex.

Values are returned in the order they appear in the file, subindex==trackId for single file output (but not for mpi multiple-file outputs)

GetProgenitorHaloes(HostHaloId, isnap=-1)

Returns progenitors of a given host halo.

Given a HostHaloId and a snapshot number, it finds all subhaloes within the host, follows their track ids to the previous snapshot, checks if they are the main / central subhalo (by Rank values), finds those subhaloes’ hosts and keeps the unique IDs. Filtering by Rank is necessary to remove fly-by and re-merger events.

Parameters:
  • HostHaloId (int) – host halo id
  • isnap (int) – (default=-1) snapshot number
Returns:

array of host halo ids of progenitors

Return type:

(numpy.ndarray)

GetScaleFactor(isnap)

Reads scale factor at a given snapshot.

GetScaleFactorDict()

Returns a dictionary that maps snapshot_index to ScaleFactor.

GetSub(trackId, isnap=-1)

Loads a subhalo with the given trackId at snapshot isnap.

GetSubsOfHost(HostHaloId, isnap=-1)

Loads all subhaloes belonging to a host halo.

Uses information from Membership/GroupedTrackIds.

Parameters:
  • HostHaloId (int) – row number
  • isnap (int) – (default = -1)
Returns:

array of TrackIds, or empty array if FoF does

not host subhalos

Return type:

(numpy.ndarray)

GetTrack(trackId, fields=None, MaxSnap=None)

Loads an entire track of the given trackId.

LoadHostHalos(isnap=-1, selection=None)

Returns spatial properties of FoF groups for a snapshot.

Parameters:
  • isnap (int) – snapshot number
  • selection (tuple) – (default = None) selection query being passed on
  • HBT file (to) –
Returns:

(numpy.ndarray) host haloes matching the selection

LoadNestedSubhalos(isnap=-1, selection=None)

Load the list of nested subhalo indices for each subhalo

Parameters:isnap (int) – (default = -1) snapshot number
Returns:array of nested indices
Return type:(numpy.ndarray)
LoadParticles(isnap=-1, subindex=None, filetype='Sub')

Loads subhalo particle list at snapshot

If subindex is given, only load subhalo of the given index (the order it appears in the file, subindex==trackId for single file output, but not for mpi multiple-file outputs). Otherwise loads all the subhaloes.

Default filetype (Sub) will load subhalo particles. Filetype Src loads source subhalo particles instead (for debugging purpose only).

Parameters:
  • isnap (int) – (default=-1) snapshot number
  • subindex (int) – (default=None) index of a subhalo
  • filetype (str) – (default=’Sub’) HBT file type
LoadSubhalos(isnap=-1, selection=None, show_progress=False)

Load all subhaloes from a snapshot.

Note

selection=('Rank', 'Nbound') will load only the Rank and Nbound fields of subhaloes; selection=3 will only load subhalo with subindex 3; default will load all fields of all subhaloes. You can also use numpy slice for selection, e.g. selection=np.s_[:10, 'Rank','HostHaloId'] will select the Rank and HostHaloId of the first 10 subhaloes. You can also specify multiple subhaloes by passing a list of (ordered) subindex, e.g., selection=((1,2,3),). However, currently only a single subhalo can be specified for multiple-file HBT data (not restricted for single-file data).

Note

Subindex specifies the order of the subhalo in the file at the current snapshot, i.e., subhalo=AllSubhalo[subindex]. subindex == trackId for single file output, but subindex != trackId for mpi multiple-file outputs.

Parameters:
  • isnap (int) – (default = -1) snapshot
  • selection (numpy.s_) – (default = None) can be a single field, a list of the field names or a single subhalo index
  • show_progress (bool) – (default = False)
OpenFile(isnap, ifile=0, filetype='Sub', mode='r')

Opens HDF5 file.

Parameters:
  • isnap (int) – snapshot of the file
  • ifile (int) – (default=0) index for sub-snapshots
  • filetype (str) – (default=’Sub’) ‘Src’, ‘Sub’ or ‘HaloSize’
  • mode (chr) – (default=’r’) file handle mode
Returns:

HDF5 HBT file handle

Return type:

(File)

Snapshots()
hbtp.PeriodicDistance(x, y, BoxSize, axis=-1)
hbtp.distance(x, y, axis=-1)
hbtp.get_hbt_snapnum(snapname)

Extracts snapshot number from a filename.

Parameters:snapname (str) – name of snapshot file
Returns:snapshot number
Return type:(int)