edisgo.network.results.Results ============================== .. py:class:: edisgo.network.results.Results(edisgo_object) Power flow analysis results management Includes raw power flow analysis results, history of measures to increase the network's hosting capacity and information about changes of equipment. .. attribute:: edisgo_object :type: :class:`~.EDisGo` .. py:attribute:: edisgo_object .. py:property:: measures List with measures conducted to increase network's hosting capacity. :param measure: Measure to increase network's hosting capacity. Possible options so far are 'grid_expansion', 'storage_integration', 'curtailment'. :type measure: str :returns: A stack that details the history of measures to increase network's hosting capacity. The last item refers to the latest measure. The key `original` refers to the state of the network topology as it was initially imported. :rtype: list .. py:property:: pfa_p Active power over components in MW from last power flow analysis. The given active power for each line / transformer is the active power at the line ending / transformer side with the higher apparent power determined from active powers :math:`p_0` and :math:`p_1` and reactive powers :math:`q_0` and :math:`q_0` at the line endings / transformer sides: .. math:: S = max(\sqrt{p_0^2 + q_0^2}, \sqrt{p_1^2 + q_1^2}) :param df: Results for active power over lines and transformers in MW from last power flow analysis. Index of the dataframe is a :pandas:`pandas.DatetimeIndex` indicating the time period the power flow analysis was conducted for; columns of the dataframe are the representatives of the lines and stations included in the power flow analysis. Provide this if you want to set values. For retrieval of data do not pass an argument. :type df: :pandas:`pandas.DataFrame` :returns: Results for active power over lines and transformers in MW from last power flow analysis. For more information on the dataframe see input parameter `df`. :rtype: :pandas:`pandas.DataFrame` .. py:property:: pfa_q Active power over components in Mvar from last power flow analysis. The given reactive power over each line / transformer is the reactive power at the line ending / transformer side with the higher apparent power determined from active powers :math:`p_0` and :math:`p_1` and reactive powers :math:`q_0` and :math:`q_1` at the line endings / transformer sides: .. math:: S = max(\sqrt{p_0^2 + q_0^2}, \sqrt{p_1^2 + q_1^2}) :param df: Results for reactive power over lines and transformers in Mvar from last power flow analysis. Index of the dataframe is a :pandas:`pandas.DatetimeIndex` indicating the time period the power flow analysis was conducted for; columns of the dataframe are the representatives of the lines and stations included in the power flow analysis. Provide this if you want to set values. For retrieval of data do not pass an argument. :type df: :pandas:`pandas.DataFrame` :returns: Results for reactive power over lines and transformers in Mvar from last power flow analysis. For more information on the dataframe see input parameter `df`. :rtype: :pandas:`pandas.DataFrame` .. py:property:: v_res Voltages at buses in p.u. from last power flow analysis. :param df: Dataframe with voltages at buses in p.u. from last power flow analysis. Index of the dataframe is a :pandas:`pandas.DatetimeIndex` indicating the time steps the power flow analysis was conducted for; columns of the dataframe are the bus names of all buses in the analyzed grids. Provide this if you want to set values. For retrieval of data do not pass an argument. :type df: :pandas:`pandas.DataFrame` :returns: Dataframe with voltages at buses in p.u. from last power flow analysis. For more information on the dataframe see input parameter `df`. :rtype: :pandas:`pandas.DataFrame` .. py:property:: i_res Current over components in kA from last power flow analysis. :param df: Results for currents over lines and transformers in kA from last power flow analysis. Index of the dataframe is a :pandas:`pandas.DatetimeIndex` indicating the time steps the power flow analysis was conducted for; columns of the dataframe are the representatives of the lines and stations included in the power flow analysis. Provide this if you want to set values. For retrieval of data do not pass an argument. :type df: :pandas:`pandas.DataFrame` :returns: Results for current over lines and transformers in kA from last power flow analysis. For more information on the dataframe see input parameter `df`. :rtype: :pandas:`pandas.DataFrame` .. py:property:: s_res Apparent power over components in MVA from last power flow analysis. The given apparent power over each line / transformer is the apparent power at the line ending / transformer side with the higher apparent power determined from active powers :math:`p_0` and :math:`p_1` and reactive powers :math:`q_0` and :math:`q_1` at the line endings / transformer sides: .. math:: S = max(\sqrt{p_0^2 + q_0^2}, \sqrt{p_1^2 + q_1^2}) :returns: Apparent power in MVA over lines and transformers. Index of the dataframe is a :pandas:`pandas.DatetimeIndex` indicating the time steps the power flow analysis was conducted for; columns of the dataframe are the representatives of the lines and stations included in the power flow analysis. :rtype: :pandas:`pandas.DataFrame` .. py:property:: equipment_changes Tracks changes to the grid topology. When the grid is reinforced using :attr:`~.EDisGo.reinforce` or new generators added using :attr:`~.EDisGo.import_generators`, new lines and/or transformers are added, lines split, etc. This is tracked in this attribute. :param df: Dataframe holding information on added, changed and removed lines and transformers. Index of the dataframe is in case of lines the name of the line, and in case of transformers the name of the grid the station is in (in case of MV/LV transformers the name of the LV grid and in case of HV/MV transformers the name of the MV grid). Columns are the following: equipment : str Type of new line or transformer as in :attr:`~.network.topology.Topology.equipment_data`. change : str Specifies if something was added, changed or removed. iteration_step : int Grid reinforcement iteration step the change was conducted in. For changes conducted during grid integration of new generators the iteration step is set to 0. quantity : int Number of components added or removed. Only relevant for calculation of network expansion costs to keep track of how many new standard lines were added. Provide this if you want to set values. For retrieval of data do not pass an argument. :type df: :pandas:`pandas.DataFrame` :returns: Dataframe holding information on added, changed and removed lines and transformers. For more information on the dataframe see input parameter `df`. :rtype: :pandas:`pandas.DataFrame` .. py:property:: grid_expansion_costs Costs per expanded component in kEUR. :param df: Costs per expanded line and transformer in kEUR. Index of the dataframe is the name of the expanded component as string. Columns are the following: type : str Type of new line or transformer as in :attr:`~.network.topology.Topology.equipment_data`. total_costs : float Costs of equipment in kEUR. For lines the line length and number of parallel lines is already included in the total costs. quantity : int For transformers quantity is always one, for lines it specifies the number of parallel lines. length : float Length of line or in case of parallel lines all lines in km. voltage_level : str Specifies voltage level the equipment is in ('lv', 'mv' or 'mv/lv'). Provide this if you want to set grid expansion costs. For retrieval of costs do not pass an argument. :type df: :pandas:`pandas.DataFrame` :returns: Costs per expanded line and transformer in kEUR. For more information on the dataframe see input parameter `df`. :rtype: :pandas:`pandas.DataFrame` .. rubric:: Notes Network expansion measures are tracked in :attr:`~.network.results.Results.equipment_changes`. Resulting costs are calculated using :func:`~.flex_opt.costs.grid_expansion_costs`. Total network expansion costs can be obtained through grid_expansion_costs.total_costs.sum(). .. py:property:: grid_losses Active and reactive network losses in MW and Mvar, respectively. :param df: Results for active and reactive network losses in columns 'p' and 'q' and in MW and Mvar, respectively. Index is a :pandas:`pandas.DatetimeIndex`. Provide this if you want to set values. For retrieval of data do not pass an argument. :type df: :pandas:`pandas.DataFrame` :returns: Results for active and reactive network losses MW and Mvar, respectively. For more information on the dataframe see input parameter `df`. :rtype: :pandas:`pandas.DataFrame` .. rubric:: Notes Grid losses are calculated as follows: .. math:: P_{loss} = \lvert \sum{infeed} - \sum{load} + P_{slack} \lvert .. math:: Q_{loss} = \lvert \sum{infeed} - \sum{load} + Q_{slack} \lvert As the slack is placed at the station's secondary side (if MV is included, it's positioned at the HV/MV station's secondary side and if a single LV grid is analysed it's positioned at the LV station's secondary side) losses do not include losses over the respective station's transformers. .. py:property:: pfa_slack Active and reactive power from slack in MW and Mvar, respectively. In case the MV level is included in the power flow analysis, the slack is placed at the secondary side of the HV/MV station and gives the energy transferred to and taken from the HV network. In case a single LV network is analysed, the slack is positioned at the respective station's secondary, in which case this gives the energy transferred to and taken from the overlying MV network. :param df: Results for active and reactive power from the slack in MW and Mvar, respectively. Dataframe has the columns 'p', holding the active power results, and 'q', holding the reactive power results. Index is a :pandas:`pandas.DatetimeIndex`. Provide this if you want to set values. For retrieval of data do not pass an argument. :type df: :pandas:`pandas.DataFrame` :returns: Results for active and reactive power from the slack in MW and Mvar, respectively. For more information on the dataframe see input parameter `df`. :rtype: :pandas:`pandas.DataFrame` .. py:property:: pfa_v_mag_pu_seed Voltages in p.u. from previous power flow analyses to be used as seed. See :func:`~.io.pypsa_io.set_seed` for more information. :param df: Voltages at buses in p.u. from previous power flow analyses including the MV level. Index of the dataframe is a :pandas:`pandas.DatetimeIndex` indicating the time steps previous power flow analyses were conducted for; columns of the dataframe are the representatives of the buses included in the power flow analyses. Provide this if you want to set values. For retrieval of data do not pass an argument. :type df: :pandas:`pandas.DataFrame` :returns: Voltages at buses in p.u. from previous power flow analyses to be opionally used as seed in following power flow analyses. For more information on the dataframe see input parameter `df`. :rtype: :pandas:`pandas.DataFrame` .. py:property:: pfa_v_ang_seed Voltages in p.u. from previous power flow analyses to be used as seed. See :func:`~.io.pypsa_io.set_seed` for more information. :param df: Voltage angles at buses in radians from previous power flow analyses including the MV level. Index of the dataframe is a :pandas:`pandas.DatetimeIndex` indicating the time steps previous power flow analyses were conducted for; columns of the dataframe are the representatives of the buses included in the power flow analyses. Provide this if you want to set values. For retrieval of data do not pass an argument. :type df: :pandas:`pandas.DataFrame` :returns: Voltage angles at buses in radians from previous power flow analyses to be opionally used as seed in following power flow analyses. For more information on the dataframe see input parameter `df`. :rtype: :pandas:`pandas.DataFrame` .. py:property:: unresolved_issues Lines and buses with remaining grid issues after network reinforcement. In case overloading or voltage issues could not be solved after maximum number of iterations, network reinforcement is not aborted but network expansion costs are still calculated and unresolved issues listed here. :param df: Dataframe containing remaining grid issues. Names of remaining critical lines, stations and buses are in the index of the dataframe. Columns depend on the equipment type. See :func:`~.flex_opt.check_tech_constraints.mv_line_overload` for format of remaining overloading issues of lines, :func:`~.flex_opt.check_tech_constraints.hv_mv_station_overload` for format of remaining overloading issues of transformers, and :func:`~.flex_opt.check_tech_constraints.voltage_issues` for format of remaining voltage issues. Provide this if you want to set unresolved_issues. For retrieval of data do not pass an argument. :type df: :pandas:`pandas.DataFrame` :returns: Dataframe with remaining grid issues. For more information on the dataframe see input parameter `df`. :rtype: :pandas:`pandas.DataFrame` .. py:method:: reduce_memory(attr_to_reduce=None, to_type='float32') Reduces size of dataframes containing time series to save memory. See :attr:`~.EDisGo.reduce_memory` for more information. :param attr_to_reduce: List of attributes to reduce size for. Attributes need to be dataframes containing only time series. Possible options are: 'pfa_p', 'pfa_q', 'v_res', 'i_res', and 'grid_losses'. Per default, all these attributes are reduced. :type attr_to_reduce: list(str), optional :param to_type: Data type to convert time series data to. This is a tradeoff between precision and memory. Default: "float32". :type to_type: str, optional .. rubric:: Notes Reducing the data type of the seeds for the power flow analysis, :py:attr:`~pfa_v_mag_pu_seed` and :py:attr:`~pfa_v_ang_seed`, can lead to non-convergence of the power flow analysis, wherefore memory reduction is not provided for those attributes. .. py:method:: equality_check(results_obj) Checks the equality of two results objects. :param results_obj: Contains the results of analyze function with default settings. :type results_obj: :class:~.network.results.Results :returns: True if equality check is successful, False otherwise. :rtype: bool .. py:method:: to_csv(directory, parameters=None, reduce_memory=False, save_seed=False, **kwargs) Saves results to csv. Saves power flow results and grid expansion results to separate directories. Which results are saved depends on what is specified in `parameters`. Per default, all attributes are saved. Power flow results are saved to directory 'powerflow_results' and comprise the following, if not otherwise specified: * 'v_res' : Attribute :py:attr:`~v_res` is saved to `voltages_pu.csv`. * 'i_res' : Attribute :py:attr:`~i_res` is saved to `currents.csv`. * 'pfa_p' : Attribute :py:attr:`~pfa_p` is saved to `active_powers.csv`. * 'pfa_q' : Attribute :py:attr:`~pfa_q` is saved to `reactive_powers.csv`. * 's_res' : Attribute :py:attr:`~s_res` is saved to `apparent_powers.csv`. * 'grid_losses' : Attribute :py:attr:`~grid_losses` is saved to `grid_losses.csv`. * 'pfa_slack' : Attribute :py:attr:`~pfa_slack` is saved to `pfa_slack.csv`. * 'pfa_v_mag_pu_seed' : Attribute :py:attr:`~pfa_v_mag_pu_seed` is saved to `pfa_v_mag_pu_seed.csv`, if `save_seed` is set to True. * 'pfa_v_ang_seed' : Attribute :py:attr:`~pfa_v_ang_seed` is saved to `pfa_v_ang_seed.csv`, if `save_seed` is set to True. Grid expansion results are saved to directory 'grid_expansion_results' and comprise the following, if not otherwise specified: * grid_expansion_costs : Attribute :py:attr:`~grid_expansion_costs` is saved to `grid_expansion_costs.csv`. * equipment_changes : Attribute :py:attr:`~equipment_changes` is saved to `equipment_changes.csv`. * unresolved_issues : Attribute :py:attr:`~unresolved_issues` is saved to `unresolved_issues.csv`. :param directory: Main directory to save the results in. :type directory: str :param parameters: Specifies which results to save. By default this is set to None, in which case all results are saved. To only save certain results provide a dictionary. Possible keys are 'powerflow_results' and 'grid_expansion_results'. Corresponding values must be lists with attributes to save or None to save all attributes. For example, with the first input only the power flow results `i_res` and `v_res` are saved, and with the second input all power flow results are saved. .. code-block:: python {'powerflow_results': ['i_res', 'v_res']} .. code-block:: python {'powerflow_results': None} See function docstring for possible power flow and grid expansion results to save and under which file name they are saved. :type parameters: None or dict, optional :param reduce_memory: If True, size of dataframes containing time series to save memory is reduced using :attr:`~.network.results.Results.reduce_memory`. Optional parameters of :attr:`~.network.results.Results.reduce_memory` can be passed as kwargs to this function. Default: False. :type reduce_memory: bool, optional :param save_seed: If True, :py:attr:`~pfa_v_mag_pu_seed` and :py:attr:`~pfa_v_ang_seed` are as well saved as csv. As these are only relevant if calculations are not final, the default is False, in which case they are not saved. :type save_seed: bool, optional :param kwargs: Kwargs may contain optional arguments of :attr:`~.network.results.Results.reduce_memory`. .. py:method:: from_csv(data_path, parameters=None, dtype=None, from_zip_archive=False) Restores results from csv files. See :func:`~to_csv` for more information on which results can be saved and under which filename and directory they are stored. :param data_path: Main data path results are saved in. Must be directory or zip archive. :type data_path: str :param parameters: Specifies which results to restore. By default this is set to None, in which case all available results are restored. To only restore certain results provide a dictionary. Possible keys are 'powerflow_results' and 'grid_expansion_results'. Corresponding values must be lists with attributes to restore or None to restore all available attributes. See function docstring `parameters` parameter in :func:`~to_csv` for more information. :type parameters: None or dict, optional :param dtype: Numerical data type for data to be loaded from csv, e.g. "float32". Per default this is None in which case data type is inferred. :type dtype: str, optional :param from_zip_archive: Set True if data is archived in a zip archive. Default: False. :type from_zip_archive: bool, optional