diff --git a/Scripts/parameters/assignment.py b/Scripts/parameters/assignment.py index 3daaa07b..9fbf6991 100644 --- a/Scripts/parameters/assignment.py +++ b/Scripts/parameters/assignment.py @@ -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, diff --git a/Scripts/utils/calc_noise.py b/Scripts/utils/calc_noise.py index 7c2d9306..a7e84a37 100644 --- a/Scripts/utils/calc_noise.py +++ b/Scripts/utils/calc_noise.py @@ -33,17 +33,16 @@ 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 @@ -51,10 +50,10 @@ def calc_noise(self, link): 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 @@ -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