Skip to content

Commit

Permalink
handle model number in create_project_structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobson committed Mar 21, 2024
1 parent 1496d9d commit e4f9c06
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 10 additions & 2 deletions swmmanywhere/preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ def get_next_bbox_number(bbox: tuple[float, float, float, float],

def create_project_structure(bbox: tuple[float, float, float, float],
project: str,
base_dir: Path):
base_dir: Path,
model_number: int | None = None):
"""Create the project directory structure.
Create the project, bbox, national, model and download directories within
Expand All @@ -103,6 +104,9 @@ def create_project_structure(bbox: tuple[float, float, float, float],
the format (minx, miny, maxx, maxy).
project (str): Name of the project.
base_dir (Path): Path to the base directory.
model_number (int | None): Model number, if not provided it will use a
number that is one higher than the highest number that exists for
that bbox.
Returns:
Addresses: Class containing the addresses of the directories.
Expand All @@ -128,7 +132,11 @@ def create_project_structure(bbox: tuple[float, float, float, float],
addresses.download.mkdir(parents=True, exist_ok=True)

# Create model directory
addresses.model_number = next_directory('model', addresses.bbox)
if not model_number:
addresses.model_number = next_directory('model', addresses.bbox)
else:
addresses.model_number = model_number

addresses.model.mkdir(parents=True, exist_ok=True)

return addresses
Expand Down
4 changes: 1 addition & 3 deletions swmmanywhere/swmmanywhere.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ def swmmanywhere(config: dict) -> tuple[parameters.FilePaths, dict | None]:
addresses = preprocessing.create_project_structure(config['bbox'],
config['project'],
config['base_dir'],
config.get('model_number',None)
)

if config.get('model_number', None):
addresses.model_number = config['model_number']

for key, val in config.get('address_overrides', {}).items():
setattr(addresses, key, val)

Expand Down

0 comments on commit e4f9c06

Please sign in to comment.