pynbody.halo.details.number_mapping.NonMonotonicHaloNumberMapper#

class pynbody.halo.details.number_mapping.NonMonotonicHaloNumberMapper(halo_numbers_or_ordering: ndarray[tuple[int, ...], dtype[int]], ordering=False, start_index=0)[source]#

Bases: MonotonicHaloNumberMapper

Attributes:
all_numbers

Returns the original halo numbers

Methods

index_to_number(halo_index)

Convert a zero-based offset to a halo number

number_to_index(halo_number)

Convert a halo number to a zero-based index

__init__(halo_numbers_or_ordering: ndarray[tuple[int, ...], dtype[int]], ordering=False, start_index=0)[source]#

A HaloNumberMapper that allows for arbitrary mappings between halo numbers and indices.

Can be created either by specifying the halo numbers for each halo, in index order, or by specifying the ordering that the halos should take, starting from start_index and running contiguously.

Parameters:
  • halo_numbers_or_ordering (array-like) – If ordering is False, this should be an array of halo numbers. If ordering is True, this should be an array of the same length as the number of halos, specifying the order in which the halos should be presented.

  • ordering (bool) – The meaning of halo_numbers_or_ordering. If False, it is an array of halo numbers. If True, it is an array of the same length as the number of halos, specifying the order in which the halos should be presented, starting at start_index.

  • start_index (int) – The starting index for the ordering. Only used if ordering is True.

property all_numbers#

Returns the original halo numbers

index_to_number(halo_index: int | ndarray[tuple[int, ...], dtype[int]]) int | ndarray[tuple[int, ...], dtype[int]][source]#

Convert a zero-based offset to a halo number

number_to_index(halo_number: int | ndarray[tuple[int, ...], dtype[int]]) int | ndarray[tuple[int, ...], dtype[int]][source]#

Convert a halo number to a zero-based index