reader_moana_0 = reader_ROMS_native_MOANA.Reader(paths[start_month]) # load data for that year reader_moana_1 = reader_ROMS_native_MOANA.Reader(paths[start_month+1]) # load data for that year reader_moana_2 = reader_ROMS_native_MOANA.Reader(paths[start_month+2]) # load data for that year reader_moana_0.multiprocessing_fail = True # bypass the use of multi core for coordinates conversion and seems to make the model run much faster. reader_moana_1.multiprocessing_fail = True # bypass the use of multi core for coordinates conversion and seems to make the model run much faster. reader_moana_2.multiprocessing_fail = True # bypass the use of multi core for coordinates conversion and seems to make the model run much faster. # # Making customised landmask - not required here, we are using the ROMS landmask i.e. included in netcdf files # reader_landmask = reader_global_landmask.Reader( # llcrnrlon=171.0, llcrnrlat=184.5, # urcrnrlon=-42.0, urcrnrlat=-34.0) # use native landmask of ROMS files o.add_reader([reader_moana_0, reader_moana_1, reader_moana_2]) # o.set_config('general:use_auto_landmask', False) # prevent opendrift from making a new dynamical landmask ############################### # PARTICLE SEEDING ############################### #Reinga lons = [172.75, 172.8, 172.8, 172.75] lats = [-34.3, -34.3, -34.35, -34.35] def create_seed_times(start, end, delta): """ crate times at given interval to seed particles """ out = [] start_t = start end_t = datetime.strptime(str(end), "%Y-%m-%d %H:%M:%S")
import time import numpy as np import matplotlib from datetime import datetime, timedelta from opendrift.readers import reader_ROMS_native_MOANA from opendrift.models.bivalvelarvae import BivalveLarvae r = reader_ROMS_native_MOANA.Reader('input/nz5km_avg_200601.nc') o = BivalveLarvae(loglevel=30) o.add_reader([r]) ############################### #Set Configs ############################### o.set_config('general:use_auto_landmask', True) o.set_config('environment:fallback:x_wind', 0.0) o.set_config('environment:fallback:y_wind', 0.0) o.set_config('environment:fallback:x_sea_water_velocity', 0.0) o.set_config('environment:fallback:y_sea_water_velocity', 0.0) o.set_config('environment:fallback:sea_floor_depth_below_sea_level', 100000.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)
############################### # 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. # # Making customised landmask - not required here, using ROMS landmask # reader_landmask = reader_global_landmask.Reader( # llcrnrlon=171.0, llcrnrlat=184.5, # urcrnrlon=-42.0, urcrnrlat=-34.0) # max is 185deg # 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 ############################### # generic point release location for test # Define the starting position of the particles within the buffer of intertidal rocky shore on the West Coast of the North Island (NZ) nb_parts = 100 points = np.loadtxt('./Release_centroid_nat_dist_paua.xyz', 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)
o = BivalveLarvae(loglevel=100) # Set loglevel to 0 for debug information o.max_speed = 5.0 # ############################### # READERS ############################### reader_moana_v19_1 = reader_ROMS_native_MOANA.Reader( '/nesi/nobackup/mocean02574/NZB_N50/nz5km_his_201706.nc') reader_moana_v19_2 = reader_ROMS_native_MOANA.Reader( '/nesi/nobackup/mocean02574/NZB_N50/nz5km_his_201707.nc') reader_moana_v19_3 = reader_ROMS_native_MOANA.Reader( '/nesi/nobackup/mocean02574/NZB_N50/nz5km_his_201708.nc') o.add_reader([reader_moana_v19_1, reader_moana_v19_2, reader_moana_v19_3]) o.set_config('general:use_auto_landmask', False) # dynamical landmask if true ############################### # PARTICLE SEEDING ############################### # Define the starting position of the particles within the buffer of intertidal rocky shore on the West Coast of the North Island (NZ) nb_parts = 250 # number of particles released per point during the release interval points = np.loadtxt( '/nesi/project/vuw03295/Regional_projects/Ninety_miles_beach/First_foreward_input_files/Release_points_rocky_shore_005deg_Moana_all_poly.xyz', 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)
# # Atmospheric model for wind # reader_arome = reader_netCDF_CF_generic.Reader(o.test_data_folder() + # '16Nov2015_NorKyst_z_surface/arome_subset_16Nov2015.nc') # Ocean model for current # 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, neutral_buoyancy_salinity=31.25) #################################################################################################################### # CONFIG
############################### # READERS ############################### thredds_path_1 = 'http://thredds.moanaproject.org:8080/thredds/dodsC/moana/ocean/NZB/v1.9/monthly_avg/nz5km_avg_201706.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. # # Making customised landmask - not required here, using ROMS landmask # reader_landmask = reader_global_landmask.Reader( # llcrnrlon=171.0, llcrnrlat=184.5, # urcrnrlon=-42.0, urcrnrlat=-34.0) # max is 185deg # use native landmask of ROMS files o.add_reader([reader_moana_v19]) # [reader_landmask,reader_moana_v19] o.set_config('general:use_auto_landmask', True) # prevent opendrift from making a new dynamical landmask ############################### # Define habitat ############################### shp, bins = o.habitat('./habitat/Test_habitat.shp') # Location of the shapefile with the habitat ############################### # PARTICLE SEEDING ############################### # generic point release location for test # Define the starting position of the particles within the buffer of intertidal rocky shore on the West Coast of the North Island (NZ) nb_parts = 1 points = np.loadtxt('./Release_test.xyz', delimiter='\t', dtype=str) plon = points[:,0].astype(np.float)
# python example_bivalvelarvae_moana.py 0, for example with no habitat # python example_bivalvelarvae_moana.py 1 for example with habitat use_habitat = int(sys.argv[1]) o = BivalveLarvae(loglevel=0) # Set loglevel to 0 for debug information ############################### # 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
reader1 = reader_ROMS_native_MOANA.Reader(data_path1) reader0.multiprocessing_fail = True #No idea what these lines do, but Simon told me that they make the model ruun faster so I've always included them reader1.multiprocessing_fail = True #add readers to the simulation o.add_reader([reader0, reader1]) ############################## #SET CONFIGURATIONS ############################## #There are a bunch of configs you can set, I'll just explain the ones I've used o.set_config( 'general:use_auto_landmask', False ) #If you use True, opendrift will automatically create a higher-res landmask and project data to try and fill in the gaps. False runs using the backbone's block, 5km landmask. # setting fallback values o.set_config('environment:fallback:x_wind', 0.0) o.set_config('environment:fallback:y_wind', 0.0) o.set_config('environment:fallback:x_sea_water_velocity', 0.0) o.set_config('environment:fallback:y_sea_water_velocity', 0.0) o.set_config('environment:fallback:sea_floor_depth_below_sea_level', 100000.0) #setting diffusion— some horizontal and vertical randomization Kxy = 0.1176 #m2/s-1. These numbers come from some calculation based on the resolution of the model, some one calculated this a while ago for the backbone 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(