Read energy demand as an array of floats
This commit is contained in:
parent
ab4492aebb
commit
025fe02f71
|
@ -21,6 +21,7 @@ class CityInfo(Resource):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@role_required([UserRoles.Admin.value])
|
||||||
def get():
|
def get():
|
||||||
session = refresh_session(request)
|
session = refresh_session(request)
|
||||||
if session is None:
|
if session is None:
|
||||||
|
|
0
hub_api/config.py
Normal file
0
hub_api/config.py
Normal file
|
@ -1,2 +1,3 @@
|
||||||
from .misc import validate_hp_model
|
from .misc import validate_hp_model
|
||||||
from .hp_simulator import HeatPumpSimulator
|
from .hp_simulator import HeatPumpSimulator
|
||||||
|
from .misc import expand_energy_demand
|
||||||
|
|
|
@ -17,10 +17,10 @@ class HeatPumpSimulator:
|
||||||
:param user_input: the user parameters for running simulation
|
:param user_input: the user parameters for running simulation
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
self._user_input = user_input
|
self._user_input = user_input
|
||||||
self._hp_type = user_input['HeatPumpType'].replace(" ", "_").lower()
|
self._hp_type = user_input['HeatPumpType'].replace(" ", "_").lower()
|
||||||
# file to have results after simulation is run
|
# file to have results after simulation is run
|
||||||
self._output_path = Path(Path(__file__).parent.parent / "data/dompark_{}.csv".format(self._hp_type))
|
|
||||||
self._city = city
|
self._city = city
|
||||||
EnergySystemsFactory(user_input['HeatPumpType'].lower(), self._city).enrich()
|
EnergySystemsFactory(user_input['HeatPumpType'].lower(), self._city).enrich()
|
||||||
|
|
||||||
|
@ -32,10 +32,12 @@ class HeatPumpSimulator:
|
||||||
"""
|
"""
|
||||||
hp_type = 'water' if 'water' in self._hp_type else 'air'
|
hp_type = 'water' if 'water' in self._hp_type else 'air'
|
||||||
del self._user_input['HeatPumpType']
|
del self._user_input['HeatPumpType']
|
||||||
|
del self._user_input['EnergyDemand']
|
||||||
model = self._user_input.pop('HeatPumpModel')
|
model = self._user_input.pop('HeatPumpModel')
|
||||||
EnergySystemsExportFactory(self._city,
|
energy_demand_path = Path(Path(__file__).parent.parent / "data/energy_demand.txt")
|
||||||
self._user_input,
|
return EnergySystemsExportFactory(city=self._city,
|
||||||
model,
|
user_input=self._user_input,
|
||||||
self._output_path,
|
hp_model=model,
|
||||||
self._user_input['SimType']).export(hp_type)
|
output_path=None,
|
||||||
return str(self._output_path)
|
sim_type=self._user_input['SimType'],
|
||||||
|
demand_path=energy_demand_path).export(hp_type)
|
||||||
|
|
|
@ -3,6 +3,11 @@ Miscellaneous
|
||||||
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
||||||
Copyright © 2022 Project Author Peter Yefi peteryefi@gmail.com
|
Copyright © 2022 Project Author Peter Yefi peteryefi@gmail.com
|
||||||
"""
|
"""
|
||||||
|
from typing import List
|
||||||
|
from pathlib import Path
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
hp_models = {
|
hp_models = {
|
||||||
'air_source': ['012', '015', '018', '023', '030', '033', '037', '044', '047', '057', '070', '087', '097', '102',
|
'air_source': ['012', '015', '018', '023', '030', '033', '037', '044', '047', '057', '070', '087', '097', '102',
|
||||||
'120', '130', '140'],
|
'120', '130', '140'],
|
||||||
|
@ -26,3 +31,15 @@ def validate_hp_model(hp_type: str, model: str) -> bool:
|
||||||
if model in hp_models['water_to_water']:
|
if model in hp_models['water_to_water']:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def expand_energy_demand(hourly_energy_demand: List[float]):
|
||||||
|
"""
|
||||||
|
Replicates each value in the list 11 times and persist the values to a file
|
||||||
|
:param hourly_energy_demand: a list of hourly energy demand data
|
||||||
|
"""
|
||||||
|
energy_demand = Path(Path(__file__).parent.parent / "data/energy_demand.txt")
|
||||||
|
with open(energy_demand, 'w') as demand_file:
|
||||||
|
repeated_demand_values = np.repeat(hourly_energy_demand, 12).tolist()
|
||||||
|
for demand in repeated_demand_values:
|
||||||
|
demand_file.write("%.6f\n" % demand)
|
Loading…
Reference in New Issue
Block a user