Closed AndresSepulveda closed 2 years ago
There is presently no built-in method in OpenDrift to calculate the distance to coast for a particle. But this would certainly be useful for several purposes.
Positions (or properties in general) for the previous time is more problematic than it sounds, as elements may have been seeded and deactivated since last time step. Hence some present particles may have no previous position, and indices are generally shifted. Anyway, previous positions are stored when setting o.set_config('general:coastline_action', 'previous')
, and may be retrieved inside your update() method by:
self.previous_lon[self.elements.ID-1]
self.previous_lat[self.elements.ID-1]
There is a mechanism to store the previous value/property of any element (not only lon and lat), but this needs some polishing and documentation before it is ready to be used. https://github.com/OpenDrift/opendrift/blob/master/opendrift/models/basemodel.py#L544
The polygons in the landmask reader can probably be used to search for the closest one. If you don't need a very accurate one, you could use nearest point in a kdtree query.
tor. 15. apr. 2021, 15:42 skrev Knut-Frode Dagestad < @.***>:
There is presently no built-in method in OpenDrift to calculate the distance to coast for a particle. But this would certainly be useful for several purposes.
Positions (or properties in general) for the previous time is more problematic than it sounds, as elements may have been seeded and deactivated since last time step. Hence some present particles may have no previous position, and indices are generally shifted. Anyway, previous positions are stored when setting o.set_config('general:coastline_action', 'previous'), and may be retrieved inside your update() method by:
self.previous_lon[self.elements.ID-1] self.previous_lat[self.elements.ID-1]
There is a mechanism to store the previous value/property of any element (not only lon and lat), but this needs some polishing and documentation before it is ready to be used.
https://github.com/OpenDrift/opendrift/blob/master/opendrift/models/basemodel.py#L544
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/OpenDrift/opendrift/issues/585#issuecomment-820432222, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAN364ZLLAGIKROYUMOGJ3TI3UN7ANCNFSM4233FN2Q .
Closing for now
Is it possible to measure the distance to the coast for each particle?
What we are looking for is, after a certain period of development, to deactivate a particle if it reaches the coast.
I thinking that with the "previous" option for interaction with the coast this must be calculated somewhere. Is there an index/variable where one could store the time,lat,lon where a particle was moved back to the water? An array of stranding events...