Skip to content
Open
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
26 changes: 25 additions & 1 deletion API/Classes/Case/DataFileClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def gen_R(self):
r = self.R(File.readFile(self.rPath))
for id, param in self.PARAM['R'].items():
self.f.write('{} {} {} {} {} {}'.format('param', param,'default', self.defaultValue[id], ':=','\n'))
tmp = self.defaultValue[id]
for sc in self.scOrder:
if r[id][sc['ScId']]['value'] is not None and sc['Active'] == True:
tmp = r[id][sc['ScId']]['value']
Expand All @@ -115,6 +116,7 @@ def gen_RY(self):
self.f.write('{}{}{}'.format(self.years, ':=', '\n'))
ryString = ''
for yearId in self.yearIDs:
tmp = self.defaultValue[id]
for sc in self.scOrder:
if ry[id][sc['ScId']][yearId] is not None and sc['Active'] == True:
tmp = ry[id][sc['ScId']][yearId]
Expand All @@ -129,6 +131,7 @@ def gen_RT(self):
self.f.write('{}{}{}'.format(self.techs, ':=', '\n'))
rtString = ''
for techId in self.techIDs:
tmp = self.defaultValue[id]
for sc in self.scOrder:
if rt[id][sc['ScId']][techId] is not None and sc['Active'] == True:
tmp = rt[id][sc['ScId']][techId]
Expand All @@ -143,6 +146,7 @@ def gen_RE(self):
self.f.write('{}{}{}'.format(self.emis, ':=', '\n'))
reString = ''
for emiId in self.emiIDs:
tmp = self.defaultValue[id]
for sc in self.scOrder:
if re[id][sc['ScId']][emiId] is not None and sc['Active'] == True:
tmp = re[id][sc['ScId']][emiId]
Expand All @@ -157,6 +161,7 @@ def gen_RS(self):
self.f.write('{}{}{}'.format(self.stgs, ':=', '\n'))
rsString = ''
for stgId in self.stgIDs:
tmp = self.defaultValue[id]
for sc in self.scOrder:
if re[id][sc['ScId']][stgId] is not None and sc['Active'] == True:
tmp = re[id][sc['ScId']][stgId]
Expand All @@ -180,6 +185,7 @@ def gen_RTSM(self):


# for yearId in self.yearIDs:
tmp = self.defaultValue[id]
for sc in self.scOrder:
rtsmValue = rtsm[id][sc['ScId']][stgId][storageTechId][mod]
if rtsmValue is not None and sc['Active'] == True:
Expand All @@ -204,6 +210,7 @@ def gen_RYCn(self):
for conId in self.conIDs:
rycnString = ''
for yearId in self.yearIDs:
tmp = self.defaultValue[id]
for sc in self.scOrder:
if rycn[id][sc['ScId']][yearId][conId] is not None and sc['Active'] == True:
tmp = rycn[id][sc['ScId']][yearId][conId]
Expand All @@ -220,6 +227,7 @@ def gen_RYTs(self):
rytsString = ''
#defaultValueFlag = False
for yearId in self.yearIDs:
tmp = self.defaultValue[id]
for sc in self.scOrder:
rytsValue = ryts[id][sc['ScId']][yearId][timesliceId]
if rytsValue is not None and sc['Active'] == True:
Expand All @@ -240,6 +248,7 @@ def gen_RYDtb(self):
rydtbString = ''
#defaultValueFlag = False
for yearId in self.yearIDs:
tmp = self.defaultValue[id]
for sc in self.scOrder:
rydtbValue = rydtb[id][sc['ScId']][yearId][dtbId]
if rydtbValue is not None and sc['Active'] == True:
Expand All @@ -263,6 +272,7 @@ def gen_RYSeDt(self):
rysedtString = ''
defaultValueFlag = False
for yearId in self.yearIDs:
tmp = self.defaultValue[id]
for sc in self.scOrder:
rysedtValue = rysedt[id][sc['ScId']][yearId][seId][dtId]
if rysedtValue is not None and sc['Active'] == True:
Expand All @@ -289,6 +299,7 @@ def gen_RYT(self):
rytString = ''
defaultValueFlag = False
for yearId in self.yearIDs:
tmp = self.defaultValue[id]
for sc in self.scOrder:
rytValue = ryt[id][sc['ScId']][yearId][techId]
if rytValue is not None and sc['Active'] == True:
Expand All @@ -315,6 +326,7 @@ def gen_RYS(self):
rysString = ''
defaultValueFlag = False
for yearId in self.yearIDs:
tmp = self.defaultValue[id]
for sc in self.scOrder:
rysValue = rys[id][sc['ScId']][yearId][stgId]
if rysValue is not None and sc['Active'] == True:
Expand Down Expand Up @@ -345,6 +357,7 @@ def gen_RYTCn(self):
# self.f.write('{}{}{}'.format( self.years, ':=', '\n'))
rytcnString = ''
for yearId in self.yearIDs:
tmp = self.defaultValue[id]
for sc in self.scOrder:
rytcnValue = rytcn[id][sc['ScId']][yearId][constraintTechId][conId]
if rytcnValue is not None and sc['Active'] == True:
Expand Down Expand Up @@ -373,6 +386,7 @@ def gen_RYTM(self):
rytmString = ''
defaultValueFlag = False
for yearId in self.yearIDs:
tmp = self.defaultValue[id]
for sc in self.scOrder:
rytmValue = rytm[id][sc['ScId']][yearId][techId][mod]
if rytmValue is not None and sc['Active'] == True:
Expand All @@ -399,6 +413,7 @@ def gen_RYC(self):
rycString = ''
defaultValueFlag = False
for yearId in self.yearIDs:
tmp = self.defaultValue[id]
for sc in self.scOrder:
rycValue = ryc[id][sc['ScId']][yearId][commId]
if rycValue is not None and sc['Active'] == True:
Expand All @@ -425,6 +440,7 @@ def gen_RYE(self):
ryeString = ''
defaultValueFlag = False
for yearId in self.yearIDs:
tmp = self.defaultValue[id]
for sc in self.scOrder:
ryeValue = rye[id][sc['ScId']][yearId][emiId]
if ryeValue is not None and sc['Active'] == True:
Expand All @@ -450,6 +466,7 @@ def gen_RYTC(self):
rytcString = ''
defaultValueFlag = False
for yearId in self.yearIDs:
tmp = self.defaultValue[id]
for sc in self.scOrder:
rytcValue = rytc[id][sc['ScId']][yearId][inputCapTechId][inputCapCommId]
if rytcValue is not None and sc['Active'] == True:
Expand Down Expand Up @@ -478,6 +495,7 @@ def gen_RYTCM(self):
rytcString = ''
defaultValueFlag = False
for yearId in self.yearIDs:
tmp = self.defaultValue[id]
for sc in self.scOrder:
rytcmValue = rytcm[id][sc['ScId']][yearId][activityTechId][activityCommId][mod]
if rytcmValue is not None and sc['Active'] == True:
Expand Down Expand Up @@ -507,6 +525,7 @@ def gen_RYTSM(self):
rytcString = ''
defaultValueFlag = False
for yearId in self.yearIDs:
tmp = self.defaultValue[id]
for sc in self.scOrder:
rytsmValue = rytsm[id][sc['ScId']][yearId][stgId][storageTechId][mod]
if rytsmValue is not None and sc['Active'] == True:
Expand All @@ -532,6 +551,7 @@ def gen_RYTE(self):
defaultValueFlag = False
ryteString = ''
for yearId in self.yearIDs:
tmp = self.defaultValue[id]
for sc in self.scOrder:
ryteValue = ryte[id][sc['ScId']][yearId][emissionTechId][activityEmissionId]
if ryteValue is not None and sc['Active'] == True:
Expand Down Expand Up @@ -560,6 +580,7 @@ def gen_RYTEM(self):
ryteString = ''
defaultValueFlag = False
for yearId in self.yearIDs:
tmp = self.defaultValue[id]
for sc in self.scOrder:
rytemValue = rytem[id][sc['ScId']][yearId][emissionTechId][activityEmissionId][mod]
if rytemValue is not None and sc['Active'] == True:
Expand Down Expand Up @@ -587,6 +608,7 @@ def gen_RYTTs(self):
ryttsString = ''
defaultValueFlag = False
for yearId in self.yearIDs:
tmp = self.defaultValue[id]
for sc in self.scOrder:
ryttsValue = rytts[id][sc['ScId']][yearId][techId][timesliceId]
if ryttsValue is not None and sc['Active'] == True:
Expand Down Expand Up @@ -614,6 +636,7 @@ def gen_RYCTs(self):
ryctsString = ''
defaultValueFlag = False
for yearId in self.yearIDs:
tmp = self.defaultValue[id]
for sc in self.scOrder:
ryctsValue = rycts[id][sc['ScId']][yearId][commId][timesliceId]
if ryctsValue is not None and sc['Active'] == True:
Expand Down Expand Up @@ -731,7 +754,8 @@ def generateDatafile( self, caserunname ):
path = '"{}"'.format(self.resPath)

dataFilePath = Path(Config.DATA_STORAGE, self.case, 'res',caserunname,'data.txt')

# restored backups may lack an empty res/<caserunname>/ folder
dataFilePath.parent.mkdir(parents=True, exist_ok=True)

# self.f = open(self.dataFile, mode="w", encoding='utf-8')
#self.f = open(dataFilePath, mode="w", encoding='utf-8')
Expand Down