Skip to content

Commit

Permalink
Merge branch 'main' into olex/improve-topology
Browse files Browse the repository at this point in the history
  • Loading branch information
olejandro authored Oct 12, 2023
2 parents b821c63 + 230e55c commit 6e9c552
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 4 additions & 0 deletions times_reader/config/times_mapping.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ NCAP_AFA[REG,DATAYEAR,PRC,BD,VALUE] = ~FI_T(Region,Year,TechName,LimType,VALUE,A
NCAP_AFC[REG,DATAYEAR,PRC,COM_GRP,TSLVL,VALUE] = ~FI_T(Region,Year,TechName,Other_Indexes,TimeSlice,VALUE,Attribute:NCAP_AFC)
NCAP_AFCS[REG,DATAYEAR,PRC,COM_GRP,TSLVL,VALUE] = ~FI_T(Region,Year,TechName,Other_Indexes,TimeSlice,VALUE,Attribute:NCAP_AFCS)
NCAP_AF[REG,DATAYEAR,PRC,ALL_TS,BD,VALUE] = ~FI_T(Region,Year,TechName,TimeSlice,LimType,VALUE,Attribute:NCAP_AF)
NCAP_AFS[REG,DATAYEAR,PRC,ALL_TS,BD,VALUE] = ~FI_T(Region,Year,TechName,TimeSlice,LimType,VALUE,Attribute:NCAP_AFS)
NCAP_BND[REG,DATAYEAR,PRC,BD,VALUE] = ~FI_T(Region,Year,TechName,LimType,VALUE,Attribute:NCAP_BND)
NCAP_CHPR[REG,DATAYEAR,PRC,BD,VALUE] = ~FI_T(Region,Year,TechName,LimType,VALUE,Attribute:NCAP_CHPR)
NCAP_COST[REG,DATAYEAR,PRC,CUR,VALUE] = ~FI_T(Region,Year,TechName,Curr,VALUE,Attribute:NCAP_COST)
NCAP_CPX[REG,DATAYEAR,PRC,VALUE] = ~FI_T(Region,Year,TechName,VALUE,Attribute:NCAP_CPX)
NCAP_DCOST[REG,DATAYEAR,PRC,CUR,VALUE] = ~FI_T(Region,Year,TechName,Curr,VALUE,Attribute:NCAP_DCOST)
NCAP_DISC[REG,DATAYEAR,PRC,UNIT,VALUE] = ~FI_T(Region,Year,TechName,Other_Indexes,VALUE,Attribute:NCAP_DISC)
NCAP_DRATE[REG,DATAYEAR,PRC,VALUE] = ~FI_T(Region,Year,TechName,VALUE,Attribute:NCAP_DRATE)
NCAP_ELIFE[REG,DATAYEAR,PRC,VALUE] = ~FI_T(Region,Year,TechName,VALUE,Attribute:NCAP_ELIFE)
Expand Down Expand Up @@ -98,7 +100,9 @@ UC_FLO[UC_N,SIDE,REG,DATAYEAR,PRC,COM,TSLVL,VALUE] = ~TODO(UC_N,Side,Region,Year
UC_IRE[UC_N,SIDE,REG,DATAYEAR,PRC,COM,TSLVL,IMP,VALUE] = ~TODO(TODO)
UC_NCAP[UC_N,SIDE,REG,DATAYEAR,PRC,VALUE] = ~UC_T(UC_N,Side,Region,Year,TechName,VALUE,Attribute:UC_NCAP)
UC_N[UC_N,TEXT] = ~UC_T(UC_N,UC_Desc)
UC_RHSR[REG,UC_N,BD,VALUE] = ~UC_T(Region,UC_N,LimType,VALUE,Attribute:UC_RHSR)
UC_RHSRT[REG,UC_N,DATAYEAR,BD,VALUE] = ~UC_T(Region,UC_N,Year,LimType,VALUE,Attribute:UC_RHSRT)
UC_RHST[UC_N,DATAYEAR,BD,VALUE] = ~UC_T(UC_N,Year,LimType,VALUE,Attribute:UC_RHST)
UC_RHSRTS[REG,UC_N,DATAYEAR,TSLVL,BD,VALUE] = ~UC_T(Region,UC_N,Year,TimeSlice,LimType,VALUE,Attribute:UC_RHSRTS)
UC_RHSTS[UC_N,DATAYEAR,TSLVL,BD,VALUE] = ~UC_T(UC_N,Year,TimeSlice,LimType,VALUE,Attribute:UC_RHSTS)
UC_R_EACH[REG,UC_N] = ~TODO(Region,UC_N)
Expand Down
17 changes: 14 additions & 3 deletions utils/dd_to_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def parse_parameter_values_from_file(
if data[index].startswith("PARAMETER"):
# We expect the parameter name on the next line.
index += 1
while data[index].strip() == "":
index += 1

param_name = data[index].replace(
" ' '/", ""
Expand Down Expand Up @@ -75,9 +77,13 @@ def parse_parameter_values_from_file(
# See https://www.gams.com/latest/docs/UG_SetDefinition.html
# This can only parse a subset of the allowed representations
_, name = data[index].split(" ")
assert data[index + 1].startswith("/")
index += 1
while data[index].strip() == "":
index += 1

assert data[index].startswith("/")
index += 1

index += 2
set_data = set()
while not data[index].startswith("/") and data[index] != "":
parts = [[]]
Expand Down Expand Up @@ -129,7 +135,12 @@ def save_data_with_headers(
Note that the header and data dictionaries are assumed to be parallel dictionaries
"""
for param_name, param_data in param_data_dict.items():
columns = headers_data[param_name]
try:
columns = headers_data[param_name]
except KeyError:
raise ValueError(
f"Could not find mapping for {param_name} in mapping file."
)
for row in param_data:
if len(row) != len(columns):
raise ValueError(
Expand Down

0 comments on commit 6e9c552

Please sign in to comment.