def test_read_results_dicts(): # Using temp dir to ensure that each time a new directory is used inputs, results = ds.get_sim_results(path=SIM_DIR, return_xarray=False, return_status=False) assert isinstance(inputs, dict) assert isinstance(results, dict)
# Load the configuration file config = ds.load_config_excel('../ConfigFiles/ConfigEU.xlsx') # Limit the simulation period (for testing purposes, comment the line to run the whole year) config['StartDate'] = (2016, 1, 1, 0, 0, 0) config['StopDate'] = (2016, 1, 7, 0, 0, 0) # Build the simulation environment: SimData = ds.build_simulation(config) # Solve using GAMS: _ = ds.solve_GAMS(config['SimulationDirectory'], config['GAMS_folder']) # Load the simulation results: inputs, results = ds.get_sim_results(config['SimulationDirectory'], cache=False) # Generate country-specific plots ds.plot_country(inputs, results) # Bar plot with the installed capacities in all countries: cap = ds.plot_country_capacities(inputs) # Bar plot with the energy balances in all countries: ds.plot_energy_country_fuel(inputs, results, ds.get_indicators_powerplant(inputs, results)) # Analyse the results for each country and provide quantitative indicators: r = ds.get_result_analysis(inputs, results) # Plot the reservoir levels
import datetime as dt from dispaset.postprocessing import postprocessing as post import importlib importlib.reload(post) import dispaset as ds import matplotlib.pyplot as plt from matplotlib.pyplot import * import seaborn as sns import matplotlib.dates as mdates import pickle import time as tm import logging import shutil import json shutil.copy('input_data/ConfigGCC2.xlsx', 'Simulations/ConfigGCC2.xlsx') # Load the configuration file config = ds.load_config_excel('Simulations/ConfigGCC2.xlsx') # Build the simulation environment: SimData, FuelPrices, FuelPrices2 = ds.build_simulation( config, LocalSubsidyMultiplier=1, ExportCostMultiplier=1) r = ds.solve_GAMS(config['SimulationDirectory'], config['GAMS_folder']) path = 'Simulations/simulation_GCC' inputs, results = ds.get_sim_results(path=path, cache=True) with open('output_data/results.json', 'w') as fp: json.dump(str(results), fp)
#%% Import results import sys,os sys.path.append(os.path.abspath(r'C:\Users\Andrea\GitHub\Dispa-SET-2.3')) # Import Dispa-SET import dispaset as ds inputs, results = ds.get_sim_results(path=r"C:\Users\Andrea\GitHub\Dispa-SET-2.3\Simulations\Article PROres1 coupling\TIMES_ProRes_2050_EVFLEX_new",cache=False) inputs0, results_aug = ds.get_sim_results(path=r"C:\Users\Andrea\GitHub\Dispa-SET-2.3\Simulations\Article PROres1 coupling\TIMES_ProRes_2050_EVFLEX_new_aug",cache=False) #inputs1, results_apr = ds.get_sim_results(path=r"C:\Users\Andrea\GitHub\Dispa-SET-2.3\Simulations\Article PROres1 coupling\TIMES_ProRes_2050_ALLFLEX_new_apr",cache=False) #inputs2, results_aug = ds.get_sim_results(path=r"C:\Users\Andrea\GitHub\Dispa-SET-2.3\Simulations\Article PROres1 coupling\TIMES_ProRes_2050_ALLFLEX_new_aug",cache=False) #inputs3, results_oct = ds.get_sim_results(path=r"C:\Users\Andrea\GitHub\Dispa-SET-2.3\Simulations\Article PROres1 coupling\TIMES_ProRes_2050_ALLFLEX_new_oct",cache=False) #inputs4, results_nov = ds.get_sim_results(path=r"C:\Users\Andrea\GitHub\Dispa-SET-2.3\Simulations\Article PROres1 coupling\TIMES_ProRes_2050_ALLFLEX_new_nov",cache=False) # import pandas as pd start_remove1 = pd.to_datetime('2016-8-28') end_remove1 = pd.to_datetime('2016-9-5 23') #start_remove2 = pd.to_datetime('2016-4-3') #end_remove2 = pd.to_datetime('2016-4-11 23') #start_remove3 = pd.to_datetime('2016-8-10') #end_remove3 = pd.to_datetime('2016-8-18 23') #start_remove4 = pd.to_datetime('2016-10-24') #end_remove4 = pd.to_datetime('2016-11-1 23') #start_remove5 = pd.to_datetime('2016-11-14') #end_remove5 = pd.to_datetime('2016-11-22 23') #%% Create merged results
# -*- coding: utf-8 -*- """ Minimalist example file showing how to read the results of a Dispa-SET run @author: Sylvain Quoilin """ # Add the root folder of Dispa-SET to the path so that the library can be loaded: import sys, os sys.path.append(os.path.abspath('../../Dispa-SET')) # Import Dispa-SET import dispaset as ds # Load the inputs and the results of the simulation inputs, results = ds.get_sim_results(path='../Simulations/bolivia_base_2025', cache=False) # if needed, define the plotting range for the dispatch plot: import pandas as pd rng = pd.date_range(start='2025-01-01', end='2025-12-31', freq='h') # Generate country-specific plots ds.plot_zone(inputs, results, rng=rng) # Bar plot with the installed capacities in all countries: cap = ds.plot_zone_capacities(inputs) # Bar plot with the energy balances in all countries: ds.plot_energy_zone_fuel(inputs, results, ds.get_indicators_powerplant(inputs, results))
# -*- coding: utf-8 -*- """ Minimalist example file showing how to read the results of a Dispa-SET run @author: Sylvain Quoilin """ # Add the root folder of Dispa-SET to the path so that the library can be loaded: import sys,os sys.path.append(os.path.abspath('..')) # Import Dispa-SET import dispaset as ds # Load the inputs and the results of the simulation inputs,results = ds.get_sim_results(path='../Simulations/simulation_test',cache=False) # if needed, define the plotting range for the dispatch plot: import pandas as pd rng = pd.date_range(start='2016-01-01',end='2016-12-31',freq='h') # Generate country-specific plots ds.plot_country(inputs,results,rng=rng) # Bar plot with the installed capacities in all countries: cap = ds.plot_country_capacities(inputs) # Bar plot with the energy balances in all countries: ds.plot_energy_country_fuel(inputs,results,ds.get_indicators_powerplant(inputs,results)) # Analyse the results for each country and provide quantitative indicators:
all_combinations = list( product(heat_demand_scen, power_scen, cost_heat_slack_scen, res_mod_scen)) logging.info(str(len(all_combinations)) + ' runs will be made') # 36 for this case i = 0 for iheat, ipower, icost_heat, iresmod in all_combinations: i += 1 scenario_name = "run_1_" + str(i) # Load run specific inputs config['HeatDemand'] = iheat config['PowerPlantData'] = ipower config['default']['CostHeatSlack'] = icost_heat config['modifiers']['Solar'] = config['modifiers']['wind'] = iresmod # Build simulation SimData = ds.build_simulation(config) # Solve using GAMS: r = ds.solve_GAMS(config['SimulationDirectory'], config['GAMS_folder']) # Load inputs and results to memory inputs, results = ds.get_sim_results(path=config['SimulationDirectory'], cache=True) # Save inputs and results to a file filename = os.path.join(path_to_save, scenario_name + ".p") with open(filename, "wb") as f: pickle.dump((inputs, results), f, protocol=pickle.HIGHEST_PROTOCOL) logging.info('Saved {} to pickle file'.format(scenario_name))
r = ds.solve_GAMS(folder, config['GAMS_folder']) #%% # Read all the simulation folders one by one and store key results in dataframe: paths = os.listdir(sim_folder) # Only take into account the ones for which a valid dispa-set result file is present paths_ok = [ x for x in paths if os.path.isfile(sim_folder + x + '/Results.gdx') ] N = len(paths_ok) data = pd.DataFrame(index=range(N)) for i, path in enumerate(paths_ok): inputs, results = ds.get_sim_results(path=sim_folder + path, cache=True) FuelPower = ds.aggregate_by_fuel(results['OutputPower'], inputs, SpecifyFuels=None) # get installed capacities by fuel: cap = ds.plot_country_capacities(inputs, plot=False) # Capacity factors: CF = {} for f in ['GAS', 'NUC', 'WAT', 'WIN', 'SUN']: CF[f] = FuelPower[f].sum() / (cap['PowerCapacity'].loc['BE', f] * 8760) r = ds.get_result_analysis(inputs, results) # Compute total lost load
def get_OSE_MC(model,scenario,coverage): if scenario == 'Baseline battery costs': scenario_folder = '_Baseline battery costs' elif scenario == '50percent battery costs': scenario_folder = '_50percent battery costs' elif scenario == '25percent battery costs': scenario_folder = '_25percent battery costs' if coverage == 'Full geographic coverage': coverage_folder = '_Full_geographic_coverage' elif coverage == 'Germany only': coverage_folder = '_Germany_only' path = input_folder + 'simulation_OSE_' + model + scenario_folder + coverage_folder if os.path.isdir(path) == False: print('Path: ' + path + ' does not exist') else: inputs,results = ds.get_sim_results(path=path,cache=False) ppt = ds.get_indicators_powerplant(inputs,results) ppt.reset_index(inplace=True) ## Get caoacities def capacity_df(df): df.loc[(df['Fuel'] == 'HRD') & (df['Technology'] == 'STUR'),'Variable'] = 'Capacity|Electricity|Hard coal' df.loc[(df['Fuel'] == 'NUC') & (df['Technology'] == 'STUR'),'Variable'] = 'Capacity|Electricity|Nuclear' df.loc[(df['Fuel'] == 'LIG') & (df['Technology'] == 'STUR'),'Variable'] = 'Capacity|Electricity|Lignite' df.loc[(df['Fuel'] == 'OIL') & (df['Technology'] == 'STUR'),'Variable'] = 'Capacity|Electricity|Oil' df.loc[(df['Fuel'] == 'BIO') & (df['Technology'] == 'STUR'),'Variable'] = 'Capacity|Electricity|Bioenergy' df.loc[(df['Fuel'] == 'OTH') & (df['Technology'] == 'STUR'),'Variable'] = 'Capacity|Electricity|Other nonrenewable' df.loc[(df['Fuel'] == 'GAS') & (df['Technology'] == 'GTUR'),'Variable'] = 'Capacity|Electricity|Gas OCGT' df.loc[(df['Fuel'] == 'GAS') & (df['Technology'] == 'COMC'),'Variable'] = 'Capacity|Electricity|Gas CCGT' df.loc[(df['Fuel'] == 'WST') & (df['Technology'] == 'STUR'),'Variable'] = 'Capacity|Electricity|Other renewable' df.loc[(df['Fuel'] == 'WIN') & (df['Technology'] == 'WTON'),'Variable'] = 'Capacity|Electricity|Wind Onshore' df.loc[(df['Fuel'] == 'WIN') & (df['Technology'] == 'WTOF'),'Variable'] = 'Capacity|Electricity|Wind Offshore' df.loc[(df['Fuel'] == 'SUN') & (df['Technology'] == 'PHOT'),'Variable'] = 'Capacity|Electricity|Solar PV' df.loc[(df['Fuel'] == 'WAT') & (df['Technology'] == 'HROR'),'Variable'] = 'Capacity|Electricity|Hydro ROR' df.loc[(df['Fuel'] == 'WAT') & (df['Technology'] == 'HPHS'),'Variable'] = 'Capacity|Electricity|Storage|Pumped hydro|Power' df.loc[(df['Fuel'] == 'WAT') & (df['Technology'] == 'HDAM'),'Variable'] = 'Capacity|Electricity|Hydro Reservoir' df.loc[(df['Fuel'] == 'OTH') & (df['Technology'] == 'BATS'),'Variable'] = 'Capacity|Electricity|Storage|Liion|Power' df['Value'] = df['Nunits'] * df['PowerCapacity'] / 1e3 # Total capacity df_total = df.groupby(['Variable'])['Value'].sum().reset_index() df_total.reset_index(inplace=True) df_total.rename(columns={'index': 'Zone'}, inplace=True) df_total['Zone'] = 'Whole Region' df = df.append(df_total, ignore_index=True, sort=True) df['Unit'] = 'GW' df = df[['Zone','Variable','Unit','Value']] return df df_capacity = capacity_df(ppt) ## Get generation, shedding,emmisions and curtailment def generation_df(df,results,inputs): df.set_index('index', inplace=True) df['CO2'] = df['Generation'] / inputs['units']['Efficiency'] * inputs['units']['EmissionRate'] co2_zone = df.groupby(['Zone'])['CO2'].sum().reset_index() co2_zone.reset_index(inplace=True) co2_zone['Variable'] = 'Carbon emissions' co2_zone['Unit'] = 't_CO2' co2_zone.rename(columns={'CO2': 'Value'}, inplace=True) # df.groupby(['Fruit', 'Name'])['Number'].sum().reset_index() # CO2 Emissions co2 = {'Value': [df['CO2'].sum()]} co2 = pd.DataFrame(co2) co2.reset_index(inplace=True) co2['Variable'] = 'Carbon emissions' co2['Unit'] = 't_CO2' co2['Zone'] = 'Whole Region' df.loc[(df['Fuel'] == 'HRD') & (df['Technology'] == 'STUR'),'Variable'] = 'Energy|Electricity|Hard coal' df.loc[(df['Fuel'] == 'NUC') & (df['Technology'] == 'STUR'),'Variable'] = 'Energy|Electricity|Nuclear' df.loc[(df['Fuel'] == 'LIG') & (df['Technology'] == 'STUR'),'Variable'] = 'Energy|Electricity|Lignite' df.loc[(df['Fuel'] == 'OIL') & (df['Technology'] == 'STUR'),'Variable'] = 'Energy|Electricity|Oil' df.loc[(df['Fuel'] == 'BIO') & (df['Technology'] == 'STUR'),'Variable'] = 'Energy|Electricity|Bioenergy' df.loc[(df['Fuel'] == 'OTH') & (df['Technology'] == 'STUR'),'Variable'] = 'Energy|Electricity|Other nonrenewable' df.loc[(df['Fuel'] == 'GAS') & (df['Technology'] == 'GTUR'),'Variable'] = 'Energy|Electricity|Gas OCGT' df.loc[(df['Fuel'] == 'GAS') & (df['Technology'] == 'COMC'),'Variable'] = 'Energy|Electricity|Gas CCGT' df.loc[(df['Fuel'] == 'WST') & (df['Technology'] == 'STUR'),'Variable'] = 'Energy|Electricity|Other renewable' df.loc[(df['Fuel'] == 'WIN') & (df['Technology'] == 'WTON'),'Variable'] = 'Energy|Electricity|Wind Onshore' df.loc[(df['Fuel'] == 'WIN') & (df['Technology'] == 'WTOF'),'Variable'] = 'Energy|Electricity|Wind Offshore' df.loc[(df['Fuel'] == 'SUN') & (df['Technology'] == 'PHOT'),'Variable'] = 'Energy|Electricity|Solar PV' df.loc[(df['Fuel'] == 'WAT') & (df['Technology'] == 'HROR'),'Variable'] = 'Energy|Electricity|Hydro ROR' df.loc[(df['Fuel'] == 'WAT') & (df['Technology'] == 'HPHS'),'Variable'] = 'Energy|Electricity|Storage|Pumped hydro|Power' df.loc[(df['Fuel'] == 'WAT') & (df['Technology'] == 'HDAM'),'Variable'] = 'Energy|Electricity|Hydro Reservoir' df.loc[(df['Fuel'] == 'OTH') & (df['Technology'] == 'BATS'),'Variable'] = 'Energy|Electricity|Storage|Liion|Power' df['Value'] = df['Generation'] / 1e6 # Curtailment tmp_df = pd.DataFrame(results['OutputCurtailedPower'].sum() / 1e6) tmp_df.reset_index(inplace=True) tmp_df.rename(columns={'index':'Zone', 0:'Value'}, inplace=True) tmp_df['Variable'] = 'Energy|Electricity|Renewable curtailment|Absolute' df = df.append(tmp_df, ignore_index=True, sort = True) # Total generation df_total = df.groupby(['Variable'])['Value'].sum().reset_index() df_total.reset_index(inplace=True) df_total.rename(columns={'index': 'Zone'}, inplace=True) df_total['Zone'] = 'Whole Region' df = df.append(df_total, ignore_index=True, sort = True) # Shedding tmp_df = pd.DataFrame(results['OutputShedLoad'].sum() / 1e6) tmp_df.reset_index(inplace=True) tmp_df.rename(columns={'index':'Zone', 0:'Value'}, inplace=True) tmp_df['Variable'] = 'Energy|Electricity|Load Shedding' df = df.append(tmp_df, ignore_index=True, sort = True) df['Unit'] = 'TWh' df = df[['Zone','Variable','Unit','Value']] # Reserves # LL_2D lost_load_2D = pd.DataFrame(results['LostLoad_2D'].sum() / 1e6) lost_load_2D.reset_index(inplace=True) lost_load_2D.rename(columns={'index':'Zone', 0:'Value'}, inplace=True) lost_load_2D['Variable'] = 'Energy|Electricity|Lost Load 2D' lost_load_2D['Unit'] = 'TWh' df = df.append(lost_load_2D, ignore_index=True, sort = True) df = df[['Zone','Variable','Unit','Value']] # LL_2U lost_load_2U = pd.DataFrame(results['LostLoad_2U'].sum() / 1e6) lost_load_2U.reset_index(inplace=True) lost_load_2U.rename(columns={'index':'Zone', 0:'Value'}, inplace=True) lost_load_2U['Variable'] = 'Energy|Electricity|Lost Load 2U' lost_load_2U['Unit'] = 'TWh' df = df.append(lost_load_2U, ignore_index=True, sort = True) df = df[['Zone','Variable','Unit','Value']] # LL_3U lost_load_3U = pd.DataFrame(results['LostLoad_3U'].sum() / 1e6) lost_load_3U.reset_index(inplace=True) lost_load_3U.rename(columns={'index':'Zone', 0:'Value'}, inplace=True) lost_load_3U['Variable'] = 'Energy|Electricity|Lost Load 3U' lost_load_3U['Unit'] = 'TWh' df = df.append(lost_load_3U, ignore_index=True, sort = True) df = df[['Zone','Variable','Unit','Value']] # LL_Max_Power lost_load_max_power = pd.DataFrame(results['LostLoad_MaxPower'].sum() / 1e6) lost_load_max_power.reset_index(inplace=True) lost_load_max_power.rename(columns={'index':'Zone', 0:'Value'}, inplace=True) lost_load_max_power['Variable'] = 'Energy|Electricity|Lost Load Max Power' lost_load_max_power['Unit'] = 'TWh' df = df.append(lost_load_max_power, ignore_index=True, sort = True) df = df[['Zone','Variable','Unit','Value']] # LL_Min_Power lost_load_min_power = pd.DataFrame(results['LostLoad_MinPower'].sum() / 1e6) lost_load_min_power.reset_index(inplace=True) lost_load_min_power.rename(columns={'index':'Zone', 0:'Value'}, inplace=True) lost_load_min_power['Variable'] = 'Energy|Electricity|Lost Load Min Power' lost_load_min_power['Unit'] = 'TWh' df = df.append(lost_load_min_power, ignore_index=True, sort = True) df = df[['Zone','Variable','Unit','Value']] # LL_Ramp_Down lost_load_ramp_down = pd.DataFrame(results['LostLoad_RampDown'].sum() / 1e6) lost_load_ramp_down.reset_index(inplace=True) lost_load_ramp_down.rename(columns={'index':'Zone', 0:'Value'}, inplace=True) lost_load_ramp_down['Variable'] = 'Energy|Electricity|Lost Load Ramp Down' lost_load_ramp_down['Unit'] = 'TWh' df = df.append(lost_load_ramp_down, ignore_index=True, sort = True) df = df[['Zone','Variable','Unit','Value']] # LL_Ramp_Up lost_load_ramp_up = pd.DataFrame(results['LostLoad_RampUp'].sum() / 1e6) lost_load_ramp_up.reset_index(inplace=True) lost_load_ramp_up.rename(columns={'index':'Zone', 0:'Value'}, inplace=True) lost_load_ramp_up['Variable'] = 'Energy|Electricity|Lost Load Ramp Up' lost_load_ramp_up['Unit'] = 'TWh' df = df.append(lost_load_ramp_up, ignore_index=True, sort = True) df = df[['Zone','Variable','Unit','Value']] # LL_Total lost_load = pd.DataFrame([results['LostLoad_2D'].sum(),results['LostLoad_2U'].sum(), results['LostLoad_3U'].sum(),results['LostLoad_MaxPower'].sum(), results['LostLoad_MinPower'].sum(), results['LostLoad_RampDown'].sum(), results['LostLoad_RampUp'].sum()]) lost_load = lost_load / 1e6 lost_load = lost_load.sum(skipna=True) lost_load.reset_index(inplace=True) lost_load.rename(columns={'index':'Zone', 0:'Value'}, inplace=True) lost_load['Variable'] = 'Energy|Electricity|Lost Load Total' lost_load['Unit'] = 'TWh' df = df.append(lost_load, ignore_index=True, sort = True) df = df[['Zone','Variable','Unit','Value']] # CO2 df = df.append(co2_zone, ignore_index=True, sort = True) df = df[['Zone','Variable','Unit','Value']] df = df.append(co2, ignore_index=True, sort = True) df = df[['Zone','Variable','Unit','Value']] return df df_generation = generation_df(ppt,results,inputs) tmp_df = df_capacity.append(df_generation, ignore_index=True) # Get startups & costs def startups_df(df,results): df.loc[(df['Fuel'] == 'HRD') & (df['Technology'] == 'STUR'),'Variable'] = 'Startups|Electricity|Hard coal' df.loc[(df['Fuel'] == 'NUC') & (df['Technology'] == 'STUR'),'Variable'] = 'Startups|Electricity|Nuclear' df.loc[(df['Fuel'] == 'LIG') & (df['Technology'] == 'STUR'),'Variable'] = 'Startups|Electricity|Lignite' df.loc[(df['Fuel'] == 'OIL') & (df['Technology'] == 'STUR'),'Variable'] = 'Startups|Electricity|Oil' df.loc[(df['Fuel'] == 'BIO') & (df['Technology'] == 'STUR'),'Variable'] = 'Startups|Electricity|Bioenergy' df.loc[(df['Fuel'] == 'OTH') & (df['Technology'] == 'STUR'),'Variable'] = 'Startups|Electricity|Other nonrenewable' df.loc[(df['Fuel'] == 'GAS') & (df['Technology'] == 'GTUR'),'Variable'] = 'Startups|Electricity|Gas OCGT' df.loc[(df['Fuel'] == 'GAS') & (df['Technology'] == 'COMC'),'Variable'] = 'Startups|Electricity|Gas CCGT' df.loc[(df['Fuel'] == 'WST') & (df['Technology'] == 'STUR'),'Variable'] = 'Startups|Electricity|Other renewable' df.loc[(df['Fuel'] == 'WIN') & (df['Technology'] == 'WTON'),'Variable'] = 'Startups|Electricity|Wind Onshore' df.loc[(df['Fuel'] == 'WIN') & (df['Technology'] == 'WTOF'),'Variable'] = 'Startups|Electricity|Wind Offshore' df.loc[(df['Fuel'] == 'SUN') & (df['Technology'] == 'PHOT'),'Variable'] = 'Startups|Electricity|Solar PV' df.loc[(df['Fuel'] == 'WAT') & (df['Technology'] == 'HROR'),'Variable'] = 'Startups|Electricity|Hydro ROR' df.loc[(df['Fuel'] == 'WAT') & (df['Technology'] == 'HPHS'),'Variable'] = 'Startups|Electricity|Storage|Pumped hydro|Power' df.loc[(df['Fuel'] == 'WAT') & (df['Technology'] == 'HDAM'),'Variable'] = 'Startups|Electricity|Hydro Reservoir' df.loc[(df['Fuel'] == 'OTH') & (df['Technology'] == 'BATS'),'Variable'] = 'Startups|Electricity|Storage|Liion|Power' df['Value'] = df['startups'] df['Unit'] = '##' tmp_df = results['OutputSystemCost'].sum() tmp_df = {'Value': [results['OutputSystemCost'].sum()]} tmp_df = pd.DataFrame(tmp_df) tmp_df.reset_index(inplace=True) tmp_df['Variable'] = 'Cost|Total system' tmp_df['Zone'] = 'Whole Region' tmp_df['Unit'] = 'EUR' df = df.append(tmp_df, ignore_index=True, sort = True) df = df[['Zone','Variable','Unit','Value']] return df df_startups = startups_df(ppt,results) tmp_df = tmp_df.append(df_startups, ignore_index=True) # Get capacity factors and storage cycles def cap_factor_df(df,results): df.loc[(df['Fuel'] == 'HRD') & (df['Technology'] == 'STUR'),'Variable'] = 'Full load hours|Electricity|Hard coal' df.loc[(df['Fuel'] == 'NUC') & (df['Technology'] == 'STUR'),'Variable'] = 'Full load hours|Electricity|Nuclear' df.loc[(df['Fuel'] == 'LIG') & (df['Technology'] == 'STUR'),'Variable'] = 'Full load hours|Electricity|Lignite' df.loc[(df['Fuel'] == 'OIL') & (df['Technology'] == 'STUR'),'Variable'] = 'Full load hours|Electricity|Oil' df.loc[(df['Fuel'] == 'BIO') & (df['Technology'] == 'STUR'),'Variable'] = 'Full load hours|Electricity|Bioenergy' df.loc[(df['Fuel'] == 'OTH') & (df['Technology'] == 'STUR'),'Variable'] = 'Full load hours|Electricity|Other nonrenewable' df.loc[(df['Fuel'] == 'GAS') & (df['Technology'] == 'GTUR'),'Variable'] = 'Full load hours|Electricity|Gas OCGT' df.loc[(df['Fuel'] == 'GAS') & (df['Technology'] == 'COMC'),'Variable'] = 'Full load hours|Electricity|Gas CCGT' df.loc[(df['Fuel'] == 'WST') & (df['Technology'] == 'STUR'),'Variable'] = 'Full load hours|Electricity|Other renewable' df.loc[(df['Fuel'] == 'WIN') & (df['Technology'] == 'WTON'),'Variable'] = 'Full load hours|Electricity|Wind Onshore' df.loc[(df['Fuel'] == 'WIN') & (df['Technology'] == 'WTOF'),'Variable'] = 'Full load hours|Electricity|Wind Offshore' df.loc[(df['Fuel'] == 'SUN') & (df['Technology'] == 'PHOT'),'Variable'] = 'Full load hours|Electricity|Solar PV' df.loc[(df['Fuel'] == 'WAT') & (df['Technology'] == 'HROR'),'Variable'] = 'Full load hours|Electricity|Hydro ROR' df.loc[(df['Fuel'] == 'WAT') & (df['Technology'] == 'HPHS'),'Variable'] = 'Full load hours|Electricity|Storage|Pumped hydro|Power' df.loc[(df['Fuel'] == 'WAT') & (df['Technology'] == 'HDAM'),'Variable'] = 'Full load hours|Electricity|Hydro Reservoir' df.loc[(df['Fuel'] == 'OTH') & (df['Technology'] == 'BATS'),'Variable'] = 'Full load hours|Electricity|Storage|Liion|Power' df['Value'] = df['Generation']/df['Nunits']/df['PowerCapacity'] df['Unit'] = 'hours' tmp_stor_input = pd.DataFrame(results['OutputStorageInput'].sum()) isstorage = pd.Series(index=inputs['units'].index) for u in isstorage.index: isstorage[u] = inputs['units'].Technology[u] in commons['tech_storage'] sto_units = inputs['units'][isstorage] sto_units['Value'] = pd.DataFrame(tmp_stor_input[0]/sto_units['StorageCapacity']) sto_units.reset_index(inplace=True) sto_units.loc[(sto_units['Fuel'] == 'OTH') & (sto_units['Technology'] == 'BATS'),'Variable'] = \ 'Cycles|Electricity|Storage|Liion' sto_units.loc[(sto_units['Fuel'] == 'WAT') & (sto_units['Technology'] == 'HPHS'),'Variable'] = \ 'Cycles|Electricity|Storage|Pumped hydro' sto_units = sto_units.drop(sto_units.loc[(sto_units['Fuel'] == 'WAT') & (sto_units['Technology'] == 'HDAM')].index) sto_units['Unit'] = '##' df = df.append(sto_units, ignore_index=True, sort = True) sto_capacity = inputs['units'] sto_capacity.rename(columns={'StorageCapacity':'Value'}, inplace=True) sto_capacity.loc[(sto_capacity['Fuel'] == 'OTH') & (sto_capacity['Technology'] == 'BATS'),'Variable'] = \ 'Capacity|Electricity|Storage|Liion|Energy' sto_capacity.loc[(sto_capacity['Fuel'] == 'WAT') & (sto_capacity['Technology'] == 'HPHS'),'Variable'] = \ 'Capacity|Electricity|Storage|Pumped hydro|Energy' sto_capacity['Value'] = sto_capacity['Value'] / 1e3 sto_capacity['Unit'] = 'GWh' df1 = sto_capacity.loc[(sto_capacity['Fuel'] == 'OTH') & (sto_capacity['Technology'] == 'BATS')] df2 = sto_capacity.loc[(sto_capacity['Fuel'] == 'WAT') & (sto_capacity['Technology'] == 'HPHS')] sto_capacity = df1.append(df2, ignore_index=True, sort = True) df = df.append(sto_capacity, ignore_index=True, sort = True) # Reserves lost_load_2D = {'Value': [results['LostLoad_2D'].sum().sum() / 1e6]} lost_load_2D = pd.DataFrame(lost_load_2D) lost_load_2D.reset_index(inplace=True) lost_load_2D['Variable'] = 'Energy|Electricity|Lost Load 2D' lost_load_2D['Unit'] = 'TWh' lost_load_2D['Zone'] = 'Whole Region' df = df.append(lost_load_2D, ignore_index=True, sort = True) df = df[['Zone','Variable','Unit','Value']] lost_load_2U = {'Value': [results['LostLoad_2U'].sum().sum() / 1e6]} lost_load_2U = pd.DataFrame(lost_load_2U) lost_load_2U.reset_index(inplace=True) lost_load_2U['Variable'] = 'Energy|Electricity|Lost Load 2U' lost_load_2U['Unit'] = 'TWh' lost_load_2U['Zone'] = 'Whole Region' df = df.append(lost_load_2U, ignore_index=True, sort = True) df = df[['Zone','Variable','Unit','Value']] lost_load_3U = {'Value': [results['LostLoad_3U'].sum().sum() / 1e6]} lost_load_3U = pd.DataFrame(lost_load_3U) lost_load_3U.reset_index(inplace=True) lost_load_3U['Variable'] = 'Energy|Electricity|Lost Load 3U' lost_load_3U['Unit'] = 'TWh' lost_load_3U['Zone'] = 'Whole Region' df = df.append(lost_load_3U, ignore_index=True, sort = True) df = df[['Zone','Variable','Unit','Value']] lost_load_max_power = {'Value': [results['LostLoad_MaxPower'].sum().sum() / 1e6]} lost_load_max_power = pd.DataFrame(lost_load_max_power) lost_load_max_power.reset_index(inplace=True) lost_load_max_power['Variable'] = 'Energy|Electricity|Lost Load Max Power' lost_load_max_power['Unit'] = 'TWh' lost_load_max_power['Zone'] = 'Whole Region' df = df.append(lost_load_max_power, ignore_index=True, sort = True) df = df[['Zone','Variable','Unit','Value']] lost_load_min_power = {'Value': [results['LostLoad_MinPower'].sum().sum() / 1e6]} lost_load_min_power = pd.DataFrame(lost_load_min_power) lost_load_min_power.reset_index(inplace=True) lost_load_min_power['Variable'] = 'Energy|Electricity|Lost Load Min Power' lost_load_min_power['Unit'] = 'TWh' lost_load_min_power['Zone'] = 'Whole Region' df = df.append(lost_load_min_power, ignore_index=True, sort = True) df = df[['Zone','Variable','Unit','Value']] lost_load_ramp_down = {'Value': [results['LostLoad_RampDown'].sum().sum() / 1e6]} lost_load_ramp_down = pd.DataFrame(lost_load_ramp_down) lost_load_ramp_down.reset_index(inplace=True) lost_load_ramp_down['Variable'] = 'Energy|Electricity|Lost Load Ramp Down' lost_load_ramp_down['Unit'] = 'TWh' lost_load_ramp_down['Zone'] = 'Whole Region' df = df.append(lost_load_ramp_down, ignore_index=True, sort = True) df = df[['Zone','Variable','Unit','Value']] lost_load_ramp_up = {'Value': [results['LostLoad_RampUp'].sum().sum() / 1e6]} lost_load_ramp_up = pd.DataFrame(lost_load_ramp_up) lost_load_ramp_up.reset_index(inplace=True) lost_load_ramp_up['Variable'] = 'Energy|Electricity|Lost Load Ramp Up' lost_load_ramp_up['Unit'] = 'TWh' lost_load_ramp_up['Zone'] = 'Whole Region' df = df.append(lost_load_ramp_up, ignore_index=True, sort = True) df = df[['Zone','Variable','Unit','Value']] lost_load = {'Value': [(results['LostLoad_2D'].sum().sum() + results['LostLoad_2U'].sum().sum() + results['LostLoad_3U'].sum().sum() + results['LostLoad_MaxPower'].sum().sum() + results['LostLoad_MinPower'].sum().sum() + results['LostLoad_RampDown'].sum().sum() + results['LostLoad_RampUp'].sum().sum()) / 1e6]} lost_load = pd.DataFrame(lost_load) lost_load.reset_index(inplace=True) lost_load['Variable'] = 'Energy|Electricity|Lost Load Total' lost_load['Unit'] = 'TWh' lost_load['Zone'] = 'Whole Region' df = df.append(lost_load, ignore_index=True, sort = True) df = df[['Zone','Variable','Unit','Value']] shed_load = {'Value': [results['OutputShedLoad'].sum().sum() / 1e6]} shed_load = pd.DataFrame(shed_load) shed_load.reset_index(inplace=True) shed_load['Variable'] = 'Energy|Electricity|Load Shedding' shed_load['Unit'] = 'TWh' shed_load['Zone'] = 'Whole Region' df = df.append(shed_load, ignore_index=True, sort = True) df = df[['Zone','Variable','Unit','Value']] return df df_cap_factor = cap_factor_df(ppt,results) OSE_report = tmp_df.append(df_cap_factor, ignore_index=True) # Get additional info for each scenario OSE_report['Model'] = 'Dispa-SET (' + model + ')' OSE_report['Scenario'] = scenario + '|' + coverage OSE_report.rename(columns={'Zone':'Region'}, inplace=True) OSE_report['Unnamed: 6'] = np.nan OSE_report['1'] = scenario OSE_report['2'] = coverage OSE_report['3'] = np.nan OSE_report = OSE_report[['Model','Scenario','Region','Variable','Unit','Value','Unnamed: 6','1','2','3']] return OSE_report