# Vertical swimming ############################### # Need a null terminal_velocity o.set_config('drift:active_vertical_swimming', False) # Correlated random walk across the water column when advected away from coastal habitats #o.set_config('drift:vertical_velocity', (0.001/10)) # Vertical swimming speed of the larvae: in meter/seconds o.set_config('drift:maximum_depth', -50) # Maximum depth of larvae: negative in meters #o.set_config('drift:persistence', 50) # Control the persistence (memory) of the vertical movement to create a correlated random walk and sample the water column o.list_config() # o.list_configspec() ############################### # RUN ############################### # Running model (until end of driver data) o.run(stop_on_error=False, time_step=timedelta(seconds = 900), end_time = finish_time, time_step_output=timedelta(minutes = 60*24), outfile= 'test_development_Opendrift_using_moana.nc') print("--- %s seconds ---" % (time.time() - start_time)) print(process.memory_info().rss) # in bytes print(o) o.plot(fast=True, color='z', corners=[163, 180, -52, -31]) o.animation(fast=True, color='z', corners=[163, 180, -52, -31]) o.animation_profile()
#################################################################################################################### # CONFIG # Adjusting some configuration o.set_config('general:coastline_action', 'previous') o.set_config('drift:vertical_advection', True) o.set_config('drift:vertical_mixing', True) o.set_config('drift:min_settlement_age_seconds', 3600) # minimum age before settling can occur o.set_config( 'vertical_mixing:diffusivitymodel', 'constant') # use eddy diffusivity from ocean model, or fallback value o.set_config( 'vertical_mixing:timestep', 900. ) # seconds - # Vertical mixing requires fast time step (but for constant diffusivity, use same as model step) #################################################################################################################### # Running model o.run(end_time=nordic_native.start_time + timedelta(days=4.0), time_step=900) # Print and plot results. # At the end the wind vanishes, and eggs come to surface print(o) o.plot(fast=True) o.animation(fast=True, color='z') # Interactive slider (not working in browser) o.plot_vertical_distribution()
o.set_config('drift:vertical_advection', False) o.set_config('drift:vertical_mixing', True) o.set_config('vertical_mixing:timestep', 90.0) # if some ocean_vertical_diffusivity!=0, turbulentmixing:timestep should be << 900 seconds ############################### # Type of settlement ############################### #o.set_config('general:coastline_action','previous') # option('none', 'stranding', 'previous', default='stranding') o.set_config('drift:settlement_in_habitat', True) o.set_config('drift:max_age_seconds', 30*24*3600) # o.set_config('drift:min_settlement_age_seconds', 1*24*3600) #o.disable_vertical_motion() #Deactivate any vertical processes/advection""" o.list_config() # o.list_configspec() ############################### # RUN ############################### # Running model (until end of driver data) o.run(stop_on_error=False, time_step=timedelta(seconds = 900), end_time = finish_time, time_step_output=timedelta(minutes = 120), outfile= 'test_development_Opendrift_using_moana.nc') print(o) o.plot(fast=True, color='z') o.animation(fast=True, color='z')
o.set_config('biology:settlement_in_habitat', True) # settlement restricted to suitable habitat only, specified by shapefile or txt file with nan-delimited polys o.add_settlement_habitat('./habitat_moana/poly_habitat_taranaki_bivalve.txt') # Location of the files with the user-defined habitat polygons # habitat files can be text file with simple nan-delimited polygon(s) else: o.set_config('biology:settlement_in_habitat', False) # particle will settle on coast or seafloor after it reached 'min_settlement_age_seconds' o.list_config() ############################### # RUN ############################### # Running model (until end of driver data) o.run(stop_on_error=False, time_step=timedelta(seconds = 900), end_time = reader_moana_v19.start_time + timedelta(days = 4.0), time_step_output=timedelta(seconds = 3600 * 3)) import matplotlib.pyplot as plt plt.ion() o.plot(fast=True)#, corners=[163, 180, -52, -31]) if use_habitat ==1 : # add habitat polygons import cartopy.crs as ccrs gcrs = ccrs.PlateCarree() plt.plot(o.multiShp.exterior.xy[0][:],o.multiShp.exterior.xy[1][:], transform = gcrs) import pdb;pdb.set_trace() # o.animation(fast=True, color='status') #corners=[163, 180, -52, -31]) # o.animation_profile() # o.plot(fast=True)
o.set_config('drift:max_age_seconds', 3600 * 24 * 35) o.set_config('drift:min_settlement_age_seconds', 3600 * 24 * 21) o.set_config('general:seafloor_action', 'lift_to_seafloor') o.set_config('drift:vertical_mixing', False) o.set_config('general:coastline_action', 'previous') o.list_config() ############################### #Run ############################### lons_start = o.elements_scheduled.lon lats_start = o.elements_scheduled.lat o.plot() o.run(stop_on_error=False, end_time=reader2.end_time, time_step=900, time_step_output=86400.0, export_variables=[]) index_of_first, index_of_last = o.index_of_activation_and_deactivation() lons = o.get_property('lon')[0] lats = o.get_property('lat')[0] status = o.get_property('status')[0] lons_end = lons[index_of_last, range(lons.shape[1])] lats_end = lats[index_of_last, range(lons.shape[1])] status_end = status[index_of_last, range(lons.shape[1])] print(o.status_categories)
#SEED PARTICLES ############################## #There's a bunch of different ways to seed particles, here's my go-to method #give corners of a polygon to seed within minlon = 173.2 maxlon = 173.3 minlat = -35.6 maxlat = -35.5 lons = [minlon, maxlon, maxlon, minlon] lats = [maxlat, maxlat, minlat, minlat] time0 = reader0.start_time z = -5 number = 100 o.seed_within_polygon(lons, lats, number=number, z=z, time=time0) ############################## #RUN ############################## #a bunch of tricks you can do here to save only exactly what you want, but here's the basics o.run(stop_on_error=False, end_time=reader1.end_time, time_step=3600, time_step_output=3600.0, outfile='path/outfile_name.nc') o.plot(filename='path/figure_name.jpg') o.animation(filename='path/anim_name.mp4')