astro3D.genesis.utils package

Submodules

astro3D.genesis.utils.adjust_spec module

Authors: Jacob Seiler, Manodeep Sinha

astro3D.genesis.utils.adjust_spec.adjust_spec(fname_in, fname_out, haloID_field='ID', FirstHaloInFOFgroup_field='hostHaloID', index_mult_factor=1000000000000)

Adjusts some fields of the VELOCIraptor trees to match the LHaloTree Specs.

Currently calls the following functions:
  1. astro3D.genesis.utils.`adjust_hostHaloID
Parameters:
  • fname_in, fname_out (String) – Path to the input HDF5 trees and path to where the updated trees will be saved.
  • haloID_field (String, optional) – Field name within the HDF5 file that corresponds to the unique halo ID.
  • FirstHaloInFOFgroup_field (String, optional) – Field name within the HDF5 file that corresponds to FirstHaloInFOFgroup in the LHaloTree structure.
  • index_mult_factor (Integer, optional) – Multiplication factor to generate a temporally unique halo ID.
Returns:

Return type:

None.

Notes

The default parameters are chosen to match the ASTRO3D Genesis trees as produced by VELOCIraptor + Treefrog.

astro3D.genesis.utils.adjust_spec.adjust_hostHaloID(f_out, haloID_field, FirstHaloInFOFgroup_field, Snap_Keys, Snap_Nums, index_mult_factor)

Adjusts the hostHaloID field in the output HDF5 file.

In the original trees, if a halo is the main background FoF halo, its value of hostHaloID is set to -1. Under the LHaloTree specs, the property correpsonding to this field (FirstHaloInFOFgroup) can never be -1. Instead, halos in these instances should point to themselves.

Parameters:
  • f_out (Open HDF5 file.) – The HDF5 trees we’re adjusting.
  • haloID_field (String, optional) – Field name within the HDF5 file that corresponds to the unique halo ID.
  • FirstHaloInFOFgroup_field (String, optional) – Field name within the HDF5 file that corresponds to FirstHaloInFOFgroup in the LHaloTree structure.
  • Snap_Keys (List of strings.) – Names of the snapshot keys within the passed keys.
  • Snap_Nums (Dictionary of integers keyed by Snap_Keys.) – Snapshot number of each snapshot key.
  • index_mult_factor (Integer, optional) – Multiplication factor to generate a temporally unique halo ID.
Returns:

Return type:

None.

astro3D.genesis.utils.common module

astro3D.genesis.utils.convert_indices module

astro3D.genesis.utils.convert_indices.convert_indices(fname_in, fname_out, haloID_field='ID', forestID_field='ForestID', ID_fields=['Head', 'Tail', 'RootHead', 'RootTail', 'ID', 'hostHaloID'], index_mult_factor=1000000000000)

Converts temporally unique tree IDs to ones that are forest-local as required by the LHalo Trees format.

The data-structure of the Treefrog trees is assumed to be HDF5 File -> Snapshots -> Halo Properties at each snapshot.

A new HDF5 file is saved out with the updated IDs.

Note

We require the input trees to be sorted via the forest ID (forestID_field) and suggest to also sub-sort on hostHaloID and mass. Sorting can be done using astro3D.genesis.utils.forest_sorter.

Parameters:
  • fname_in, fname_out (String) – Path to the input HDF5 VELOCIraptor + treefrog trees and the path where the LHalo correct trees will be saved.
  • haloID_field (String, optional) – Field name within the HDF5 file that corresponds to the unique halo ID.
  • forestID_field (String, optional) – Field name within the HDF5 file that corresponds to forest ID.
  • ID_fields (List of strings, optional) – The HDF5 field names that correspond to properties that use halo IDs. As the halo IDs are updated to match the required LHalo Tree format, these must also be updated.
  • index_mult_factor (Integer, optional) – Multiplication factor to generate a temporally unique halo ID.
Returns:

Return type:

None.

Notes

The default parameters are chosen to match the ASTRO3D Genesis trees as produced by VELOCIraptor + Treefrog.

astro3D.genesis.utils.forest_sorter module

Authors: Jacob Seiler, Manodeep Sinha

astro3D.genesis.utils.forest_sorter.forest_sorter(fname_in, fname_out, haloID_field='ID', sort_fields=['ForestID', 'hostHaloID', 'Mass_200mean'], sort_direction=[1, 1, -1], ID_fields=['Head', 'Tail', 'RootHead', 'RootTail', 'ID', 'hostHaloID'], index_mult_factor=1000000000000)

Sorts and saves a HDF5 tree file on the specified sort fields. The IDs of the halos are assume to use the index within the data file and hence will be updated to reflect the sorted order.

Parameters:
  • fname_in, fname_out (String) – Path to the input HDF5 trees and path to where the sorted trees will be saved.
  • haloID_field (String, optional) – Field name within the HDF5 file that corresponds to the unique halo ID.
  • sort_fields (List of strings, optional) – The HDF5 field names that the sorting will be performed on. The entries are ordered such that the first field will be the outer-most sort and the last field will be the inner-most sort.
  • sort_direction (List of integers, optional) – Specifies the direction in which the sorting will occur for each sort_field entry. 1 corresponds to ascending, -1 to descending.
  • ID_fields (List of strings, optional) – The HDF5 field names that correspond to properties that use halo IDs. As the halo IDs are updated to reflect the new sort order, these fields must also be updated.
  • index_mult_factor (Integer, optional) – Multiplication factor to generate a temporally unique halo ID.
Returns:

Return type:

None.

Notes

The default parameters are chosen to match the ASTRO3D Genesis trees as produced by VELOCIraptor + Treefrog.

astro3D.genesis.utils.treefrog_to_lhalo module

Authors: Jacob Seiler, Manodeep Sinha

astro3D.genesis.utils.treefrog_to_lhalo.treefrog_to_lhalo(fname_in, fname_out, haloID_field='ID', forestID_field='ForestID', Nforests=None, write_binary_flag=1, debug=0)

Takes the Treefrog trees that have had their IDs corrected to be in LHalo format and saves them in LHalo binary format.

The data-structure of the Treefrog trees is assumed to be HDF5 File -> Snapshots -> Halo Properties at each snapshot.

Note

We require the input trees to be sorted via the forest ID (forestID_field) and suggest to also sub-sort on hostHaloID and mass. Sorting can be done using astro3D.genesis.utils.forest_sorter.

We also require the input trees to have IDs that are LHalo compatible. See astro3D.genesis.utils.convert_indices.

Parameters:
  • fname_in, fname_out (String) – Path to the input HDF5 VELOCIraptor + treefrog trees and the path where the LHalo binary file will be saved.
  • haloID_field (String, optional) – Field name within the HDF5 file that corresponds to the unique halo ID.
  • forestID_field (String, optional) – Field name within the HDF5 file that corresponds to forest ID.
  • Nforests (Integer, optional) – The number of forests to be processed. If None is passed then all forests are processed.
  • write_binary_flag (Integer, optional) – Flag to decide whether to write to a binary or HDF5 file. 0: HDF5 file only. 1: Binary file only. 2: Both binary and HDF5 file.
Returns:

Return type:

None.

Notes

The default parameters are chosen to match the ASTRO3D Genesis trees as produced by VELOCIraptor + Treefrog.