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

GadgetParticleDataset.update_particle_ids(groups: list[str] = None, policy: str = None, **kwargs)#

Update (reset) particle IDs for groups that already have an ID field.

This method goes through each of the specified groups and checks for the existence of a particle ID field. If the field exists, it is overwritten with a new set of IDs according to the specified policy. If the field does not exist, the group is skipped silently.

For policy='global', IDs are assigned sequentially across all specified groups. As such, even if a group does not have particle ids, it’s total number of particles is still counted towards the global ID assignment.

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”.

  • 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

  • Groups without an existing ID field are skipped silently.

  • This operation overwrites the existing ID field for selected groups.

  • IDs are always assigned as 1-based positive integers, consistent with Gadget and most downstream analysis tools.