一.代码流程(运行效果:
短期光伏发电量短期预测(Python代码,基于SARIMA(季节性自回归移动平均模型)和Prophet工具结合预测未来发电量)_哔哩哔哩_bilibili
模型流程:
导入所需的库,包括NumPy、Pandas、Matplotlib、Seaborn等,并设置Seaborn的图表样式为'darkgrid'。
读取两个数据集,分别为"Plant_1_Generation_Data.csv"和"Plant_1_Weather_Sensor_Data.csv",然后对数据进行处理,包括删除不需要的列和格式化日期时间。
创建两个图表的子图,一个包含每日产量图和AC & DC功率图,另一个包含每日产量和总产量的图。
对实际DC功率进行计算,计算每天DC功率转换成AC功率的损失百分比。
绘制所有源的DC功率图。
分析DC功率和时间的关系,绘制前11个源和后11个源的DC功率图。
分析温度数据,绘制模块温度和环境温度的图表。
选取最差的一个源,绘制该源的DC功率和每日产量图。
使用SARIMA(季节性自回归移动平均模型)和Prophet(Facebook开发的时间序列预测工具)进行时间序列预测。
绘制预测结果与原始数据的对比图,并计算预测性能指标,包括R²分数、平均绝对误差(MAE)和均方根误差(RMSE)。
二.数据集(68779条数据)
这些数据是在印度的两个太阳能发电厂收集的,时间跨度为34天。每对文件包含一个电力发电数据集和一个传感器读数数据集。电力发电数据集是在逆变器级别收集的,每个逆变器都连接着多行太阳能电池板。传感器数据是在发电厂级别收集的,是单个传感器阵列在发电厂中的最佳放置。
DATE_TIME
: 表示日期和时间的时间戳,记录数据采集的具体时间点。PLANT_ID
: 发电厂的唯一标识符,用于区分不同的太阳能发电厂。SOURCE_KEY
: 太阳能发电设备的唯一标识符,用于区分不同的发电设备。DC_POWER
: 直流功率的测量值,表示从太阳能电池板产生的直流电功率。AC_POWER
: 交流功率的测量值,表示从逆变器转换后的交流电功率。DAILY_YIELD
: 每天的发电量,表示在给定日期内生成的总电量。TOTAL_YIELD
: 总发电量,表示从安装以来生成的总电量。这些列提供了关于太阳能发电厂的重要信息,包括发电设备的功率输出、每天的发电量以及总发电量。通过这些数据,可以进行发电量的分析、设备性能的评估以及故障检测等任务。
开始时间
DATE_TIME | PLANT_ID | SOURCE_KEY | DC_POWER | AC_POWER | DAILY_YIELD | TOTAL_YIELD |
15-05-2020 00:00 | 4135001 | 1BY6WEcLGh8j5v7 | 0 | 0 | 0 | 6259559 |
15-05-2020 00:00 | 4135001 | 1IF53ai7Xc0U56Y | 0 | 0 | 0 | 6183645 |
15-05-2020 00:00 | 4135001 | 3PZuoBAID5Wc2HD | 0 | 0 | 0 | 6987759 |
15-05-2020 00:00 | 4135001 | 7JYdWkrLSPkdwr4 | 0 | 0 | 0 | 7602960 |
15-05-2020 00:00 | 4135001 | McdE0feGgRqW7Ca | 0 | 0 | 0 | 7158964 |
15-05-2020 00:00 | 4135001 | VHMLBKoKgIrUVDU | 0 | 0 | 0 | 7206408 |
15-05-2020 00:00 | 4135001 | WRmjgnKYAwPKWDb | 0 | 0 | 0 | 7028673 |
15-05-2020 00:00 | 4135001 | ZnxXDlPa8U1GXgE | 0 | 0 | 0 | 6522172 |
15-05-2020 00:00 | 4135001 | ZoEaEvLYb1n2sOq | 0 | 0 | 0 | 7098099 |
15-05-2020 00:00 | 4135001 | adLQvlD726eNBSB | 0 | 0 | 0 | 6271355 |
15-05-2020 00:00 | 4135001 | bvBOhCH3iADSZry | 0 | 0 | 0 | 6316803 |
15-05-2020 00:00 | 4135001 | iCRJl6heRkivqQ3 | 0 | 0 | 0 | 7177992 |
15-05-2020 00:00 | 4135001 | ih0vzX44oOqAx2f | 0 | 0 | 0 | 6185184 |
15-05-2020 00:00 | 4135001 | pkci93gMrogZuBj | 0 | 0 | 0 | 7169102 |
15-05-2020 00:00 | 4135001 | rGa61gmuvPhdLxV | 0 | 0 | 0 | 7111493 |
15-05-2020 00:00 | 4135001 | sjndEbLyjtCKgGv | 0 | 0 | 0 | 7016832 |
15-05-2020 00:00 | 4135001 | uHbuxQJl8lW7ozc | 0 | 0 | 0 | 7038681 |
15-05-2020 00:00 | 4135001 | wCURE6d3bPkepu2 | 0 | 0 | 0 | 6782598 |
15-05-2020 00:00 | 4135001 | z9Y9gH1T5YWrNuG | 0 | 0 | 0 | 7007866 |
15-05-2020 00:00 | 4135001 | zBIq5rxdHJRwDNY | 0 | 0 | 0 | 6339380 |
15-05-2020 00:00 | 4135001 | zVJPv84UY57bAof | 0 | 0 | 0 | 7116151 |
15-05-2020 00:15 | 4135001 | 1BY6WEcLGh8j5v7 | 0 | 0 | 0 | 6259559 |
15-05-2020 00:15 | 4135001 | 1IF53ai7Xc0U56Y | 0 | 0 | 0 | 6183645 |
15-05-2020 00:15 | 4135001 | 3PZuoBAID5Wc2HD | 0 | 0 | 0 | 6987759 |
15-05-2020 00:15 | 4135001 | 7JYdWkrLSPkdwr4 | 0 | 0 | 0 | 7602960 |
15-05-2020 00:15 | 4135001 | McdE0feGgRqW7Ca | 0 | 0 | 0 | 7158964 |
15-05-2020 00:15 | 4135001 | VHMLBKoKgIrUVDU | 0 | 0 | 0 | 7206408 |
15-05-2020 00:15 | 4135001 | WRmjgnKYAwPKWDb | 0 | 0 | 0 | 7028673 |
15-05-2020 00:15 | 4135001 | ZnxXDlPa8U1GXgE | 0 | 0 | 0 | 6522172 |
中期时间段数据展示
20-05-2020 06:45 | 4135001 | uHbuxQJl8lW7ozc | 947.875 | 92.0875 | 40.25 | 7071238.25 |
20-05-2020 06:45 | 4135001 | wCURE6d3bPkepu2 | 944.25 | 91.725 | 41.25 | 6815390.25 |
20-05-2020 06:45 | 4135001 | z9Y9gH1T5YWrNuG | 953.875 | 92.6625 | 40.375 | 7040505.375 |
20-05-2020 06:45 | 4135001 | zBIq5rxdHJRwDNY | 936.75 | 91 | 39.625 | 6372010.625 |
20-05-2020 06:45 | 4135001 | zVJPv84UY57bAof | 933.625 | 90.675 | 40.125 | 7148377.125 |
20-05-2020 07:00 | 4135001 | 1BY6WEcLGh8j5v7 | 1564.714286 | 152.9571429 | 68 | 6290165 |
20-05-2020 07:00 | 4135001 | 1IF53ai7Xc0U56Y | 1790.375 | 175.2375 | 76.625 | 6216506.625 |
20-05-2020 07:00 | 4135001 | 3PZuoBAID5Wc2HD | 1728.714286 | 169.1571429 | 73.71428571 | 7020585.714 |
20-05-2020 07:00 | 4135001 | 7JYdWkrLSPkdwr4 | 1690.571429 | 165.4285714 | 74.85714286 | 7635282.857 |
20-05-2020 07:00 | 4135001 | McdE0feGgRqW7Ca | 1628.714286 | 159.2571429 | 71.42857143 | 7192169.429 |
20-05-2020 07:00 | 4135001 | VHMLBKoKgIrUVDU | 1727.428571 | 169.0428571 | 76.57142857 | 7239618.571 |
20-05-2020 07:00 | 4135001 | WRmjgnKYAwPKWDb | 1700 | 166.3571429 | 72.57142857 | 7061004.571 |
20-05-2020 07:00 | 4135001 | YxYtjZvoooNbGkE | 1593.857143 | 155.7857143 | 70 | 7212546 |
20-05-2020 07:00 | 4135001 | ZnxXDlPa8U1GXgE | 1638.428571 | 160.1857143 | 59.57142857 | 6555195.571 |
20-05-2020 07:00 | 4135001 | ZoEaEvLYb1n2sOq | 1567 | 153.1857143 | 69.57142857 | 7130401.571 |
20-05-2020 07:00 | 4135001 | adLQvlD726eNBSB | 1818.125 | 178 | 79.125 | 6304592.125 |
20-05-2020 07:00 | 4135001 | bvBOhCH3iADSZry | 1535.714286 | 150 | 66.85714286 | 6346973.857 |
20-05-2020 07:00 | 4135001 | iCRJl6heRkivqQ3 | 1568.857143 | 153.2857143 | 69.85714286 | 7210787.857 |
20-05-2020 07:00 | 4135001 | ih0vzX44oOqAx2f | 1584.142857 | 154.8571429 | 69 | 6217346 |
20-05-2020 07:00 | 4135001 | pkci93gMrogZuBj | 1550.571429 | 151.5 | 68.57142857 | 7201417.571 |
20-05-2020 07:00 | 4135001 | rGa61gmuvPhdLxV | 1542 | 150.6714286 | 68.57142857 | 7143880.571 |
20-05-2020 07:00 | 4135001 | sjndEbLyjtCKgGv | 1587.714286 | 155.2428571 | 69.57142857 | 7049353.571 |
20-05-2020 07:00 | 4135001 | uHbuxQJl8lW7ozc | 1588.571429 | 155.3 | 69.71428571 | 7071267.714 |
20-05-2020 07:00 | 4135001 | wCURE6d3bPkepu2 | 1578.571429 | 154.3 | 70 | 6815419 |
截止时间的数据展示
17-06-2020 23:30 | 4135001 | wCURE6d3bPkepu2 | 0 | 0 | 5883 | 7028601 |
17-06-2020 23:30 | 4135001 | z9Y9gH1T5YWrNuG | 0 | 0 | 5819 | 7251204 |
17-06-2020 23:30 | 4135001 | zBIq5rxdHJRwDNY | 0 | 0 | 5817 | 6583369 |
17-06-2020 23:30 | 4135001 | zVJPv84UY57bAof | 0 | 0 | 5910 | 7363272 |
17-06-2020 23:45 | 4135001 | 1BY6WEcLGh8j5v7 | 0 | 0 | 5521 | 6485319 |
17-06-2020 23:45 | 4135001 | 1IF53ai7Xc0U56Y | 0 | 0 | 6034 | 6433566 |
17-06-2020 23:45 | 4135001 | 3PZuoBAID5Wc2HD | 0 | 0 | 6052 | 7237425 |
17-06-2020 23:45 | 4135001 | 7JYdWkrLSPkdwr4 | 0 | 0 | 5856 | 7846821 |
17-06-2020 23:45 | 4135001 | McdE0feGgRqW7Ca | 0 | 0 | 5992 | 7408587 |
17-06-2020 23:45 | 4135001 | VHMLBKoKgIrUVDU | 0 | 0 | 6007 | 7456208 |
17-06-2020 23:45 | 4135001 | WRmjgnKYAwPKWDb | 0 | 0 | 5953 | 7273532 |
17-06-2020 23:45 | 4135001 | YxYtjZvoooNbGkE | 0 | 0 | 5886 | 7425442 |
17-06-2020 23:45 | 4135001 | ZnxXDlPa8U1GXgE | 0 | 0 | 5929 | 6770737 |
17-06-2020 23:45 | 4135001 | ZoEaEvLYb1n2sOq | 0 | 0 | 5871 | 7341753 |
17-06-2020 23:45 | 4135001 | adLQvlD726eNBSB | 0 | 0 | 5237.142857 | 6524508 |
17-06-2020 23:45 | 4135001 | bvBOhCH3iADSZry | 0 | 0 | 5460 | 6539009 |
17-06-2020 23:45 | 4135001 | iCRJl6heRkivqQ3 | 0 | 0 | 5957 | 7426263 |
17-06-2020 23:45 | 4135001 | ih0vzX44oOqAx2f | 0 | 0 | 5758 | 6426129 |
17-06-2020 23:45 | 4135001 | pkci93gMrogZuBj | 0 | 0 | 5952 | 7415430 |
17-06-2020 23:45 | 4135001 | rGa61gmuvPhdLxV | 0 | 0 | 5950 | 7356897 |
17-06-2020 23:45 | 4135001 | sjndEbLyjtCKgGv | 0 | 0 | 5887 | 7261681 |
17-06-2020 23:45 | 4135001 | uHbuxQJl8lW7ozc | 0 | 0 | 5967 | 7287002 |
17-06-2020 23:45 | 4135001 | wCURE6d3bPkepu2 | 0 | 0 | 5147.625 | 7028601 |
17-06-2020 23:45 | 4135001 | z9Y9gH1T5YWrNuG | 0 | 0 | 5819 | 7251204 |
17-06-2020 23:45 | 4135001 | zBIq5rxdHJRwDNY | 0 | 0 | 5817 | 6583369 |
17-06-2020 23:45 | 4135001 | zVJPv84UY57bAof | 0 | 0 | 5910 | 7363272 |
三.效果图
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style('darkgrid')
import warnings
import datetime as dt
import matplotlib.dates as mdates
#代码和数据的压缩包:https://mbd.pub/o/bread/mbd-ZJ6Zm5du
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style('darkgrid')
import warnings
import datetime as dt
import matplotlib.dates as mdates