Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion opmd_viewer/openpmd_timeseries/particle_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class ParticleTracker( object ):
"""

def __init__(self, ts, species=None, t=None,
iteration=None, select=None, preserve_particle_index=False):
iteration=None, select=None, preserve_particle_index=False,
trackers=[]):
"""
Initialize an instance of `ParticleTracker`: select particles at
a given iteration, so that they can be retrieved at a later iteration.
Expand Down Expand Up @@ -93,12 +94,21 @@ def __init__(self, ts, species=None, t=None,
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

trackers: list of ParticleTracker instances
An optional list of trackers. The final result will be the
intersection of the selected particles and the specified
trackers.
"""
# Extract the particle id and sort them
self.selected_pid, = ts.get_particle(['id'], species=species,
select=select, t=t, iteration=iteration)
self.selected_pid.sort()

for tracker in trackers:
self.selected_pid = np.intersect1d(self.selected_pid,
tracker.selected_pid)

# Register a few metadata
self.N_selected = len( self.selected_pid )
self.species = species
Expand Down