OpenDrift/opendrift

Recording the final position of deactivated particles

CaroMedel opened this issue · 4 comments

Hi,

I'm working with the stranding method for coastal interaction. Is it possible for deactivated particles to continue recording their last horizontal and vertical positions? By default, when a particle is deactivated, its variables lon, lat and z become a huge number. I would like them to record their last position until the end of simulation. Is that possible?

Best,
Caro

Hi,

For performance reasons, no more data are written to file after a particle has been deactivated (and before it has been seeded).
Thus when loading this, and not filtering away deactivated particles, you will see garbage values, e.g. very large numbers for latitude/longitude.

However, the built-in method get_property replaces these values with the last value before deactivation, e.g.:
>>> lon = o.get_property('lon')[0]
This is used e.g. by the internal plotting-methods.

If importing the output from OpenDrift with Xarray, you can filter away the garbage values with ds = ds.where(ds.status>=0), see e.g. this example from the stand-alone TrajAn-package:
https://opendrift.github.io/trajan/gallery/example_opendrift.html#sphx-glr-gallery-example-opendrift-py

Thanks for your quick response. But I don't wan to to filter away the deactivated particles. I'm reviewing a specific time and I want to check the position of activated particles and deactivated ones as well. Not for visual purposes, but for analysis

Caro

When using o.get_property() the NaN-values are filled with the last value before deactivation:
https://opendrift.github.io/_modules/opendrift/models/basemodel.html#OpenDriftSimulation.get_property

In the future, the writing to file will probably be changed so that the last value is written also after deactivation.

I'm not using python for this analysis. But I solved it during the post-processing of the output.

Thanks