end_t = datetime.strptime(str(end), "%Y-%m-%d %H:%M:%S") while start_t < end: out.append(start_t) start_t += delta return out times = create_seed_times(runtime[0], runtime[1], timedelta(days = 1)) # Define release depth z = np.random.uniform(-0.5,-8,size=tot_parts) # generate random depth #z = 'seafloor+1' # Seed particles for i in range(len(times)): o.seed_elements(plon, plat, number=tot_parts, z=z, time = times[i], terminal_velocity=0.001) # seed o.set_config('seed:ocean_only',False) # keep only particles from the "frame" that are on the ocean #lon0 = 173.11611246985 #lat0 = -35.3876529758404 #radius_in_m = 1000 #nb_parts = 1000 #z = np.random.uniform(-50,0,size=nb_parts) # generate random depth # continuous release from tstart_release to tend_release within a 1000m radius #o.seed_elements(plon, plat, # #radius=radius_in_m, # number=tot_parts, # z=z,
delimiter='\t', dtype=str) plon = points[:, 0].astype(np.float) plat = points[:, 1].astype(np.float) tot_parts = nb_parts * len(plon) # total number of particles released plon = np.tile(plon, nb_parts) plat = np.tile(plat, nb_parts) z = np.random.uniform(-20, -1, size=tot_parts) # generate random depth #z = 'seafloor+1' # continuous release from tstart_release to tend_release at random depth o.seed_elements(plon, plat, number=tot_parts, z=z, time=[datetime(2017, 6, 9), datetime(2017, 6, 16)], terminal_velocity=0.0025) # seed o.set_config( 'seed:ocean_only', True) # keep only particles from the "frame" that are on the ocean ############################### # PHYSICS ############################### o.set_config('environment:fallback:x_wind', 0.0) o.set_config('environment:fallback:y_wind', 0.0)
############################### # READERS ############################### thredds_path_1 = 'http://thredds.moanaproject.org:8080/thredds/dodsC/moana/ocean/NZB/v1.9/monthly_avg/nz5km_avg_201603.nc' reader_moana_v19 = reader_ROMS_native_MOANA.Reader(thredds_path_1) # load data for that year reader_moana_v19.multiprocessing_fail = True # bypass the use of multi core for coordinates conversion and seems to make the model run much faster. # use native landmask of ROMS files o.add_reader([reader_moana_v19]) # [reader_landmask,reader_moana_v19] o.set_config('general:use_auto_landmask', False) # prevent opendrift from making a new dynamical landmask ############################### # PARTICLE SEEDING ############################### # 174.949513895 -40.029317969 28045 Taranaki Bight o.seed_elements( lon = 174.949513895-.1, lat = -40.029317969-.1, number=100, z = - np.linspace(2,50,100) , radius = 1000, terminal_velocity = -1.0, # setting a large settling velocity on purpose to make seafloor contacts time = reader_moana_v19.start_time) ############################### # PHYSICS & CONFIG ############################### # horizontal and vertical diffusion Kxy = 0.1 # m2/s-1 Kz = 0.001 # m2/s-1 - setting a large o.set_config('environment:fallback:ocean_vertical_diffusivity', Kz) # specify constant ocean_vertical_diffusivity in m2.s-1 o.set_config('drift:vertical_mixing', True) o.set_config('vertical_mixing:diffusivitymodel', 'constant') # constant >> use fall back values (can be environment (i.e. from reader), windspeed_Large1994 ,windspeed_Sundby1983) o.set_config('vertical_mixing:timestep', 900.) # seconds - # Vertical mixing requires fast time step (but for constant diffusivity, use same as model step) o.set_config('drift:horizontal_diffusivity',Kxy) # using new config rather than current uncertainty o.set_config('drift:max_age_seconds', 10*24*3600) # max age before dying ###############################
nordic_native = reader_ROMS_native.Reader( o.test_data_folder() + '2Feb2016_Nordic_sigma_3d/Nordic-4km_SLEVELS_avg_00_subset2Feb2016.nc') o.add_reader(nordic_native) # default values for forcing variables o.set_config('environment:fallback:ocean_vertical_diffusivity', 0.001) # m2/s #################################################################################################################### #################################################################################################################### # SEEDING # time = datetime.utcnow() o.seed_elements(lon=12.0, lat=68.3, z=-3.0, radius=100, number=100, time=nordic_native.start_time, neutral_buoyancy_salinity=31.25) #################################################################################################################### # 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',
# reader_norkyst = reader_netCDF_pytCF_generic.Reader(o.test_data_folder() + # '16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc') # # Creating and adding reader for Nordic 4km current dataset nordic_native = reader_ROMS_native.Reader(o.test_data_folder() + '2Feb2016_Nordic_sigma_3d/Nordic-4km_SLEVELS_avg_00_subset2Feb2016.nc') o.add_reader(nordic_native) # default values for forcing variables o.set_config('environment:fallback:ocean_vertical_diffusivity',0.001) # m2/s #################################################################################################################### #################################################################################################################### # SEEDING # time = datetime.utcnow() o.seed_elements(lon=12.0, lat=68.3, z=-3.0, radius=100, number=100, time=nordic_native.start_time, terminal_velocity = 0.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('biology:min_settlement_age_seconds', 3600) # minimum age before settling can occur o.set_config('vertical_mixing:diffusivitymodel', 'constant') # use fallback value ocean_vertical_diffusivity 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