Pythonize for loops
This commit is contained in:
parent
128634fa25
commit
9db261c548
|
@ -39,43 +39,34 @@ class Co2Emission:
|
||||||
results = {}
|
results = {}
|
||||||
for energy_system in self._building.energy_systems:
|
for energy_system in self._building.energy_systems:
|
||||||
fuel_type = energy_system.generation_system.generic_generation_system.fuel_type
|
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:
|
for demand_type in energy_system.demand_types:
|
||||||
if demand_type == cte.ELECTRICITY:
|
if demand_type == cte.ELECTRICITY:
|
||||||
continue
|
continue
|
||||||
results_by_time_period = {}
|
results_by_time_period = {}
|
||||||
if demand_type == cte.HEATING:
|
if demand_type == cte.HEATING:
|
||||||
for time_period in self._building.heating_consumption:
|
for time_period in self._building.heating_consumption:
|
||||||
values = []
|
values = [v * emissions_factor for v in self._building.heating_consumption[time_period]]
|
||||||
for value in self._building.heating_consumption[time_period]:
|
|
||||||
values.append(value * self._emissions_factor[fuel_type])
|
|
||||||
results_by_time_period[time_period] = values
|
results_by_time_period[time_period] = values
|
||||||
if demand_type == cte.COOLING:
|
if demand_type == cte.COOLING:
|
||||||
for time_period in self._building.cooling_consumption:
|
for time_period in self._building.cooling_consumption:
|
||||||
values = []
|
values = [v * emissions_factor for v in self._building.cooling_consumption[time_period]]
|
||||||
for value in self._building.cooling_consumption[time_period]:
|
|
||||||
values.append(value * self._emissions_factor[fuel_type])
|
|
||||||
results_by_time_period[time_period] = values
|
results_by_time_period[time_period] = values
|
||||||
if demand_type == cte.DOMESTIC_HOT_WATER:
|
if demand_type == cte.DOMESTIC_HOT_WATER:
|
||||||
for time_period in self._building.domestic_hot_water_consumption:
|
for time_period in self._building.domestic_hot_water_consumption:
|
||||||
values = []
|
values = [v * emissions_factor for v in self._building.domestic_hot_water_consumption[time_period]]
|
||||||
for value in self._building.domestic_hot_water_consumption[time_period]:
|
|
||||||
values.append(value * self._emissions_factor[fuel_type])
|
|
||||||
results_by_time_period[time_period] = values
|
results_by_time_period[time_period] = values
|
||||||
results[demand_type] = results_by_time_period
|
results[demand_type] = results_by_time_period
|
||||||
|
emission_factor = self._emissions_factor[cte.ELECTRICITY]
|
||||||
results_by_time_period = {}
|
results_by_time_period = {}
|
||||||
for time_period in self._building.lighting_electrical_demand:
|
for time_period in self._building.lighting_electrical_demand:
|
||||||
values = []
|
values = [v * emission_factor for v in self._building.lighting_electrical_demand[time_period]]
|
||||||
for value in self._building.lighting_electrical_demand[time_period]:
|
|
||||||
values.append(value * self._emissions_factor[cte.ELECTRICITY])
|
|
||||||
results_by_time_period[time_period] = values
|
results_by_time_period[time_period] = values
|
||||||
results[cte.LIGHTING] = results_by_time_period
|
results[cte.LIGHTING] = results_by_time_period
|
||||||
|
|
||||||
results_by_time_period = {}
|
results_by_time_period = {}
|
||||||
for time_period in self._building.appliances_electrical_demand:
|
for time_period in self._building.appliances_electrical_demand:
|
||||||
values = []
|
values = [v * emission_factor for v in self._building.appliances_electrical_demand[time_period]]
|
||||||
for value in self._building.appliances_electrical_demand[time_period]:
|
|
||||||
values.append(value * self._emissions_factor[cte.ELECTRICITY])
|
|
||||||
results_by_time_period[time_period] = values
|
results_by_time_period[time_period] = values
|
||||||
results[cte.APPLIANCES] = results_by_time_period
|
results[cte.APPLIANCES] = results_by_time_period
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user