diff --git a/co2_emission/co2_emission.py b/co2_emission/co2_emission.py index ea781fd..6739ca7 100644 --- a/co2_emission/co2_emission.py +++ b/co2_emission/co2_emission.py @@ -39,43 +39,34 @@ class Co2Emission: results = {} for energy_system in self._building.energy_systems: fuel_type = energy_system.generation_system.generic_generation_system.fuel_type + emissions_factor = self._emissions_factor[fuel_type] for demand_type in energy_system.demand_types: if demand_type == cte.ELECTRICITY: continue results_by_time_period = {} if demand_type == cte.HEATING: for time_period in self._building.heating_consumption: - values = [] - for value in self._building.heating_consumption[time_period]: - values.append(value * self._emissions_factor[fuel_type]) + values = [v * emissions_factor for v in self._building.heating_consumption[time_period]] results_by_time_period[time_period] = values if demand_type == cte.COOLING: for time_period in self._building.cooling_consumption: - values = [] - for value in self._building.cooling_consumption[time_period]: - values.append(value * self._emissions_factor[fuel_type]) + values = [v * emissions_factor for v in self._building.cooling_consumption[time_period]] results_by_time_period[time_period] = values if demand_type == cte.DOMESTIC_HOT_WATER: for time_period in self._building.domestic_hot_water_consumption: - values = [] - for value in self._building.domestic_hot_water_consumption[time_period]: - values.append(value * self._emissions_factor[fuel_type]) + values = [v * emissions_factor for v in self._building.domestic_hot_water_consumption[time_period]] results_by_time_period[time_period] = values results[demand_type] = results_by_time_period - + emission_factor = self._emissions_factor[cte.ELECTRICITY] results_by_time_period = {} for time_period in self._building.lighting_electrical_demand: - values = [] - for value in self._building.lighting_electrical_demand[time_period]: - values.append(value * self._emissions_factor[cte.ELECTRICITY]) + values = [v * emission_factor for v in self._building.lighting_electrical_demand[time_period]] results_by_time_period[time_period] = values results[cte.LIGHTING] = results_by_time_period results_by_time_period = {} for time_period in self._building.appliances_electrical_demand: - values = [] - for value in self._building.appliances_electrical_demand[time_period]: - values.append(value * self._emissions_factor[cte.ELECTRICITY]) + values = [v * emission_factor for v in self._building.appliances_electrical_demand[time_period]] results_by_time_period[time_period] = values results[cte.APPLIANCES] = results_by_time_period