예제 #1
0
def get_scenario_model_object():

    scenario_model = ScenarioModel('test_scenario_model')
    scenario_model.add_output('raininess',
                              scenario_model.regions.get_entry('LSOA'),
                              scenario_model.intervals.get_entry('annual'),
                              'ml')
    scenario_model.scenario_set = 'raininess'
    return scenario_model
예제 #2
0
    def test_serialise_scenario_two_outputs(self):
        scenario_model = ScenarioModel('High Population (ONS)')
        scenario_model.add_output('population_count',
                                  scenario_model.regions.get_entry('LSOA'),
                                  scenario_model.intervals.get_entry('annual'),
                                  'people')
        scenario_model.add_output('population_density',
                                  scenario_model.regions.get_entry('LSOA'),
                                  scenario_model.intervals.get_entry('annual'),
                                  'people/km^2')
        scenario_model.description = 'The High ONS Forecast for UK population out to 2050'
        scenario_model.scenario_set = 'population'
        actual = scenario_model.as_dict()
        # sort to match expected output
        actual['parameters'].sort(key=lambda p: p['name'])

        expected = {
            'name':
            'High Population (ONS)',
            'description':
            'The High ONS Forecast for UK population out to 2050',
            'scenario_set':
            'population',
            'parameters': [{
                'name': 'population_count',
                'spatial_resolution': 'LSOA',
                'temporal_resolution': 'annual',
                'units': 'people'
            }, {
                'name': 'population_density',
                'spatial_resolution': 'LSOA',
                'temporal_resolution': 'annual',
                'units': 'people/km^2'
            }]
        }
        assert actual == expected