def test_with_dispersion_and_configured_time_window_and_three_fires( self, reset_config): fm = FiresManager() fm.load({ "fires": [FIRE_1, FIRE_2, FIRE_3], }) Config().set({ "dispersion": { "start": "2014-05-29T19:00:00Z", "num_hours": 12 }, "findmetdata": { "time_window": { "first_hour": "2016-01-04T04:00:00Z", "last_hour": "2016-01-05T13:00:00Z" } } }) expected = [{ 'start': datetime.datetime(2014, 5, 29, 19, 0, 0), 'end': datetime.datetime(2014, 5, 30, 7, 0, 0), }, { 'start': datetime.datetime(2015, 1, 21, 2, 0, 0), 'end': datetime.datetime(2015, 1, 23, 2, 0, 0), }, { 'start': datetime.datetime(2015, 2, 2, 0, 0, 0), 'end': datetime.datetime(2015, 2, 3, 0, 0, 0), }, { 'start': datetime.datetime(2016, 1, 4, 4, 0, 0), 'end': datetime.datetime(2016, 1, 5, 13, 0, 0), }] assert expected == findmetdata._get_time_windows(fm)
def test_one_fire(self, reset_config, monkeypatch): monkeypatch_arl_profiler(monkeypatch) fm = FiresManager() fm.met = MET_INFO fm.load({"fires": [FIRE]}) localmet.run(fm) assert _ARLP_ARGS == (MET_INFO['files'], ) assert _ARLP_KWARGS == { 'time_step': defaults._DEFAULTS['localmet']['time_step'] } assert _ARLP_PROFILE_CALL_ARGS == [ (datetime.datetime(2015, 1, 21, 0, 0), datetime.datetime(2015, 1, 22, 0, 0), [{ 'latitude': 45.0, 'longitude': -119.0 }, { 'latitude': 47.415, 'longitude': -121.42 }]) ]
def test_two_fires(self, reset_config): fm = FiresManager() fm.load({"fires": [FIRE_1, FIRE_2]}) expected = [{ 'start': datetime.datetime(2015, 1, 21, 2, 0, 0), 'end': datetime.datetime(2015, 1, 23, 2, 0, 0), }] assert expected == findmetdata._get_time_windows(fm)
def test_no_met(self, reset_config, monkeypatch): monkeypatch_arl_profiler(monkeypatch) fm = FiresManager() fm.load({"fires": [FIRE]}) with raises(ValueError) as e_info: localmet.run(fm) assert e_info.value.args[0] == localmet.NO_MET_ERROR_MSG
def test_fire_no_activity(self, reset_config, monkeypatch): monkeypatch_arl_profiler(monkeypatch) fm = FiresManager() fm.met = MET_INFO fm.load({"fires": [FIRE_NO_ACTIVITY]}) with raises(ValueError) as e_info: localmet.run(fm) assert e_info.value.args[0] == localmet.NO_ACTIVITY_ERROR_MSG
def test_no_fires(self, reset_config, monkeypatch): monkeypatch_arl_profiler(monkeypatch) fm = FiresManager() fm.met = MET_INFO fm.load({"fires": []}) with raises(RuntimeError) as e_info: localmet.run(fm) assert e_info.value.args[0] == localmet.NO_START_OR_END_ERROR_MSG
def test_no_fires(self, reset_config, monkeypatch): monkeypatch_arl_profiler(monkeypatch) fm = FiresManager() fm.met = MET_INFO fm.load({"fires": []}) localmet.run(fm) assert _ARLP_ARGS == (MET_INFO['files'], ) assert _ARLP_KWARGS == { 'time_step': defaults._DEFAULTS['localmet']['time_step'] } assert _ARLP_PROFILE_CALL_ARGS == []
def test_fire_no_activity(self, reset_config): fm = FiresManager() fm.load({"fires": [FIRE_NO_ACTIVITY]}) with raises(BlueSkyConfigurationError) as e_info: findmetdata._get_time_windows(fm)
def test_no_fires(self, reset_config): fm = FiresManager() fm.load({"fires": []}) with raises(BlueSkyConfigurationError) as e_info: findmetdata._get_time_windows(fm)
class TestPlumeRiseRunSev(object): def setup(self): Config().set('sev', 'plumerise', 'model') Config().set(False, 'skip_failed_fires') self.fm = FiresManager() def test_fire_no_activity(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": [FIRE_NO_ACTIVITY]}) with raises(ValueError) as e_info: plumerise.run(self.fm) assert e_info.value.args[0] == plumerise.NO_ACTIVITY_ERROR_MSG def test_fire_missing_location_area(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": [FIRE_MISSING_LOCATION_AREA]}) with raises(ValueError) as e_info: plumerise.run(self.fm) assert e_info.value.args[0] == activity.INVALID_LOCATION_MSGS[ 'specified_points'] def test_fire_missing_location_consumption(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": [FIRE_MISSING_CONSUMPTION]}) plumerise.run(self.fm) assert _PR_ARGS == () assert _PR_KWARGS == defaults._DEFAULTS['plumerise']['sev'] assert _PR_COMPUTE_CALL_ARGS == [({"baz": 444}, 123)] assert _PR_COMPUTE_CALL_KWARGS == [{'frp': None}] def test_fire_missing_timeprofile(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": [FIRE_MISSING_TIMEPROFILE]}) plumerise.run(self.fm) assert _PR_ARGS == () assert _PR_KWARGS == defaults._DEFAULTS['plumerise']['sev'] assert _PR_COMPUTE_CALL_ARGS == [({"baz": 444}, 123)] assert _PR_COMPUTE_CALL_KWARGS == [{'frp': None}] def test_fire_missing_start_time(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": [FIRE_MISSING_START_TIME]}) plumerise.run(self.fm) assert _PR_ARGS == () assert _PR_KWARGS == defaults._DEFAULTS['plumerise']['sev'] assert _PR_COMPUTE_CALL_ARGS == [({"baz": 444}, 123)] assert _PR_COMPUTE_CALL_KWARGS == [{'frp': None}] # TODO: test with invalid start time def test_fire_missing_localmet(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": [FIRE_MISSING_LOCALMET]}) with raises(ValueError) as e_info: plumerise.run(self.fm) assert e_info.value.args[0] == plumerise.MISSING_LOCALMET_ERROR_MSG def test_no_fires(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": []}) plumerise.run(self.fm) assert _PR_ARGS == () assert _PR_KWARGS == defaults._DEFAULTS['plumerise']['sev'] assert _PR_COMPUTE_CALL_ARGS == [] def test_one_fire(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": [FIRE]}) plumerise.run(self.fm) assert _PR_ARGS == () assert _PR_KWARGS == defaults._DEFAULTS['plumerise']['sev'] loc1 = FIRE['activity'][0]['active_areas'][0]['specified_points'][0] loc2 = FIRE['activity'][0]['active_areas'][1]['perimeter'] assert _PR_COMPUTE_CALL_ARGS == [({ "baz": 444 }, 123), ({ "bazoo": 555 }, 3232)] assert _PR_COMPUTE_CALL_KWARGS == [{'frp': None}, {'frp': None}]
class TestPlumeRiseRunFeps(object): def setup(self): Config().set('feps', 'plumerise', 'model') Config().set(False, 'skip_failed_fires') self.fm = FiresManager() def test_fire_no_activity(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": [FIRE_NO_ACTIVITY]}) with raises(ValueError) as e_info: plumerise.run(self.fm) assert e_info.value.args[0] == plumerise.NO_ACTIVITY_ERROR_MSG def test_fire_missing_location_area(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": [FIRE_MISSING_LOCATION_AREA]}) with raises(ValueError) as e_info: plumerise.run(self.fm) assert e_info.value.args[0] == activity.INVALID_LOCATION_MSGS[ 'specified_points'] def test_fire_missing_location_consumption(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": [FIRE_MISSING_CONSUMPTION]}) with raises(ValueError) as e_info: plumerise.run(self.fm) assert e_info.value.args[0] == plumerise.MISSING_CONSUMPTION_ERROR_MSG def test_fire_missing_timeprofile(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": [FIRE_MISSING_TIMEPROFILE]}) with raises(ValueError) as e_info: plumerise.run(self.fm) assert e_info.value.args[0] == plumerise.MISSING_TIMEPROFILE_ERROR_MSG def test_fire_missing_start_time(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": [FIRE_MISSING_START_TIME]}) with raises(ValueError) as e_info: plumerise.run(self.fm) assert e_info.value.args[0] == plumerise.MISSING_START_TIME_ERROR_MSG # TODO: test with invalid start time def test_fire_missing_localmet(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) monkeypatch_tempfile_mkdtemp(monkeypatch) self.fm.load({"fires": [FIRE_MISSING_LOCALMET]}) plumerise.run(self.fm) assert _PR_ARGS == () assert _PR_KWARGS == defaults._DEFAULTS['plumerise']['feps'] loc1 = FIRE_MISSING_LOCALMET['activity'][0]['active_areas'][0][ 'specified_points'][0] assert _PR_COMPUTE_CALL_ARGS == [({ "foo": 1 }, { "smoldering": 123 }, loc1)] assert _PR_COMPUTE_CALL_KWARGS == [{ 'working_dir': os.path.join(TEMPFILE_DIRS[-1], 'feps-plumerise-' + FIRE_MISSING_LOCALMET.id) }] def test_no_fires(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) self.fm.load({"fires": []}) plumerise.run(self.fm) assert _PR_ARGS == () assert _PR_KWARGS == defaults._DEFAULTS['plumerise']['feps'] assert _PR_COMPUTE_CALL_ARGS == [] def test_one_fire(self, reset_config, monkeypatch): monkeypatch_plumerise_class(monkeypatch) monkeypatch_tempfile_mkdtemp(monkeypatch) self.fm.load({"fires": [FIRE]}) plumerise.run(self.fm) assert _PR_ARGS == () assert _PR_KWARGS == defaults._DEFAULTS['plumerise']['feps'] loc1 = FIRE['activity'][0]['active_areas'][0]['specified_points'][0] loc2 = FIRE['activity'][0]['active_areas'][1]['perimeter'] assert _PR_COMPUTE_CALL_ARGS == [({ "foo": 1 }, { "smoldering": 123 }, loc1), ({ "bar": 2 }, { "flaming": 434 }, loc2)] assert _PR_COMPUTE_CALL_KWARGS == [{ 'working_dir': os.path.join(TEMPFILE_DIRS[-1], 'feps-plumerise-' + FIRE.id) }, { 'working_dir': os.path.join(TEMPFILE_DIRS[-1], 'feps-plumerise-' + FIRE.id) }]