def test_unseeded_elements(self): o = PlastDrift() # Seeding elements for 12 hours, but running only 6 time = datetime(2019, 8, 30, 12) o.seed_elements(lon=4.85, lat=60, number=10, time=[time, time + timedelta(hours=6)], origin_marker=7) o.seed_elements(lon=4.75, lat=60, number=10, time=[time, time + timedelta(hours=6)], origin_marker=8) o.fallback_values['land_binary_mask'] = 0 o.fallback_values['y_sea_water_velocity'] = 1 o.run(duration=timedelta(hours=3)) self.assertEqual(o.history.shape[0], 10) self.assertEqual(o.history.shape[1], 4) self.assertEqual(o.history['origin_marker'].min(), 7) self.assertEqual(o.history['origin_marker'].max(), 8)
def test_wind_drift_shear(self): """Testing PlastDrift model, with wind-induced current shear""" o = PlastDrift(loglevel=30) o.fallback_values['x_wind'] = 10 o.fallback_values['y_wind'] = 0 o.fallback_values['land_binary_mask'] = 0 o.seed_elements(lat=60, lon=5, time=datetime.now(), number=3, z = np.array([0, -0.05, -.1])) o.run(duration=timedelta(hours=10)) self.assertIsNone(np.testing.assert_array_almost_equal( o.elements.lon, [5.013484,5.03395595,5.01149002])) self.assertAlmostEqual(o.elements.lat[0], o.elements.lat[2])
#!/usr/bin/env python from datetime import datetime, timedelta from opendrift.readers import reader_netCDF_CF_generic from opendrift.models.plastdrift import PlastDrift o = PlastDrift(loglevel=0) o.list_configspec() # Arome atmospheric model reader_arome = reader_netCDF_CF_generic.Reader(o.test_data_folder() + '16Nov2015_NorKyst_z_surface/arome_subset_16Nov2015.nc') # 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]) start_time = reader_arome.start_time end_time = reader_arome.start_time + timedelta(hours=5) end_time = reader_arome.end_time time = [start_time, start_time + timedelta(hours=5)] # Seeding some particles lon = 4.6; lat = 60.0; # Outside Bergen o.seed_elements(lon, lat, radius=50, number=3000, time=time) o.run(end_time=end_time, time_step=1800, time_step_output=3600) o2 = PlastDrift(loglevel=0) o2.add_reader([reader_norkyst]) # No wind/Stokes o2.seed_elements(lon, lat, radius=50, number=3000, time=time)
def test_wind_drift_shear(self): """Testing PlastDrift model, with wind-induced current shear""" o = PlastDrift(loglevel=30) o.set_config('environment:fallback:x_wind', 10) o.set_config('environment:fallback:y_wind', 0) o.set_config('environment:fallback:land_binary_mask', 0) o.seed_elements(lat=60, lon=5, time=datetime.now(), number=3, z = np.array([0, -0.05, -.1])) o.run(duration=timedelta(hours=10)) self.assertIsNone(np.testing.assert_array_almost_equal( o.elements.lon, [5.011935,5.01738,5.011235])) self.assertAlmostEqual(o.elements.lat[0], o.elements.lat[2], 3)
#!/usr/bin/env python """ Plastic ================================== """ from datetime import timedelta from opendrift.readers import reader_netCDF_CF_generic from opendrift.models.plastdrift import PlastDrift o = PlastDrift(loglevel=20) o.list_configspec() # to see available configuration options # Arome atmospheric model reader_arome = reader_netCDF_CF_generic.Reader( o.test_data_folder() + '16Nov2015_NorKyst_z_surface/arome_subset_16Nov2015.nc') # 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]) start_time = reader_arome.start_time end_time = reader_arome.start_time + timedelta(hours=5) end_time = reader_arome.end_time time = [start_time, start_time + timedelta(hours=5)] #%% # Seeding some particles lon = 4.6
#!/usr/bin/env python """ Plastic ================================== """ from datetime import datetime, timedelta from opendrift.readers import reader_netCDF_CF_generic from opendrift.models.plastdrift import PlastDrift o = PlastDrift(loglevel=0) o.list_configspec() # Arome atmospheric model reader_arome = reader_netCDF_CF_generic.Reader( o.test_data_folder() + '16Nov2015_NorKyst_z_surface/arome_subset_16Nov2015.nc') # 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]) start_time = reader_arome.start_time end_time = reader_arome.start_time + timedelta(hours=5) end_time = reader_arome.end_time time = [start_time, start_time + timedelta(hours=5)] # Seeding some particles lon = 4.6