Skip to content

Commit

Permalink
Fix/noise zones (#450)
Browse files Browse the repository at this point in the history
* Print nodes to better debug errors

* Print 5 meter noise buffers for negative values

* Set `cross_traffic` minimum value to 0.01

* Add error message

* Revert zone width change

Co-authored-by: Jens West <jens.west@hsl.fi>
  • Loading branch information
johpiip and Jens West authored Apr 25, 2022
1 parent 4845217 commit 4262eac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Scripts/parameters/assignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@
years_average_day_factor = 0.85
# Factor for converting day traffic into 7:00-22:00 traffic
share_7_22_of_day = 0.9
# Noice zone width as function of start noise
# Noise zone width as function of start noise
noise_zone_width = {
(0, 55): lambda x: 5,
(55, 65): lambda x: 10 + 31./10*x,
Expand Down
13 changes: 7 additions & 6 deletions Scripts/utils/calc_noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,27 @@ def calc_noise(self, link):
float
Noise zone width (m)
"""
traffic = sum([link[mode] for mode in self.light_modes])
traffic = max(sum([link[mode] for mode in self.light_modes]), 0.01)
rlink = link.reverse_link
if rlink is None:
reverse_traffic = 0
else:
reverse_traffic = sum([rlink[mode] for mode in self.light_modes])
cross_traffic = (param.years_average_day_factor
* param.share_7_22_of_day
* (traffic+reverse_traffic))
* param.share_7_22_of_day
* (traffic+reverse_traffic))
heavy = sum([link[mode] for mode in self.heavy_modes])
traffic = max(traffic, 0.01)
heavy_share = heavy / (traffic+heavy)

# Calculate speed
link = self.morning_network.link(link.i_node, link.j_node)
rlink = link.reverse_link
if reverse_traffic > 0:
speed = (60 * 2 * link.length
/ (link[self.car_morning]+rlink[self.car_morning]))
/ (link[self.car_morning]+rlink[self.car_morning]))
else:
speed = (0.3*(60*link.length/link[self.car_morning])
+ 0.7*link.data2)
+ 0.7*link.data2)
speed = max(speed, 50.0)

# Calculate start noise
Expand All @@ -75,4 +74,6 @@ def calc_noise(self, link):
if interval[0] <= start_noise < interval[1]:
zone_width = func[interval](start_noise - interval[0])
break
else:
raise ValueError("No noise interval found for link {}".format(link.id))
return zone_width

0 comments on commit 4262eac

Please sign in to comment.