Update bivalvelarvae.py with habitat settlement#1
Open
RomainChaput wants to merge 5 commits into
Open
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
RomainChaput
commented
Apr 29, 2021
| in_habitat = pt.within(poly) | ||
| if in_habitat == True: | ||
| #import pdb; pdb.set_trace() | ||
| self.environment.land_binary_mask[old_enough[i]] = 1 |
Author
There was a problem hiding this comment.
This should work better:
self.environment.land_binary_mask[old_enough[i]] = 6
RomainChaput
commented
Apr 29, 2021
|
|
||
| # 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') |
Author
There was a problem hiding this comment.
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.
Owner
|
@RomainChaput - sorry I've missed this one ! I'll have a good look next week. |
Author
… 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).
simonweppe
pushed a commit
that referenced
this pull request
Feb 22, 2024
…ce-for-physics-presentation Add files via upload
simonweppe
pushed a commit
that referenced
this pull request
Mar 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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