예제 #1
0
    def test_one_weather(self):
        '''
        calls one weathering step and checks that we decayed at the expected
        rate. Needs more tests with varying half_lives
        '''
        time_step = 15. * 60
        hl = tuple([time_step] * subs.num_components)
        weatherer = HalfLifeWeatherer(half_lives=hl)
        sc = weathering_data_arrays(weatherer.array_types, Water(),
                                    time_step)[0]

        print '\nsc["mass"]:\n', sc['mass']

        orig_mc = np.copy(sc['mass_components'])

        model_time = rel_time

        weatherer.prepare_for_model_run(sc)
        weatherer.prepare_for_model_step(sc, time_step, model_time)
        weatherer.weather_elements(sc, time_step, model_time)
        weatherer.model_step_is_done()

        print '\nsc["mass"]:\n', sc['mass']
        assert np.allclose(0.5 * orig_mc.sum(1), sc['mass'])
        assert np.allclose(0.5 * orig_mc, sc['mass_components'])
예제 #2
0
    def test_one_weather(self):
        '''
        calls one weathering step and checks that we decayed at the expected
        rate. Needs more tests with varying half_lives
        '''
        time_step = 15.*60
        hl = tuple([time_step] * subs.num_components)
        weatherer = HalfLifeWeatherer(half_lives=hl)
        sc = weathering_data_arrays(weatherer.array_types,
                                    Water(),
                                    time_step,
                                    element_type=floating(substance=subs))[0]

        print '\nsc["mass"]:\n', sc['mass']

        orig_mc = np.copy(sc['mass_components'])

        model_time = rel_time

        weatherer.prepare_for_model_run(sc)
        weatherer.prepare_for_model_step(sc, time_step, model_time)
        weatherer.weather_elements(sc, time_step, model_time)
        weatherer.model_step_is_done()

        print '\nsc["mass"]:\n', sc['mass']
        assert np.allclose(0.5 * orig_mc.sum(1), sc['mass'])
        assert np.allclose(0.5 * orig_mc, sc['mass_components'])
예제 #3
0
def test_setup_model_run(model):
    'turn of movers/weatherers and ensure data_arrays change'
    model.environment += Water()
    model.rewind()
    model.step()
    exp_keys = {
        'windages', 'windage_range', 'mass_components', 'windage_persist'
    }
    # no exp_keys in model data_arrays
    assert not exp_keys.intersection(model.spills.LE_data)

    cwm = gnome.movers.constant_wind_mover(1., 0.)

    model.weatherers += [HalfLifeWeatherer(), Evaporation()]
    model.movers += cwm
    model.rewind()
    model.step()

    assert exp_keys.issubset(model.spills.LE_data)

    cwm.on = False
    for w in xrange(2):
        model.weatherers[w].on = False

    model.rewind()
    model.step()
    assert not exp_keys.intersection(model.spills.LE_data)
예제 #4
0
def test_all_weatherers_in_model(model, add_langmuir):
    '''
    test model run with weatherer
    todo: integrate Langmuir in Model; can ensure 'frac_coverage' gets added
        to spill container data
    '''
    model.weatherers += HalfLifeWeatherer()

    model.environment += Water()
    model.full_run()

    expected_keys = {'mass_components'}
    assert expected_keys.issubset(model.spills.LE_data)