eelib.data.csv_reader.csv_reader_model
eElib csv-reader model for reading-in .csv-files to imitate different model types (e.g. PV, household or heatpump).
Module Contents
Classes
Parent class for reading-in .csv-files. |
|
CSV-Reader for profiles. Sets each column of the csv file as attribute. |
|
Base class for all CSVReaders that expect specific column content. |
|
CSV-Data-Reader parent for power profiles. |
|
CSV-Reader for power profiles that can be associated with a rated power |
|
Same as |
|
CSV-Data-Reader for household load profiles using individualy specified datafiles. |
|
CSV-Data-Reader for household load profiles in pre-defined format based on the WPuQ project. |
|
CSV-Data-Reader marking pv-generation profiles. |
|
CSV-Data-Reader for heatpump load profiles. |
|
CSV-Data-Reader marking charging station load profiles. |
|
CSV-Data-Reader for thermal demand profiles. |
Attributes
- _logger
- 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.
- property attrs: set
Contains data attrs of this model derived from col names of
self.data.
- VALID_PARAMETERS
- eid
- datafile: pathlib.Path
- date_format = "'YYYY-MM-DD HH:mm:ss'"
- start_date
- delimiter = "','"
- header_rows = '1'
- step_size = '900'
- timestep = 'None'
- values: dict[str, object]
- date: str
- classmethod get_valid_parameters() dict
Returns dictionary containing valid parameter types and values.
- Returns:
valid parameters for this model
- Return type:
dict
- _open_csv() None
Opens the .csv-file and loads data set.
- Raises:
FileNotFoundError – when .csv-file cannot be read
- _check_data() None
Checks if row in opened .csv-file contains the simulation start date.
- Raises:
ValueError – Start date is not in .csv-file
- _resample_data() None
Resamples the data to the target resolution.
- _apply_scaling(start: float, end: float, col: str | None = None) None
Apply scaling factor (
end/start).- Parameters:
start (float) – e.g. The rated power of original profile (
.csvfile).end (float) – e.g. The rated power of profile exposed to eELib.
col (str | None, optional) – Name of the column to be scaled. Leave empty to scale all columns.
- step(timestep: int) None
Performs simulation step of eELib csv_reader model, which is returning the averaged read values in the .csv-file.
- Parameters:
timestep (int) – (in s) Index of current simulation step. The length of a step is defined in
self.step_size.
- class GenericCSV(datafile: str, start_time: str, header_rows: int = 1, date_format: str = 'YYYY-MM-DD HH:mm:ss', delimiter: str = ',', **kwargs)
Bases:
CSVReaderCSV-Reader for profiles. Sets each column of the csv file as attribute.
- step(timestep: int) None
Performs simulation step of generic csv reader model, which is setting the attr according to the columns in
.csvfile.- Parameters:
timestep (int) – Index of current simulation step. The length of a step is defined in self.step_size (in s).
- class ConventionalCSV(datafile: str, start_time: str, header_rows: int = 1, date_format: str = 'YYYY-MM-DD HH:mm:ss', delimiter: str = ',', **kwargs)
Bases:
CSVReaderBase 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_unitsremain inself.dataand an error is raised, if none is found. Known conversions are stored inself._conversions.- class SymbolUnit
Represents an expected data series for this CSV-Reader via
symbolandunit.- symbol: str
- unit: str
- optional: bool = 'False'
- SYMBOLS: list[ConventionalCSV.SymbolUnit] = '[]'
- _conversions: dict
- _apply_unit_conversion(col_name: str, target_unit: str)
- _filter_expected_cols() None
The input expected symbols and their units are used in simulation. This method retrieves them from
self.dataand retrieves no others.
- 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:
ConventionalCSVCSV-Data-Reader parent for power profiles.
Exposes the annual energy from active power as
self.e_annual.Your
.csvis 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 acos_phito let this model calculateself.qfrom the active power.- if representing thermal power, do neither 1. or 2. and the model will storeself.q=0.0.- property e_annual
Annual energy based on all values in “P” column in .csv.
- VALID_PARAMETERS
- SYMBOLS: list[ConventionalCSV]
- p: float = '0.0'
- q: float = '0.0'
- _calc_reactive_power() None
Calculate reactive power if not given in csv file and if cos_phi is set.
- step(timestep: int)
Performs simulation step of eELib load model, which is returning the read reactive power value of the
.csv-file.- Parameters:
timestep (int) – Current simulation time in seconds.
- 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:
PowerCSVCSV-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
.csvprofile.- VALID_PARAMETERS
- p_rated
- 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:
RatedCSVSame as
RatedCSV, butpandqexposed to simulation may be scaled usingp_rated_sim/p_rated.- VALID_PARAMETERS
- 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:
PowerCSVCSV-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_simdefines the annual energy of the Household in simulation. If defined, the profile is scaled to fit the newe_annual. If undefined, the original profile is used in Sim.- VALID_PARAMETERS
- class HouseholdWPuQCSV(eid: str, cos_phi: float | None = None, e_annual_sim: float | None = None, incl_hp: bool = False, **kwargs)
Bases:
HouseholdCSVCSV-Data-Reader for household load profiles in pre-defined format based on the WPuQ project. Similar functionality as
HouseholdCSV, meaing it can be scaled usinge_annual_sim, but additionally…Exposes active (
p) and reactive power (q) for household loads, as profiles from the WPuQ project provide both.incl_hpdefines whether to add the heatpump of the original WPuQ profile topandq.File path (
datafileis not a parameter, as the model automatically selects unique files from thewpuqfolder. 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.- VALID_PARAMETERS
- SYMBOLS: list[ConventionalCSV]
- incl_hp: bool = 'False'
- static _select_datafile(eid: str, incl_hp: bool) tuple[str, datetime.timedelta]
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.
- static _first_date_in_profile(datafile: str | pathlib.Path)
- 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:
RatedScalableCSVCSV-Data-Reader marking pv-generation profiles.
- step(timestep: int)
Performs simulation step of eELib load model, which is returning the read active/reactive power value of the .csv-file.
- Parameters:
timestep (int) – Index of current simulation step. The length of a step is defined in
self.step_size(in s).
- 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:
RatedScalableCSVCSV-Data-Reader for heatpump load profiles. Expected input data is the electrical power. No thermal power is calculated and exposed.
- 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:
RatedCSVCSV-Data-Reader marking charging station load profiles.
- 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:
ConventionalCSVCSV-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_annualdefines the annual thermal energy in simulation. If defined, the profile is scaled to fit the newe_th_annual. If undefined, the original profile is used in Sim.- 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!
- VALID_PARAMETERS
- SYMBOLS: list[ConventionalCSV]
- p_th_room: int | float = '0'
- p_th_water: int | float = '0'
- step(timestep: int)
Performs simulation step of eELib charging_station model, which is returning the read active power value of the .csv-file.
- Parameters:
timestep (int) – Index of current simulation step. The length of a step is defined in
self.step_size(in s).