1 Star 0 Fork 0

沈欣炜/Renewables_Scenario_Gen_GAN

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
load.py 2.36 KB
一键复制 编辑 原始数据 按行查看 历史
Yize Chen 提交于 2020-08-20 14:21 . Update load.py
import sys
from numpy import shape
import csv
sys.path.append('..')
import numpy as np
import os
#Load .csv renewables data into GANs model
#Currently use power generation historical data from NREL, which can be downloaded from NREL wind or solar integration datasets
#Historical data are loaded by column sequence and reshape into model input shape, which is adjustable
#Label is only useful for event-based scenario generation
def load_wind():
#Example dataset created for evnet_based GANs wind scenarios generation
# Data from NREL wind integrated datasets
with open('datasets/wind.csv', 'r') as csvfile:
reader = csv.reader(csvfile)
rows = [row for row in reader]
rows = np.array(rows, dtype=float)
trX = []
print(shape(rows))
m = np.ndarray.max(rows)
print("Maximum value of wind", m)
print(shape(rows))
for x in range(rows.shape[1]):
train = rows[:-288, x].reshape(-1, 576)
train = train / 16
# print(shape(train))
if trX == []:
trX = train
else:
trX = np.concatenate((trX, train), axis=0)
print("Shape TrX", shape(trX))
with open('datasets/wind label.csv', 'r') as csvfile:
reader = csv.reader(csvfile)
rows = [row for row in reader]
label = np.array(rows, dtype=int)
print("Label shape", shape(label))
return trX, label
def load_wind_data_spatial():
with open('datasets/spatial.csv', 'r') as csvfile:
reader = csv.reader(csvfile)
rows = [row for row in reader]
rows = np.array(rows, dtype=float)
m = np.ndarray.max(rows)
print("Maximum value of wind", m)
rows=rows/m
return rows
def load_solar_data():
with open('datasets/solar label.csv', 'r') as csvfile:
reader = csv.reader(csvfile)
rows = [row for row in reader]
labels = np.array(rows, dtype=int)
print(shape(labels))
with open('datasets/solar.csv', 'r') as csvfile:
reader = csv.reader(csvfile)
rows = [row for row in reader]
rows = np.array(rows, dtype=float)
rows=rows[:104832,:] #Change to the time points in your own dataset
print(shape(rows))
trX = np.reshape(rows.T,(-1,576)) #Corresponds to the GAN input dimensions.
print(shape(trX))
m = np.ndarray.max(rows)
print("maximum value of solar power", m)
trY=np.tile(labels,(32,1))
trX=trX/m
return trX,trY
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/Dr-shen-xinwei/Renewables_Scenario_Gen_GAN.git
git@gitee.com:Dr-shen-xinwei/Renewables_Scenario_Gen_GAN.git
Dr-shen-xinwei
Renewables_Scenario_Gen_GAN
Renewables_Scenario_Gen_GAN
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385