Beispiel #1
0
    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)
Beispiel #2
0
    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)
# Preparing Readers
############################################

reader_current = reader_netCDF_CF_generic.Reader(
    o.test_data_folder() +
    '16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc')

reader_wind = reader_netCDF_CF_generic.Reader(
    o.test_data_folder() +
    '16Nov2015_NorKyst_z_surface/arome_subset_16Nov2015.nc')

reader_landmask = reader_global_landmask.Reader(llcrnrlon=2.9,
                                                llcrnrlat=59.7,
                                                urcrnrlon=4.9,
                                                urcrnrlat=61.5)
o.add_reader([reader_current, reader_wind, reader_landmask])

#######################
# 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.,
#%%
# Initialize model
steps = 60   # This is the number of forecast steps
o = OpenBerg(loglevel=30)  # Basic drift model suitable for icebergs

#%%
# Preparing Readers
reader_wind = reader_netCDF_CF_generic.Reader(o.test_data_folder() +
   '16Nov2015_NorKyst_z_surface/arome_subset_16Nov2015.nc',name='WIND')

reader_current = reader_current_from_track.Reader(
    obslon, obslat, obstime, wind_east=0, wind_north=0,
    windreader=reader_wind, wind_factor=0.018)

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)
reader_current = reader_netCDF_CF_generic.Reader(
    o.test_data_folder() +
    '16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc')

reader_wind = reader_netCDF_CF_generic.Reader(
    o.test_data_folder() +
    '16Nov2015_NorKyst_z_surface/arome_subset_16Nov2015.nc')

reader_basemap = reader_basemap_landmask.Reader(llcrnrlon=2.9,
                                                llcrnrlat=59.7,
                                                urcrnrlon=4.9,
                                                urcrnrlat=61.5,
                                                resolution='l',
                                                projection='gall')
o.add_reader([reader_current, reader_wind, reader_basemap])

#######################
# 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.,