Ejemplo n.º 1
0
def test__university_for_super_areas():
    super_area = SuperArea(name="durham",
                           areas=None,
                           coordinates=[54.768, -1.571868])
    super_areas = SuperAreas([super_area])
    unis = Universities.for_super_areas(super_areas)
    durham_uni = unis[0]
    assert durham_uni.n_students_max == 19025
def make_world(geography):
    geography.hospitals = Hospitals.for_geography(geography)
    geography.schools = Schools.for_geography(geography)
    geography.companies = Companies.for_geography(geography)
    geography.care_homes = CareHomes.for_geography(geography)
    geography.universities = Universities.for_super_areas(
        geography.super_areas)
    world = generate_world_from_geography(geography,
                                          include_households=False,
                                          include_commute=False)
    return world
Ejemplo n.º 3
0
def create_world(geography_h5):
    with h5py.File("test.hdf5", "w"):
        pass  # reset file
    geography = geography_h5
    geography.hospitals = Hospitals.for_geography(geography)
    geography.schools = Schools.for_geography(geography)
    geography.companies = Companies.for_geography(geography)
    geography.care_homes = CareHomes.for_geography(geography)
    geography.universities = Universities.for_super_areas(geography.super_areas)
    world = generate_world_from_geography(
        geography=geography, include_households=True, include_commute=True
    )
    world.pubs = Pubs.for_geography(geography)
    world.cinemas = Cinemas.for_geography(geography)
    world.groceries = Groceries.for_geography(geography)
    leisure = generate_leisure_for_world(
        ["pubs", "cinemas", "groceries", "household_visits", "care_home_vists"], world
    )
    leisure.distribute_social_venues_to_households(world.households)
    return world
Ejemplo n.º 4
0
geography = Geography.from_file({
    "super_area": [
        "E02003282",
        "E02001720",
        "E00088544",
        "E02002560",
        "E02002559",
        "E02004314",
    ]
})
geography.hospitals = Hospitals.for_geography(geography)
geography.schools = Schools.for_geography(geography)
geography.companies = Companies.for_geography(geography)
geography.care_homes = CareHomes.for_geography(geography)
geography.universities = Universities.for_super_areas(geography.super_areas)
world = generate_world_from_geography(geography,
                                      include_households=True,
                                      include_commute=True)

print("World length", len(world.people))
world.to_hdf5("world.hdf5")

world = generate_world_from_hdf5("world.hdf5")

# leisure
geography = load_geography_from_hdf5("world.hdf5")
world.cinemas = Cinemas.for_geography(geography)
world.pubs = Pubs.for_geography(geography)
world.groceries = Groceries.for_super_areas(world.super_areas,
                                            venues_per_capita=1 / 500)