pv forecaster added
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
from influxdb_client import InfluxDBClient, Point, WritePrecision
|
||||
from datetime import datetime
|
||||
import datetime as dt
|
||||
import pandas as pd
|
||||
|
||||
class DataBaseInflux:
|
||||
def __init__(self, url: str, token: str, org: str, bucket: str):
|
||||
@@ -25,4 +27,22 @@ class DataBaseInflux:
|
||||
# Punkt in InfluxDB schreiben
|
||||
self.write_api.write(bucket=self.bucket, org=self.org, record=point)
|
||||
|
||||
def store_forecasts(self, forecast_name: str, data: pd.Series):
|
||||
|
||||
measurement = forecast_name
|
||||
run_tag = dt.datetime.now(dt.timezone.utc).replace(second=0, microsecond=0).isoformat(timespec="minutes")
|
||||
|
||||
pts = []
|
||||
|
||||
series = pd.to_numeric(data, errors="coerce").dropna()
|
||||
|
||||
for ts, val in series.items():
|
||||
pts.append(
|
||||
Point(measurement)
|
||||
.tag("run", run_tag)
|
||||
.field("value", float(val))
|
||||
.time(ts.to_pydatetime(), WritePrecision.S)
|
||||
)
|
||||
|
||||
self.write_api.write(bucket=self.bucket, org=self.org, record=pts)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user