Compare commits
3 Commits
cb0bd2c3e0
...
32e8e59c82
Author | SHA1 | Date | |
---|---|---|---|
|
32e8e59c82 | ||
|
c4ec4590c2 | ||
|
4364411485 |
56
draw.py
56
draw.py
@ -35,7 +35,6 @@ def draw_results(results, filename, title_benefit, annot_benefit=False, figure_s
|
||||
new_Data = pd.DataFrame(index=[df.index[-1] + 1], columns=df.columns)
|
||||
for i in df.columns:
|
||||
new_Data[i] = df[i].iloc[-1]
|
||||
# print(new_Data)
|
||||
df = pd.concat([df, new_Data])
|
||||
|
||||
X, Y = np.meshgrid(np.arange(df.shape[1]), np.arange(df.shape[0]))
|
||||
@ -68,7 +67,6 @@ def draw_cost(costs, filename, title_cost, annot_cost=False, figure_size=(10, 10
|
||||
new_Data = pd.DataFrame(index=[df.index[-1] + 1], columns=df.columns)
|
||||
for i in df.columns:
|
||||
new_Data[i] = df[i].iloc[-1]
|
||||
# print(new_Data)
|
||||
df = pd.concat([df, new_Data])
|
||||
X, Y = np.meshgrid(np.arange(df.shape[1]), np.arange(df.shape[0]))
|
||||
|
||||
@ -98,7 +96,6 @@ def draw_overload(overload_cnt, filename, title_unmet, annot_unmet=False, figure
|
||||
df.columns = df.columns.map(int)
|
||||
min_value = df.min().min()
|
||||
max_value = df.max().max()
|
||||
# max_scale = max(abs(min_value/1000), abs(max_value/1000))
|
||||
|
||||
|
||||
df[df.columns[-1] + 1] = df.iloc[:, -1]
|
||||
@ -132,6 +129,41 @@ def draw_overload(overload_cnt, filename, title_unmet, annot_unmet=False, figure
|
||||
plt.ylabel('PV Capacity (MW)')
|
||||
plt.savefig(filename)
|
||||
|
||||
with open('config.json', 'r') as f:
|
||||
js_data = json.load(f)
|
||||
|
||||
data = pd.read_csv('combined_data.csv')
|
||||
time_interval = js_data["time_interval"]["numerator"] / js_data["time_interval"]["denominator"]
|
||||
|
||||
pv_loss = js_data["pv"]["loss"]
|
||||
pv_cost_per_kW = js_data["pv"]["cost_per_kW"]
|
||||
pv_lifetime = js_data["pv"]["lifetime"]
|
||||
|
||||
ess_loss = js_data["ess"]["loss"]
|
||||
ess_cost_per_kW = js_data["ess"]["cost_per_kW"]
|
||||
ess_lifetime = js_data["ess"]["lifetime"]
|
||||
|
||||
grid_loss = js_data["grid"]["loss"]
|
||||
sell_price = js_data["grid"]["sell_price"]
|
||||
grid_capacity = js_data["grid"]["capacity"]
|
||||
|
||||
pv_begin = js_data["pv_capacities"]["begin"]
|
||||
pv_end = js_data["pv_capacities"]["end"]
|
||||
pv_groups = js_data["pv_capacities"]["groups"]
|
||||
|
||||
ess_begin = js_data["ess_capacities"]["begin"]
|
||||
ess_end = js_data["ess_capacities"]["end"]
|
||||
ess_groups = js_data["ess_capacities"]["groups"]
|
||||
|
||||
annot_unmet = js_data["annotated"]["unmet_prob"]
|
||||
annot_benefit = js_data["annotated"]["benefit"]
|
||||
annot_cost = js_data["annotated"]["cost"]
|
||||
|
||||
title_unmet = js_data["plot_title"]["unmet_prob"]
|
||||
title_cost = js_data["plot_title"]["cost"]
|
||||
title_benefit = js_data["plot_title"]["benefit"]
|
||||
|
||||
figure_size = (js_data["figure_size"]["length"], js_data["figure_size"]["height"])
|
||||
|
||||
directory = 'data/'
|
||||
|
||||
@ -143,9 +175,9 @@ split_files = [f.split('-') for f in file_list]
|
||||
costs_files = [f for f in split_files if f[-1].endswith('costs.json')]
|
||||
print(f'find costs files: {costs_files}')
|
||||
overload_files = [f for f in split_files if f[-1].endswith('overload_cnt.json')]
|
||||
print(f'find overload files: {overload_files}')
|
||||
print(f'find coverage/unmet files: {overload_files}')
|
||||
results_files = [f for f in split_files if f[-1].endswith('results.json')]
|
||||
print(f'find results files: {results_files}')
|
||||
print(f'find profit/benefit files: {results_files}')
|
||||
|
||||
costs_dfs = [read_data(directory + '-'.join(f)) for f in costs_files]
|
||||
overload_dfs = [read_data(directory + '-'.join(f)) for f in overload_files]
|
||||
@ -154,17 +186,19 @@ results_dfs = [read_data(directory + '-'.join(f)) for f in results_files]
|
||||
for costs_df, overload_df, results_df in zip(costs_dfs, overload_dfs, results_dfs):
|
||||
|
||||
draw_cost(costs_df,
|
||||
f'plots/costs-{int(costs_df.columns[-1])}-pv-{int(costs_df.index[-1])}.png',
|
||||
f'Costs for ESS-{int(costs_df.columns[-1])}-pv-{int(costs_df.index[-1])}MWh', annot_cost=False)
|
||||
f'plots/costs-ess-{int(costs_df.columns[0])}-{int(costs_df.columns[-1])}-pv-{int(costs_df.index[0])}-{int(costs_df.index[-1])}.png',
|
||||
title_cost=title_cost,
|
||||
annot_cost=annot_cost)
|
||||
|
||||
draw_overload(overload_df,
|
||||
f'plots/overload-ess-{overload_df.columns[-1]}-pv-{overload_df.index[-1]}.png',
|
||||
f'Overload for ess-{overload_df.columns[-1]}MW pv-{overload_df.index[-1]}MWh',
|
||||
f'plots/overload-ess-{overload_df.columns[0]}-{overload_df.columns[-1]}-pv-{overload_df.index[0]}-{overload_df.index[-1]}.png',
|
||||
title_unmet=title_unmet,
|
||||
annot_unmet=False)
|
||||
|
||||
draw_results(results_df,
|
||||
f'plots/results-{results_df.columns[-1]}-pv-{results_df.index[-1]}.png',
|
||||
f'Results for ess-{results_df.columns[-1]}MW pv-{results_df.index[-1]}MWh', annot_benefit=False)
|
||||
f'plots/results-ess-{results_df.columns[0]}-{results_df.columns[-1]}-pv-{results_df.index[0]}-{results_df.index[-1]}.png',
|
||||
title_benefit=title_benefit,
|
||||
annot_benefit=False)
|
||||
|
||||
|
||||
|
||||
|
2
main.py
2
main.py
@ -111,7 +111,7 @@ def cal_profit(es: EnergySystem, saved_money):
|
||||
for ess_capacity in ess_capacities:
|
||||
print(f"ess_capacity:{ess_capacity}")
|
||||
for pv_capacity in pv_capacities:
|
||||
print(f"pv_capacity:{ess_capacity}")
|
||||
print(f"pv_capacity:{pv_capacity}")
|
||||
pv = pv_config(capacity=pv_capacity,
|
||||
cost_per_kW=pv_cost_per_kW,
|
||||
lifetime=pv_lifetime,
|
||||
|
22
read_data.py
22
read_data.py
@ -4,6 +4,7 @@ import csv
|
||||
|
||||
sunlight_file_name = 'lightintensity.xlsx'
|
||||
factory_demand_file_name = 'factory_power1.xlsx'
|
||||
electricity_price_data = 'electricity_price_data.csv'
|
||||
|
||||
df_sunlight = pd.read_excel(sunlight_file_name, header=None, names=['SunlightIntensity'])
|
||||
|
||||
@ -25,20 +26,31 @@ print(df_power.head())
|
||||
|
||||
df_combined = df_sunlight_resampled.join(df_power)
|
||||
|
||||
|
||||
df_combined.to_csv('combined_data.csv', index=True, index_label='Time')
|
||||
|
||||
price_data = np.random.uniform(0.3, 0.3, len(times))
|
||||
def read_csv(file_path):
|
||||
return pd.read_csv(file_path, index_col='Time', usecols=['Time', 'ElectricityPrice'])
|
||||
|
||||
# price_data = np.random.uniform(0.3, 0.3, len(times))
|
||||
|
||||
# 创建DataFrame
|
||||
price_df = pd.DataFrame(data={'Time': times, 'ElectricityPrice': price_data})
|
||||
price_df = read_csv(electricity_price_data)
|
||||
price_df.index = pd.to_datetime(price_df.index)
|
||||
price_df = price_df.reindex(df_combined.index)
|
||||
|
||||
price_df.set_index('Time', inplace=True)
|
||||
# price_df.set_index('Time', inplace=True)
|
||||
|
||||
# 保存到CSV文件
|
||||
price_df.to_csv('electricity_price_data.csv', index=True)
|
||||
print(price_df.head())
|
||||
# price_df.to_csv('electricity_price_data.csv', index=True)
|
||||
print("price____")
|
||||
print(price_df.index)
|
||||
print("df_combined____")
|
||||
print(df_combined.index)
|
||||
|
||||
print("Electricity price data generated and saved.")
|
||||
|
||||
|
||||
df_combined2 = df_combined.join(price_df)
|
||||
print(df_combined2.head())
|
||||
# 保存结果
|
||||
|
Loading…
Reference in New Issue
Block a user