update generate data code
This commit is contained in:
parent
33871fba77
commit
ad9b5e6a19
42933
combined_data.csv
42933
combined_data.csv
File diff suppressed because it is too large
Load Diff
20
read_data.py
20
read_data.py
@ -2,20 +2,15 @@ import pandas as pd
|
||||
import numpy as np
|
||||
import csv
|
||||
|
||||
sunlight_file_name = 'lightintensity.xlsx'
|
||||
pv_yield_file_name = 'read_data/Riyahd.csv'
|
||||
factory_demand_file_name = 'factory_power1.xlsx'
|
||||
electricity_price_data = 'electricity_price_data.csv'
|
||||
electricity_price_data_sell = 'electricity_price_data_sell.csv'
|
||||
|
||||
df_sunlight = pd.read_excel(sunlight_file_name, header=None, names=['SunlightIntensity'])
|
||||
|
||||
start_date = '2023-01-01 00:00:00' # 根据数据的实际开始日期调整
|
||||
hours = pd.date_range(start=start_date, periods=len(df_sunlight), freq='h')
|
||||
df_sunlight['Time'] = hours
|
||||
df_sunlight.set_index('Time', inplace=True)
|
||||
|
||||
df_sunlight_resampled = df_sunlight.resample('15min').interpolate()
|
||||
pv_df = pd.read_csv(pv_yield_file_name, index_col='Time', usecols=['Time', 'PV yield[kW/kWp]'])
|
||||
pv_df.index = pd.to_datetime(pv_df.index)
|
||||
|
||||
start_date = '2023-01-01'
|
||||
df_power = pd.read_excel(factory_demand_file_name,
|
||||
header=None,
|
||||
names=['FactoryPower'],
|
||||
@ -25,7 +20,7 @@ df_power['Time'] = times
|
||||
df_power.set_index('Time',inplace=True)
|
||||
print(df_power.head())
|
||||
|
||||
df_combined = df_sunlight_resampled.join(df_power)
|
||||
df_combined = pv_df.join(df_power)
|
||||
|
||||
|
||||
|
||||
@ -44,14 +39,13 @@ df_combined3 = df_combined2.join(sell_df)
|
||||
|
||||
with open('combined_data.csv', 'w', newline='') as file:
|
||||
writer = csv.writer(file)
|
||||
writer.writerow(['time', 'sunlight', 'demand','buy', 'sell'])
|
||||
writer.writerow(['time', 'PV yield[kW/kWp]', 'demand','buy', 'sell'])
|
||||
cnt = 0
|
||||
for index, row in df_combined3.iterrows():
|
||||
time_formatted = index.strftime('%H:%M')
|
||||
writer.writerow([time_formatted, row['SunlightIntensity'], row['FactoryPower'],row['ElectricityBuy'], row['ElectricitySell']])
|
||||
writer.writerow([time_formatted, row['PV yield[kW/kWp]'], row['FactoryPower'],row['ElectricityBuy'], row['ElectricitySell']])
|
||||
|
||||
print('The file is written to combined_data.csv')
|
||||
|
||||
# combined_data.to_csv('updated_simulation_with_prices.csv', index=False)
|
||||
|
||||
print("Simulation data with electricity prices has been updated and saved.")
|
Loading…
Reference in New Issue
Block a user