Skip to content

Stopping particle tracking at different times #1344

Answered by VeckoTheGecko
MiriamSterl asked this question in Q&A
Discussion options

You must be logged in to vote

I see two ways that this could be done. With kernels, or using post-processing with xarray.

Custom kernels

You can add an "age" to particles (e.g. in seconds as shown below) which tracks how old each particle is. If above a threshold it gets deleted.

Here's an code snippet illustrating what I mean.

class AgingParticle(JITParticle):
    # Age in seconds
    age = Variable(
        'age', dtype=np.float32,
        initial=0.0,
    )

def aging_kernel(particle, fieldset, time):
    particle.age = particle.age + particle.dt

def delete_old_particle_kernel(particle, fieldset, time):
    if particle.age > 25.0:
        particle.delete()

fieldset = ...
lon = ...
lat = ...
pset = ParticleSet(fie…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@erikvansebille
Comment options

Answer selected by erikvansebille
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants