pisces.extensions.simulation.gadget.particles.GadgetParticleDataset.add_particle_ids#

GadgetParticleDataset.add_particle_ids(groups: list[str] = None, policy: str = None, overwrite: bool = False, **kwargs)#

Add unique particle IDs to specified groups.

Parameters:
  • groups (list of str, optional) – List of particle group names to add particle ids to. If None, all groups are used. This can be used both to specify the groups that should be given an ID field and (for policy='global') to specify the order in which the IDs are assigned to each group.

  • policy ({"global", "per_group"}, optional) –

    The policy for assigning particle IDs. Options are:

    • ”global”: Assign unique IDs across all specified groups, ensuring no duplicates. IDs are assigned sequentially starting from 1, in the order of groups provided.

    • ”per_group”: Assign unique IDs within each group, starting from 1 for each group. This allows for duplicate IDs across different groups.

    Default is “global”.

  • overwrite (bool, optional) – Whether to overwrite existing ID fields if they already exist. Defaults to False.

  • kwargs

    Additional keyword arguments passed to the ID generation function. The following are recognized:

    • start_id: int, optional

      The starting ID number for the first group (default is 1).

    • dtype: numpy dtype, optional

      The numpy dtype to use for the ID field (default is np.uint32).

Notes

Behind the scenes, this method will do two things:

  1. Create a “particle id” group (named following the class’s _ID_FIELD_NAME attribute) which contains an ordered list of all of the particle IDs for that particle type. Depending on the policy, these ids will either start from 1 for each group or will be globally unique across all groups.

  2. Each group will get a PIDOFF attribute, which indicates the PID of the very first particle in that group.