You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/config_guide.md
+3-1
Original file line number
Diff line number
Diff line change
@@ -49,9 +49,11 @@ parameter_overrides:
49
49
max_street_length: 40
50
50
```
51
51
52
-
Note that we must provide the parameter category for the parameter that we are
52
+
Note that we must provide the parameter group for the parameter that we are
53
53
changing (`subcatchment_derivation` above).
54
54
55
+
If you want to understand how parameters are implemented in more detail, and in particular if you are creating new behaviours and need to add your own parameters, see our [parameter guide](parameters_guide.md).
56
+
55
57
As our SWMManywhere paper [link preprint](https://doi.org/10.1016/j.envsoft.2025.106358) demonstrates, you can capture an enormously wide range of UDM behaviours through changing parameters. However, if your system is particularly unusual, or you are testing out new behaviours then you may need to adopt a more elaborate approach.
SWMManywhere is a deliberately highly parameterised workflow, with the goal of enabling users to create a diverse range of UDMs. This guide is to explain the logic of the implemented parameters and how to customise them, as what each parameter does is highly specific to the [`graphfcn`](graphfcns_guide.md) that uses it. Instead, to understand specific parameter purposes, you can view all available parameters at the [API](reference-parameters.md).
4
+
5
+
## Using parameters
6
+
7
+
Let's look at a [parameter group](reference-parameters.md#swmmanywhere.parameters.OutfallDerivation), which is a group of parameters related to identifying outfall locations.
8
+
9
+
:::swmmanywhere.parameters.OutfallDerivation
10
+
handler: python
11
+
options:
12
+
members: no
13
+
show_root_heading: false
14
+
show_bases: false
15
+
show_source: true
16
+
show_root_toc_entry: false
17
+
show_docstring_attributes: false
18
+
show_docstring_description: false
19
+
show_docstring_examples: false
20
+
show_docstring_parameters: false
21
+
show_docstring_returns: false
22
+
show_docstring_raises: false
23
+
24
+
We can see here three related parameters and relevant metadata, grouped together in a [`pydantic.BaseModel`](https://docs.pydantic.dev/latest/api/base_model/) object. Parameters in SWMManywhere are grouped together because `graphfcns` that need one of them tend to need the others. Let's look at [`identify_outfalls`](reference-graph-utilities.md#swmmanywhere.graphfcns.outfall_graphfcns.identify_outfalls), which needs these parameters.
When calling [`iterate_graphfcns`](reference-graph-utilities.md#swmmanywhere.graph_utilities.iterate_graphfcns), for more information see [here](graphfcns_guide.md#lists-of-graph-functions), SWMManywhere will automatically provide any parameters that have been registered to any graphfcn.
42
+
43
+
## Registering parameters
44
+
45
+
When you create a new parameter, it will need to belong to an existing or new parameter group.
46
+
47
+
### Creating a new parameter group(s)
48
+
49
+
You create a new module(s) that can contain multiple parameter groups. See below as a template of such amodule.
Now when we run our `config` file, these parameters will be registered and any [custom graphfcns](graphfcns_guide.md#add-a-new-graph-function) will have access to them.
73
+
74
+
### Changing existing parameter groups
75
+
76
+
There may be cases where you want to change existing parameter groups, such as introducing new weights to the [`calculate_weights`](reference-graph-utilities.md#swmmanywhere.graphfcns.topology_graphfcns.calculate_weights) step so that they are minimized during the shortest path optimization. In this example, we want the [`TopologyDerivation`](reference-parameters.md#swmmanywhere.parameters.TopologyDerviation) group to include some new parameters. We can do this in a similar way to [above](#creating-a-new-parameter-groups), but being mindful to inherit from `TopologyDerivation` rather than `BaseModel`:
77
+
78
+
```python
79
+
from swmmanywhere.parameters import register_parameter_group, TopologyDerivation, Field
80
+
81
+
@register_parameter_group("topology_derivation")
82
+
class NewTopologyDerivation(TopologyDerivation):
83
+
new_weight_scaling: float = Field(
84
+
default=1,
85
+
le=1,
86
+
ge=0,
87
+
)
88
+
new_weight_exponent: float = Field(
89
+
default=1,
90
+
le=2,
91
+
ge=0,
92
+
)
93
+
```
94
+
95
+
Now the `calculate_weights` function will have access to these new weighting parameters, as well as existing ones.
96
+
97
+
Note, in this specific example of adding custom weights, you will also have to:
98
+
99
+
- Update the `weights` parameter in your `config` file, for example:
100
+
101
+
```yaml
102
+
parameter_overrides:
103
+
topology_derviation:
104
+
weights:
105
+
- new_weight
106
+
- length
107
+
```
108
+
109
+
- [Create and register a `graphfcn`](graphfcns_guide.md#add-a-new-graph-function) that adds the `new_weight` parameter to the graph.
0 commit comments