コード例 #1
0
    def test_weather_elements(self):
        '''
        use ObjMakeTests from test_cleanup to setup test
        Langmuir weather_elements must be called after weather elements
        for other objects
        '''
        langmuir = Langmuir(self.water, constant_wind(5., 0.))

        self.prepare_test_objs(langmuir.array_types)
        langmuir.prepare_for_model_run(self.sc)

        # create WeatheringData object, initialize instantaneously released
        # elements
        model_time = self.sc.spills[0].release_time
        time_step = 900.
        self.release_elements(time_step, model_time)
        self.step(langmuir, time_step, model_time)

        assert langmuir.active
        assert np.all(self.sc['area'] < self.sc['fay_area'])
        assert np.all(self.sc['frac_coverage'] < 1.0)
コード例 #2
0
ファイル: test_spreading.py プロジェクト: liuy0813/PyGnome
 def test_update_from_dict(self):
     '''
     just a simple test to ensure schema/serialize/deserialize is correclty
     setup
     '''
     j = self.l.serialize()
     j['wind']['timeseries'][0] = \
         (j['wind']['timeseries'][0][0],
          (j['wind']['timeseries'][0][1][0] + 1, 0))
     updated = self.l.update_from_dict(Langmuir.deserialize(j))
     assert updated
     assert self.l.serialize() == j
コード例 #3
0
ファイル: test_spreading.py プロジェクト: satcomlabs/PyGnome
 def test_update_from_dict(self):
     '''
     just a simple test to ensure schema/serialize/deserialize is correclty
     setup
     '''
     j = self.l.serialize()
     j['wind']['timeseries'][0] = \
         (j['wind']['timeseries'][0][0],
          (j['wind']['timeseries'][0][1][0] + 1, 0))
     updated = self.l.update_from_dict(Langmuir.deserialize(j))
     assert updated
     assert self.l.serialize() == j
コード例 #4
0
    def test_weather_elements(self):
        '''
        use ObjMakeTests from test_cleanup to setup test
        Langmuir weather_elements must be called after weather elements
        for other objects
        '''
        l = Langmuir(self.water, constant_wind(5., 0.))

        self.prepare_test_objs(l.array_types)
        l.prepare_for_model_run(self.sc)

        # create WeatheringData object, initialize instantaneously released
        # elements
        model_time = self.sc.spills[0].release_time
        time_step = 900.
        self.release_elements(time_step, model_time)
        self.step(l, time_step, model_time)

        assert l.active
        assert np.all(self.sc['area'] < self.sc['fay_area'])
        assert np.all(self.sc['frac_coverage'] < 1.0)
コード例 #5
0
ファイル: test_spreading.py プロジェクト: satcomlabs/PyGnome
 def test_init(self):
     l = Langmuir(self.water, self.wind)
     assert l.wind is self.wind
コード例 #6
0
ファイル: test_spreading.py プロジェクト: satcomlabs/PyGnome
class TestLangmuir(ObjForTests):
    thick = 1e-4
    wind = constant_wind(5, 0)
    model_time = datetime(2015, 1, 1, 12, 0)
    water = Water()

    l = Langmuir(water, wind)
    (vmin, vmax) = l._wind_speed_bound(rel_buoy, thick)

    (sc, weatherers) = ObjForTests.mk_test_objs(water)

    def test_init(self):
        l = Langmuir(self.water, self.wind)
        assert l.wind is self.wind

    @pytest.mark.parametrize(("l", "speed", "exp_bound"),
                             [(l, vmin - 0.01 * vmin, 1.0),
                              (l, vmax + 0.01 * vmax, 0.1)])
    def test_speed_bounds(self, l, speed, exp_bound):
        '''
        Check that the input speed for Langmuir object returns frac_coverage
        within bounds:
            0.1 <= frac_cov <= 1.0
        '''
        self.l.wind.timeseries = (self.l.wind.timeseries['time'][0], (speed,
                                                                      0.0))

        # rel_buoy is always expected to be a numpy array
        frac_cov = l._get_frac_coverage(self.model_time,
                                        np.asarray([rel_buoy]), self.thick)
        assert frac_cov == exp_bound

    def test_update_from_dict(self):
        '''
        just a simple test to ensure schema/serialize/deserialize is correclty
        setup
        '''
        j = self.l.serialize()
        j['wind']['timeseries'][0] = \
            (j['wind']['timeseries'][0][0],
             (j['wind']['timeseries'][0][1][0] + 1, 0))
        updated = self.l.update_from_dict(Langmuir.deserialize(j))
        assert updated
        assert self.l.serialize() == j

    def test_weather_elements(self):
        '''
        use ObjMakeTests from test_cleanup to setup test
        Langmuir weather_elements must be called after weather elements
        for other objects
        '''
        l = Langmuir(self.water, constant_wind(5., 0.))

        self.prepare_test_objs(l.array_types)
        l.prepare_for_model_run(self.sc)

        # create WeatheringData object, initialize instantaneously released
        # elements
        model_time = self.sc.spills[0].get('release_time')
        time_step = 900.
        self.release_elements(time_step, model_time)
        self.step(l, time_step, model_time)

        assert l.active
        assert np.all(self.sc['area'] < self.sc['fay_area'])
        assert np.all(self.sc['frac_coverage'] < 1.0)