Reference for SWMManywhere/filepaths.py
File paths module for SWMMAnywhere.
BBoxPaths
Paths for the bounding box folder (within project folder).
Source code in swmmanywhere/filepaths.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
|
bbox
property
The bounding box folder (specific to a bounding box).
building
property
The building file for the bounding box (clipped from national scale).
download
property
The download folder (for bbox specific downloaded data).
elevation
property
The elevation file for the bounding box.
precipitation
property
The precipitation data.
river
property
The river graph for the bounding box.
street
property
The street graph for the bounding box.
__init__(project_paths, bbox_bounds, bbox_number=None, extension='parquet', **kwargs)
Initialise the bounding box paths.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_paths
|
ProjectPaths
|
The project paths. |
required |
bbox_bounds
|
tuple[float, float, float, float]
|
Bounding box coordinates in the format (minx, miny, maxx, maxy). |
required |
bbox_number
|
int
|
The bounding box number. Defaults to None, in which case if the existing bounding box has already been created it will be found, otherwise the next number will be used. |
None
|
extension
|
str
|
The extension for the files. Defaults to 'parquet'. |
'parquet'
|
**kwargs
|
Additional file paths to override. |
{}
|
Source code in swmmanywhere/filepaths.py
FilePaths
File paths class (manager for project, bbox and model).
Source code in swmmanywhere/filepaths.py
__init__(base_dir, project_name, bbox_bounds, bbox_number=None, model_number=None, extension='parquet', **kwargs)
Initialise the file paths.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_dir
|
Path
|
The base directory. |
required |
project_name
|
str
|
The name of the project. |
required |
bbox_bounds
|
tuple[float, float, float, float]
|
Bounding box coordinates in the format (minx, miny, maxx, maxy). |
required |
bbox_number
|
int
|
The bounding box number. Defaults to None, in which case if the existing bounding box has already been created it will be found, otherwise the next number will be used. |
None
|
model_number
|
int
|
The model number. Defaults to None, in which case the next number in the bbox directory will be used. |
None
|
extension
|
str
|
The extension for the files. |
'parquet'
|
**kwargs
|
Additional file paths. |
{}
|
Source code in swmmanywhere/filepaths.py
get_path(name)
set_bbox_number(number)
set_model_number(number)
to_yaml(f)
Convert a file to json.
Source code in swmmanywhere/filepaths.py
ModelPaths
Paths for the model folder (within bbox folder).
Source code in swmmanywhere/filepaths.py
edges
property
The edges file for the model.
graph
property
The graph file for the model.
inp
property
The synthesised SWMM input file for the model.
model
property
The model folder (one specific synthesised model).
nodes
property
The nodes file for the model.
streetcover
property
The street cover file for the model.
subcatchments
property
The subcatchments file for the model.
__init__(bbox_paths, model_number=None, extension='parquet', **kwargs)
Initialise the model paths.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bbox_paths
|
BBoxPaths
|
The bounding box paths. |
required |
model_number
|
(int, None)
|
The model number. Defaults to None, in which case the next number in the bbox directory will be used. |
None
|
extension
|
str
|
The extension for the files. |
'parquet'
|
**kwargs
|
Additional file paths to override. |
{}
|
Source code in swmmanywhere/filepaths.py
ProjectPaths
Paths for the project folder (within base_dir).
Source code in swmmanywhere/filepaths.py
national
property
The national folder (for national scale downloads).
national_building
property
The national scale building file.
project
property
The project folder (sits in the base_dir).
__init__(base_dir, project_name, extension='parquet', **kwargs)
Initialise the project paths.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_dir
|
Path
|
The base directory. |
required |
project_name
|
str
|
The name of the project. |
required |
extension
|
str
|
The extension for the files. |
'parquet'
|
**kwargs
|
Additional file paths to override. |
{}
|
Source code in swmmanywhere/filepaths.py
check_bboxes(bbox, data_dir)
Find the bounding box number.
Check if the bounding box coordinates match any existing bounding box directories within data_dir.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bbox
|
tuple[float, float, float, float]
|
Bounding box coordinates in the format (minx, miny, maxx, maxy). |
required |
data_dir
|
Path
|
Path to the data directory. |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int | bool
|
Bounding box number if the coordinates match, else False. |
Source code in swmmanywhere/filepaths.py
filepaths_from_yaml(f)
Get file paths from a yaml file.
Source code in swmmanywhere/filepaths.py
get_next_bbox_number(bbox, data_dir)
Get the next bounding box number.
If there are existing bounding box directories, check within them to see if any have the same bounding box, otherwise find the next number. If there are no existing bounding box directories, return 1.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bbox
|
tuple[float, float, float, float]
|
Bounding box coordinates in the format (minx, miny, maxx, maxy). |
required |
data_dir
|
Path
|
Path to the data directory. |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
Next bounding box number. |
Source code in swmmanywhere/filepaths.py
get_overrides(klass, overrides)
Get overrides for a class.
next_directory(keyword, directory)
Find the next directory number.
Find the next directory number within a directory with a
Parameters:
Name | Type | Description | Default |
---|---|---|---|
keyword
|
str
|
Keyword to search for in the directory name. |
required |
directory
|
Path
|
Path to the directory to search within. |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
int
|
Next directory number. |