Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 33 additions & 1 deletion ExcelReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,22 @@ def get_Power_Demand(excel_file_path: str, keep_excluded_entries: bool = False,
return dPower_Demand


def get_Power_Demand_KInRows(excel_file_path: str, keep_excluded_entries: bool = False, fail_on_wrong_version: bool = False) -> pd.DataFrame:
"""
Read the dPower_Demand_KInRows data from the Excel file.
:param excel_file_path: Path to the Excel file
:param keep_excluded_entries: Unused but kept for compatibility with other functions
:param fail_on_wrong_version: If True, raise an error if the version of the Excel file does not match the expected version
:return: dPower_Demand_KInRows
"""
dPower_Demand_KInRows = __read_pivoted_file(excel_file_path, "v0.1.2", ['rp', 'k', 'i'], 'i', ['rp', 'k', 'dataPackage', 'dataSource', 'id'], False, False, fail_on_wrong_version)

if keep_excluded_entries:
printer.warning("'keep_excluded_entries' is set for 'get_dPower_Demand_KInRows', although nothing is excluded anyway - please check if this is intended.")

return dPower_Demand_KInRows


def get_Power_Hindex(excel_file_path: str, keep_excluded_entries: bool = False, fail_on_wrong_version: bool = False) -> pd.DataFrame:
"""
Read the dPower_Hindex data from the Excel file.
Expand Down Expand Up @@ -251,7 +267,7 @@ def get_Power_VRESProfiles(excel_file_path: str, keep_excluded_entries: bool = F
:param excel_file_path: Path to the Excel file
:param keep_excluded_entries: Unused but kept for compatibility with other functions
:param fail_on_wrong_version: If True, raise an error if the version of the Excel file does not match the expected version
:return: dPower_VRES
:return: dPower_VRESProfiles
"""
dPower_VRESProfiles = __read_pivoted_file(excel_file_path, "v0.1.0", ['rp', 'k', 'g'], 'k', ['rp', 'g', 'dataPackage', 'dataSource', 'id'], False, False, fail_on_wrong_version)

Expand All @@ -261,6 +277,22 @@ def get_Power_VRESProfiles(excel_file_path: str, keep_excluded_entries: bool = F
return dPower_VRESProfiles


def get_Power_VRESProfiles_KInRows(excel_file_path: str, keep_excluded_entries: bool = False, fail_on_wrong_version: bool = False) -> pd.DataFrame:
"""
Read the dPower_VRESProfiles_KInRows data from the Excel file.
:param excel_file_path: Path to the Excel file
:param keep_excluded_entries: Unused but kept for compatibility with other functions
:param fail_on_wrong_version: If True, raise an error if the version of the Excel file does not match the expected version
:return: dPower_VRESProfiles_KInRows
"""
dPower_VRESProfiles_KInRows = __read_pivoted_file(excel_file_path, "v0.1.0", ['rp', 'k', 'g'], 'g', ['rp', 'k', 'dataPackage', 'dataSource', 'id'], False, False, fail_on_wrong_version)

if keep_excluded_entries:
printer.warning("'keep_excluded_entries' is set for 'get_dPower_VRESProfiles_KInRows', although nothing is excluded anyway - please check if this is intended.")

return dPower_VRESProfiles_KInRows


def get_Power_WeightsK(excel_file_path: str, keep_excluded_entries: bool = False, fail_on_wrong_version: bool = False) -> pd.DataFrame:
"""
Read the dPower_WeightsK data from the Excel file.
Expand Down
21 changes: 21 additions & 0 deletions ExcelWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,16 @@ def write_Power_Demand(self, dPower_Demand: pd.DataFrame, folder_path: str) -> N

self._write_Excel_from_definition(dPower_Demand, folder_path, "Power_Demand")

def write_Power_Demand_KInRows(self, dPower_Demand_KInRows: pd.DataFrame, folder_path: str) -> None:
"""
Write the dPower_Demand_KInRows DataFrame to an Excel file in LEGO format.
:param dPower_Demand_KInRows: DataFrame containing the dPower_Demand_KInRows data.
:param folder_path: Path to the folder where the Excel file will be saved.
:return: None
"""

self._write_Excel_from_definition(dPower_Demand_KInRows, folder_path, "Power_Demand_KInRows")

def write_Power_Hindex(self, dPower_Hindex: pd.DataFrame, folder_path: str) -> None:
"""
Write the dPower_Hindex DataFrame to an Excel file in LEGO format.
Expand Down Expand Up @@ -309,6 +319,15 @@ def write_VRESProfiles(self, dPower_VRESProfiles: pd.DataFrame, folder_path: str
"""
self._write_Excel_from_definition(dPower_VRESProfiles, folder_path, "Power_VRESProfiles")

def write_VRESProfiles_KInRows(self, dPower_VRESProfiles_KInRows: pd.DataFrame, folder_path: str) -> None:
"""
Write the dPower_VRESProfiles_KInRows DataFrame to an Excel file in LEGO format.
:param dPower_VRESProfiles_KInRows: DataFrame containing the dPower_VRESProfiles_KInRows data.
:param folder_path: Path to the folder where the Excel file will be saved.
:return: None
"""
self._write_Excel_from_definition(dPower_VRESProfiles_KInRows, folder_path, "Power_VRESProfiles_KInRows")

def write_Power_WeightsK(self, dPower_WeightsK: pd.DataFrame, folder_path: str) -> None:
"""
Write the dPower_WeightsK DataFrame to an Excel file in LEGO format.
Expand Down Expand Up @@ -394,13 +413,15 @@ def model_to_excel(model: pyomo.core.Model, target_path: str) -> None:
("Global_Scenarios", f"{args.caseStudyFolder}Global_Scenarios.xlsx", ExcelReader.get_Global_Scenarios, ew.write_Global_Scenarios),
("Power_BusInfo", f"{args.caseStudyFolder}Power_BusInfo.xlsx", ExcelReader.get_Power_BusInfo, ew.write_Power_BusInfo),
("Power_Demand", f"{args.caseStudyFolder}Power_Demand.xlsx", ExcelReader.get_Power_Demand, ew.write_Power_Demand),
("Power_Demand_KInRows", f"{args.caseStudyFolder}Power_Demand_KInRows.xlsx", ExcelReader.get_Power_Demand_KInRows, ew.write_Power_Demand_KInRows),
("Power_Hindex", f"{args.caseStudyFolder}Power_Hindex.xlsx", ExcelReader.get_Power_Hindex, ew.write_Power_Hindex),
("Power_Inflows", f"{args.caseStudyFolder}Power_Inflows.xlsx", ExcelReader.get_Power_Inflows, ew.write_Power_Inflows),
("Power_Network", f"{args.caseStudyFolder}Power_Network.xlsx", ExcelReader.get_Power_Network, ew.write_Power_Network),
("Power_Storage", f"{args.caseStudyFolder}Power_Storage.xlsx", ExcelReader.get_Power_Storage, ew.write_Power_Storage),
("Power_ThermalGen", f"{args.caseStudyFolder}Power_ThermalGen.xlsx", ExcelReader.get_Power_ThermalGen, ew.write_Power_ThermalGen),
("Power_VRES", f"{args.caseStudyFolder}Power_VRES.xlsx", ExcelReader.get_Power_VRES, ew.write_VRES),
("Power_VRESProfiles", f"{args.caseStudyFolder}Power_VRESProfiles.xlsx", ExcelReader.get_Power_VRESProfiles, ew.write_VRESProfiles),
("Power_VRESProfiles_KInRows", f"{args.caseStudyFolder}Power_VRESProfiles_KInRows.xlsx", ExcelReader.get_Power_VRESProfiles_KInRows, ew.write_VRESProfiles_KInRows),
("Power_WeightsK", f"{args.caseStudyFolder}Power_WeightsK.xlsx", ExcelReader.get_Power_WeightsK, ew.write_Power_WeightsK),
("Power_WeightsRP", f"{args.caseStudyFolder}Power_WeightsRP.xlsx", ExcelReader.get_Power_WeightsRP, ew.write_Power_WeightsRP),
("Power_Wind_TechnicalDetails", f"{args.caseStudyFolder}Power_Wind_TechnicalDetails.xlsx", ExcelReader.get_Power_Wind_TechnicalDetails, ew.write_Power_Wind_TechnicalDetails)
Expand Down
44 changes: 44 additions & 0 deletions TableDefinitions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@
<PivotColumn id="demand_by_k" scenarioDependent="True"/>
</Columns>
</TableDefinition>
<TableDefinition id="Power_Demand_KInRows">
<Version>v0.1.2</Version>
<TableHeader>Power - Demand</TableHeader>
<DescriptionRowHeight>30.0</DescriptionRowHeight>
<Columns>
<Column id="NOEXCL" scenarioDependent="False"/>
<Column id="id" scenarioDependent="True"/>
<Column id="rp" scenarioDependent="False"/>
<Column id="k" scenarioDependent="False"/>
<Column id="dataPackage" scenarioDependent="True"/>
<Column id="dataSource" scenarioDependent="True"/>
<PivotColumn id="demand_by_node" scenarioDependent="True"/>
</Columns>
</TableDefinition>
<TableDefinition id="Power_Hindex">
<Version>v0.1.2</Version>
<TableHeader>Power - Relation among periods and representative periods</TableHeader>
Expand Down Expand Up @@ -247,6 +261,20 @@
<PivotColumn id="capacity_by_k" scenarioDependent="True"/>
</Columns>
</TableDefinition>
<TableDefinition id="Power_VRESProfiles_KInRows">
<Version>v0.1.0</Version>
<TableHeader>Power - Variable Renewable Energy Sources Profiles</TableHeader>
<DescriptionRowHeight>60.0</DescriptionRowHeight>
<Columns>
<Column id="NOEXCL" scenarioDependent="False"/>
<Column id="id" scenarioDependent="True"/>
<Column id="rp" scenarioDependent="False"/>
<Column id="k" scenarioDependent="False"/>
<Column id="dataPackage" scenarioDependent="True"/>
<Column id="dataSource" scenarioDependent="True"/>
<PivotColumn id="capacity_by_g" scenarioDependent="True"/>
</Columns>
</TableDefinition>
<TableDefinition id="Power_Wind_TechnicalDetails">
<Version>v0.1.0</Version>
<TableHeader>Power - Wind Technical Details</TableHeader>
Expand Down Expand Up @@ -896,6 +924,14 @@
<ColumnWidth>10.57</ColumnWidth>
<CellStyle>rightFloat2</CellStyle>
</PivotColumn>
<PivotColumn id="capacity_by_g">
<ReadableName/>
<DatabaseName>g</DatabaseName>
<Description>Capacity factor for each VRES unit at this generator g</Description>
<Unit>[%, 0-1]</Unit>
<ColumnWidth>10.57</ColumnWidth>
<CellStyle>rightFloat2</CellStyle>
</PivotColumn>
<PivotColumn id="demand_by_k">
<ReadableName/>
<DatabaseName>k</DatabaseName>
Expand All @@ -904,6 +940,14 @@
<ColumnWidth>10.57</ColumnWidth>
<CellStyle>rightInt</CellStyle>
</PivotColumn>
<PivotColumn id="demand_by_node">
<ReadableName/>
<DatabaseName>i</DatabaseName>
<Description>Demand at node at node i</Description>
<Unit>[MWh]</Unit>
<ColumnWidth>10.57</ColumnWidth>
<CellStyle>rightInt</CellStyle>
</PivotColumn>
<PivotColumn id="inflow_by_k">
<ReadableName/>
<DatabaseName>k</DatabaseName>
Expand Down
Binary file modified data/example/Power_Demand.xlsx
Binary file not shown.
Binary file added data/example/Power_Demand_KInRows.xlsx
Binary file not shown.
Binary file added data/example/Power_VRESProfiles_KInRows.xlsx
Binary file not shown.
2 changes: 2 additions & 0 deletions tests/test_ExcelReaderWriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@
("Global_Scenarios", f"{case_study_folder}Global_Scenarios.xlsx", ExcelReader.get_Global_Scenarios, ew.write_Global_Scenarios),
("Power_BusInfo", f"{case_study_folder}Power_BusInfo.xlsx", ExcelReader.get_Power_BusInfo, ew.write_Power_BusInfo),
("Power_Demand", f"{case_study_folder}Power_Demand.xlsx", ExcelReader.get_Power_Demand, ew.write_Power_Demand),
("Power_Demand_KInRows", f"{case_study_folder}Power_Demand_KInRows.xlsx", ExcelReader.get_Power_Demand_KInRows, ew.write_Power_Demand_KInRows),
("Power_Hindex", f"{case_study_folder}Power_Hindex.xlsx", ExcelReader.get_Power_Hindex, ew.write_Power_Hindex),
("Power_Inflows", f"{case_study_folder}Power_Inflows.xlsx", ExcelReader.get_Power_Inflows, ew.write_Power_Inflows),
("Power_Network", f"{case_study_folder}Power_Network.xlsx", ExcelReader.get_Power_Network, ew.write_Power_Network),
("Power_Storage", f"{case_study_folder}Power_Storage.xlsx", ExcelReader.get_Power_Storage, ew.write_Power_Storage),
("Power_ThermalGen", f"{case_study_folder}Power_ThermalGen.xlsx", ExcelReader.get_Power_ThermalGen, ew.write_Power_ThermalGen),
("Power_VRES", f"{case_study_folder}Power_VRES.xlsx", ExcelReader.get_Power_VRES, ew.write_VRES),
("Power_VRESProfiles", f"{case_study_folder}Power_VRESProfiles.xlsx", ExcelReader.get_Power_VRESProfiles, ew.write_VRESProfiles),
("Power_VRESProfiles_KInRows", f"{case_study_folder}Power_VRESProfiles_KInRows.xlsx", ExcelReader.get_Power_VRESProfiles_KInRows, ew.write_VRESProfiles_KInRows),
("Power_WeightsK", f"{case_study_folder}Power_WeightsK.xlsx", ExcelReader.get_Power_WeightsK, ew.write_Power_WeightsK),
("Power_WeightsRP", f"{case_study_folder}Power_WeightsRP.xlsx", ExcelReader.get_Power_WeightsRP, ew.write_Power_WeightsRP),
("Power_Wind_TechnicalDetails", f"{case_study_folder}Power_Wind_TechnicalDetails.xlsx", ExcelReader.get_Power_Wind_TechnicalDetails, ew.write_Power_Wind_TechnicalDetails)
Expand Down
Loading