diff --git a/API/Classes/Case/DataFileClass.py b/API/Classes/Case/DataFileClass.py index 61732da2..610d33a8 100644 --- a/API/Classes/Case/DataFileClass.py +++ b/API/Classes/Case/DataFileClass.py @@ -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'] @@ -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] @@ -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] @@ -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] @@ -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] @@ -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: @@ -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] @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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: @@ -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// 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')