Skip to content

Conversation

@HaydenSchilling
Copy link

This example shows how to create a particle set in JIT mode while still sampling initial conditions of a variable eg. Temperature.

This is an example of a solution to the github issue here: Parcels-code/Parcels#861 and I am attempting to contribute this example as I recently applied it in my own code based upon suggestions in that issue thread.

Note: This is my first attempt at a contribution so please let me know if I am suppose to do anything else for a contribution.

This example shows how to create a particle set in JIT mode while still sampling initial conditions of a variable eg. Temperature.  This is an example of a solution to the github issue here: Parcels-code/Parcels#861
removed reference to a variable not in this example (previous lat and lon)
Copy link
Member

@erikvansebille erikvansebille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks ofr contributing, @HaydenSchilling. A few minor comments below

Comment on lines 28 to 36
# Excute the code
pset.execute(kernels,
dt=delta(minutes=30),
output_file=pfile,
verbose_progress=True,
#moviedt=delta(hours=1),
runtime = runtime,
recovery={ErrorCode.ErrorOutOfBounds: DeleteParticle})
pfile.close() No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this part of the script is needed. Since you've defined the kernels above, users can use them in their own pset.execute()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, that makes sense, thanks. I've now removed this bit.

Comment on lines +19 to +22
def SampleInitial(particle, fieldset, time):
if particle.sampled == 0:
particle.temp = fieldset.temp[time, particle.depth, particle.lat, particle.lon]
particle.sampled = 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this actually mean that the temperature at time=0 is also written to the ParticleFile?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was suppose to... but looking closer it appears it does not to.
I originally checked it looking at distance calulations in another script. The calculations worked with this method (using a prev_lat variable --- Did not work without this kernel) but looking closer it is calculating these initial values but not recording them in the particle file for any variable. This might need some more work. Sorry.

remove execution lines. Add a note that is is not recording the day 0 data in the particle set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants