Closed GuiCruz closed 3 years ago
Hi,
This is unfortunately not possible with the standard configuration, where you can chose only one of "stranded", "previous" or "none".
However, this should be fairly straightforward to implement within your specific update-method. E.g. you could use config:stranding, to apply to the regular coastline, and then make a check of which elements hits/crosses your barrier/polygon, and move these back to their previous position. This polygon should then also not be a part of the "coastline polygon".
I think I understood. Has something similar been done in the examples on the opendrift website? or would you have any example to give me?
My domain is a hypothetical lagoon with a small connection to the sea. I'm trying to figure out how many particles are crossing that channel between the lagoon and the sea, but some of these particles are getting stuck on the shore as well.
No, I don't think there are any examples similar to this, as exactly this is not possible to do with standard configuration (if I understand correctly).
If you don't want any stranding anywhere inside your lagoon, you should use stranding:previous
But if you at the same time would like to have stranding for the one special barrier polygon, you should leave this polygon out of your landmask, and instead do something like this inside your update
method:
self.deactivate_elements(<indices_of_elements_inside_barrier_polygon>, reason='hit barrier')
but how can I get the indices of the elements that fell in that polygon?
There is no available high-level method to give you that, so it would have to be done with "low level" python code.
But you may perhaps find something re-usable in reader_shape
, or perhaps this reader may even be used directly:
https://opendrift.github.io/_modules/opendrift/readers/reader_shape.html#Reader
I think I'll run opendrift twice one with and one without barrier and decrease afterwards. Thank you for your help
After reading the Opendrift documentation I understood that you can create your own module. Should I add something like this to this part of the update ()?
def update(self):
"""Update positions and properties of elements."""
# Simply move particles with ambient current
self.advect_ocean_current()
# Advect particles due to surface wind drag,
# according to element property wind_drift_factor
self.advect_wind()
# Stokes drift
self.stokes_drift()
# Turbulent Mixing
if self.get_config('drift:vertical_mixing') is True:
self.update_terminal_velocity()
self.vertical_mixing()
else: # Buoyancy
self.vertical_buoyancy()
# Vertical advection
self.vertical_advection()
self.deactivate_elements(self.environment.land_binary_mask==1, reason='stranded')
This code inside the update method worked for me. All particles inside this rectangle are deactivated and counted.
Thanks again for your help!
self.deactivate_elements((self.elements.lon < -52.1353) & (self.elements.lon > -52.1380) & (self.elements.lat > -32.0807) & (self.elements.lat < -32.0679), reason='inside of lagoon')
Very good, yes that should work well.
Hello again.
I would like to know if it is possible to use different types of coastilne action "stranded" and "previous" for each polygon in my domain. One of the polygons in my domain is the model's coastline and the other is like a barrier. This "barrier" polygon would later inform me how many particles got stuck in it (with the option "stranded")