Giving a group identifier to particles released with each repeatdt timestep #1720
-
QuestionQuestionHi, I am releasing all my particles every 7 days and want to give each group an ID. Initially I tried doing this with a kernel but it did not work, and I don't think it's very useful because the ID shouldn't have to be recalculated with each timestep. How can I achieve something similar, do you have any ideas? Perhaps use a different particle set for each release event? Supporting code/error messagesextra_vars = [
Variable('age', dtype=np.float32, initial=0, to_write=False),
Variable('on_land', dtype=np.int32, to_write=False),
Variable('temperature', dtype=np.float32),
Variable('cohort', dtype=np.float32)
]
Particle = JITParticle.add_variables(extra_vars)
def Cohort(particle, fieldset, time):
"""Assign each release event a cohort ID"""
cohort = time / repeatdt
particle.cohort = cohort
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi @TomMBIO, thanks for this question I think the easiest approach is to not use cohort = ... # Here code to create an array that calculates the cohort number for each particle
pset = ParticleSet(fieldset=fieldset, pclass=parcels.JITParticle, lon=lon, lat=lat, time=time, cohort=cohort) See also the assigning each particle its own time section of the delayed start tutorial. Note, by the way, that for Variable('cohort', dtype=np.float32, to_write='once') Does that help? |
Beta Was this translation helpful? Give feedback.
Hi @TomMBIO , yes, that looks like it should work. minor note is that
release_time
would need to be a datetime object.So something like