Exemple #1
0
# 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()
Exemple #2
0
#o.set_config('drift:min_settlement_age_seconds', 3600*24*21) #

o.list_config()
# o.list_configspec()

###############################
# RUN 
###############################
# Running model (until end of driver data)

lons_start = o.elements_scheduled.lon
lats_start = o.elements_scheduled.lat

o.run(stop_on_error=False,
      end_time=reader_moana_2.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])]


outFile = open(f'variability_test_reinga_{months[start_month]}.txt','w')

for i in range(len(lons_end)):
Exemple #3
0
Kxy = 0.1176  #m2/s-1
Kz = 0.01 #m2/s-1

o.set_config('drift:horizontal_diffusivity',Kxy) 
o.set_config('environment:fallback:ocean_vertical_diffusivity', Kz) 
o.set_config('seed:ocean_only',True)
o.set_config('drift:advection_scheme','runge-kutta4')
o.set_config('drift:current_uncertainty', 0.0)
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()

lons = np.array([172., 180., 180., 172.])
lats = np.array([-50., -50., -45., -45.])

nseeds = 10
o.seed_within_polygon(lons, lats, number=nseeds, time=datetime(year=2006, month=1, day=1), z = -1.)
#o.plot()

o.run(stop_on_error=False,
      end_time=datetime(year=2006, month=1, day=30),
      time_step=900, 
      time_step_output = 86400.0,
      export_variables = [])

#o.animation()
    3600)  # PLD spats (algae + mussels) = 20 days; PLD mussels = 5 weeks
o.set_config(
    'drift:min_settlement_age_seconds', 35 * 24 * 3600.0
)  #'float(min=0.0, max=100.0, default=0.0)', comment='Minimum age before beaching can occur, in seconds') => 3 weeks normally (21 days), but I will deal with that in post-processing
###############################

o.list_config()

###############################
# RUN
###############################
# Running model (until end of driver data)
o.run(
    stop_on_error=False,
    time_step=900.0,
    end_time=(datetime(2017, 6, 16) + timedelta(days=36.0)),
    outfile=
    '/nesi/nobackup/vuw03295/ninety_miles_beach_foreward_1_june_2_2017_005deg_Moana_mask.nc',
    time_step_output=3600.0)

###############################
# Plot
###############################

#print(o)
#plt = o.plot(fast=True)
#plt.savefig('/nesi/nobackup/vuw03295/ninety_miles_beach_foreward_1_july_2_2017_005deg_opendrift_mask.png')
#anim = o.animation(fast=True, color='z', background=['x_sea_water_velocity', 'y_sea_water_velocity'])
#anim.save('/nesi/nobackup/vuw03295/ninety_miles_beach_foreward_1_july_2_2017_005deg_opendrift_mask.gif', writer='imagemagick', fps=30)
#o.plot_vertical_distribution()
Exemple #5
0
####################################################################################################################
# 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()
Exemple #6
0
if use_habitat ==1 :
    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)
#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')