From 210a2f9bc37dd5b089b5ae799b0d6ad7fc3c08b4 Mon Sep 17 00:00:00 2001 From: Patrick Hangl Date: Tue, 7 Jan 2025 16:02:19 +0100 Subject: [PATCH] Einlesen .csv angepasst --- neighborhood.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/neighborhood.py b/neighborhood.py index ad33ee2..f10a8e4 100644 --- a/neighborhood.py +++ b/neighborhood.py @@ -1,7 +1,9 @@ +# https://stackoverflow.com/questions/63511090/how-can-i-smooth-data-in-python import numpy as np import matplotlib.pyplot as plt import pv_input as pv import pandas as pd +from scipy.signal import savgol_filter @@ -43,10 +45,10 @@ class Consumer: self.consumption_profile = self.create_consumption_profile() self.final_consumption = self.calculate_final_consumption() - # Vebrauchsprofil aus CSV-Datei in Dataframe einlesen und die Leistungs-Series extrahieren, Werte in Watt umrechnen und mit 4 multiplizieren, da Originalwerte 15-minütlich waren + # Vebrauchsprofil aus CSV-Datei in Dataframe einlesen und die Leistungs-Series extrahieren, Werte in Watt umrechnen def create_consumption_profile(self): - consumption_profile = pd.read_csv('Lastprofil_final_H0.csv',delimiter=';') - return consumption_profile['Leistung']*1000*4 + consumption_profile = pd.read_csv('Lastprofile_gesamt.csv',delimiter=';') + return consumption_profile['Leistung']*1000 # Verbrauchsprofil mit der Anzahl der Haushalte multiplizieren def calculate_final_consumption(self): @@ -63,11 +65,10 @@ class Neighborhood: # Gesamterzeugung, Gesamtverbrauch und Nettoverbrauch plotten def plot_consumption(self): total_consumption = -1*(self.consumer.final_consumption + self.producer.final_consumption) - total_consumption_mean = total_consumption.rolling(168).mean() total_production = self.producer.final_production - total_production_mean = total_production.rolling(168).mean() net_value = total_consumption + total_production net_value_mean = net_value.rolling(168).mean() + net_value_filtered = net_value.apply(savgol_filter, window_length=168, polyorder=2) # X-Werte anlegen, einen Wert löschen da 8761 Werte vorhanden sind, aber nur 8760 benötigt werden x = pd.date_range(start='2018-12-31', end ='2019-12-31', freq='1h')