3. Discharge object¶
The discharge object is one of the core objects in pySIMDEUM. By default, a discharge profile is not simulated when generating a House. The simulate_discharge=True argument needs to be toggled on to simulate discharge profiles. Effectively, it is a representation of the wastewater discharge for a household. The key point is that it is directly linked to the consumption simulation. Consumption events of an enduse directly trigger a matching discharge event.
Discharge data structure¶
The discharge object is a xarray.Dataset containing:
- a
xarray.DataArray(similar format to theconsumptionobject) with discharge flows - a list of dictionaries containing
discharge_eventsmetadata
The xarray.DataArray structure of discharge is a multidimensional array to handle the labelled flow data. The core of the DataArray is the numerical data of discharge flow rates in litres per second.
Dimensions define the axes of the data, and are:
time: temporal resolution of the dataenduse: appliances that are sampled to populated this householduser: individual household memberspatterns: represents different consumption patterns / scenarios
The coordinates are effectively the axes labels. For example, time will be populated with timestamps. enduse will be specific appliances such as shower, wc etc.
import pysimdeum
import matplotlib.pyplot as plt
Initialise a two-person household
# Build a house (one-person household)
house = pysimdeum.built_house(house_type='two_person', simulate_discharge=True)
The discharge profile is simulated when generating a House and can be accessed directly from the House instance.
house.discharge
<xarray.Dataset> Size: 30MB
Dimensions: (time: 86401, user: 3, enduse: 7, patterns: 1,
dischargetypes: 2, dim_0: 259)
Coordinates:
* time (time) datetime64[ns] 691kB 2025-04-25 ... 2025-04-26
* user (user) <U9 108B 'user_1' 'user_2' 'household'
* enduse (enduse) <U14 392B 'Wc' 'BathroomTap' ... 'WashingMachine'
* patterns (patterns) int64 8B 0
* dischargetypes (dischargetypes) <U10 80B 'greywater' 'blackwater'
Dimensions without coordinates: dim_0
Data variables:
discharge (time, user, enduse, patterns, dischargetypes) float64 29MB ...
discharge_events (dim_0) object 2kB {'enduse': 'Wc', 'usage': 'faeces', ...You can access the discharge dataarray of the discharge Dataset. It is structued in a similar way to the consumption object.
house.discharge.discharge
<xarray.DataArray 'discharge' (time: 86401, user: 3, enduse: 7, patterns: 1,
dischargetypes: 2)> Size: 29MB
array([[[[[0., 0.]],
[[0., 0.]],
[[0., 0.]],
...,
[[0., 0.]],
[[0., 0.]],
[[0., 0.]]],
[[[0., 0.]],
[[0., 0.]],
[[0., 0.]],
...
[[0., 0.]],
[[0., 0.]],
[[0., 0.]]],
[[[0., 0.]],
[[0., 0.]],
[[0., 0.]],
...,
[[0., 0.]],
[[0., 0.]],
[[0., 0.]]]]])
Coordinates:
* time (time) datetime64[ns] 691kB 2025-04-25 ... 2025-04-26
* user (user) <U9 108B 'user_1' 'user_2' 'household'
* enduse (enduse) <U14 392B 'Wc' 'BathroomTap' ... 'WashingMachine'
* patterns (patterns) int64 8B 0
* dischargetypes (dischargetypes) <U10 80B 'greywater' 'blackwater'And the corresponding metadata within discharge_events. It is formed of a list of dictionaries, with each dictionary tracking a discharge event of an enduse. The main use case for this is to keep track of usage types of enduses that are not relevant during simulation stage such as whether the usage of a Wc is sampled as urine or faeces as this will affect nutrient concentration sampling process, but at simulation stage it is only relevant whether a half or full flush is used (and this is somewhat indepdent of urine or faeces use). Discharge temperature is also stored for use in post-processing analysis of wastewater profiles.
house.discharge.discharge_events
<xarray.DataArray 'discharge_events' (dim_0: 259)> Size: 2kB
array([{'enduse': 'Wc', 'usage': 'faeces', 'start': 77552, 'end': 77558, 'discharge_temperature': 20},
{'enduse': 'Wc', 'usage': 'urine', 'start': 32706, 'end': 32712, 'discharge_temperature': 20},
{'enduse': 'Wc', 'usage': 'urine', 'start': 32382, 'end': 32388, 'discharge_temperature': 20},
{'enduse': 'Wc', 'usage': 'urine', 'start': 73884, 'end': 73890, 'discharge_temperature': 20},
{'enduse': 'Wc', 'usage': 'urine', 'start': 26506, 'end': 26512, 'discharge_temperature': 20},
{'enduse': 'Wc', 'usage': 'urine', 'start': 2590, 'end': 2596, 'discharge_temperature': 20},
{'enduse': 'Wc', 'usage': 'urine', 'start': 26675, 'end': 26681, 'discharge_temperature': 20},
{'enduse': 'Wc', 'usage': 'urine', 'start': 9750, 'end': 9756, 'discharge_temperature': 20},
{'enduse': 'Wc', 'usage': 'urine', 'start': 30650, 'end': 30656, 'discharge_temperature': 20},
{'enduse': 'Wc', 'usage': 'urine', 'start': 40243, 'end': 40249, 'discharge_temperature': 20},
{'enduse': 'Wc', 'usage': 'urine', 'start': 28734, 'end': 28740, 'discharge_temperature': 20},
{'enduse': 'Wc', 'usage': 'urine', 'start': 37375, 'end': 37381, 'discharge_temperature': 20},
{'enduse': 'Wc', 'usage': 'faeces', 'start': 42439, 'end': 42445, 'discharge_temperature': 20},
{'enduse': 'Wc', 'usage': 'urine', 'start': 27465, 'end': 27471, 'discharge_temperature': 20},
{'enduse': 'Wc', 'usage': 'urine', 'start': 42602, 'end': 42608, 'discharge_temperature': 20},
{'enduse': 'Wc', 'usage': 'urine', 'start': 81557, 'end': 81563, 'discharge_temperature': 20},
{'enduse': 'Wc', 'usage': 'urine', 'start': 28425, 'end': 28431, 'discharge_temperature': 20},
{'enduse': 'BathroomTap', 'usage': 'brushing_teeth', 'start': 77026, 'end': 77444, 'discharge_temperature': 10},
{'enduse': 'BathroomTap', 'usage': 'washing_shaving', 'start': 73369, 'end': 73378, 'discharge_temperature': 40},
{'enduse': 'BathroomTap', 'usage': 'brushing_teeth', 'start': 27861, 'end': 27971, 'discharge_temperature': 10},
...
{'enduse': 'BathroomTap', 'usage': 'washing_shaving', 'start': 73369, 'end': 73378, 'discharge_temperature': 40},
{'enduse': 'BathroomTap', 'usage': 'brushing_teeth', 'start': 27861, 'end': 27971, 'discharge_temperature': 10},
{'enduse': 'BathroomTap', 'usage': 'washing_shaving', 'start': 26710, 'end': 27320, 'discharge_temperature': 40},
{'enduse': 'BathroomTap', 'usage': 'brushing_teeth', 'start': 26651, 'end': 26656, 'discharge_temperature': 10},
{'enduse': 'BathroomTap', 'usage': 'washing_shaving', 'start': 82374, 'end': 82461, 'discharge_temperature': 40},
{'enduse': 'BathroomTap', 'usage': 'brushing_teeth', 'start': 81942, 'end': 82006, 'discharge_temperature': 10},
{'enduse': 'BathroomTap', 'usage': 'brushing_teeth', 'start': 27516, 'end': 27557, 'discharge_temperature': 10},
{'enduse': 'BathroomTap', 'usage': 'brushing_teeth', 'start': 26789, 'end': 27022, 'discharge_temperature': 10},
{'enduse': 'BathroomTap', 'usage': 'washing_shaving', 'start': 32958, 'end': 33002, 'discharge_temperature': 40},
{'enduse': 'BathroomTap', 'usage': 'brushing_teeth', 'start': 33002, 'end': 33009, 'discharge_temperature': 10},
{'enduse': 'BathroomTap', 'usage': 'washing_shaving', 'start': 27391, 'end': 27444, 'discharge_temperature': 40},
{'enduse': 'KitchenTap', 'usage': 'dishes', 'start': 27024, 'end': 31462, 'discharge_temperature': 40},
{'enduse': 'KitchenTap', 'usage': 'dishes', 'start': 31368, 'end': 31956, 'discharge_temperature': 40},
{'enduse': 'KitchenTap', 'usage': 'dishes', 'start': 41863, 'end': 42553, 'discharge_temperature': 40},
{'enduse': 'KitchenTap', 'usage': 'consumption', 'start': 42830, 'end': 42837, 'discharge_temperature': 0},
{'enduse': 'KitchenTap', 'usage': 'consumption', 'start': 27597, 'end': 27787, 'discharge_temperature': 0},
{'enduse': 'KitchenTap', 'usage': 'other', 'start': 31106, 'end': 31525, 'discharge_temperature': 10},
{'enduse': 'Shower', 'usage': 'Shower', 'start': 30568, 'end': 31942, 'discharge_temperature': 35},
{'enduse': 'Shower', 'usage': 'Shower', 'start': 41501, 'end': 41724, 'discharge_temperature': 35}],
dtype=object)
Dimensions without coordinates: dim_0The discharge dataarray can be used to produce plots of wastewater discharge summed across enduses and users as below.
house.discharge.discharge.sum(["enduse","user","dischargetypes"]).plot()
[<matplotlib.lines.Line2D at 0x11f398cd0>]
Or if you are specifically interested in the discharge of a certain enduse such as the Wc
house.discharge.discharge.sum(["user","dischargetypes"]).sel(enduse="Wc").plot()
[<matplotlib.lines.Line2D at 0x11f525d50>]