Skip to content

Commit

Permalink
allowable networks made more flexible
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobson committed May 9, 2024
1 parent 4ab65c7 commit 200cd4f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
5 changes: 0 additions & 5 deletions swmmanywhere/graph_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,6 @@ def __call__(self,
"""
edges_to_remove = set()
for u, v, keys, data in G.edges(data=True,keys = True):
if data.get('network_type','drive') \
not in topology_derivation.allowable_networks:

edges_to_remove.add((u, v, keys))
continue
for omit in topology_derivation.omit_edges:
if data.get('highway', None) == omit:
# Check whether the 'highway' property is 'omit'
Expand Down
6 changes: 4 additions & 2 deletions swmmanywhere/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,8 @@ def prepare_river(bbox: tuple[float, float, float, float],

def run_downloads(bbox: tuple[float, float, float, float],
addresses: parameters.FilePaths,
api_keys: dict[str, str]):
api_keys: dict[str, str],
network_types = ['drive']):
"""Run the data downloads.
Run the precipitation, elevation, building, street and river network
Expand All @@ -290,6 +291,7 @@ def run_downloads(bbox: tuple[float, float, float, float],
the format (minx, miny, maxx, maxy) in EPSG:4326.
addresses (FilePaths): Class containing the addresses of the directories.
api_keys (dict): Dictionary containing the API keys.
network_types (list): List of network types to download.
"""
target_crs = go.get_utm_epsg(bbox[0], bbox[1])

Expand All @@ -303,7 +305,7 @@ def run_downloads(bbox: tuple[float, float, float, float],
prepare_building(bbox, addresses, target_crs)

# Download street network data
prepare_street(bbox, addresses, target_crs)
prepare_street(bbox, addresses, target_crs, network_types=network_types)

# Download river network data
prepare_river(bbox, addresses, target_crs)
Expand Down
21 changes: 11 additions & 10 deletions swmmanywhere/swmmanywhere.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,21 @@ def swmmanywhere(config: dict) -> tuple[Path, dict | None]:
for key, val in config.get('address_overrides', {}).items():
setattr(addresses, key, val)

# Load the parameters and perform any manual overrides
logger.info("Loading and setting parameters.")
params = parameters.get_full_parameters()
for category, overrides in config.get('parameter_overrides', {}).items():
for key, val in overrides.items():
setattr(params[category], key, val)

# Run downloads
logger.info("Running downloads.")
api_keys = yaml.safe_load(config['api_keys'].open('r'))
preprocessing.run_downloads(config['bbox'],
addresses,
api_keys
)
addresses,
api_keys,
network_types = params['topology_derivation'].allowable_networks
)

# Identify the starting graph
logger.info("Iterating graphs.")
Expand All @@ -60,13 +68,6 @@ def swmmanywhere(config: dict) -> tuple[Path, dict | None]:
else:
G = preprocessing.create_starting_graph(addresses)

# Load the parameters and perform any manual overrides
logger.info("Loading and setting parameters.")
params = parameters.get_full_parameters()
for category, overrides in config.get('parameter_overrides', {}).items():
for key, val in overrides.items():
setattr(params[category], key, val)

# Iterate the graph functions
logger.info("Iterating graph functions.")
G = iterate_graphfcns(G,
Expand Down

0 comments on commit 200cd4f

Please sign in to comment.