Skip to content

Commit

Permalink
update output filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
arght committed Nov 26, 2023
1 parent 19f5659 commit 2ec7b69
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
10 changes: 5 additions & 5 deletions doc/rst/OutputResults.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Some maps of the electricity transmission network and the energy share of differ
:scale: 40%
:align: center

.. image:: ../img/oT_Plot_TechnologyEnergy_ES_MAF2030.png
.. image:: ../img/oT_Plot_TechnologyGenerationEnergy_ES_MAF2030.png
:scale: 6%
:align: center

Expand Down Expand Up @@ -293,7 +293,7 @@ Identifier Identifier Identifier Header Description
Period Scenario Load level Technology Percentage of energy curtailed of VRES [%]
============ ========== ========== ============== ===========================================

File ``oT_Result_TechnologyEnergy.csv``
File ``oT_Result_TechnologyGenerationEnergy.csv``

============ ========== ========== ========== =================================
Identifier Identifier Identifier Header Description
Expand All @@ -309,7 +309,7 @@ Identifier Identifier Identifier Header Description
Period Scenario Load level Technology Energy (charge in ESS) [GWh]
============ ========== ========== ========== =================================

File ``oT_Result_TechnologyEnergy_AreaName.csv``
File ``oT_Result_TechnologyGenerationEnergy_AreaName.csv``

============ ========== ========== ========== ==========================================
Identifier Identifier Identifier Header Description
Expand Down Expand Up @@ -424,15 +424,15 @@ Identifier Identifier Identifier Header Description
Period Scenario Load level Technology Charged power in ESS [MW]
============ ========== ========== ========== ==========================================

File ``oT_Result_TechnologyEnergyESS.csv``
File ``oT_Result_TechnologyConsumptionEnergyESS.csv``

============ ========== ========== ========== ==========================================
Identifier Identifier Identifier Header Description
============ ========== ========== ========== ==========================================
Period Scenario Load level Technology Energy (charge in ESS) [GWh]
============ ========== ========== ========== ==========================================

File ``oT_Result_TechnologyEnergyESS_AreaName.csv``
File ``oT_Result_TechnologyConsumptionEnergyESS_AreaName.csv``

============ ========== ========== ========== ==========================================
Identifier Identifier Identifier Header Description
Expand Down
22 changes: 11 additions & 11 deletions openTEPES/openTEPES_OutputResults.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - November 22, 2023
Open Generation, Storage, and Transmission Operation and Expansion Planning Model with RES and ESS (openTEPES) - November 26, 2023
"""

import time
Expand Down Expand Up @@ -484,12 +484,12 @@ def GenerationOperationResults(DirName, CaseName, OptModel, mTEPES, pIndTechnolo
chart.save(_path+'/oT_Plot_TechnologyOutput_'+str(p)+'_'+str(sc)+'_'+CaseName+'.html', embed_options={'renderer': 'svg'})

OutputToFile = pd.Series(data=[sum(OptModel.vTotalOutput[p,sc,n,g]()*mTEPES.pLoadLevelDuration[n]() for g in mTEPES.g if (gt,g) in mTEPES.t2g) for p,sc,n,gt in sPSNGT], index=pd.Index(sPSNGT))
OutputToFile.to_frame(name='GWh').reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='GWh', aggfunc='sum').rename_axis(['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(_path+'/oT_Result_TechnologyEnergy_'+CaseName+'.csv', sep=',')
OutputToFile.to_frame(name='GWh').reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='GWh', aggfunc='sum').rename_axis(['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(_path+'/oT_Result_TechnologyGenerationEnergy_'+CaseName+'.csv', sep=',')

if pIndPlotOutput == 1:
for p,sc in mTEPES.ps:
chart = PiePlots(p, sc, OutputToFile, 'Technology', '%')
chart.save(_path+'/oT_Plot_TechnologyEnergy_'+str(p)+'_'+str(sc)+'_'+CaseName+'.html', embed_options={'renderer': 'svg'})
chart.save(_path+'/oT_Plot_TechnologyGenerationEnergy_'+str(p)+'_'+str(sc)+'_'+CaseName+'.html', embed_options={'renderer': 'svg'})

if sum(1 for ar in mTEPES.ar if sum(1 for g in g2a[ar])) > 1:
if pIndAreaOutput == 1:
Expand All @@ -498,12 +498,12 @@ def GenerationOperationResults(DirName, CaseName, OptModel, mTEPES, pIndTechnolo
sPSNGT = [(p,sc,n,gt) for p,sc,n,gt in mTEPES.psngt if sum(1 for g in mTEPES.t2g if (ar,g) in mTEPES.a2g)]
if len(sPSNGT):
OutputToFile = pd.Series(data=[sum(OptModel.vTotalOutput[p,sc,n,g]()*mTEPES.pLoadLevelDuration[n]() for g in mTEPES.g if (gt,g) in mTEPES.t2g and (ar,g) in mTEPES.a2g) for p,sc,n,gt in sPSNGT], index=pd.Index(sPSNGT))
OutputToFile.to_frame(name='GWh').reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='GWh', aggfunc='sum').rename_axis(['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(_path+'/oT_Result_TechnologyEnergy_'+ar+'_'+CaseName+'.csv', sep=',')
OutputToFile.to_frame(name='GWh').reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='GWh', aggfunc='sum').rename_axis(['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(_path+'/oT_Result_TechnologyGenerationEnergy_'+ar+'_'+CaseName+'.csv', sep=',')

if pIndPlotOutput == 1:
for p,sc in mTEPES.ps:
chart = PiePlots(p, sc, OutputToFile, 'Technology', '%')
chart.save(_path+'/oT_Plot_TechnologyEnergy_'+str(p)+'_'+str(sc)+'_'+ar+'_'+CaseName+'.html', embed_options={'renderer': 'svg'})
chart.save(_path+'/oT_Plot_TechnologyGenerationEnergy_'+str(p)+'_'+str(sc)+'_'+ar+'_'+CaseName+'.html', embed_options={'renderer': 'svg'})

WritingResultsTime = time.time() - StartTime
StartTime = time.time()
Expand Down Expand Up @@ -562,14 +562,14 @@ def ESSOperationResults(DirName, CaseName, OptModel, mTEPES, pIndTechnologyOutpu
if pIndTechnologyOutput == 1 or pIndTechnologyOutput == 2:
sPSNOT = [(p,sc,n,ot) for p,sc,n,ot in mTEPES.psnot if sum(1 for es in o2e[ot])]
OutputToFile = pd.Series(data=[sum(OutputToFile[p,sc,n,eh] for eh in o2e[ot]) for p,sc,n,ot in sPSNOT], index=pd.Index(sPSNOT))
OutputToFile.to_frame(name='GWh').reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='GWh').rename_axis (['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(_path+'/oT_Result_TechnologyEnergyESS_' +CaseName+'.csv', sep=',')
OutputToFile.to_frame(name='GWh').reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='GWh').rename_axis (['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(_path+'/oT_Result_TechnologyConsumptionEnergyESS_' +CaseName+'.csv', sep=',')

if pIndPlotOutput == 1:
OutputToFile *= -1.0
if OutputToFile.sum() < 0.0:
for p,sc in mTEPES.ps:
chart = PiePlots(p, sc, OutputToFile, 'Technology', '%')
chart.save(_path+'/oT_Plot_TechnologyEnergyESS_'+str(p)+'_'+str(sc)+'_'+CaseName+'.html', embed_options={'renderer': 'svg'})
chart.save(_path+'/oT_Plot_TechnologyConsumptionEnergyESS_'+str(p)+'_'+str(sc)+'_'+CaseName+'.html', embed_options={'renderer': 'svg'})

if sum(1 for ar in mTEPES.ar if sum(1 for eh in e2a[ar])) > 1:
if pIndAreaOutput == 1:
Expand All @@ -578,13 +578,13 @@ def ESSOperationResults(DirName, CaseName, OptModel, mTEPES, pIndTechnologyOutpu
sPSNOT = [(p,sc,n,ot) for p,sc,n,ot in mTEPES.psnot if sum(1 for eh in e2a[ar] if (ot,eh) in mTEPES.t2g)]
if len(sPSNOT):
OutputToFile = pd.Series(data=[sum(-OptModel.vESSTotalCharge[p,sc,n,eh]()*mTEPES.pLoadLevelDuration[n]() for eh in e2a[ar] if (ot,eh) in mTEPES.t2g) for p,sc,n,ot in sPSNOT], index=pd.Index(sPSNOT))
OutputToFile.to_frame(name='GWh').reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='GWh', aggfunc='sum').rename_axis(['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(_path+'/oT_Result_TechnologyEnergyESS_'+ar+'_'+CaseName+'.csv', sep=',')
OutputToFile.to_frame(name='GWh').reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='GWh', aggfunc='sum').rename_axis(['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(_path+'/oT_Result_TechnologyConsumptionEnergyESS_'+ar+'_'+CaseName+'.csv', sep=',')

if pIndPlotOutput == 1:
OutputToFile *= -1.0
for p,sc in mTEPES.ps:
chart = PiePlots(p, sc, OutputToFile, 'Technology', '%')
chart.save(_path+'/oT_Plot_TechnologyEnergyESS_'+str(p)+'_'+str(sc)+'_'+ar+'_'+CaseName+'.html', embed_options={'renderer': 'svg'})
chart.save(_path+'/oT_Plot_TechnologyConsumptionEnergyESS_'+str(p)+'_'+str(sc)+'_'+ar+'_'+CaseName+'.html', embed_options={'renderer': 'svg'})

# tolerance to consider avoid division by 0
pEpsilon = 1e-6
Expand Down Expand Up @@ -1415,12 +1415,12 @@ def EconomicResults(DirName, CaseName, OptModel, mTEPES, pIndAreaOutput, pIndPlo
sPSNGT = [(p,sc,n,gt) for p,sc,n,gt in mTEPES.psngt if sum(1 for g in mTEPES.t2g if (ar,g) in mTEPES.a2g)]
if len(sPSNGT):
OutputToFile = pd.Series(data=[sum(OptModel.vTotalOutput[p,sc,n,g]()*mTEPES.pLoadLevelDuration[n]() for g in mTEPES.g if (gt,g) in mTEPES.t2g if (ar,g) in mTEPES.a2g) for p,sc,n,gt in sPSNGT], index=pd.Index(sPSNGT))
OutputToFile.to_frame(name='GWh').reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='GWh', aggfunc='sum').rename_axis(['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(_path+'/oT_Result_TechnologyEnergy_'+ar+'_'+CaseName+'.csv', sep=',')
OutputToFile.to_frame(name='GWh').reset_index().pivot_table(index=['level_0','level_1','level_2'], columns='level_3', values='GWh', aggfunc='sum').rename_axis(['Period', 'Scenario', 'LoadLevel'], axis=0).rename_axis([None], axis=1).to_csv(_path+'/oT_Result_TechnologyGenerationEnergy_'+ar+'_'+CaseName+'.csv', sep=',')

if pIndPlotOutput == 1:
for p,sc in mTEPES.ps:
chart = PiePlots(p, sc, OutputToFile, 'Technology', '%')
chart.save(_path+'/oT_Plot_TechnologyEnergy_'+str(p)+'_'+str(sc)+'_'+ar+'_'+CaseName+'.html', embed_options={'renderer': 'svg'})
chart.save(_path+'/oT_Plot_TechnologyGenerationEnergy_'+str(p)+'_'+str(sc)+'_'+ar+'_'+CaseName+'.html', embed_options={'renderer': 'svg'})

sPSNARND = [(p,sc,n,ar,nd) for p,sc,n,ar,nd in mTEPES.psnar*mTEPES.nd if sum(1 for g in g2n[nd]) + sum(1 for lout in lout[nd]) + sum(1 for ni,cc in lin[nd]) and (nd,ar) in mTEPES.ndar]
sPSNARNDGT = [(p,sc,n,ar,nd,gt) for p,sc,n,ar,nd,gt in sPSNARND*mTEPES.gt if sum(1 for g in g2t[gt]) and (nd,ar) in mTEPES.ndar]
Expand Down

0 comments on commit 2ec7b69

Please sign in to comment.