def test_openberg(self): """Check if weighting array is set correctly and if model returns expected positions""" o = OpenBerg(loglevel=50) reader_current = reader_netCDF_CF_generic.Reader( o.test_data_folder() + '14Jan2016_NorKyst_z_3d/NorKyst-800m_ZDEPTHS_his_00_3Dsubset.nc') reader_basemap = reader_basemap_landmask.Reader(llcrnrlon=3., llcrnrlat=60., urcrnrlon=5., urcrnrlat=63.5, resolution='c', projection='gall') # reader_basemap = reader_basemap_landmask.Reader(llcrnrlon=-1.5, llcrnrlat=59, urcrnrlon=7, urcrnrlat=64, resolution='c') o.add_reader([reader_current, reader_basemap]) o.seed_elements(4., 62., time=reader_current.start_time) o.run(steps=1) arr = [ 0.16072658, 0.16466097, 0.17384121, 0.17325179, 0.1715925, 0.15592695 ] for indx in range(len(arr)): self.assertAlmostEqual(o.uw_weighting[indx], arr[indx], 8) self.assertAlmostEqual(o.history['lon'].data[0][1], 3.9921231, 3) self.assertAlmostEqual(o.history['lat'].data[0][1], 62.0108299, 3)
def test_openberg(self): """Check if weighting array is set correctly and if model returns expected positions""" o = OpenBerg() o.set_config('drift:current_uncertainty', 0) o.set_config('drift:wind_uncertainty', 0) reader_current = reader_netCDF_CF_generic.Reader( o.test_data_folder() + '14Jan2016_NorKyst_z_3d/NorKyst-800m_ZDEPTHS_his_00_3Dsubset.nc') reader_landmask = reader_global_landmask.Reader() o.add_reader([reader_current, reader_landmask]) o.seed_elements(4., 62., time=reader_current.start_time) o.run(steps=1) arr = [ 0.16072658, 0.16466097, 0.17384121, 0.17325179, 0.1715925, 0.15592695 ] for indx in range(len(arr)): self.assertAlmostEqual(o.uw_weighting[indx], arr[indx], 8) self.assertAlmostEqual(o.history['lon'].data[0][1], 3.9921231, 3) self.assertAlmostEqual(o.history['lat'].data[0][1], 62.0108299, 3)
####################### # Seeding elements ####################### # Icebergs are moved with the ocean current as per Barker et al (2004), # in addition to a fraction of the wind speed (wind_drift_factor). # This factor depends on the properties of the elements. # Default empirical values are: # - Wind drift fraction: 0.018 (1.8 %) (Garret 1985) # - Iceberg size: Keel dept = 60m # Waterline length = 90.5m o.seed_elements(3.3, 60., radius=3000, time=reader_current.start_time, water_line_length=100, keel_depth=90, number=100) print('Starting free run .../n') print('Start time: ' + str(o.start_time)) ####################### # Running model ####################### o.run(time_step=3600, steps=steps) #########################
o.add_reader([reader_current, reader_wind]) #%% # Seeding elements # # Icebergs are moved with the ocean current as per Barker et al (2004), # in addition to a fraction of the wind speed (wind_drift_factor). # This factor depends on the properties of the elements. # Default empirical values are: # - Wind drift fraction: 0.018 (1.8 %) (Garret 1985) # - Iceberg size: Keel dept = 60m # Waterline length = 90.5m # NB! Iceberg size is irrelevant for current_reader with 1D z-profile o.seed_elements(3.3, 61.3, radius=3000, number=500, time=reader_current.start_time) #%% # Run model print('Starting free run .../n') print('Start time: ' + str(o.start_time)) o.run(time_step=3600, steps=steps) #%% # Print and plot results o.plot(fast=True) o.animation(fast=True) #%%