#%% # Note that Runge-Kutta here makes a difference to Euler scheme o.set_config('drift:advection_scheme', 'runge-kutta4') o.disable_vertical_motion() o.set_config('environment:fallback:land_binary_mask', 0) double_gyre = reader_double_gyre.Reader(epsilon=.25, omega=0.628, A=0.1) print(double_gyre) o.add_reader(double_gyre) #%% # Calculate Lyapunov exponents times = [double_gyre.initial_time + n*time_step_output for n in range(steps)] lcs = o.calculate_ftle(time=times, time_step=time_step, duration=duration, delta=delta, RLCS=False) #%% # Make run with particles for the same period o.reset() x = [.9] y = [.5] lon, lat = double_gyre.xy2lonlat(x, y) o.seed_elements(lon, lat, radius=.15, number=2000, time=double_gyre.initial_time) o.disable_vertical_motion() o.run(duration=duration, time_step=time_step, time_step_output=time_step_output) o.animation(buffer=0, lcs=lcs, hide_landmask=True)
from opendrift.readers import reader_double_gyre from opendrift.models.oceandrift import OceanDrift o = OceanDrift(loglevel=20) # Set loglevel to 0 for debug information o.fallback_values['land_binary_mask'] = 0 # Note that Runge-Kutta here makes a difference to Euler scheme o.set_config('drift:scheme', 'runge-kutta4') double_gyre = reader_double_gyre.Reader(epsilon=.25, omega=0.628, A=0.1) print double_gyre o.add_reader(double_gyre) lcs = o.calculate_ftle(time=double_gyre.initial_time + timedelta(seconds=3), time_step=timedelta(seconds=.5), duration=timedelta(seconds=15), delta=.02) # These plots should reproduce Mov 12 on this page: # http://shaddenlab.berkeley.edu/uploads/LCS-tutorial/examples.html plt.subplot(2, 1, 1) plt.imshow(lcs['RLCS'][0, :, :], interpolation='nearest', cmap='jet', origin='lower') plt.colorbar() plt.title('Repelling LCS (forwards)') plt.subplot(2, 1, 2) plt.imshow(lcs['ALCS'][0, :, :], interpolation='nearest', cmap='jet',
o = OceanDrift(loglevel=20) # Set loglevel to 0 for debug information o.set_config('general:basemap_resolution', 'i') # Norkyst ocean model reader_norkyst = reader_netCDF_CF_generic.Reader( o.test_data_folder() + '16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc') #o.add_reader([reader_norkyst, reader_arome]) o.add_reader([reader_norkyst]) # Calculating attracting/backwards FTLE/LCS at 20 hours lcs = o.calculate_ftle(time=reader_norkyst.start_time + timedelta(hours=20), time_step=timedelta(minutes=30), duration=timedelta(hours=5), delta=1000, RLCS=False) # Simulation from beginning and up to 30 hours (time of LCS) o.reset() o.seed_elements(lon=4.4, lat=60.2, number=1000, radius=1000, time=reader_norkyst.start_time) o.run(end_time=reader_norkyst.start_time + timedelta(hours=20), time_step=timedelta(minutes=30)) o.plot(lcs=lcs, vmin=1e-7, vmax=1e-4, colorbar=True, show_particles=True)