:py:mod:`eelib.data.csv_reader.csv_reader_model` ================================================ .. py:module:: eelib.data.csv_reader.csv_reader_model .. autoapi-nested-parse:: eElib csv-reader model for reading-in .csv-files to imitate different model types (e.g. PV, household or heatpump). | 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.csv_reader.csv_reader_model.CSVReader eelib.data.csv_reader.csv_reader_model.GenericCSV eelib.data.csv_reader.csv_reader_model.ConventionalCSV eelib.data.csv_reader.csv_reader_model.PowerCSV eelib.data.csv_reader.csv_reader_model.RatedCSV eelib.data.csv_reader.csv_reader_model.RatedScalableCSV eelib.data.csv_reader.csv_reader_model.HouseholdCSV eelib.data.csv_reader.csv_reader_model.HouseholdWPuQCSV eelib.data.csv_reader.csv_reader_model.PvCSV eelib.data.csv_reader.csv_reader_model.HeatpumpCSV eelib.data.csv_reader.csv_reader_model.ChargingStationCSV eelib.data.csv_reader.csv_reader_model.HouseholdThermalCSV Attributes ~~~~~~~~~~ .. autoapisummary:: eelib.data.csv_reader.csv_reader_model._logger .. py:data:: _logger .. py:class:: CSVReader(eid: str, datafile: str, start_time: str, header_rows: int = 1, date_format: str = 'YYYY-MM-DD HH:mm:ss', delimiter: str = ',', step_size: int = 60 * 15) Parent class for reading-in .csv-files. .. py:property:: attrs :type: set Contains data attrs of this model derived from col names of ``self.data``. .. py:attribute:: VALID_PARAMETERS .. py:attribute:: eid .. py:attribute:: datafile :type: pathlib.Path .. py:attribute:: date_format :value: "'YYYY-MM-DD HH:mm:ss'" .. py:attribute:: start_date .. py:attribute:: delimiter :value: "','" .. py:attribute:: header_rows :value: '1' .. py:attribute:: step_size :value: '900' .. py:attribute:: timestep :value: 'None' .. py:attribute:: values :type: dict[str, object] .. py:attribute:: date :type: str .. 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:: _open_csv() -> None Opens the .csv-file and loads data set. :raises FileNotFoundError: when .csv-file cannot be read .. py:method:: _check_data() -> None Checks if row in opened .csv-file contains the simulation start date. :raises ValueError: Start date is not in .csv-file .. py:method:: _resample_data() -> None Resamples the data to the target resolution. .. py:method:: _apply_scaling(start: float, end: float, col: str | None = None) -> None Apply scaling factor (``end``/``start``). :param start: e.g. The rated power of original profile (``.csv`` file). :type start: float :param end: e.g. The rated power of profile exposed to eELib. :type end: float :param col: Name of the column to be scaled. Leave empty to scale all columns. :type col: str | None, optional .. py:method:: step(timestep: int) -> None Performs simulation step of eELib csv_reader model, which is returning the averaged read values in the .csv-file. :param timestep: (in s) Index of current simulation step. The length of a step is defined in ``self.step_size``. :type timestep: int .. py:class:: GenericCSV(datafile: str, start_time: str, header_rows: int = 1, date_format: str = 'YYYY-MM-DD HH:mm:ss', delimiter: str = ',', **kwargs) Bases: :py:obj:`CSVReader` CSV-Reader for profiles. Sets each column of the csv file as attribute. .. py:method:: step(timestep: int) -> None Performs simulation step of generic csv reader model, which is setting the attr according to the columns in ``.csv`` file. :param timestep: Index of current simulation step. The length of a step is defined in self.step_size (in s). :type timestep: int .. py:class:: ConventionalCSV(datafile: str, start_time: str, header_rows: int = 1, date_format: str = 'YYYY-MM-DD HH:mm:ss', delimiter: str = ',', **kwargs) Bases: :py:obj:`CSVReader` Base class for all CSVReaders that expect specific column content. E.g. a PowerCSV would expect "P in W" for it's simulation. This class would search for "P in" in every column name, retrieve that column and possibly convert, if the name was "P in kW". Only cols specified in ``symbols_and_units`` remain in ``self.data`` and an error is raised, if none is found. Known conversions are stored in ``self._conversions``. .. py:class:: SymbolUnit Represents an expected data series for this CSV-Reader via ``symbol`` and ``unit``. .. py:attribute:: symbol :type: str .. py:attribute:: unit :type: str .. py:attribute:: optional :type: bool :value: 'False' .. py:attribute:: SYMBOLS :type: list[ConventionalCSV.SymbolUnit] :value: '[]' .. py:attribute:: _conversions :type: dict .. py:method:: _apply_unit_conversion(col_name: str, target_unit: str) .. py:method:: _filter_expected_cols() -> None The input expected symbols and their units are used in simulation. This method retrieves them from ``self.data`` and retrieves no others. .. py:class:: PowerCSV(datafile: str, start_time: str, header_rows: int = 1, date_format: str = 'YYYY-MM-DD HH:mm:ss', delimiter: str = ',', cos_phi: float | None = None, **kwargs) Bases: :py:obj:`ConventionalCSV` CSV-Data-Reader parent for power profiles. Exposes the annual energy from active power as ``self.e_annual``. Your ``.csv`` is expected to contain a column with the name "P in W" or "P in kW", ... | There are options for *reactive power*: | 1. add a second column "Q in VAr" in the ``.csv``-file. | 2. or input a ``cos_phi`` to let this model calculate ``self.q`` from the active power. | - if representing thermal power, do neither 1. or 2. and the model will store ``self.q=0.0``. .. py:property:: e_annual Annual energy based on all values in "P" column in .csv. .. py:attribute:: VALID_PARAMETERS .. py:attribute:: SYMBOLS :type: list[ConventionalCSV] .. py:attribute:: p :type: float :value: '0.0' .. py:attribute:: q :type: float :value: '0.0' .. py:method:: _calc_reactive_power() -> None Calculate reactive power if not given in csv file and if cos_phi is set. .. py:method:: step(timestep: int) Performs simulation step of eELib load model, which is returning the read reactive power value of the ``.csv``-file. :param timestep: Current simulation time in seconds. :type timestep: int .. py:class:: RatedCSV(datafile: str, start_time: str, p_rated: float, header_rows: int = 1, date_format: str = 'YYYY-MM-DD HH:mm:ss', delimiter: str = ',', cos_phi: float | None = None, **kwargs) Bases: :py:obj:`PowerCSV` CSV-Reader for power profiles that can be associated with a rated power (PV, HP, Thermal Power, ... - not Households). Can NOT be scaled. Always represents the original ``.csv`` profile. .. py:attribute:: VALID_PARAMETERS .. py:attribute:: p_rated .. py:class:: RatedScalableCSV(datafile: str, start_time: str, p_rated: float, p_rated_sim: float | None = None, header_rows: int = 1, date_format: str = 'YYYY-MM-DD HH:mm:ss', delimiter: str = ',', cos_phi: float | None = None, **kwargs) Bases: :py:obj:`RatedCSV` Same as ``RatedCSV``, but ``p`` and ``q`` exposed to simulation may be scaled using ``p_rated_sim``/``p_rated``. .. py:attribute:: VALID_PARAMETERS .. py:class:: HouseholdCSV(datafile: str, start_time: str, header_rows: int = 1, date_format: str = 'YYYY-MM-DD HH:mm:ss', delimiter: str = ',', cos_phi: float | None = None, e_annual_sim: float | None = None, **kwargs) Bases: :py:obj:`PowerCSV` CSV-Data-Reader for household load profiles using individualy specified datafiles. Similar functionality as ``PowerCSV``, but marking Household load. In that, can (only) be scaled by annual load (in Wh). ``e_annual_sim`` defines the annual energy of the Household in simulation. If defined, the profile is scaled to fit the new ``e_annual``. If undefined, the original profile is used in Sim. .. py:attribute:: VALID_PARAMETERS .. py:class:: HouseholdWPuQCSV(eid: str, cos_phi: float | None = None, e_annual_sim: float | None = None, incl_hp: bool = False, **kwargs) Bases: :py:obj:`HouseholdCSV` CSV-Data-Reader for household load profiles in pre-defined format based on the WPuQ project. Similar functionality as ``HouseholdCSV``, meaing it can be scaled using ``e_annual_sim``, but additionally... Exposes active (``p``) and reactive power (``q``) for household loads, as profiles from the WPuQ project provide both. ``incl_hp`` defines whether to add the heatpump of the original WPuQ profile to ``p`` and ``q``. File path (``datafile`` is not a parameter, as the model **automatically** selects unique files from the ``wpuq`` folder. If all profiles from that folder are already placed in sim, the selection starts anew from the first profile and shifts start time by 7 days, avoding simultaneity of any profiles in sim. .. py:attribute:: VALID_PARAMETERS .. py:attribute:: SYMBOLS :type: list[ConventionalCSV] .. py:attribute:: incl_hp :type: bool :value: 'False' .. py:method:: _select_datafile(eid: str, incl_hp: bool) -> tuple[str, datetime.timedelta] :staticmethod: From the eid, expected to end with an ascending index, select a wpuq profile from the dir_list. Warn if reached end -> start from first profile shifted. .. py:method:: _first_date_in_profile(datafile: str | pathlib.Path) :staticmethod: .. py:class:: PvCSV(datafile: str, start_time: str, p_rated: float, p_rated_sim: float | None = None, header_rows: int = 1, date_format: str = 'YYYY-MM-DD HH:mm:ss', delimiter: str = ',', cos_phi: float | None = None, **kwargs) Bases: :py:obj:`RatedScalableCSV` CSV-Data-Reader marking pv-generation profiles. .. py:method:: step(timestep: int) Performs simulation step of eELib load model, which is returning the read active/reactive power value of the .csv-file. :param timestep: Index of current simulation step. The length of a step is defined in ``self.step_size`` (in s). :type timestep: int .. py:class:: HeatpumpCSV(datafile: str, start_time: str, p_rated: float, p_rated_sim: float | None = None, header_rows: int = 1, date_format: str = 'YYYY-MM-DD HH:mm:ss', delimiter: str = ',', cos_phi: float | None = None, **kwargs) Bases: :py:obj:`RatedScalableCSV` CSV-Data-Reader for heatpump load profiles. Expected input data is the **electrical** power. **No thermal** power is calculated and exposed. .. py:class:: ChargingStationCSV(datafile: str, start_time: str, p_rated: float, header_rows: int = 1, date_format: str = 'YYYY-MM-DD HH:mm:ss', delimiter: str = ',', cos_phi: float | None = None, **kwargs) Bases: :py:obj:`RatedCSV` CSV-Data-Reader marking charging station load profiles. .. py:class:: HouseholdThermalCSV(datafile: str, start_time: str, header_rows: int = 1, date_format: str = 'YYYY-MM-DD HH:mm:ss', delimiter: str = ',', e_th_annual_sim: float | None = None, **kwargs) Bases: :py:obj:`ConventionalCSV` CSV-Data-Reader for thermal demand profiles. Two columns are mandatory in the ``.csv``: | - "P_th_room in W" or "P_th_room in kW", ... | - "P_th_water in W" or "P_th_water in kW", ... Can be scaled by annual thermal energy (in Wh). ``e_th_annual`` defines the annual thermal energy in simulation. If defined, the profile is scaled to fit the new ``e_th_annual``. If undefined, the original profile is used in Sim. .. py:property:: e_th_annual Calculate the annual thermal energy from the sum of power values, scaling up/down to 1 year. NOTE: Expecting second column to be power in Watt at this point! .. py:attribute:: VALID_PARAMETERS .. py:attribute:: SYMBOLS :type: list[ConventionalCSV] .. py:attribute:: p_th_room :type: int | float :value: '0' .. py:attribute:: p_th_water :type: int | float :value: '0' .. py:method:: step(timestep: int) Performs simulation step of eELib charging_station model, which is returning the read active power value of the .csv-file. :param timestep: Index of current simulation step. The length of a step is defined in ``self.step_size`` (in s). :type timestep: int