From 70f4b654acbd570fa7264f59c81fe8fc7938d76c Mon Sep 17 00:00:00 2001 From: zhled14 <¨hgmholk@gmail.com¨> Date: Wed, 29 Nov 2023 13:30:58 -0600 Subject: [PATCH] Actualizacion1 --- Environmental.py | 241 +++++++++++++++++++++++++++++++++++++++++++++++ README.md | 73 ++++++++++++++ 2 files changed, 314 insertions(+) create mode 100644 Environmental.py create mode 100644 README.md diff --git a/Environmental.py b/Environmental.py new file mode 100644 index 0000000..67bd2a3 --- /dev/null +++ b/Environmental.py @@ -0,0 +1,241 @@ +import matplotlib.pyplot as plt +from matplotlib.font_manager import FontProperties +import pandas as pd + +# Importing data + +med = pd.read_csv('med.csv') +med_discri = pd.read_csv('med_discri.csv') +data_plot= pd.read_csv('data_plot.csv') + +############## FILTERING DATA ############## + +# 24 Hrs light intensity +luxes = med.iloc[0:288,0] + +#Plotting Luxes data +plt.plot(luxes,'.k') +plt.xlabel('Sample Number') +plt.ylabel('[Lx]', rotation=90) +plt.show() + +# The data filtering function depending on the time. B and e sets upper and lower limits. +def FilteringData(b,e): + filtered_med = med[(med['hh'] >= b ) & (med['hh'] <= e)] + #Saving luxes, temp, hum and power data + luxesf = filtered_med.iloc[:,0].tolist() + tempf = filtered_med.iloc[:,1].tolist() + humf = filtered_med.iloc[:,2].tolist() + powf = filtered_med.iloc[:,5].tolist() + + return luxesf, tempf, humf, powf + +############## PLOTTING DATA FUNCTION ############## +#Inputs: Luxes, Temperature, Humidity and Power +#Output: Vs graph 4x4 + +def GenGraph(luxesf, tempf, humf, powf): + # Generates a figure of size 4x4 + figure, axis = plt.subplots(4,4, figsize=(8,6)) + # Defines limits for plotting luxes, temperature, humidity and power + luxlim=(2055,48000) + templim=(13,50) + humlim=(12,88) + powlim=(0.68,11.61) + #Text fontsize + fontsize=16 + Tfont = FontProperties(family='serif', style='normal',size=fontsize) + #Tiles fontsize, family font + font = FontProperties(family='serif',style='italic',size=fontsize) + #Positon for subplots titles + Tx=1.15 + Ty=0.36 + + #Plotting luxes vs temp, hum, pow: (0,0)-(0,3) + #Positions the Lux title at thge coordinates (0,0) + axis[0,0].text(0.5,0.5,'Lux', verticalalignment='center', horizontalalignment='center',font = Tfont) + # Clears the frame and spines + for spine in axis[0,0].spines.values(): + spine.set_visible(False) + + axis[0,1].scatter(luxesf,tempf, s=5, c='none', marker='.', facecolors='none', edgecolors='black', alpha=1) + axis[0,1].set(xlim=luxlim,ylim=templim) + axis[0,1].set_title('a)',y=Ty, x=Tx) + + axis[0,2].scatter(luxesf,humf, s=5, c='none', marker='.', facecolors='none', edgecolors='black', alpha=1) + axis[0,2].set(xlim=luxlim,ylim=humlim) + axis[0,2].set_title('b)',y=Ty, x=Tx) + + axis[0,3].scatter(luxesf,powf, s=5, c='none', marker='.', facecolors='none', edgecolors='black', alpha=1) + axis[0,3].set(xlim=luxlim,ylim=powlim) + axis[0,3].set_title('c)',y=Ty, x=Tx) + + #Plotting temp vs luxes, hum and pow: (1,0)-(1,3) + axis[1,0].scatter(tempf,luxesf, s=5, c='none', marker='o', facecolors='none', edgecolors='black', alpha=0.3) + axis[1,0].set_title('d)',y=Ty, x=Tx) + axis[1,0].set(xlim=templim,ylim=luxlim) + axis[1,0].set_ylim(luxlim) + + #Positions the Temp title at thge coordinates (1,1) + axis[1,1].text(0.5,0.5,'Temp', fontsize=fontsize, verticalalignment='center', horizontalalignment='center', font = Tfont) + #Clears the frame and spines + for spine in axis[1,1].spines.values(): + spine.set_visible(False) + + axis[1,2].scatter(tempf,humf, s=5, c='none', marker='.', facecolors='none', edgecolors='black', alpha=1) + axis[1,2].set_title('e)',y=Ty, x=Tx) + axis[1,2].set(xlim=templim,ylim=humlim) + + axis[1,3].scatter(tempf,powf, s=5, c='none', marker='.', facecolors='none', edgecolors='black', alpha=1) + axis[1,3].set_title('f)',y=Ty, x=Tx) + axis[1,3].set(xlim=templim,ylim=powlim) + + #Plotting hum vs luxes, temp and pow: (2,0)-(2,3) + axis[2,0].scatter(humf,luxesf, s=5, c='none', marker='o', facecolors='none', edgecolors='black', alpha=0.3) + axis[2,0].set_title('g)',y=Ty, x=Tx) + axis[2,0].set(xlim=humlim,ylim=luxlim) + + axis[2,1].scatter(humf,tempf, s=5, c='none', marker='o', facecolors='none', edgecolors='black', alpha=0.3) + axis[2,1].set_title('h)',y=Ty, x=Tx) + axis[2,1].set(xlim=humlim,ylim=templim) + + #Positions the Hum title at thge coordinates (2,2) + axis[2,2].text(0.5,0.5,'Hum', fontsize=fontsize, verticalalignment='center', horizontalalignment='center', font = Tfont) + #Clears the frame and spines + for spine in axis[2,2].spines.values(): + spine.set_visible(False) + + axis[2,3].scatter(humf,powf, s=5, c='none', marker='.', facecolors='none', edgecolors='black', alpha=1) + axis[2,3].set_title('i)',y=Ty, x=Tx) + axis[2,3].set(xlim=humlim,ylim=powlim) + + #Plottign power vs luxes, temp and hum: (3,0)-(3,3) + axis[3,0].scatter(powf,luxesf, s=5, c='none', marker='o', facecolors='none', edgecolors='black', alpha=0.3) + axis[3,0].set_title('j)',y=Ty, x=Tx) + axis[3,0].set(xlim=powlim,ylim=luxlim) + + axis[3,1].scatter(powf,tempf, s=5, c='none', marker='o', facecolors='none', edgecolors='black', alpha=0.3) + axis[3,1].set_title('k)',y=Ty, x=Tx) + axis[3,1].set(xlim=powlim,ylim=templim) + + axis[3,2].scatter(powf,humf, s=5, c='none', marker='o', facecolors='none', edgecolors='black', alpha=0.3) + axis[3,2].set_title('l)',y=Ty, x=Tx) + axis[3,2].set(xlim=powlim,ylim=humlim) + + #Positions the Hum title at thge coordinates (2,2) + axis[3,3].text(0.5,0.5,'Pow', fontsize=fontsize, verticalalignment='center', horizontalalignment='center', font = Tfont) + #Clears the frame and spines + for spine in axis[3,3].spines.values(): + spine.set_visible(False) + + #Clears all graphic's spines and ticks label + for ax in axis.flat: + ax.set_xticklabels([]) + ax.set_xticks([]) + ax.set_yticklabels([]) + ax.set_yticks([]) + for text in [ax.title]: + text.set_font_properties(font) + + #Defines width space and height space + plt.subplots_adjust(wspace=0.4,hspace=0.06) + plt.savefig("Graph.png") + plt.show() + +############## PLOTTING TEMPERATUR BAR FUNCTION ############## +# Inputs: x data, y data, x limits (xmin,xmax), y limits (ymin,ymax), x title, y title, temperature +# Output: Vs Graph with Temperature bar + +import numpy as np +def GenGraphTemp(x,y,xlim,ylim,xtitle,ytitle,temp): + + fig, ax = plt.subplots(figsize=(7,6)) + scatter = ax.scatter(x,y, c=temp, cmap='gray', s=50, edgecolors='none', linewidths=1.5, vmin=0, vmax=70) + ax.set(xlim=xlim,ylim=ylim, xlabel=xtitle, ylabel=ytitle) + ax.grid(True, linestyle='--', linewidth=0.5,alpha=0.7) + ax.tick_params(axis='both', direction='in',length=5,width=1, top=True, right=True) + ColorBar = fig.colorbar(scatter,ax=ax,label='Temp[°C]') + plt.savefig(f"{xtitle} vs {ytitle}",".png") + plt.show() + +############## PLOTTING DATA IN 4X4 ############## + +# Own filtered data +luxesf, tempf, humf, powf = FilteringData(9,19) +GenGraph(luxesf,tempf,humf,powf) + +# Data_plot data base + +luxesplt = data_plot.iloc[:,0].tolist() +tempplt = data_plot.iloc[:,1].tolist() +humplt = data_plot.iloc[:,2].tolist() +powplt = data_plot.iloc[:,3].tolist() +GenGraph(luxesplt,tempplt,humplt,powplt) + +# med data base + +luxesm = med.iloc[:,0].tolist() +tempm = med.iloc[:,1].tolist() +humm = med.iloc[:,2].tolist() +powm = med.iloc[:,5].tolist() +GenGraph(luxesm,tempm,humm,powm) + +# med_discri data base + +luxesdi = med_discri.iloc[:,0].tolist() +tempdi = med_discri.iloc[:,1].tolist() +humdi = med_discri.iloc[:,2].tolist() +powdi = med_discri.iloc[:,5].tolist() +GenGraph(luxesdi,tempdi,humdi,powdi) + +############## PLOTTING DATA USING TEMPERATURE BAR ############## + +# Luxes vs Power +xlim=(2055,51000) +ylim=(1,12) +# Own filtered data +GenGraphTemp(luxesf,powf,xlim,ylim,'Luxes[lx]',"PV's Power[W]",tempf) +# Data_plot data base +GenGraphTemp(luxesplt,powplt,xlim,ylim,'Luxes[lx]',"PV's Power[W]",tempplt) +# med data base +GenGraphTemp(luxesm,powm,xlim,ylim,'Luxes[lx]',"PV's Power[W]",tempm) +# med_discri data base +GenGraphTemp(luxesdi,powdi,xlim,ylim,'Luxes[lx]',"PV's Power[W]",tempdi) + +# Humidity vs Power +xlim2=(15,100) +# Own filtered data +GenGraphTemp(humf,powf,xlim2,ylim,'Luxes[lx]',"PV's Power[W]",tempf) +# Data_plot data base +GenGraphTemp(humplt,powplt,xlim2,ylim,'Luxes[lx]',"PV's Power[W]",tempplt) +# med data base +GenGraphTemp(humm,powm,xlim,ylim2,'Luxes[lx]',"PV's Power[W]",tempm) +# med_discri data base +GenGraphTemp(humdi,powdi,xlim2,ylim,'Luxes[lx]',"PV's Power[W]",tempdi) + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..94f3b46 --- /dev/null +++ b/README.md @@ -0,0 +1,73 @@ +# Description + +This public repository contains datasets, preprocessing scripts, and supplementary materials associated with the article titled "Predictive Modeling of Photovoltaic Panel Power Production through On-Site Environmental and Electrical Measurements Using Artificial Neural Networks." The datasets provide insights into the performance of PV panels under various conditions and are crucial for the development of predictive models. + +This `readme.md` file provides step-by-step guidance on how to use the provided data and scripts. Researchers and developers can use this data to replicate the study, develop their predictive models, or conduct further analyses. + + +# Contents + +1. **Raw Data Files**: + - `med.csv`: Power production data of the PV panel over 15 days that includes lighting, temperature, and humidity environmental measurements logged every 5 minutes. +2. **Preprocessed Data**: + - `med_discri.csv`: Power production data of the PV panel over 15 days **without night measurements** that includes lighting, temperature, and humidity environmental measurements logged every 5 minutes. + - `data_plots.csv`: Data of 1000 instances for plotting, correlation, and modeling process; instances used in the published paper. + +3. **Scripts and Notebooks**: + - Will be included soon. + +## Files structure +The structure of each `csv` file is similar and is shown below: + +``` +luxes, temp, hum, curr, volt, power, dd,hh,mm +3133.44,18,79,0.07,14.69,1.09,28,15,17 +5765.12,18,76,0.14,14.73,1.98,28,15,12 +5575.68,18,77,0.13,14.73,1.93,28,15,7 +5506.56,18,77,0.13,14.72,1.93,28,15,2 +5931.52,19,74,0.14,14.73,2.01,28,14,57 +5565.44,18,75,0.13,14.72,1.92,28,14,52 +6051.84,18,80,0.14,14.73,2.11,28,14,47 +3304.96,17,78,0.08,14.69,1.18,28,14,42 +2769.92,18,77,0.07,14.69,0.99,28,14,37 +5309.44,19,76,0.12,14.73,1.82,28,14,32 +8555.52,19,75,0.2,14.77,2.97,28,14,27 +``` + +The columns are arranged as follows: +- `luxes`: lighting measurements in luxes [lx] obtained in the same PV's angle. +- `temp`: temperature measurements in degrees Celsius [C] at the PV's structure. +- `hum`: relative humidity in [%RH] at the PV's structure. +- `curre`: current measurements in Amperes [A] measured at the PV's electrical output. +- `volt`: voltage measurements in volts [V] measured at the PV's electrical output. +- power: computed electrical power in Watts [S] obtained by multiplying the voltage and current measured. +- `dd`: two-digit format for day-of-month identification. +- `hh`: two-digit format for hour of day identification. +- `mm`: two-digit format for minutes of day identification. + +**More detail about the collected data can be consulted in the published paper.** + +![](./iot.png) + +**Citation:** Users of this dataset are required to cite the associated article and provide appropriate acknowledgment. **included info soon** + +## Environmental.py +The code of this file is divide in follow sections + +1. **Filtering data Function** + Takes all data from the raw data file (`med.csv`), between b and e. It returns the filtered data for lux, temperature, humidity and power. +2. **Plotting data function** + Takes values from lux, temperature, humidity and power, and builds a figure of size 4x4. The structure of these graphs is shown below: + + ``` + Lux [Lux vs Temp] [Lux vs Hum ] [Lux vs Pow ] + [Temp vs Lux] Temp [Temp vs Hum] [Temp vs Pow] + [Hum vs Lux ] [Hum vs Temp] Hum [Hum vs Pow ] + [Pow vs Lux ] [Pow vs Temp] [Pow vs Hum ] Pow + ``` +3. **Plotting Temperature Bar Function** + Generates a scatter plot with temperature bars. The input data includes coordinates for the x and y axes, limits for the x and y axes, titles for the x and y axes, and the temperature associated with each point. + +4. **Plotting data** + First, the information from all databases is divided into lux, temperature, humidity, and power. Then, the `GenGraph` function, defined in the Plotting data function section, and the `GenGraphTemp` function, defined in the Plotting Temperature Bar Function section, are used. +