From 7707c0c02577a0f282abfba02142146b9e3ffe37 Mon Sep 17 00:00:00 2001 From: Carles Tena Date: Thu, 22 Aug 2019 14:34:51 +0200 Subject: [PATCH] -Traffic: Corrected 2 bugs. Calcualte velocity and Nans on CH4 --- hermesv3_bu/sectors/traffic_sector.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hermesv3_bu/sectors/traffic_sector.py b/hermesv3_bu/sectors/traffic_sector.py index 27636b2..db584b1 100755 --- a/hermesv3_bu/sectors/traffic_sector.py +++ b/hermesv3_bu/sectors/traffic_sector.py @@ -505,7 +505,7 @@ class TrafficSector(Sector): x = pd.merge(x, speed, left_on='P_speed', right_index=True, how='left') x['speed'] = x.groupby('hour').apply(lambda y: x[[str(y.name)]]) - return x[['speed']] + return x['speed'] * x['speed_mean'] def get_temporal_factor(x): def get_hourly_id_from_weekday(weekday): @@ -674,6 +674,9 @@ class TrafficSector(Sector): (expanded_aux.Epsilon * expanded_aux.v_aux**2 + expanded_aux.Zita * expanded_aux.v_aux + expanded_aux.Hta)) * (1 - expanded_aux.RF) * \ (expanded_aux.PF * expanded_aux['T'] / expanded_aux.Q) + + # COPERT V equation can give nan for CH4 + expanded_aux[ef_name].fillna(0, inplace=True) else: expanded_aux[ef_name] = \ ((expanded_aux['a'] * expanded_aux['Cmileage'] + expanded_aux['b']) * @@ -858,6 +861,8 @@ class TrafficSector(Sector): if 'voc' in self.source_pollutants and 'ch4' in self.source_pollutants: expanded['nmvoc_{0}'.format(tstep)] = expanded['voc_{0}'.format(tstep)] - \ expanded['ch4_{0}'.format(tstep)] + # For certain vehicles (mostly diesel) and speeds, in urban road CH4 > than VOC according to COPERT V + expanded.loc[expanded['nmvoc_{0}'.format(tstep)] < 0, 'nmvoc_{0}'.format(tstep)] = 0 del expanded['voc_{0}'.format(tstep)] else: self.logger.write_log("nmvoc emissions cannot be estimated because voc or ch4 are not selected in " + -- GitLab