def atest_reader_boundary_thredds(self): o = PelagicEggDrift(loglevel=20) reader_norkyst = reader_netCDF_CF_generic.Reader('http://thredds.met.no/thredds/dodsC/sea/norkyst800m/1h/aggregate_be') reader_nordic = reader_netCDF_CF_generic.Reader('http://thredds.met.no/thredds/dodsC/fou-hi/nordic4km-1h/Nordic-4km_SURF_1h_avg_00.nc') o.add_reader([reader_norkyst, reader_nordic]) o.fallback_values['land_binary_mask'] = 0 lon = 0.2; lat = 61.0; # Close to NorKyst boundary time = reader_nordic.start_time o.seed_elements(lon, lat, radius=5000, number=100, time=time, z=0) o.set_config('turbulentmixing:timestep', 5) o.run(steps=5, time_step=3600, time_step_output=3600)
def test_get_environment(self): o = PelagicEggDrift(loglevel=0) reader_nordic = reader_ROMS_native.Reader(o.test_data_folder() + '2Feb2016_Nordic_sigma_3d/Nordic-4km_SLEVELS_avg_00_subset2Feb2016.nc', name='Nordic') reader_arctic = reader_netCDF_CF_generic.Reader(o.test_data_folder() + '2Feb2016_Nordic_sigma_3d/Arctic20_1to5Feb_2016.nc', name='Arctic') ###################################################### # Vertical interpolation is another issue to be fixed: reader_nordic.zlevels = reader_arctic.z ###################################################### o.add_reader([reader_nordic, reader_arctic]) # One point covered only by Nordic, two points coverd # by both readers, and two points covered by none of the readers testlon = np.array((14.0, 20.0, 20.1, 4, 5)) testlat = np.array((70.1, 76.0, 76.1, 60, 60)) testz = np.random.uniform(0, 0, len(testlon)) self.assertItemsEqual([0], reader_nordic.covers_positions( testlon, testlat, testz)) self.assertItemsEqual([0, 1, 2], reader_arctic.covers_positions( testlon, testlat, testz)) o.seed_elements(testlon, testlat, testz, time=reader_nordic.start_time) o.fallback_values['land_binary_mask'] = 0 env, env_profiles, missing = \ o.get_environment(o.required_variables, reader_nordic.start_time, testlon, testlat, testz, o.required_profiles) self.assertAlmostEqual(env['sea_water_temperature'][0], 4.338, 2) self.assertAlmostEqual(env['sea_water_temperature'][1], 0.6282, 3) self.assertAlmostEqual(env['sea_water_temperature'][4], 10.0) self.assertItemsEqual(missing, [False,False,False,False,False]) self.assertAlmostEqual(env_profiles['sea_water_temperature'][0,0], 4.338, 2) self.assertAlmostEqual(env_profiles['sea_water_temperature'][0,4], 10) self.assertAlmostEqual(env_profiles['sea_water_temperature'][8,2], 10) self.assertAlmostEqual(env_profiles['sea_water_temperature'][7,2], 2.252265, 3) # Get separate data env2, env_profiles2, missing2 = \ o.get_environment(['x_sea_water_velocity', 'y_sea_water_velocity', 'sea_water_temperature'], reader_nordic.start_time, testlon, testlat, testz, ['sea_water_temperature']) self.assertTrue(env_profiles2 is not None) self.assertEqual(env_profiles2.keys(), ['z', 'sea_water_temperature']) # Get separate data, without profile env3, env_profiles3, missing3 = \ o.get_environment(['x_sea_water_velocity', 'y_sea_water_velocity', 'sea_water_temperature'], reader_nordic.start_time, testlon, testlat, testz, profiles=None) self.assertTrue(env_profiles3 is None) # Get separate data env4, env_profiles4, missing4 = \ o.get_environment(['x_sea_water_velocity', 'y_sea_water_velocity', 'sea_water_temperature'], reader_nordic.start_time, testlon, testlat, testz, ['sea_water_temperature']) self.assertItemsEqual(env['x_sea_water_velocity'], env2['x_sea_water_velocity']) #print env_profiles['sea_water_temperature'], '1'*50 #print env_profiles2['sea_water_temperature'], '2'*50 #print env_profiles4['sea_water_temperature'], '4'*50 # Test below should also pass, To be fixed #self.assertItemsEqual(env_profiles['sea_water_temperature'].ravel(), # env_profiles2['sea_water_temperature'].ravel()) self.assertItemsEqual(env_profiles2['sea_water_temperature'].ravel(), env_profiles4['sea_water_temperature'].ravel())
def test_stranding_3d(self): o = PelagicEggDrift(loglevel=30) reader_nordic = reader_ROMS_native.Reader( o.test_data_folder() + '2Feb2016_Nordic_sigma_3d/Nordic-4km_SLEVELS_avg_00_subset2Feb2016.nc' ) o.add_reader(reader_nordic) o.set_config('environment:fallback:y_wind', 10) # Some wind for mixing o.seed_elements( lon=14.0, lat=68.15, radius=2000, number=100, time=[reader_nordic.start_time, reader_nordic.end_time], z=0) o.set_config('general:coastline_action', 'stranding') o.set_config('vertical_mixing:timestep', 120) o.max_speed = .1 o.run(end_time=reader_nordic.end_time, time_step=3600 * 6) self.assertEqual(o.status_categories[1], 'stranded') self.assertEqual(o.elements_deactivated.status.min(), 1) self.assertEqual(o.elements_deactivated.status.max(), 1) self.assertEqual(o.num_elements_scheduled(), 0) self.assertEqual(o.num_elements_active(), 81) self.assertEqual(o.num_elements_activated(), 100) self.assertEqual(o.num_elements_deactivated(), 19) self.assertEqual(o.num_elements_total(), 100) # Check calculated trajectory lengths and speeds total_length, distances, speeds = o.get_trajectory_lengths() self.assertAlmostEqual(total_length.max(), 14978.3, 1) self.assertAlmostEqual(total_length.min(), 1225.2, 1) self.assertAlmostEqual(speeds.max(), 0.127, 1) self.assertAlmostEqual(distances.max(), 2859.0, 1)
def atest_reader_boundary_thredds(self): o = PelagicEggDrift(loglevel=20) reader_norkyst = reader_netCDF_CF_generic.Reader( 'http://thredds.met.no/thredds/dodsC/sea/norkyst800m/1h/aggregate_be' ) reader_nordic = reader_netCDF_CF_generic.Reader( 'http://thredds.met.no/thredds/dodsC/fou-hi/nordic4km-1h/Nordic-4km_SURF_1h_avg_00.nc' ) o.add_reader([reader_norkyst, reader_nordic]) o.fallback_values['land_binary_mask'] = 0 lon = 0.2 lat = 61.0 # Close to NorKyst boundary time = reader_nordic.start_time o.seed_elements(lon, lat, radius=5000, number=100, time=time, z=0) o.set_config('turbulentmixing:timestep', 5) o.run(steps=5, time_step=3600, time_step_output=3600)
def test_reader_boundary(self): o = PelagicEggDrift(loglevel=0) reader_nordic = reader_ROMS_native.Reader( o.test_data_folder() + '2Feb2016_Nordic_sigma_3d/Nordic-4km_SLEVELS_avg_00_subset2Feb2016.nc' ) reader_arctic = reader_netCDF_CF_generic.Reader( o.test_data_folder() + '2Feb2016_Nordic_sigma_3d/Arctic20_1to5Feb_2016.nc') ###################################################### # Vertical interpolation is another issue to be fixed: reader_nordic.zlevels = reader_arctic.z ###################################################### o.add_reader([reader_nordic, reader_arctic]) o.fallback_values['land_binary_mask'] = 0 o.fallback_values['x_wind'] = 10 # Some wind for mixing # Seed close to Nordic boundary o.seed_elements(lon=14.9, lat=71.1, radius=2000, number=100, time=reader_nordic.start_time, z=0) o.set_config('turbulentmixing:timestep', 20) o.set_config('drift:scheme', 'runge-kutta') o.run(steps=5, time_step=3600, time_step_output=3600) self.assertEqual(o.num_elements_active(), 100) self.assertEqual(o.num_elements_deactivated(), 0) self.assertAlmostEqual(o.elements.lat[0], 71.16, 1) #self.assertAlmostEqual(o.elements.z.min(), -41.92, 1) # With past ROMS-masking self.assertAlmostEqual(o.elements.z.min(), -40.1, 1) self.assertAlmostEqual(o.elements.z.max(), -0.01, 1) #self.assertAlmostEqual(o.elements.lon.max(), 14.949, 2) self.assertAlmostEqual(o.elements.lon.max(), 14.87, 2)
#!/usr/bin/env python from opendrift.readers import reader_netCDF_CF_generic from opendrift.models.pelagicegg import PelagicEggDrift import datetime o = PelagicEggDrift(loglevel=0) # Set loglevel to 0 for debug information # Arome #reader_arome = reader_netCDF_CF_generic.Reader(o.test_data_folder() + '16Nov2015_NorKyst_z_surface/arome_subset_16Nov2015.nc') #reader_arome = reader_netCDF_CF_generic.Reader('http://thredds.met.no/thredds/dodsC/meps25files/meps_det_extracted_2_5km_latest.nc') # Norkyst #reader_norkyst = reader_netCDF_CF_generic.Reader(o.test_data_folder() + '16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc') #reader_norkyst = reader_netCDF_CF_generic.Reader('http://thredds.met.no/thredds/dodsC/sea/norkyst800m/1h/aggregate_be') reader_norkyst = reader_netCDF_CF_generic.Reader( 'http://thredds.met.no/thredds/dodsC/sea/norkyst800m/1h/aggregate_be') reader_norshelf = reader_netCDF_CF_generic.Reader( 'http://thredds.met.no/thredds/dodsC/sea_norshelf_his_ZDEPTHS_agg') o.add_reader([reader_norkyst, reader_norshelf]) # spawn NEA cod eggs at defined position and time time = datetime.datetime.today() - datetime.timedelta(1) o.seed_elements(14., 68.1, z=-40, radius=2000, number=500, time=time, diameter=0.0014,
#!/usr/bin/env python from opendrift.readers import reader_basemap_landmask from opendrift.readers import reader_netCDF_CF_generic from opendrift.models.pelagicegg import PelagicEggDrift o = PelagicEggDrift(loglevel=0) # Set loglevel to 0 for debug information # Arome #reader_arome = reader_netCDF_CF_generic.Reader(o.test_data_folder() + '16Nov2015_NorKyst_z_surface/arome_subset_16Nov2015.nc') reader_arome = reader_netCDF_CF_generic.Reader('http://thredds.met.no/thredds/dodsC/arome25/arome_metcoop_default2_5km_latest.nc') # Norkyst #reader_norkyst = reader_netCDF_CF_generic.Reader(o.test_data_folder() + '16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc') reader_norkyst = reader_netCDF_CF_generic.Reader('http://thredds.met.no/thredds/dodsC/sea/norkyst800m/1h/aggregate_be') # Landmask (Basemap) reader_basemap = reader_basemap_landmask.Reader( llcrnrlon=10, llcrnrlat=67., urcrnrlon=16, urcrnrlat=69., resolution='h', projection='merc') o.add_reader([reader_norkyst, reader_basemap, reader_arome]) time = reader_arome.start_time # spawn NEA cod eggs at defined position and time o.seed_elements(14. , 68.1, z=-40, radius=2000, number=500, time=time, diameter=0.0014, neutral_buoyancy_salinity=31.25) o.seed_elements(12.5, 68.5, z=-40, radius=2000, number=500, time=time, diameter=0.0014, neutral_buoyancy_salinity=31.25)
def test_stranding_3d(self): o = PelagicEggDrift(loglevel=30) reader_nordic = reader_ROMS_native.Reader( o.test_data_folder() + '2Feb2016_Nordic_sigma_3d/Nordic-4km_SLEVELS_avg_00_subset2Feb2016.nc' ) o.add_reader(reader_nordic) o.fallback_values['y_wind'] = 10 # Some wind for mixing o.seed_elements( lon=14.0, lat=68.15, radius=2000, number=100, time=[reader_nordic.start_time, reader_nordic.end_time], z=0) o.set_config('general:coastline_action', 'stranding') o.set_config('turbulentmixing:timestep', 120) o.max_speed = .1 o.run(end_time=reader_nordic.end_time, time_step=3600 * 6) self.assertEqual(o.status_categories[1], 'stranded') self.assertEqual(o.elements_deactivated.status.min(), 1) self.assertEqual(o.elements_deactivated.status.max(), 1) self.assertEqual(o.num_elements_scheduled(), 0) self.assertEqual(o.num_elements_active(), 79) self.assertEqual(o.num_elements_activated(), 100) self.assertEqual(o.num_elements_deactivated(), 21) self.assertEqual(o.num_elements_total(), 100)
#!/usr/bin/env python from opendrift.readers import reader_netCDF_CF_generic from opendrift.models.pelagicegg import PelagicEggDrift o = PelagicEggDrift(loglevel=0) # Set loglevel to 0 for debug information # Arome #reader_arome = reader_netCDF_CF_generic.Reader(o.test_data_folder() + '16Nov2015_NorKyst_z_surface/arome_subset_16Nov2015.nc') reader_arome = reader_netCDF_CF_generic.Reader('http://thredds.met.no/thredds/dodsC/meps25files/meps_det_extracted_2_5km_latest.nc') # Norkyst #reader_norkyst = reader_netCDF_CF_generic.Reader(o.test_data_folder() + '16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc') reader_norkyst = reader_netCDF_CF_generic.Reader('http://thredds.met.no/thredds/dodsC/sea/norkyst800m/1h/aggregate_be') o.add_reader([reader_norkyst, reader_arome]) # spawn NEA cod eggs at defined position and time time = reader_arome.start_time o.seed_elements(14. , 68.1, z=-40, radius=2000, number=500, time=time, diameter=0.0014, neutral_buoyancy_salinity=31.25) o.seed_elements(12.5, 68.5, z=-40, radius=2000, number=500, time=time, diameter=0.0014, neutral_buoyancy_salinity=31.25) # Adjusting some configuration o.set_config('processes:turbulentmixing', True) o.set_config('turbulentmixing:diffusivitymodel', 'windspeed_Sundby1983') # windspeed parameterization for eddy diffusivity #o.set_config('turbulentmixing:diffusivitymodel', 'environment') # use eddy diffusivity from ocean model # Vertical resolution and time step should be adjusted so to avoid getting # output warnings like 'DEBUG: WARNING! some elements have p+q>1.'
def test_reader_boundary(self): o = PelagicEggDrift(loglevel=0) reader_nordic = reader_ROMS_native.Reader( o.test_data_folder() + "2Feb2016_Nordic_sigma_3d/Nordic-4km_SLEVELS_avg_00_subset2Feb2016.nc" ) reader_arctic = reader_netCDF_CF_generic.Reader( o.test_data_folder() + "2Feb2016_Nordic_sigma_3d/Arctic20_1to5Feb_2016.nc" ) ###################################################### # Vertical interpolation is another issue to be fixed: reader_nordic.zlevels = reader_arctic.z ###################################################### o.add_reader([reader_nordic, reader_arctic]) o.fallback_values["land_binary_mask"] = 0 o.fallback_values["x_wind"] = 10 # Some wind for mixing # Seed close to Nordic boundary o.seed_elements(lon=14.9, lat=71.1, radius=2000, number=100, time=reader_nordic.start_time, z=0) o.set_config("turbulentmixing:timestep", 20) o.set_config("turbulentmixing:verticalresolution", 1) o.set_config("drift:scheme", "runge-kutta") o.run(steps=5, time_step=3600, time_step_output=3600) self.assertEqual(o.num_elements_active(), 100) self.assertEqual(o.num_elements_deactivated(), 0) self.assertAlmostEqual(o.elements.lat[0], 71.15, 2) self.assertAlmostEqual(o.elements.z.min(), -35.0, 3) self.assertAlmostEqual(o.elements.z.max(), -0.5, 3) self.assertAlmostEqual(o.elements.lon.max(), 14.87, 2)
def test_stranding_3d(self): o = PelagicEggDrift(loglevel=30) reader_nordic = reader_ROMS_native.Reader(o.test_data_folder() + '2Feb2016_Nordic_sigma_3d/Nordic-4km_SLEVELS_avg_00_subset2Feb2016.nc') o.add_reader(reader_nordic) o.fallback_values['y_wind'] = 10 # Some wind for mixing o.seed_elements(lon=14.0, lat=68.15, radius=2000, number=100, time=[reader_nordic.start_time, reader_nordic.end_time], z=0) o.set_config('general:coastline_action', 'stranding') o.set_config('turbulentmixing:timestep', 60) o.set_config('turbulentmixing:verticalresolution', 10) o.run(end_time=reader_nordic.end_time, time_step=3600*3) self.assertEqual(o.status_categories[1], 'stranded') self.assertEqual(o.elements_deactivated.status.min(), 1) self.assertEqual(o.elements_deactivated.status.max(), 1)
#!/usr/bin/env python """ Cod egg ============= """ from opendrift.readers import reader_netCDF_CF_generic from opendrift.models.pelagicegg import PelagicEggDrift from datetime import datetime, timedelta o = PelagicEggDrift(loglevel=20) # Set loglevel to 0 for debug information # Forcing with Topaz ocean model and MEPS atmospheric model o.add_readers_from_list([ 'https://thredds.met.no/thredds/dodsC/cmems/topaz6/dataset-topaz6-arc-15min-3km-be.ncml', 'https://thredds.met.no/thredds/dodsC/mepslatest/meps_lagged_6_h_latest_2_5km_latest.nc' ]) #%% # spawn NEA cod eggs at defined position and time time = datetime.utcnow() o.seed_elements(14., 68.1, z=-40, radius=2000, number=500, time=time, diameter=0.0014, neutral_buoyancy_salinity=31.25) o.seed_elements(12.5, 68.,
def test_outside_reader_time_coverage(self): o = PelagicEggDrift() reader = reader_netCDF_CF_generic.Reader(o.test_data_folder() + '16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc') o.add_reader(reader) o.fallback_values['x_sea_water_velocity'] = 1 o.fallback_values['land_binary_mask'] = 0 o.set_config('processes:turbulentmixing', False) o.seed_elements(lon=4.8, lat=60, number=1, time=reader.end_time) o.run(steps=2) # Check that fallback value is used when outside time coverage self.assertEqual(o.history['x_sea_water_velocity'][0][-1], 1.0)
def test_get_environment(self): o = PelagicEggDrift(loglevel=0) reader_nordic = reader_ROMS_native.Reader(o.test_data_folder() + '2Feb2016_Nordic_sigma_3d/Nordic-4km_SLEVELS_avg_00_subset2Feb2016.nc', name='Nordic') reader_arctic = reader_netCDF_CF_generic.Reader(o.test_data_folder() + '2Feb2016_Nordic_sigma_3d/Arctic20_1to5Feb_2016.nc', name='Arctic') ###################################################### # Vertical interpolation is another issue to be fixed: reader_nordic.zlevels = reader_arctic.z ###################################################### o.add_reader([reader_nordic, reader_arctic]) # One point covered only by Nordic, two points coverd # by both readers, and two points covered by none of the readers testlon = np.array((14.0, 20.0, 20.1, 4, 5)) testlat = np.array((70.1, 76.0, 76.1, 60, 60)) testz = np.random.uniform(0, 0, len(testlon)) self.assertItemsEqual([0], reader_nordic.covers_positions( testlon, testlat, testz)) self.assertItemsEqual([0, 1, 2], reader_arctic.covers_positions( testlon, testlat, testz)) o.seed_elements(testlon, testlat, testz, time=reader_nordic.start_time) o.fallback_values['land_binary_mask'] = 0 env, env_profiles, missing = \ o.get_environment(o.required_variables, reader_nordic.start_time, testlon, testlat, testz, o.required_profiles) self.assertAlmostEqual(env['sea_water_temperature'][0], 4.2849, 3) self.assertAlmostEqual(env['sea_water_temperature'][1], 0.6282, 3) self.assertAlmostEqual(env['sea_water_temperature'][4], 10.0) self.assertItemsEqual(missing, [False,False,False,False,False]) self.assertAlmostEqual(env_profiles['sea_water_temperature'][0,0], 4.284938, 3) self.assertAlmostEqual(env_profiles['sea_water_temperature'][0,4], 10) self.assertAlmostEqual(env_profiles['sea_water_temperature'][8,2], 10) self.assertAlmostEqual(env_profiles['sea_water_temperature'][7,2], 2.252265, 3) # Get separate data env2, env_profiles2, missing2 = \ o.get_environment(['x_sea_water_velocity', 'y_sea_water_velocity', 'sea_water_temperature'], reader_nordic.start_time, testlon, testlat, testz, ['sea_water_temperature']) self.assertTrue(env_profiles2 is not None) self.assertEqual(env_profiles2.keys(), ['z', 'sea_water_temperature']) # Get separate data, without profile env3, env_profiles3, missing3 = \ o.get_environment(['x_sea_water_velocity', 'y_sea_water_velocity', 'sea_water_temperature'], reader_nordic.start_time, testlon, testlat, testz, profiles=None) self.assertTrue(env_profiles3 is None) # Get separate data env4, env_profiles4, missing4 = \ o.get_environment(['x_sea_water_velocity', 'y_sea_water_velocity', 'sea_water_temperature'], reader_nordic.start_time, testlon, testlat, testz, ['sea_water_temperature']) self.assertItemsEqual(env['x_sea_water_velocity'], env2['x_sea_water_velocity']) #print env_profiles['sea_water_temperature'], '1'*50 #print env_profiles2['sea_water_temperature'], '2'*50 #print env_profiles4['sea_water_temperature'], '4'*50 # Test below should also pass, To be fixed #self.assertItemsEqual(env_profiles['sea_water_temperature'].ravel(), # env_profiles2['sea_water_temperature'].ravel()) self.assertItemsEqual(env_profiles2['sea_water_temperature'].ravel(), env_profiles4['sea_water_temperature'].ravel())
#!/usr/bin/env python """ Cod egg ============= """ from opendrift.readers import reader_netCDF_CF_generic from opendrift.models.pelagicegg import PelagicEggDrift from datetime import datetime o = PelagicEggDrift(loglevel=20) # Set loglevel to 0 for debug information # Forcing with Topaz ocean model and MEPS atmospheric model o.add_readers_from_list([ 'https://thredds.met.no/thredds/dodsC/topaz/dataset-topaz4-arc-unmasked-be', 'https://thredds.met.no/thredds/dodsC/mepslatest/meps_lagged_6_h_latest_2_5km_latest.nc' ]) #%% # spawn NEA cod eggs at defined position and time time = datetime.now() o.seed_elements(14., 68.1, z=-40, radius=2000, number=500, time=time, diameter=0.0014, neutral_buoyancy_salinity=31.25) o.seed_elements(12.5, 68.,
def test_vertical_mixing(self): # Export to file only at end o1 = PelagicEggDrift(loglevel=20) # Profiles and vertical mixing norkyst = reader_netCDF_CF_generic.Reader( o1.test_data_folder() + '14Jan2016_NorKyst_z_3d/NorKyst-800m_ZDEPTHS_his_00_3Dsubset.nc') o1.add_reader([norkyst]) o1.fallback_values['x_wind'] = 8 o1.fallback_values['land_binary_mask'] = 0 o1.seed_elements(4.1, 63.3, radius=1000, number=100, time=norkyst.start_time) o1.set_config('turbulentmixing:timestep', 20.) # seconds o1.set_config('turbulentmixing:verticalresolution', 1.) # m o1.run(steps=20, time_step=300, time_step_output=1800, export_buffer_length=10, outfile='verticalmixing.nc') self.assertAlmostEqual(o1.history['z'].min(), -31.9, 1) self.assertAlmostEqual(o1.history['z'].max(), 0.0, 1) os.remove('verticalmixing.nc')
def test_vertical_mixing(self): # Export to file only at end o1 = PelagicEggDrift(loglevel=20) # Profiles and vertical mixing norkyst = reader_netCDF_CF_generic.Reader(o1.test_data_folder() + '14Jan2016_NorKyst_z_3d/NorKyst-800m_ZDEPTHS_his_00_3Dsubset.nc') o1.add_reader([norkyst]) o1.fallback_values['x_wind'] = 8 o1.fallback_values['land_binary_mask'] = 0 o1.seed_elements(4.1, 63.3, radius=1000, number=100, time=norkyst.start_time) o1.set_config('turbulentmixing:timestep', 20.) # seconds o1.set_config('turbulentmixing:verticalresolution', 1.) # m o1.run(steps=20, time_step=300, time_step_output=1800, export_buffer_length=10, outfile='verticalmixing.nc') self.assertAlmostEqual(o1.history['z'].min(), -25.0) self.assertAlmostEqual(o1.history['z'].max(), 0.0) os.remove('verticalmixing.nc')
def test_stranding_roms(self): o = PelagicEggDrift(loglevel=0) reader_arctic = reader_netCDF_CF_generic.Reader( o.test_data_folder() + '2Feb2016_Nordic_sigma_3d/Arctic20_1to5Feb_2016.nc') reader_nordic = reader_ROMS_native.Reader( o.test_data_folder() + '2Feb2016_Nordic_sigma_3d/Nordic-4km_SLEVELS_avg_00_subset2Feb2016.nc' ) o.add_reader(reader_arctic) o.add_reader(reader_nordic) o.fallback_values['x_sea_water_velocity'] = 1 o.seed_elements( lon=13.0, lat=68.0, radius=20000, number=100, time=[reader_arctic.start_time, reader_nordic.end_time], z=-30) o.set_config('general:coastline_action', 'previous') o.set_config('processes:turbulentmixing', False) o.max_speed = 1 o.run(end_time=reader_nordic.end_time, time_step=3600 * 36) self.assertEqual(o.num_elements_scheduled(), 0) self.assertEqual(o.num_elements_active(), 100) self.assertEqual(o.num_elements_activated(), 100) self.assertEqual(o.num_elements_deactivated(), 0) self.assertEqual(o.num_elements_total(), 100)
def test_stranding_roms(self): o = PelagicEggDrift(loglevel=0) reader_arctic = reader_netCDF_CF_generic.Reader(o.test_data_folder() + '2Feb2016_Nordic_sigma_3d/Arctic20_1to5Feb_2016.nc') reader_nordic = reader_ROMS_native.Reader(o.test_data_folder() + '2Feb2016_Nordic_sigma_3d/Nordic-4km_SLEVELS_avg_00_subset2Feb2016.nc') o.add_reader(reader_arctic) o.add_reader(reader_nordic) o.fallback_values['x_sea_water_velocity'] = 1 o.seed_elements(lon=13.0, lat=68.0, radius=20000, number=100, time=[reader_arctic.start_time, reader_nordic.end_time], z=-30) o.set_config('general:basemap_resolution', 'c') o.set_config('general:coastline_action', 'previous') o.set_config('processes:turbulentmixing', False) o.max_speed=1 o.run(end_time=reader_nordic.end_time, time_step=3600*36) self.assertEqual(o.num_elements_scheduled(), 0) self.assertEqual(o.num_elements_active(), 100) self.assertEqual(o.num_elements_activated(), 100) self.assertEqual(o.num_elements_deactivated(), 0) self.assertEqual(o.num_elements_total(), 100)