Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

steps:
- name: Download sdist artifact
uses: actions/download-artifact@v7
uses: actions/download-artifact@v8
with:
name: artifact
path: dist
Expand Down
1 change: 0 additions & 1 deletion docs/demo/scripts/customise_interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@

from wsimod.nodes.sewer import Sewer


my_sewer = Sewer(name="mr_sewer")
print(my_sewer.push_set_handler)

Expand Down
1 change: 1 addition & 0 deletions tests/run_all_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@author: Barney

"""

import os
import unittest

Expand Down
40 changes: 20 additions & 20 deletions tests/test_land.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_atmospheric_dep(self):

d1 = {"ammonia": 1, "nitrate": 4, "phosphate": 2, "volume": 0, "temperature": 0}
d2 = {"volume": 0, "temperature": 0, "phosphate": 0}
(r1, r2) = surface.atmospheric_deposition()
r1, r2 = surface.atmospheric_deposition()
self.assertDictAlmostEqual(d1, r1)
self.assertDictAlmostEqual(d2, r2)

Expand All @@ -93,7 +93,7 @@ def test_precip_dep(self):

d1 = {"ammonia": 1, "nitrate": 4, "phosphate": 2, "volume": 0, "temperature": 0}
d2 = {"volume": 0, "temperature": 0, "phosphate": 0}
(r1, r2) = surface.precipitation_deposition()
r1, r2 = surface.precipitation_deposition()
self.assertDictAlmostEqual(d1, r1)
self.assertDictAlmostEqual(d2, r2)

Expand Down Expand Up @@ -164,7 +164,7 @@ def test_simple_dep(self):

surface = Surface(pollutant_load=d1, area=1)

(in_, out_) = surface.simple_deposition()
in_, out_ = surface.simple_deposition()

d2 = {"volume": 0, "temperature": 0, "phosphate": 0}
self.assertDictAlmostEqual(d1, in_)
Expand Down Expand Up @@ -193,7 +193,7 @@ def test_urban_precip(self):
d1 = {"volume": 0.1 * 1.5, "temperature": 0, "phosphate": 0}
d2 = {"phosphate": 0, "volume": 0.01 * 1.5 * 0.9, "temperature": 0}
d3 = {"phosphate": 0, "temperature": 10, "volume": (0.1 - 0.01 * 0.9) * 1.5}
(r1, r2) = surface.precipitation_evaporation()
r1, r2 = surface.precipitation_evaporation()
self.assertDictAlmostEqual(d1, r1, 17)
self.assertDictAlmostEqual(d2, r2, 17)
self.assertDictAlmostEqual(d3, surface.storage, 17)
Expand All @@ -206,7 +206,7 @@ def test_urban_precip(self):
"temperature": 10,
"volume": (0.1 - (0.01 + 0.02) * 0.9) * 1.5,
}
(r1, r2) = surface.precipitation_evaporation()
r1, r2 = surface.precipitation_evaporation()
self.assertDictAlmostEqual(d3, r1, 17)
self.assertDictAlmostEqual(d4, r2, 17)
self.assertDictAlmostEqual(d5, surface.storage, 17)
Expand Down Expand Up @@ -279,7 +279,7 @@ def test_ihacres1(self):

node.t = 1

(r1, r2) = surface.ihacres()
r1, r2 = surface.ihacres()

d1 = {"volume": 0.1 * 1.5, "phosphate": 0, "temperature": 0}

Expand Down Expand Up @@ -350,7 +350,7 @@ def test_ihacres2(self):

node.t = 1

(r1, r2) = surface.ihacres()
r1, r2 = surface.ihacres()

evaporation_ = (
0.01
Expand Down Expand Up @@ -407,7 +407,7 @@ def test_ihacres3(self):

node.t = 1

(r1, r2) = surface.ihacres()
r1, r2 = surface.ihacres()

d1 = {"volume": 0.1 * 1.5, "phosphate": 0, "temperature": 0}

Expand Down Expand Up @@ -472,7 +472,7 @@ def test_perv_route(self):
surface.subsurface_flow = d2
surface.percolation = d3

(r1, r2) = surface.route()
r1, r2 = surface.route()
self.assertDictAlmostEqual(d4, r1)
self.assertDictAlmostEqual(d4, r2)
self.assertDictAlmostEqual(d1, land.surface_runoff.storage)
Expand Down Expand Up @@ -508,7 +508,7 @@ def test_soil_temp(self):
"phosphate": 0.2,
}

(r1, r2) = surface.calculate_soil_temperature()
r1, r2 = surface.calculate_soil_temperature()
self.assertDictAlmostEqual(d1, r1)
self.assertDictAlmostEqual(d1, r2)
self.assertDictAlmostEqual(d2, surface.storage, 14)
Expand Down Expand Up @@ -727,7 +727,7 @@ def test_fertiliser(self):
node.monthyear = 1
surface.parent = node

(r1, r2) = surface.fertiliser()
r1, r2 = surface.fertiliser()

d1 = surface.empty_vqip()

Expand All @@ -752,7 +752,7 @@ def test_manure(self):
node.monthyear = 1
surface.parent = node

(r1, r2) = surface.manure()
r1, r2 = surface.manure()

d1 = surface.empty_vqip()

Expand Down Expand Up @@ -844,7 +844,7 @@ def test_soil_pool(self):

nut_p = surface.nutrient_pool
cf = nut_p.temperature_dependence_factor * nut_p.soil_moisture_dependence_factor
(r1, r2) = surface.soil_pool_transformation()
r1, r2 = surface.soil_pool_transformation()

fast_ = {"N": isoil["org-nitrogen"], "P": isoil["org-phosphorus"]} # original
dissolved_inorganic_ = {
Expand Down Expand Up @@ -919,7 +919,7 @@ def test_crop_uptake(self):
surface.days_after_sow = date.dayofyear - surface.sowing_day
_ = surface.calc_crop_cover()

(r1, r2) = surface.calc_crop_uptake()
r1, r2 = surface.calc_crop_uptake()

d1 = surface.empty_vqip()
self.assertDictAlmostEqual(r1, d1)
Expand Down Expand Up @@ -956,7 +956,7 @@ def test_erosion1(self):
node.t = date
surface.parent = node
_ = surface.ihacres()
(r1, r2) = surface.erosion()
r1, r2 = surface.erosion()
d1 = surface.empty_vqip()
self.assertDictAlmostEqual(d1, r2)
d1["phosphate"] = 0.0019497135091285024
Expand All @@ -979,7 +979,7 @@ def test_erosion2(self):
node.t = date
surface.parent = node
_ = surface.ihacres()
(r1, r2) = surface.erosion()
r1, r2 = surface.erosion()
d1 = surface.empty_vqip()
self.assertDictAlmostEqual(d1, r2)
d1["phosphate"] = 1.0244298083948e-06
Expand All @@ -1002,7 +1002,7 @@ def test_erosion3(self):
node.t = date
surface.parent = node
_ = surface.ihacres()
(r1, r2) = surface.erosion()
r1, r2 = surface.erosion()
d1 = surface.empty_vqip()
self.assertDictAlmostEqual(d1, r2)
d1["phosphate"] = 8.3285749289e-09
Expand All @@ -1014,7 +1014,7 @@ def test_denitrification(self):
constants.set_default_pollutants()
surface, ivol, isoil = self.create_growing_surface()
surface.calc_temperature_dependence_factor()
(r1, r2) = surface.denitrification()
r1, r2 = surface.denitrification()
d1 = surface.empty_vqip()
self.assertDictAlmostEqual(d1, r1)
d1["nitrate"] = 0.03295446191742672
Expand All @@ -1024,7 +1024,7 @@ def test_desorption(self):
constants.set_default_pollutants()
surface, ivol, isoil = self.create_growing_surface()
surface.nutrient_pool.adsorbed_inorganic_pool.storage["P"] = 1e6
(r1, r2) = surface.adsorption()
r1, r2 = surface.adsorption()
d1 = surface.empty_vqip()
self.assertDictAlmostEqual(d1, r2)
d1["phosphate"] = 29534.602916697728
Expand Down Expand Up @@ -1054,7 +1054,7 @@ def test_adsorption(self):

surface.fertiliser()

(r1, r2) = surface.adsorption()
r1, r2 = surface.adsorption()
d1 = surface.empty_vqip()
self.assertDictAlmostEqual(d1, r1)
d1["phosphate"] = 1.5761692429741743
Expand Down
1 change: 1 addition & 0 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@author: Barney

"""

import os
import pytest
import unittest
Expand Down
1 change: 1 addition & 0 deletions wsimod/core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

@author: bdobson
"""

from wsimod.core import constants

M3_S_TO_ML_D = 86.4
Expand Down
1 change: 1 addition & 0 deletions wsimod/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

Converted to totals on Thur Apr 21 2022
"""

from math import log10

from wsimod.core import constants
Expand Down
1 change: 1 addition & 0 deletions wsimod/demo/create_oxford.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

@author: Barney
"""

import os
import re

Expand Down
1 change: 1 addition & 0 deletions wsimod/nodes/catchment.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

Converted to totals on 2022-05-03
"""

from wsimod.core import constants
from wsimod.nodes.nodes import Node

Expand Down
1 change: 1 addition & 0 deletions wsimod/nodes/demand.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

Converted to totals BD 2022-05-03
"""

from typing import Any, Dict

from wsimod.core import constants
Expand Down
13 changes: 5 additions & 8 deletions wsimod/nodes/land.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

@author: Barney
"""

import sys
from bisect import bisect_left
from math import exp, log, log10, sin
Expand Down Expand Up @@ -633,10 +634,8 @@ def apply_overrides(self, overrides=Dict[str, Any]):
self.et0_to_e = overrides.pop("et0_to_e", self.et0_to_e)
if "depth" in overrides.keys():
overrides.pop("depth")
print(
"ERROR: specifying depth is depreciated in overrides for \
impervious surface, please specify pore_depth instead"
)
print("ERROR: specifying depth is depreciated in overrides for \
impervious surface, please specify pore_depth instead")
self.pore_depth = overrides.pop("pore_depth", self.pore_depth)
self.depth = self.pore_depth
self.capacity = self.area * self.depth
Expand Down Expand Up @@ -1411,10 +1410,8 @@ def apply_overrides(self, overrides=Dict[str, Any]):

if "depth" in overrides.keys():
overrides.pop("depth")
print(
"ERROR: specifying depth is depreciated in overrides for \
GrowingSurface, please specify rooting_depth instead"
)
print("ERROR: specifying depth is depreciated in overrides for \
GrowingSurface, please specify rooting_depth instead")
self.rooting_depth = overrides.pop("rooting_depth", self.rooting_depth)
overrides["depth"] = self.rooting_depth
super().apply_overrides(overrides)
Expand Down
1 change: 1 addition & 0 deletions wsimod/nodes/nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

Converted to totals on Thur Apr 21 2022
"""

import logging
from typing import Any, Dict

Expand Down
1 change: 1 addition & 0 deletions wsimod/nodes/nutrient_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

@author: barna
"""

from typing import Any, Dict

from wsimod.core import constants
Expand Down
7 changes: 3 additions & 4 deletions wsimod/nodes/sewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@author: bdobson
Converted to totals on 2022-05-03
"""

from typing import Any, Dict

from wsimod.core import constants
Expand Down Expand Up @@ -135,10 +136,8 @@ def apply_overrides(self, overrides: Dict[str, Any] = {}):
if "pipe_timearea" in overrides.keys():
pipe_timearea_sum = sum([v for k, v in overrides["pipe_timearea"].items()])
if pipe_timearea_sum != 1:
print(
"ERROR: the sum of pipe_timearea in the overrides dict \
is not equal to 1, please check it"
)
print("ERROR: the sum of pipe_timearea in the overrides dict \
is not equal to 1, please check it")
self.pipe_timearea = overrides.pop("pipe_timearea", self.pipe_timearea)
super().apply_overrides(overrides)

Expand Down
13 changes: 5 additions & 8 deletions wsimod/nodes/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

@author: bdobson Converted to totals on 2022-05-03
"""

import warnings
from math import exp
from typing import Any, Dict
Expand Down Expand Up @@ -644,16 +645,12 @@ def apply_overrides(self, overrides=Dict[str, Any]):
setattr(self, param, overrides.pop(param))

if "area" in overrides.keys():
warnings.warn(
"WARNING: specifying area is depreciated in overrides \
for river, please specify length and width instead"
)
warnings.warn("WARNING: specifying area is depreciated in overrides \
for river, please specify length and width instead")
overrides["area"] = self.length * self.width
if "capacity" in overrides.keys():
warnings.warn(
"ERROR: specifying capacity is depreciated in overrides \
for river, it is always set as unbounded capacity"
)
warnings.warn("ERROR: specifying capacity is depreciated in overrides \
for river, it is always set as unbounded capacity")
overrides["capacity"] = constants.UNBOUNDED_CAPACITY
super().apply_overrides(overrides)

Expand Down
1 change: 1 addition & 0 deletions wsimod/nodes/waste.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

@author: bdobson
"""

from wsimod.nodes.nodes import Node


Expand Down
1 change: 1 addition & 0 deletions wsimod/nodes/wtw.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@author: bdobson
Converted to totals on 2022-05-03
"""

from typing import Any, Dict

from wsimod.core import constants
Expand Down
1 change: 1 addition & 0 deletions wsimod/orchestration/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

@author: bdobson
"""

import csv
import gzip
import importlib.util
Expand Down
Loading