eelib.data.influx_reader.influx_reader_model

eElib Influx-reader models for reading-in from Influx database to imitate different model types. Specializations for certain model types like Household series.

Author: elenia@TUBS
Copyright 2024 elenia
This file is part of eELib, which is free software under the terms of the GNU GPL Version 3.

Module Contents

Classes

GenericInflux

Class for reading data from an influxdb.

RatedInflux

Influx-Data-Reader for profiles. Inherits from class GenericInflux.

PowerInflux

Influx-Data-Reader for power profiles. Inherits from class RatedInflux.

HouseholdInflux

Influx-Data-Reader for household load profiles. Inherits from class PowerInflux.

PvInflux

Influx-Data-Reader for pv load profiles. Inherits from class PowerInflux.

Attributes

_logger

_logger
class GenericInflux(ename: str, step_size: int, measurement_name: str, tags: dict[str, str], fields: list[str], start_time: str, end_time: str, influx_url: str | None = None, influx_token: str | None = None, influx_org: str | None = None, influx_bucket: str | None = None)

Class for reading data from an influxdb.

_VALID_PARAMETERS
classmethod get_valid_parameters()

Returns dictionary containing valid parameter types and values.

Returns:

valid parameters for this model

Return type:

dict

__del__()

Close the client after the reader’s job is done.

static generate_tag_filter(tags: dict[str, str] = None) str

Generates tag filters for Influx query.

Parameters:

tags (dict[str, str], optional) – Tags to generate filter.

Returns:

Tag selection part of Influx query.

Return type:

str

generate_influx_query(measurement_name: str, start_time: str, end_time: str, resolution: int, tags: dict[str, str] = None, fields: list[str] = None) str

Generates influx query based on given parameters.

Parameters:
  • measurement_name (str) – Name of the series.

  • start_time (str) – Start time of the series slice.

  • end_time (str) – End time of the series slice.

  • resolution (int) – Time resolution used for aggregation.

  • tags (dict[str, str], optional) – Tags wirth keys and values. Defaults to None.

  • fields (list[str], optional) – Fields of the series. Defaults to None.

Returns:

Influx query

Return type:

str

_read_db(measurement_name: str, tags: dict[str, str], fields: list[str], start_time: str, end_time: str, resolution: int)

Filters data in the database based on given parameters and returns the result as a dataframe.

Parameters:
  • measurement_name (str) – Name to filter _measurement

  • tags (dict[str, str]) – Tags to filter, e.g. “type”: “load”

  • fields (list[str]) – Fields to select

  • start_time (str) – Range start time

  • end_time (str) – Range end time

  • resolution (int) – time resolution to aggregate

Returns:

query result with DateTime index and one column for each field.

Return type:

pd.DataFrame

step(time)

Performs simulation step of eELib influx_reader model.

Parameters:

time (int) – Current simulation time

Raises:

IndexError – when end of data is reached before simulation end

class RatedInflux(ename: str, step_size: int, measurement_name: str, tags: dict[str, str], fields: list[str], start_time: str, end_time: str, p_rated: int = 4500, p_rated_profile: int = 4500, influx_url: str | None = None, influx_token: str | None = None, influx_org: str | None = None, influx_bucket: str | None = None)

Bases: GenericInflux

Influx-Data-Reader for profiles. Inherits from class GenericInflux. Adds support for scaling to p_rated.

classmethod get_valid_parameters()

Returns dictionary containing valid parameter types and values.

Returns:

valid parameters for this model

Return type:

dict

_apply_p_rated() None

Apply scaling factor (p_rated/p_rated_profile).

class PowerInflux(ename: str, step_size: int, measurement_name: str, tags: dict[str, str], fields: list[str], start_time: str, end_time: str, p_rated: int = 4500, p_rated_profile: int = 4500, cos_phi: float = 1.0, influx_url: str | None = None, influx_token: str | None = None, influx_org: str | None = None, influx_bucket: str | None = None)

Bases: RatedInflux

Influx-Data-Reader for power profiles. Inherits from class RatedInflux.

Adds support for calculating reactive power. Assumptions: - first field is p - second field is q, if more than one field is given

classmethod get_valid_parameters()

Returns dictionary containing valid parameter types and values.

Returns:

valid parameters for this model

Return type:

dict

_set_reactive_power() None

Calculate reactive power if not given as field of that series in influx and if cos_phi is set.

step(time)

Performs simulation step of eELib load model, which is returning the read active/reactive power value of the series read from Influx database.

Parameters:

time (int) – Current simulation time in seconds.

class HouseholdInflux(ename: str, step_size: int, measurement_name: str, fields: list[str], start_time: str, end_time: str, p_rated: int = 4500, p_rated_profile: int = 4500, cos_phi: float = 1, influx_url: str | None = None, influx_token: str | None = None, influx_org: str | None = None, influx_bucket: str | None = None)

Bases: PowerInflux

Influx-Data-Reader for household load profiles. Inherits from class PowerInflux. Data in Influx Database must have a tag with key value pair {‘type’: ‘load’}.

classmethod get_valid_parameters()

Returns dictionary containing valid parameter types and values.

Returns:

valid parameters for this model

Return type:

dict

class PvInflux(ename: str, step_size: int, measurement_name: str, fields: list[str], start_time: str, end_time: str, p_rated: int = 4500, p_rated_profile: int = 4500, cos_phi: float = 1, influx_url: str | None = None, influx_token: str | None = None, influx_org: str | None = None, influx_bucket: str | None = None)

Bases: PowerInflux

Influx-Data-Reader for pv load profiles. Inherits from class PowerInflux. Data in Influx Database must have a tag with key value pair {‘type’: ‘pv’}.

classmethod get_valid_parameters()

Returns dictionary containing valid parameter types and values.

Returns:

valid parameters for this model

Return type:

dict