-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update bivalvelarvae.py with habitat settlement #1
base: master
Are you sure you want to change the base?
Conversation
I tried to add the ability to settlement particles in a shapefile (representing a suitable environment). When settlement_in_habitat is True, elements are only deactivated if they are old enough to settle and if they are within the boundaries of an element of the shapefile. To activate in a script add these lines before running OpenDrift: ############################### # Define habitat ############################### shp, bins = o.habitat('./habitat/Test_habitat.shp') # Location of the shapefile with the habitat ############################### # Type of settlement ############################### o.set_config('drift:settlement_in_habitat', True) o.set_config('drift:max_age_seconds', max_PLD) # maximum duration of PLD without settlement o.set_config('drift:min_settlement_age_seconds', min_PLD) # Beginning of the competency period
opendrift/models/bivalvelarvae.py
Outdated
in_habitat = pt.within(poly) | ||
if in_habitat == True: | ||
#import pdb; pdb.set_trace() | ||
self.environment.land_binary_mask[old_enough[i]] = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should work better:
self.environment.land_binary_mask[old_enough[i]] = 6
opendrift/models/bivalvelarvae.py
Outdated
|
||
# Deactivate elements that are within a polygon and old enough to settle | ||
# ** function expects an array of size consistent with self.elements.lon | ||
self.deactivate_elements((self.environment.land_binary_mask == 1), reason='settled_in_habitat') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should work better:
self.deactivate_elements((self.environment.land_binary_mask == 6), reason='settled_in_habitat')
Changed self.environment.land_binary_mask == 1 to self.environment.land_binary_mask == 6 when particles are within an habitat (land_binary_mask == 1 was conflicting with settlement at the coast).
Calvin found that the function seeded_on_land was flagging the particles that stopped moving long after being released. I changed the function with the original version of basemodel.py and it seems to work as intended.
Optimization of the habitat module. The use of the MultiPolygon object should speed up the function.
@RomainChaput - sorry I've missed this one ! I'll have a good look next week. |
… maximum depth, and Haliotis iris I added a vertical swimming behavior correlated to the direction of the currents: when larvae are advected away from the coast they start a correlated random walk, swimming up and down until they find a current that bring them closer to shore. Because this code involves calling the habitat module at every timestep, I used a Ball Tree algorithm to classify the habitat centroids and improve the efficiency of the searching algorithm. I also added a maximum dispersal depth that the user can specify. Finally, I added an option to simulate the vertical migration of Haliotis iris during the first 12 hours of dispersal (sink, then rise to the surface).
…ce-for-physics-presentation Add files via upload
I tried to add the ability to settlement particles in a shapefile (representing a suitable environment). When settlement_in_habitat is True, elements are only deactivated if they are old enough to settle and if they are within the boundaries of an element of the shapefile.
To activate in a script add these lines before running OpenDrift:
###############################
Define habitat
###############################
shp, bins = o.habitat('./habitat/Test_habitat.shp') # Location of the shapefile with the habitat
###############################
Type of settlement
###############################
o.set_config('drift:settlement_in_habitat', True)
o.set_config('drift:max_age_seconds', max_PLD) # maximum duration of PLD without settlement
o.set_config('drift:min_settlement_age_seconds', min_PLD) # Beginning of the competency period