pynbody.bridge.OneToOneBridge#
- class pynbody.bridge.OneToOneBridge(start: snapshot.SimSnap, end: snapshot.SimSnap)[source]#
Bases:
AbstractBridge
Connects two snapshots with identical particle numbers and file layout.
Particle
i
in the start point is the same as particlei
in the end point.Methods
__call__
(s)Map from a
SubSnap
at one end of the bridge, to the correspondingSubSnap
at the other endcatalog_transfer_matrix
([min_index, ...])Deprecated interface to
count_particles_in_common()
.count_particles_in_common
(halos_1, halos_2, /)Return a matrix with the number of particles transferred from
groups_1
to groups_2.fuzzy_match_catalog
([min_index, max_index, ...])Deprecated alternative to
fuzzy_match_halos()
.fuzzy_match_halos
(halos_1, halos_2, /[, ...])Given halo catalogues, return possible matches within the second catalogue for each halo in the first.
match_catalog
([min_index, max_index, ...])Deprecated alternative to
match_halos()
.match_halos
(halos_1, halos_2, /[, ...])Given halo catalogues, identify the likely halo number in the second catalogue for each halo in the first.
- catalog_transfer_matrix(min_index=1, max_index=30, groups_1=None, groups_2=None, use_family=None, only_family=None)#
Deprecated interface to
count_particles_in_common()
. Use that method instead.
- count_particles_in_common(halos_1, halos_2, /, max_num_halos=None, use_family=None) ndarray #
Return a matrix with the number of particles transferred from
groups_1
to groups_2.Normally,
match_catalog()
(orfuzzy_match_catalog()
) are easier to use, but this routine provides the maximal information.Warning
This routine returns results in terms of halo indexes, rather than halo numbers. This is because halo indexes are guaranteed to be continuous starting at zero, while halo numbers may have gaps. If you need to convert from halo indexes to halo numbers, you can use
number_mapper()
attribute ofHaloCatalogue
. Alternatively, use thematch_catalog()
method which returns results in terms of halo numbers.- Parameters:
halos_1 (pynbody.halo.HaloCatalogue) – The HaloCatalogue for the first snapshot (the one at the start of the bridge).
halos_2 (pynbody.halo.HaloCatalogue) – The HaloCatalogue for the second snapshot (the one at the end of the bridge).
max_num_halos (int, optional) – The maximum number of halos
use_family (str) – Only match particles of this family. Default is None, in which case all particles are matched.
- Returns:
A matrix with the number of particles transferred from each halo in the first catalogue to each halo in the second. The size of the matrix is determined by the maximum number of halos in either catalogue, or by the value of
max_num_halos
if specified.- Return type:
numpy.ndarray
- fuzzy_match_catalog(min_index=1, max_index=30, threshold=0.01, groups_1=None, groups_2=None, use_family=None, only_family=None)#
Deprecated alternative to
fuzzy_match_halos()
. Use that method instead.
- fuzzy_match_halos(halos_1, halos_2, /, threshold=0.01, use_family=None, use_halo_indexes=False) dict[int, list[tuple[int, float]]] #
Given halo catalogues, return possible matches within the second catalogue for each halo in the first.
For details about the parameters to this function, see the documentation for
match_catalog()
.- Parameters:
halos_1 (pynbody.halo.HaloCatalogue) – The HaloCatalogue for the source snapshot
halos_2 (pynbody.halo.HaloCatalogue) – The HaloCatalogue for the destination snapshot
threshold (float) – The minimum fraction of particles in common for a match to be considered. Default is 0.01.
use_family (str) – Only match particles of this family. Default is None, in which case all particles are matched.
use_halo_indexes (bool) – If True, instead of returning halo numbers, return halo indexes. Default is False.
- Returns:
Maps from halo number in the first catalogue to a list of tuples. Each tuple contains the halo number in the second catalogue and the fraction of particles in the first halo that are in the second halo. If
use_halo_indexes
is True, the halo numbers are replaced by halo indexes.- Return type:
dict[int, list[tuple[int, float]]]
- match_catalog(min_index=1, max_index=30, threshold=0.5, groups_1=None, groups_2=None, use_family=None)#
Deprecated alternative to
match_halos()
. Use that method instead.
- match_halos(halos_1, halos_2, /, threshold=0.5, use_family=None, fill_value=-1, use_halo_indexes=False)#
Given halo catalogues, identify the likely halo number in the second catalogue for each halo in the first.
For example, if a bridge
b
links snapshotf1
(high redshift) tof2
(low redshift) and we perform:>>> h1 = f1.halos() >>> h2 = f2.halos() >>> cat = b.match_halos(h1, h2)
then
cat
is now a dictionary such that f1.halos()[i] is the major progenitor for``f2.halos()[cat[i]]``, assumingcat[i]
is positive.Halos which cannot be matched because they have too few particles in common give the result
fill_value
, default -1. This is determined by the given threshold fraction of particles in common (specified bythreshold
, default 50%)- Parameters:
halos_1 (pynbody.halo.HaloCatalogue) – The HaloCatalogue for the first snapshot.
halos_2 (pynbody.halo.HaloCatalogue) – The HaloCatalogue for the second snapshot.
threshold (float) – The minimum fraction of particles in common for a match to be considered. Default is 0.5.
use_family (str) – Only match particles of this family. Default is None, in which case all particles are matched. Setting this to a family name can be useful if matching between two different simulations where the relationship between DM particles is known, but perhaps the relationship between gas particles is not (e.g. a Ramses simulation where actually the gas ‘particles’ are cells)
use_halo_indexes (bool) – If True, instead of returning a dictionary mapping to halo numbers, return a numpy array that matches halo IDs (which are zero-based indexes into the full list of halos; for more information see the nomenclature guide in the documentation for
HaloCatalogue
. The default is False, so that halo numbers are used throughout.fill_value (int) – The value to use for halos that cannot be matched. Default is -1.