示例#1
0
path201008 = '/nesi/nobackup/mocean02574/NZB_N50/nz5km_his_201008.nc'
path201009 = '/nesi/nobackup/mocean02574/NZB_N50/nz5km_his_201009.nc'
path201010 = '/nesi/nobackup/mocean02574/NZB_N50/nz5km_his_201010.nc'
path201011 = '/nesi/nobackup/mocean02574/NZB_N50/nz5km_his_201011.nc'
path201012 = '/nesi/nobackup/mocean02574/NZB_N50/nz5km_his_201012.nc'
path201101 = '/nesi/nobackup/mocean02574/NZB_N50/nz5km_his_201101.nc'
path201102 = '/nesi/nobackup/mocean02574/NZB_N50/nz5km_his_201102.nc'


paths = [path201001, path201002, path201003, path201004, path201005, path201006, path201007, path201008, path201009, path201010, path201011, path201012, path201101, path201102]

# reader_moana_dec15 = reader_ROMS_native_MOANA.Reader(data_path+"nz5km_his_201707.nc") # load data for that year
# reader_moana_dec15.multiprocessing_fail = True # thisb ypasses the use of multi core for coordinates conversion and seems to make the model run much faster.


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
示例#2
0
date1 = date0 + timedelta(days=31)
mm1 = date1.strftime('%m')
yyyy1 = date1.strftime('%Y')
date2 = date1 + timedelta(days=31)
mm2 = date2.strftime('%m')
yyyy2 = date2.strftime('%Y')

path0 = args.input + 'nz5km_his_' + yyyy0 + mm0 + '.nc'
path1 = args.input + 'nz5km_his_' + yyyy1 + mm1 + '.nc'
path2 = args.input + 'nz5km_his_' + yyyy2 + mm2 + '.nc'

#print(path0)
#print(path1)
#print(path2)

reader0 = reader_ROMS_native_MOANA.Reader(path0)
reader1 = reader_ROMS_native_MOANA.Reader(path1)
reader2 = reader_ROMS_native_MOANA.Reader(path2)

reader0.multiprocessing_fail = True
reader1.multiprocessing_fail = True
reader2.multiprocessing_fail = True

###############################
#Create Simulation Object
###############################

o = BivalveLarvae(loglevel=30)
o.add_reader([reader0, reader1, reader2])

###############################
示例#3
0
####

runtime = [datetime(2016,3,2), datetime(2016,3,3)]
finish_time = (datetime(2016,3,2) + timedelta(days = 31.0))


###############################
# MODEL SELECTION
###############################
o = BivalveLarvae(loglevel=100)
o.max_speed = 3#
###############################
# 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
###############################
示例#4
0
import os
import sys
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')
from opendrift.readers import reader_global_landmask
from opendrift.readers import reader_ROMS_native_MOANA
from opendrift.models.bivalvelarvae import BivalveLarvae

###############################
# MODEL SELECTION
###############################

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(
示例#6
0
###############################
# MODEL SELECTION
###############################

o = OceanDrift(loglevel=100)
#o = SedimentDrift(loglevel=100)  # 0 for debug output
#o = PelagicPlanktonDrift(loglevel=50)  # Set loglevel to 0 for debug information
o.max_speed = 3.0  #

###############################
# READERS
###############################

thredds_path_1 = 'http://thredds.moanaproject.org:8080/thredds/dodsC/moana/ocean/NZB/v1.9/raw_3D/nz5km_his_201709.nc?ntimes,dt,hc,grid,s_rho[5:1:12],Cs_r[5:1:12],h[0:1:466][0:1:396],lon_rho[0:1:466][0:1:396],lat_rho[0:1:466][0:1:396],lon_u[0:1:466][0:1:395],lat_u[0:1:466][0:1:395],lon_v[0:1:465][0:1:396],lat_v[0:1:465][0:1:396],lon_psi[0:1:465][0:1:395],angle[0:1:466][0:1:396],mask_rho[0:1:466][0:1:396],mask_u[0:1:466][0:1:395],mask_v[0:1:465][0:1:396],ocean_time[0:1:240],z_rho[0:1:240][5:1:12][0:1:466][0:1:396],u_eastward[0:1:240][5:1:12][0:1:466][0:1:396],v_northward[0:1:240][5:1:12][0:1:466][0:1:396]'  # Limit to selected depths (raw data: [0:1:39])#'http://thredds.moanaproject.org:8080/thredds/dodsC/moana/ocean/NZB/v1.9/raw_3D/nz5km_his_201710.nc'
reader_moana_v19_1 = reader_ROMS_native_MOANA.Reader(
    [thredds_path_1])  #load data for that year
reader_moana_v19_1.multiprocessing_fail = True  # bypass the use of multi core for coordinates conversion and seems to make the model run much faster.

thredds_path_2 = 'http://thredds.moanaproject.org:8080/thredds/dodsC/moana/ocean/NZB/v1.9/raw_3D/nz5km_his_201708.nc?ntimes,dt,hc,grid,s_rho[5:1:12],Cs_r[5:1:12],h[0:1:466][0:1:396],lon_rho[0:1:466][0:1:396],lat_rho[0:1:466][0:1:396],lon_u[0:1:466][0:1:395],lat_u[0:1:466][0:1:395],lon_v[0:1:465][0:1:396],lat_v[0:1:465][0:1:396],lon_psi[0:1:465][0:1:395],angle[0:1:466][0:1:396],mask_rho[0:1:466][0:1:396],mask_u[0:1:466][0:1:395],mask_v[0:1:465][0:1:396],ocean_time[0:1:248],z_rho[0:1:248][5:1:12][0:1:466][0:1:396],u_eastward[0:1:248][5:1:12][0:1:466][0:1:396],v_northward[0:1:248][5:1:12][0:1:466][0:1:396]'  # to finish the run in the previous month
reader_moana_v19_2 = reader_ROMS_native_MOANA.Reader([thredds_path_2])  #
reader_moana_v19_2.multiprocessing_fail = True

thredds_path_3 = 'http://thredds.moanaproject.org:8080/thredds/dodsC/moana/ocean/NZB/v1.9/raw_3D/nz5km_his_201707.nc?ntimes,dt,hc,grid,s_rho[5:1:12],Cs_r[5:1:12],h[0:1:466][0:1:396],lon_rho[0:1:466][0:1:396],lat_rho[0:1:466][0:1:396],lon_u[0:1:466][0:1:395],lat_u[0:1:466][0:1:395],lon_v[0:1:465][0:1:396],lat_v[0:1:465][0:1:396],lon_psi[0:1:465][0:1:395],angle[0:1:466][0:1:396],mask_rho[0:1:466][0:1:396],mask_u[0:1:466][0:1:395],mask_v[0:1:465][0:1:396],ocean_time[0:1:248],z_rho[0:1:248][5:1:12][0:1:466][0:1:396],u_eastward[0:1:248][5:1:12][0:1:466][0:1:396],v_northward[0:1:248][5:1:12][0:1:466][0:1:396]'  # to finish the run in the previous month
reader_moana_v19_3 = reader_ROMS_native_MOANA.Reader([thredds_path_3])  #
reader_moana_v19_3.multiprocessing_fail = True

# 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=-32.0)# max is 185deg
示例#7
0
date1 = date0 - timedelta(days=15)
mm1 = date1.strftime('%m')
yyyy1 = date1.strftime('%Y')
date2 = date1 - timedelta(days=30)
mm2 = date2.strftime('%m')
yyyy2 = date2.strftime('%Y')

path0 = args.input + 'nz5km_his_' + yyyy0 + mm0 + '.nc'
path1 = args.input + 'nz5km_his_' + yyyy1 + mm1 + '.nc'
path2 = args.input + 'nz5km_his_' + yyyy2 + mm2 + '.nc'

#print(path0)
#print(path1)
#print(path2)

reader0 = reader_ROMS_native_MOANA.Reader(path0)
readerminus1 = reader_ROMS_native_MOANA.Reader(path1)
readerminus2 = reader_ROMS_native_MOANA.Reader(path2)

reader0.multiprocessing_fail = True
readerminus1.multiprocessing_fail = True
readerminus2.multiprocessing_fail = True

###############################
#Create Simulation Object
###############################

o = BivalveLarvae(loglevel=30)
o.add_reader([reader0, readerminus1, readerminus2])

###############################
#e.g.
#from opendrift.models.pelagicegg import PelagicEggDrift

##############################
#CREATING THE SIMLATION OBJECT
##############################
o = BivalveLarvae(
    loglevel=0
)  #loglevel = 0 will print out what the model is doing at every step, so helpful when getting started, but creates huge output files. When you are running larger quantities of runs, you'll want to change to loglevel = 30

#provide paths to the data for the months you want
data_path0 = '/nesi/nobackup/mocean02574/NZB_N50/nz5km_his_201606.nc'
data_path1 = '/nesi/nobackup/mocean02574/NZB_N50/nz5km_his_201607.nc'

#create readers for the backbone files
reader0 = reader_ROMS_native_MOANA.Reader(data_path0)
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(