From dec82d71ee57c9127ac8746faf435e590733d944 Mon Sep 17 00:00:00 2001 From: Mathias157 Date: Tue, 24 Sep 2024 10:39:46 +0200 Subject: [PATCH] Some formatting --- src/Modules/exo_electricity_demand.py | 52 +++++++++++++-------------- src/Modules/exo_heat_demand.py | 21 ++++++----- 2 files changed, 34 insertions(+), 39 deletions(-) diff --git a/src/Modules/exo_electricity_demand.py b/src/Modules/exo_electricity_demand.py index 5669555..b9b585c 100644 --- a/src/Modules/exo_electricity_demand.py +++ b/src/Modules/exo_electricity_demand.py @@ -16,17 +16,10 @@ ### ------------------------------- ### import matplotlib.pyplot as plt -import pandas as pd -import textwrap -import numpy as np import click -import pickle from Submodules.utils import convert_names, transform_xrdata import xarray as xr -from typing import Tuple from pybalmorel import IncFile -from Submodules.municipal_template import DataContainer -from Submodules.utils import convert_coordname_elements import matplotlib try: import cmcrameri @@ -85,16 +78,18 @@ def main(conversion_file: str, # 1.2 Make .inc-files out_path = 'Output' ## 1.2.1 DE - DE = IncFile(name='DE', - prefix=textwrap.dedent("""* Data from Energinet Dataservice 2023 - TABLE DE1(RRR,DEUSER,YYY) 'Annual electricity consumption (MWh)' - """), - suffix=textwrap.dedent("""; - DE(YYY,RRR,DEUSER)=DE1(RRR,DEUSER,YYY); - DE('2050',RRR,DEUSER) = DE('2023', RRR, DEUSER); - DE1(RRR,DEUSER,YYY) = 0; - """), - path=out_path + DE = IncFile(name='DE', path=out_path, + prefix='\n'.join([ + "* Data from Energinet Dataservice 2023", + "TABLE DE1(RRR,DEUSER,YYY) 'Annual electricity consumption (MWh)'", + "", + ]), + suffix='\n'.join([ + ";", + "DE(YYY,RRR,DEUSER)=DE1(RRR,DEUSER,YYY);", + "DE('2050',RRR,DEUSER) = DE('2023', RRR, DEUSER);", + "DE1(RRR,DEUSER,YYY) = 0;", + ]) ) ### Sum to annual electricity demands DE.body = ( @@ -109,17 +104,18 @@ def main(conversion_file: str, DE.save() ## 1.2.2 DE_VAR_T - DE_VAR_T = IncFile(name='DE_VAR_T', - prefix=textwrap.dedent(""" - * Data from Energinet Dataservice 2023 - TABLE DE_VAR_T1(DEUSER,SSS,TTT,RRR) "Variation in electricity demand" - """), - suffix=textwrap.dedent(""" - ; - PARAMETER DE_VAR_T(RRR,DEUSER,SSS,TTT) "Variation in electricity demand"; - DE_VAR_T(RRR,DEUSER,SSS,TTT) = DE_VAR_T1(DEUSER,SSS,TTT,RRR); - """), - path=out_path) + DE_VAR_T = IncFile(name='DE_VAR_T', path=out_path, + prefix='\n'.join(["* Data from Energinet Dataservice 2023", + "TABLE DE_VAR_T1(DEUSER,SSS,TTT,RRR) 'Variation in electricity demand'", + "", + ]), + suffix='\n'.join(["", + ";", + "PARAMETER DE_VAR_T(RRR,DEUSER,SSS,TTT) 'Variation in electricity demand';", + "DE_VAR_T(RRR,DEUSER,SSS,TTT) = DE_VAR_T1(DEUSER,SSS,TTT,RRR); ", + "DE_VAR_T1(DEUSER,SSS,TTT,RRR) = 0;" + ]), + ) DE_VAR_T.body = ( transform_xrdata(new_dataset, 'electricity_demand_mwh') diff --git a/src/Modules/exo_heat_demand.py b/src/Modules/exo_heat_demand.py index 70d0cd4..e04264e 100644 --- a/src/Modules/exo_heat_demand.py +++ b/src/Modules/exo_heat_demand.py @@ -309,18 +309,17 @@ def main(show_difference: bool = False): create_INDUSTRY_DH_VAR_T(el_new_dataset=el_new_dataset, name='INDUSTRY_DH_VAR_T', path=out_path, - prefix="""TABLE DH_VAR_T_IND(SSS,TTT,AAA,DHUSER)\n""", - suffix="""\n;\n* Collect series to other heat series, if there is a industry heat series -DH_VAR_T(AAA,DHUSER,SSS,TTT)$(SUM((S,T), DH_VAR_T_IND(S,T,AAA,DHUSER))) = DH_VAR_T_IND(SSS,TTT,AAA,DHUSER); -DH_VAR_T_IND(SSS,TTT,AAA,DHUSER)=0; + prefix="TABLE DH_VAR_T_IND(SSS,TTT,AAA,DHUSER)\n", + suffix='\n'.join(["", + ";", + "* Collect series to other heat series, if there is a industry heat series", + "DH_VAR_T(AAA,DHUSER,SSS,TTT)$(SUM((S,T), DH_VAR_T_IND(S,T,AAA,DHUSER))) = DH_VAR_T_IND(SSS,TTT,AAA,DHUSER);", + "DH_VAR_T_IND(SSS,TTT,AAA,DHUSER)=0;", + "* Assume that other temperature processes follow the same pattern, if there is a profile", + "DH_VAR_T(AAA,'IND-PHM',SSS,TTT)$(SUM((S,T), DH_VAR_T(AAA,'IND-PHH',SSS,TTT))) = DH_VAR_T(AAA,'IND-PHH',SSS,TTT);", + "DH_VAR_T(AAA,'IND-PHL',SSS,TTT)$(SUM((S,T), DH_VAR_T(AAA,'IND-PHH',SSS,TTT))) = DH_VAR_T(AAA,'IND-PHH',SSS,TTT);", + ])) -* Assume that other temperature processes follow the same pattern, if there is a profile -DH_VAR_T(AAA,'IND-PHM',SSS,TTT)$(SUM((S,T), DH_VAR_T(AAA,'IND-PHH',SSS,TTT))) = DH_VAR_T(AAA,'IND-PHH',SSS,TTT); -DH_VAR_T(AAA,'IND-PHL',SSS,TTT)$(SUM((S,T), DH_VAR_T(AAA,'IND-PHH',SSS,TTT))) = DH_VAR_T(AAA,'IND-PHH',SSS,TTT); -""") - - - if __name__ == '__main__': main(show_difference=False) \ No newline at end of file