Exemple #1
0
    def test_filtering(self):
        expected = copy.deepcopy(MET)

        expected["files"].pop(0)
        assert expected == metutils.filter_met(MET,
            datetime.datetime(2016,9,21,14,0,0), 100)

        expected["files"].pop()
        assert expected == metutils.filter_met(MET,
            datetime.datetime(2016,9,21,14,0,0), 60)
Exemple #2
0
def run(fires_manager):
    """Runs dispersion module

    Args:
     - fires_manager -- bluesky.models.fires.FiresManager object
    """
    model = Config().get('dispersion', 'model').lower()
    processed_kwargs = {}
    try:
        module, klass = import_class("bluesky.dispersers.{}".format(model),
            "{}Dispersion".format(model.upper()))

        start, num_hours = _get_time(fires_manager)
        met = filter_met(fires_manager.met, start, num_hours)

        disperser = klass(met)
        processed_kwargs.update({
            "{}_version".format(model): module.__version__
        })

        output_dir, working_dir = get_working_and_output_dirs('dispersion')

        # further validation of start and num_hours done in 'run'
        dispersion_info = disperser.run(fires_manager, start,
            num_hours, output_dir, working_dir=working_dir)
        dispersion_info.update(model=model)
        # TODO: store dispersion into in summary?
        #   > fires_manager.summarize(disperion=disperser.run(...))
        fires_manager.dispersion = dispersion_info

        # TODO: add information about fires to processed_kwargs

    finally:
        fires_manager.processed(__name__, __version__, model=model,
            **processed_kwargs)
Exemple #3
0
 def test_no_filtering_needed(self):
     expected = copy.deepcopy(MET)
     assert expected == metutils.filter_met(MET,
         datetime.datetime(2016,9,21,0,0,0), 100)
Exemple #4
0
 def _get_met_files(self, start):
     met = filter_met(self._met, start, self._num_hours)
     return sorted([f['file'] for f in met['files']])