Skip to content

Commit

Permalink
Add test_customise_orchestration
Browse files Browse the repository at this point in the history
  • Loading branch information
liuly12 committed Sep 12, 2024
1 parent 834d42e commit ca82a8e
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 2 deletions.
138 changes: 138 additions & 0 deletions docs/demo/examples/test_customise_orchestration_example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
inputs: docs/demo/data/processed
outputs: results/quickstart_results

orchestration:
- Land: run
- Groundwater: infiltrate
- Sewer: make_discharge
- Land: apply_irrigation

data:
my_land_data:
filename: timeseries_data.csv
filter:
- where: site
is: oxford_land
scaling:
- where: variable
is: precipitation
variable: value
factor: "MM_TO_M"
format: dict
index: ['variable', 'date']
output: 'value'
options: parse_dates=['date']

dates_data:
filename: timeseries_data.csv
options: usecols=['date'],parse_dates=['date']

dates: data:dates_data

nodes:
Sewer:
type_: Sewer
name: my_sewer
capacity: 0.04
Land:
type_: Land
name: my_land
data_input_dict: data:my_land_data
surfaces:
ImperviousSurface:
type_: ImperviousSurface
surface: urban
area: 10
pollutant_load:
phosphate: 1.0e-07
PerviousSurface:
type_: PerviousSurface
surface: rural
area: 100
depth: 0.5
pollutant_load:
phosphate: 1.0e-07

Groundwater:
type_: Groundwater
name: my_groundwater
capacity: 100
area: 100

River:
type_: Node
name: my_river

Waste:
type_: Waste
name: my_outlet

arcs:
urban_drainage:
type_: Arc
name: urban_drainage
in_port: my_land
out_port: my_sewer

percolation:
type_: Arc
name: percolation
in_port: my_land
out_port: my_groundwater

runoff:
type_: Arc
name: runoff
in_port: my_land
out_port: my_river

storm_outflow:
type_: Arc
name: storm_outflow
in_port: my_sewer
out_port: my_river

baseflow:
type_: Arc
name: baseflow
in_port: my_groundwater
out_port: my_river

catchment_outflow:
type_: Arc
name: catchment_outflow
in_port: my_river
out_port: my_outlet

pollutants:
- org-phosphorus
- phosphate
- ammonia
- solids
- temperature
- nitrate
- nitrite
- org-nitrogen
additive_pollutants:
- org-phosphorus
- phosphate
- ammonia
- solids
- nitrate
- nitrite
- org-nitrogen
non_additive_pollutants:
- temperature
float_accuracy: 1.0e-06

dates:
- '2000-01-01'
- '2000-01-02'
- '2000-01-03'
- '2000-01-04'
- '2000-01-05'
- '2000-01-06'
- '2000-01-07'
- '2000-01-08'
- '2000-01-09'
- '2000-01-10'
12 changes: 10 additions & 2 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from wsimod.nodes.sewer import Sewer
from wsimod.nodes.waste import Waste
from wsimod.orchestration.model import Model, to_datetime

import os

class MyTestClass(TestCase):
def assertDictAlmostEqual(self, d1, d2, accuracy=19):
Expand Down Expand Up @@ -290,7 +290,15 @@ def test_run(self):
self.assertEqual(
0.03, my_model.nodes["my_land"].get_surface("urban").storage["volume"]
)

def test_customise_orchestration(self):
my_model = Model()
my_model.load(os.path.join(os.getcwd(), os.pardir, "docs", "demo", "examples"),
config_name='test_customise_orchestration_example.yaml')
revised_orchestration = [{'Land': 'run'},
{'Groundwater': 'infiltrate'},
{'Sewer': 'make_discharge'},
{'Land': 'apply_irrigation'}]
self.assertListEqual(my_model.orchestration, revised_orchestration)

if __name__ == "__main__":
unittest.main()

0 comments on commit ca82a8e

Please sign in to comment.