:py:mod:`eelib.data.influx_reader.influx_reader_model` ====================================================== .. py:module:: eelib.data.influx_reader.influx_reader_model .. autoapi-nested-parse:: eElib Influx-reader models for reading-in from Influx database to imitate different model types. Specializations for certain model types like Household series. Before using these models in a simulation, you have to set the credentials for your influx database. Those need to be set in an ``.env`` file. Have a look at the ``dummy.env`` of this repository for further instructions and the influx fields that need to be given. | 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 ~~~~~~~ .. autoapisummary:: eelib.data.influx_reader.influx_reader_model.GenericInflux eelib.data.influx_reader.influx_reader_model.RatedInflux eelib.data.influx_reader.influx_reader_model.PowerInflux eelib.data.influx_reader.influx_reader_model.HouseholdInflux eelib.data.influx_reader.influx_reader_model.PvInflux Attributes ~~~~~~~~~~ .. autoapisummary:: eelib.data.influx_reader.influx_reader_model._logger .. py:data:: _logger .. py:class:: GenericInflux(eid: 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. .. py:attribute:: _VALID_PARAMETERS .. py:attribute:: influx_url .. py:attribute:: influx_token .. py:attribute:: influx_org .. py:attribute:: influx_bucket .. py:attribute:: client .. py:attribute:: eid .. py:attribute:: measurement_name .. py:attribute:: tags .. py:attribute:: fields .. py:attribute:: start_time .. py:attribute:: end_time .. py:attribute:: step_size .. py:attribute:: attrs .. py:attribute:: timestep :value: 'None' .. py:attribute:: index :value: '0' .. py:attribute:: data .. py:method:: get_valid_parameters() -> dict :classmethod: Returns dictionary containing valid parameter types and values. :returns: valid parameters for this model :rtype: dict .. py:method:: __del__() Close the client after the reader's job is done. .. py:method:: generate_tag_filter(tags: dict[str, str] = None) -> str :staticmethod: Generates tag filters for Influx query. :param tags: Tags to generate filter. :type tags: dict[str, str], optional :returns: Tag selection part of Influx query. :rtype: str .. py:method:: 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. :param measurement_name: Name of the series. :type measurement_name: str :param start_time: Start time of the series slice. :type start_time: str :param end_time: End time of the series slice. :type end_time: str :param resolution: Time resolution used for aggregation. :type resolution: int :param tags: Tags wirth keys and values. Defaults to None. :type tags: dict[str, str], optional :param fields: Fields of the series. Defaults to None. :type fields: list[str], optional :returns: Influx query :rtype: str .. py:method:: _read_db(measurement_name: str, tags: dict[str, str], fields: list[str], start_time: str, end_time: str, resolution: int) -> pandas.DataFrame Filters data in the database based on given parameters and returns the result as a dataframe. :param measurement_name: Name to filter _measurement :type measurement_name: str :param tags: Tags to filter, e.g. "type": "load" :type tags: dict[str, str] :param fields: Fields to select :type fields: list[str] :param start_time: Range start time :type start_time: str :param end_time: Range end time :type end_time: str :param resolution: time resolution to aggregate :type resolution: int :returns: query result with DateTime index and one column for each field. :rtype: pd.DataFrame .. py:method:: step(timestep: int) Performs simulation step of eELib influx_reader model. :param timestep: Current simulation time :type timestep: int :raises IndexError: when end of data is reached before simulation end .. py:class:: RatedInflux(eid: 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: :py:obj:`GenericInflux` Influx-Data-Reader for profiles. Inherits from class GenericInflux. Adds support for scaling to p_rated. .. py:attribute:: p_rated :value: '4500' .. py:attribute:: p_rated_profile :value: '4500' .. py:attribute:: scaling_factor .. py:method:: get_valid_parameters() -> dict :classmethod: Returns dictionary containing valid parameter types and values. :returns: valid parameters for this model :rtype: dict .. py:method:: _apply_p_rated() -> None Apply scaling factor (``p_rated``/``p_rated_profile``). .. py:class:: PowerInflux(eid: 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: :py:obj:`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 .. py:attribute:: p :value: 'None' .. py:attribute:: q :value: 'None' .. py:attribute:: cos_phi :value: '1.0' .. py:method:: get_valid_parameters() -> dict :classmethod: Returns dictionary containing valid parameter types and values. :returns: valid parameters for this model :rtype: dict .. py:method:: _set_reactive_power() -> None Calculate reactive power if not given as field of that series in influx and if cos_phi is set. .. py:method:: step(timestep: int) Performs simulation step of eELib load model, which is returning the read active/reactive power value of the series read from Influx database. :param timestep: Current simulation time in seconds. :type timestep: int .. py:class:: HouseholdInflux(eid: 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: :py:obj:`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'}. .. py:method:: get_valid_parameters() -> dict :classmethod: Returns dictionary containing valid parameter types and values. :returns: valid parameters for this model :rtype: dict .. py:class:: PvInflux(eid: 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: :py:obj:`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'}. .. py:method:: get_valid_parameters() -> dict :classmethod: Returns dictionary containing valid parameter types and values. :returns: valid parameters for this model :rtype: dict