Particle tracking: ParticleTracker

class openpmd_viewer.ParticleTracker(ts, species=None, t=None, iteration=None, select=None, preserve_particle_index=False)[source]

Initialize an instance of ParticleTracker: select particles at a given iteration, so that they can be retrieved at a later iteration.

Parameters:
  • ts (an OpenPMDTimeSeries object) – Contains the data on the particles

  • species (string) – A string indicating the name of the species This is optional if there is only one species

  • t (float (in seconds), optional) – Time at which to obtain the data (if this does not correspond to an existing iteration, the closest existing iteration will be used) Either t or iteration should be given by the user.

  • iteration (int) – The iteration at which to obtain the data Either t or iteration should be given by the user.

  • select (dict or 1darray of int, optional) – Either None or a dictionary of rules to select the particles, of the form ‘x’ : [-4., 10.] (Particles having x between -4 and 10) ‘ux’ : [-0.1, 0.1] (Particles having ux between -0.1 and 0.1 mc) ‘uz’ : [5., None] (Particles with uz above 5 mc). Can also be a 1d array of interegers corresponding to the selected particles id

  • preserve_particle_index (bool, optional) – When retrieving particles at a several iterations, (for instance, with: ` >>> x1, = ts.get_particle( ['x'], select=pt, iteration=400 ) >>> x2, = ts.get_particle( ['x'], select=pt, iteration=500 ) ` it is sometimes important that the same individual particle has the same index in the array x1 and x2. Using preserve_particle_index=True ensures that this is the case. However, this means that, for a particle that becomes absent at a later iteration, its index in the array has to be filled also. In this case, a NaN is returned at the index of this particle. When preserve_particle_index=False, no NaN is returned (the returned array is simply smaller when particles are absent) but then it is not garanteed that a given particle keeps the same index