diff --git a/ArbitrageTool/Plots.py b/ArbitrageTool/Plots.py index a11b3b19a7e68f4a620e45f47defb7e0b49e7d7b..2dbddbff60d7ee70283609f4a02dd2df73f58db6 100644 --- a/ArbitrageTool/Plots.py +++ b/ArbitrageTool/Plots.py @@ -5,6 +5,7 @@ import numpy as np import matplotlib.pyplot as plt import matplotlib.dates as md from matplotlib.ticker import MaxNLocator +import matplotlib as mp @@ -54,22 +55,60 @@ def Barplotting_group(path): ax.set_ylabel('Energy in kWh') ax.set_title('Energy demand at 2019/6/1 0:00:00') ax.set_xticks(x, ['electricity', 'heat']) #matplotlib version >= 3.4 - ax.legend() + ax.legend(loc = 'upper left') ax.bar_label(rects1, labels=["elec_demand","therm_dmd"]) ax.bar_label(rects2, labels=["('grd', 'elec_cns')","('gas_boi', 'therm_cns')"]) fig.tight_layout() plt.show() -def Barplotting_sum(path): - df = pd.read_excel(path, index_col=0) #, header=0 - values = df.iloc[140] #pd.series - dmd1 = values['elec_demand'] - dmd2 = values['therm_demand'] - supel_1 = values["('grd', 'elec_cns')"] - supel_2 = values["('bhkw', 'elec_cns')"] - supth_1 = values["('bhkw', 'therm_cns')"] - supth_2 = values["('gas_boi', 'therm_cns')"] +def plots(): + X_axis = ["2021-01", "2021-07", "2021-09", "2021-12", "2022-01", "2022-05", "2022-07"] + y_val = [6969, 8851, 17411, 24097, 38194, 38212, 38250] + y_val2 = [13.62, 15.66, 12.92, 11.79, 13.34, 12.94, 15.31] + y_val3 = [15.33, 17.90, 15.13, 14.62, 15.05, 15.05, 17.56] + x = np.arange(len(X_axis)) + width = 0.3 + fig, ax = plt.subplots() + #ax.grid(True) + + f1 = ax.bar(x - width, y_val, width, color=[0.1686, 0.3098, 0.5059], label='Arbitrage profit') # + #f2 = ax.bar(x + width / 2, y_val2, width, color=[0.251, 0.498, 0.7176], label='Arbitrage profit')) + # f3 = ax.bar(x + width / 2, y_val2, width, color=[0.251, 0.498, 0.7176]) + ax2 = ax.twinx() + f2 = ax2.bar(x, y_val2, width, color=[0.251, 0.498, 0.7176], label='Electric price without investment') + f3 = ax2.bar(x + width, y_val3, width, color=[0.7804, 0.8667, 0.949], label='Electric price with investment')# + ax.set_ylabel('mothly arbitrage profit in €', fontsize = 14) + ax.yaxis.set_major_formatter(mp.ticker.StrMethodFormatter('{x:,.0f}')) + ax2.set_ylabel('Electric price in Cent/kWh ', fontsize = 14) + ax.set_title('Trend of Arbitrage profit and electric price', fontsize = 16) + ax.set_xticks(x,X_axis) + ax.legend(loc = 'upper left') + ax2.legend() #loc = (0.005, 0.85) + + ax.bar_label(f1, labels=y_val) #, padding=3 + ax2.bar_label(f2, labels=y_val2) + ax2.bar_label(f3, labels=y_val3) + fig.tight_layout() + plt.show() + +def Barplots(): + #X_axis = ['2019','2020','2021'] + #X_axis = ['10% - 90%','15% - 85%','20% - 80%'] + X_axis = ['1000kWh','5000kWh','10000kWh'] + y_values = [3724.576/1000, 18622.882/5000, 37245.765/10000] + + width = 0.5 + fig, ax = plt.subplots() + f1 = ax.bar(X_axis, y_values, width, color=['tab:blue','tab:blue', 'tab:orange', 'tab:orange']) + + ax.set_ylabel('annual arbitrage resulted cost in €/kWh') + ax.set_title('2021 Arbitrage results per kWh of LiionBatteryStack') + + ax.legend() + ax.bar_label(f1) #, padding=3 + plt.show() + def Barplotting0(path): df = pd.read_excel(path, index_col=0) # , header=0 @@ -91,59 +130,6 @@ def Barplotting0(path): ax.bar_label(f1) plt.show() -def Barplots():# path_lst - y = list() - # cycles=[] - # for i in range(len(path_lst)): - # df = pd.read_excel(path_lst[i], index_col=0) - # arb_cost = df["('arbitrage_cost', 'batterySta')"].iloc[-1] - # y.append(arb_cost) - #cyc = df["('cum_cycle', 'batterySta')"].iloc[-1] - #cycles.append(cyc) - #X_axis = ['2019','2020','2021'] - #X_axis = ['10% - 90%','15% - 85%','20% - 80%'] - #X_axis = ['1000kWh','5000kWh','10000kWh'] - X_axis = ["SCN1", "SCN2", "SCN3_10MW", "SCN3_15MW", "SCN_2030"] - y_val = [0.13879954, 0.13879954, 0.13755484, 0.13693249, 0.19911065] - y_val2 = [0.13879954, 0.13816321, 0.13691852, 0.13629624, 0.19848812]#y[0], y[1], y[2] - #y_values = [round(i, 3) for i in y_val] - #cyc_val = [cycles[0], cycles[1],cycles[2]] - #cyc_val = [round(i, 3) for i in cyc_val] - x = np.arange(len(X_axis)) - # rects1 = ax.bar(x - width/2, y1, width, label='demand') #(0-0.1) (1-0.1) - # rects2 = ax.bar(x + width/2, y2, width, label='supplier') - - width = 0.35 - fig, ax = plt.subplots() - f1 = ax.bar(x - width/2, y_val, width, color=['tab:blue','tab:red', 'tab:orange', 'tab:green', 'tab:brown']) # - f2 = ax.bar(x + width/2, y_val2, width, color=['tab:blue','tab:red', 'tab:orange', 'tab:green', 'tab:brown']) # - ax.legend() - #ax.grid(True) - ax.bar_label(f1) #, padding=3 - ax.bar_label(f2) - ##################grouped Barplots - # y1 = y_values - # y2 = cyc_val - # x = np.arange(len(X_axis)) ## the label locations - # width = 0.35 - # fig, ax = plt.subplots() - # # ax2 = ax.twinx() - # rects1 = ax.bar(x - width / 2, y1, width, label='arbitrage profits') # (0-0.1) (1-0.1) - # rects2 = ax.bar(x + width / 2, y2, width, label='cumulative cycles') # (0+0.1) (1+0.1) - # - # ax.set_xticks(x, X_axis) # matplotlib version >= 3.4 - # ax.legend() - # ax.bar_label(rects1, labels=y_values ) - # ax.bar_label(rects2, labels=cyc_val) - - #ax.set_ylabel('annual arbitrage profits in €/kWh') - ax.set_ylabel('Monthly Electric Gestehungskosten in (ohne fixed) €/kWh_el') #'montly arbitrage profits in €' - - #ax2.set_ylabel('cumulative cycles in 2021') - #ax.set_title('2021-07 Arbitrage profits per kWh of LiionBatteryStack') - ax.set_title('Comparation of electricity price in €/kWh') #Arbitrage profits of LiionBatteryStack in July 2021 - plt.show() - def plotting_BAS1(path): df = pd.read_excel(path, index_col=0) @@ -504,8 +490,8 @@ if __name__ == "__main__": # Subplots_3(path_lst, titles) - Barplots() - + #Barplots() + plots() #path = r'C:\Users\10947\sciebo\Scenarios_v3\Outputfiles\Jan\SCN2_SG_BAS1_BHKW\results_SCN2_SG_BAS1_BHKW.xlsx' # path = r'C:\Users\10947\sciebo\Scenarios_v3\Outputfiles\July\SCN2_SG_BAS1_BHKW_6_8\results_SCN2_SG_BAS1_BHKW_6_8.xlsx' #path = r'C:\Users\10947\sciebo\Scenarios_v3\Outputfiles\Jan\SCN3_SG_BAS1_BHKW_PV10MW\results_SCN3_SG_BAS1_BHKW_PV10MW.xlsx' diff --git a/ArbitrageTool/generate_signals_profile.py b/ArbitrageTool/generate_signals_profile.py index 2b5c3a82f20133a5db3686cb09d2604073bde8ec..232e8693aa92666d8bd3e04667e787c4a87be4ec 100644 --- a/ArbitrageTool/generate_signals_profile.py +++ b/ArbitrageTool/generate_signals_profile.py @@ -1,9 +1,8 @@ import pandas as pd import datetime -#import numpy as np +import numpy as np def extract_elec_price_profile(dstart, dend, t_step): - # year = 2021 # dstart = datetime.datetime(year,1,1,00,00,00) # dend = datetime.datetime(year,12,31,23,00,00) year = dstart.year @@ -35,35 +34,29 @@ def extract_elec_price_profile(dstart, dend, t_step): freq=str(t_step) + 'H') price_df = price_year_data - else: - # if year == 2020: - # pricedata_path = r'C:\Users\10947\sciebo\MA Mao\Preisdaten\Stromproduktion_und_Boersenstrompreise_in_Deutschland_2020.csv' - # elif year == 2021: - # pricedata_path = r'C:\Users\10947\sciebo\MA Mao\Preisdaten\Stromproduktion_und_Boersenstrompreise_in_Deutschland_2021.csv' - # elif year == 2030: - # pricedata_path = r'C:\Users\10947\sciebo\MA Mao\Preisdaten\predicted_Strompreise_in_Deutschland_2030.csv' - # - # raw_data = pd.read_csv(pricedata_path, usecols=['Time', 'Intraday Continuous Average Price']) - # if len(raw_data) == t_horizon: - # price_year_data = raw_data.iloc[:,1].astype(float) - # else: - # diff_len = int(t_horizon-len(raw_data)) - # price_year_data = raw_data.iloc[:diff_len, 1].astype(float) - # price_year_data.index = pd.date_range(dstart, periods=t_horizon, freq= str(t_step) +'H') - # price_year_data = pd.DataFrame(price_year_data) - # - # if len(price_year_data) != t_horizon: - # price_df = pd.DataFrame(index=pd.date_range(datetime.datetime(year, 1, 1, 00, 00, 00), periods=t_horizon, freq= str(t_step) +'H')) - # price_df['price'] = price_year_data.iloc[:,0] - # price_df = price_df.fillna(method='ffill') #Todo: fill with rational values - # else: - # price_df = price_year_data + elif year == 2022: #2021 pricedata_path = r'C:\Users\10947\sciebo\MA Mao\Preisdaten\epex_price_2022.csv' price_df = pd.read_csv(pricedata_path, index_col=0) - price_df.index = pd.date_range(dstart, periods=len(price_df), freq='15min') + price_df.index = pd.date_range(dstart, periods=len(price_df), freq='15min') # intraday price 2022 has 15 min resolution price_df = price_df.loc[dstart:dend] - price_df = price_df.resample(str(t_step) +'H').mean().interpolate('linear') + price_df = price_df.resample(str(t_step) + 'H').mean().interpolate('linear') + + else: + if year == 2020: + pricedata_path = r'C:\Users\10947\sciebo\MA Mao\Preisdaten\Stromproduktion_und_Boersenstrompreise_in_Deutschland_2020.csv' + elif year == 2021: + pricedata_path = r'C:\Users\10947\sciebo\MA Mao\Preisdaten\Stromproduktion_und_Boersenstrompreise_in_Deutschland_2021.csv' + elif year == 2030: + pricedata_path = r'C:\Users\10947\sciebo\MA Mao\Preisdaten\predicted_Strompreise_in_Deutschland_2030.csv' + + raw_data = pd.read_csv(pricedata_path, usecols=['Intraday Continuous Average Price']) # this data has resolution of 1h + price_year_data = raw_data.replace(to_replace='None', value=np.nan).dropna() + price_year_data.index = pd.date_range(datetime.datetime(year, 1, 1, 00, 00, 00), periods=len(price_year_data), freq='1h') + price_df = price_year_data.loc[dstart:dend] + price_df = price_df.astype(float) + price_df = price_df.resample(str(t_step) + 'H').mean().interpolate('linear') + return price_df @@ -119,4 +112,3 @@ def export_arbitrage_signals(dstart, dend, t_step): #if __name__ == "__main__": #df = export_arbitrage_signals() - #df.to_csv(r'C:\Users\10947\sciebo\MA Mao\Preisdaten_bearbeitet\Price_data_and_signals_2021.csv') \ No newline at end of file