Example #1
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()
Example #2
0
  start_t = start
  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(reader_moana_0.start_time, 
                          reader_moana_0.end_time, timedelta(hours = 2))


number = 100
z = np.random.uniform(-10,0,size=len(times)) # generate random depth

for i in range(len(times)):
  o.seed_within_polygon(lons, lats, number = number, time = times[i], z = z[i])

###############################
# PHYSICS
###############################
# these will list all possible options for that model
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)

# No diffusion - constant in that example
#Kxy = 1.0 #0.1176 # m2/s-1
#Kz = 0.001 # m2/s-1
Kxy = 0.1176  #0.1176 # m2/s-1
#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')