Statistics
StatisticsAccessor
ΒΆ
StatisticsAccessor(n: Network | NetworkCollection)
Bases: AbstractStatisticsAccessor
Accessor to calculate different metrics from the network.
All methods and attributes of the accessor can be used with any pypsa.Network
instance via n.statistics, which is the main facade to the statistics module.
The statistics methods are another level of accessors, which means that they can yield statistics as pandas DataFrames or plots based on them. See the examples for more details.
Examples:
The examples below can be used with any statistical method. The default arguments used and the plot type yielded will vary.
Get aggregated statistics in a single DataFrame:
>>> n.statistics()
Optimal Capacity ... Market Value
Generator gas 982.03448 ... 1559.511099
wind 7292.13406 ... 589.813549
Line AC 5613.82931 ... -43.277041
Link DC 4003.90110 ... 0.132018
Load load 0.00000 ... NaN
[5 rows x 12 columns]
Get the energy balance:
>>> n.statistics.energy_balance()
component carrier bus_carrier
Generator gas AC 1465.27439
wind AC 31082.35370
Load load AC -32547.62808
dtype: float64
Get the optimal capacity:
>>> n.statistics.optimal_capacity()
component carrier
Generator gas 982.03448
wind 7292.13406
Line AC 5613.82931
Link DC 4003.90110
dtype: float64
Create a basic plot on any statistic:
>>> n.statistics.energy_balance.plot()
#TODO Add plot
Choose a specific plot type:
>>> n.statistics.energy_balance.plot("bar")
#TODO Add plot
Create a interactive plot:
>>> n.statistics.energy_balance.iplot()
#TODO Add plot
Methods:
-
__call__βCalculate multiple statistical values for a network.
-
capacity_factorβCalculate the capacity factor of components in the network.
-
capexβCalculate the capital expenditure.
-
curtailmentβCalculate the curtailment of components in the network in MWh.
-
energy_balanceβCalculate the energy balance of components in network.
-
expanded_capacityβCalculate the expanded capacity of the network components in MW.
-
expanded_capexβCalculate the capital expenditure of expanded capacities.
-
installed_capacityβCalculate the installed capacity of the network components in MW.
-
installed_capexβCalculate the capital expenditure of already built capacities.
-
market_valueβCalculate the market value of components in the network.
-
opexβCalculate the operational expenditure in the network in given currency.
-
optimal_capacityβCalculate the optimal capacity of the network components in MW.
-
pricesβCalculate the average marginal prices in the network per bus.
-
revenueβCalculate the revenue of components in the network in given currency.
-
supplyβCalculate the supply of components in the network.
-
system_costβCalculate the total system cost.
-
transmissionβCalculate the transmission of branch components in the network.
-
withdrawalβCalculate the withdrawal of components in the network.
pypsa.Network.statistics.__call__
ΒΆ
__call__(
components: str | Sequence[str] | None = None,
groupby_method: Callable | str = "sum",
aggregate_across_components: bool = False,
groupby: str | Sequence[str] | Callable = "carrier",
at_port: bool | str | Sequence[str] = False,
carrier: str | Sequence[str] | None = None,
bus_carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
drop_zero: bool | None = None,
round: int | None = None,
) -> DataFrame
Calculate multiple statistical values for a network.
This function calls multiple function in the background in order to derive a full table of relevant network information. It groups the values to components according to the groupby argument.
Parameters:
-
components(str | Sequence[str] | None, default:None) βComponents to include in the calculation. If None, includes all one-port and branch components. Available components are 'Generator', 'StorageUnit', 'Store', 'Load', 'Line', 'Transformer' and'Link'.
-
groupby_method(Callable | str, default:"sum") βFunction to aggregate groups when using the groupby parameter. Any pandas aggregation function can be used.
-
aggregate_across_components(bool, default:False) βWhether to aggregate across components. If there are different components which would be grouped together due to the same index, this is avoided.
-
groupby(str | Sequence[str] | Callable, default:["carrier", "bus_carrier"]) βHow to group components: -
False: No grouping, return all components individually - string or list of strings: Group by column names from c.static - callable: Function that takes network and component name as arguments -
at_port(bool | str | Sequence[str], default:True) βWhich ports to consider: - True: All ports of components - False: Exclude first port ("bus"/"bus0") - str or list of str: Specific ports to include
-
carrier(str | Sequence[str] | None, default:None) βFilter by carrier. If specified, only considers assets with given carrier(s).
-
bus_carrier(str | Sequence[str] | None, default:None) βFilter by carrier of connected buses. If specified, only considers assets connected to buses with the given carrier(s).
-
nice_names(bool | None, default:None) βWhether to use carrier nice names defined in n.carriers.nice_name. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
drop_zero(bool | None, default:None) βWhether to drop zero values from the result. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
round(int | None, default:None) βNumber of decimal places to round the result to. Defaults to module wide option (default: 2). See
https://go.pypsa.org/options-paramsfor more information.
Returns:
-
df(DataFrame) βpandas.DataFrame with columns given the different quantities.
Examples:
>>> n.statistics.optimal_capacity()
component carrier
Generator gas 982.03448
wind 7292.13406
Line AC 5613.82931
Link DC 4003.90110
dtype: float64
pypsa.Network.statistics.capacity_factor
ΒΆ
capacity_factor(
components: str | Sequence[str] | None = None,
groupby_time: str | bool = "mean",
groupby_method: Callable | str = "sum",
aggregate_across_components: bool = False,
at_port: bool | str | Sequence[str] = False,
groupby: str | Sequence[str] | Callable = "carrier",
carrier: str | Sequence[str] | None = None,
bus_carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
drop_zero: bool | None = None,
round: int | None = None,
) -> DataFrame
Calculate the capacity factor of components in the network.
Parameters:
-
components(str | Sequence[str] | None, default:None) βComponents to include in the calculation. If None, includes all one-port and branch components. Available components are 'Generator', 'StorageUnit', 'Store', 'Load', 'Line', 'Transformer' and'Link'.
-
groupby_method(Callable | str, default:"sum") βFunction to aggregate groups when using the groupby parameter. Any pandas aggregation function can be used.
-
aggregate_across_components(bool, default:False) βWhether to aggregate across components. If there are different components which would be grouped together due to the same index, this is avoided.
-
groupby(str | Sequence[str] | Callable, default:["carrier", "bus_carrier"]) βHow to group components: -
False: No grouping, return all components individually - string or list of strings: Group by column names from c.static - callable: Function that takes network and component name as arguments -
at_port(bool | str | Sequence[str], default:True) βWhich ports to consider: - True: All ports of components - False: Exclude first port ("bus"/"bus0") - str or list of str: Specific ports to include
-
carrier(str | Sequence[str] | None, default:None) βFilter by carrier. If specified, only considers assets with given carrier(s).
-
bus_carrier(str | Sequence[str] | None, default:None) βFilter by carrier of connected buses. If specified, only considers assets connected to buses with the given carrier(s).
-
nice_names(bool | None, default:None) βWhether to use carrier nice names defined in n.carriers.nice_name. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
drop_zero(bool | None, default:None) βWhether to drop zero values from the result. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
round(int | None, default:None) βNumber of decimal places to round the result to. Defaults to module wide option (default: 2). See
https://go.pypsa.org/options-paramsfor more information.
Other Parameters:
-
groupby_time(str | bool) βType of aggregation when aggregating time series. Deactivate by setting to False. Any pandas aggregation function can be used. Note that when aggregating the time series are aggregated to MWh using snapshot weightings. With False the time series is given in MW.
Returns:
-
DataFrameβCapacity factor of components in the network with components as rows and either time steps as columns (if groupby_time=False) or a single column of aggregated values.
Examples:
>>> n.statistics.capacity_factor()
Series([], dtype: float64)
pypsa.Network.statistics.capex
ΒΆ
capex(
components: str | Sequence[str] | None = None,
groupby_method: Callable | str = "sum",
aggregate_across_components: bool = False,
groupby: str | Sequence[str] | Callable = "carrier",
at_port: bool | str | Sequence[str] = False,
carrier: str | Sequence[str] | None = None,
bus_carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
drop_zero: bool | None = None,
round: int | None = None,
cost_attribute: str = "capital_cost",
) -> DataFrame
Calculate the capital expenditure.
Includes newly installed and existing assets, measured in the specified currency.
Parameters:
-
components(str | Sequence[str] | None, default:None) βComponents to include in the calculation. If None, includes all one-port and branch components. Available components are 'Generator', 'StorageUnit', 'Store', 'Load', 'Line', 'Transformer' and'Link'.
-
groupby_method(Callable | str, default:"sum") βFunction to aggregate groups when using the groupby parameter. Any pandas aggregation function can be used.
-
aggregate_across_components(bool, default:False) βWhether to aggregate across components. If there are different components which would be grouped together due to the same index, this is avoided.
-
groupby(str | Sequence[str] | Callable, default:["carrier", "bus_carrier"]) βHow to group components: -
False: No grouping, return all components individually - string or list of strings: Group by column names from c.static - callable: Function that takes network and component name as arguments -
at_port(bool | str | Sequence[str], default:True) βWhich ports to consider: - True: All ports of components - False: Exclude first port ("bus"/"bus0") - str or list of str: Specific ports to include
-
carrier(str | Sequence[str] | None, default:None) βFilter by carrier. If specified, only considers assets with given carrier(s).
-
bus_carrier(str | Sequence[str] | None, default:None) βFilter by carrier of connected buses. If specified, only considers assets connected to buses with the given carrier(s).
-
nice_names(bool | None, default:None) βWhether to use carrier nice names defined in n.carriers.nice_name. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
drop_zero(bool | None, default:None) βWhether to drop zero values from the result. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
round(int | None, default:None) βNumber of decimal places to round the result to. Defaults to module wide option (default: 2). See
https://go.pypsa.org/options-paramsfor more information.
Other Parameters:
-
cost_attribute(str) βNetwork attribute that should be used to calculate Capital Expenditure. Defaults to
capital_cost.
Returns:
-
DataFrameβCapital expenditure with components as rows and a single column of aggregated values.
Examples:
>>> n.statistics.capex()
Series([], dtype: float64)
pypsa.Network.statistics.curtailment
ΒΆ
curtailment(
components: str | Sequence[str] | None = None,
groupby_time: str | bool = "sum",
groupby_method: Callable | str = "sum",
aggregate_across_components: bool = False,
groupby: str | Sequence[str] | Callable = "carrier",
at_port: bool | str | Sequence[str] = False,
carrier: str | Sequence[str] | None = None,
bus_carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
drop_zero: bool | None = None,
round: int | None = None,
) -> DataFrame
Calculate the curtailment of components in the network in MWh.
The calculation only considers assets with a p_max_pu time
series, which is used to quantify the available power potential.
Parameters:
-
components(str | Sequence[str] | None, default:None) βComponents to include in the calculation. If None, includes all one-port and branch components. Available components are 'Generator', 'StorageUnit', 'Store', 'Load', 'Line', 'Transformer' and'Link'.
-
groupby_method(Callable | str, default:"sum") βFunction to aggregate groups when using the groupby parameter. Any pandas aggregation function can be used.
-
aggregate_across_components(bool, default:False) βWhether to aggregate across components. If there are different components which would be grouped together due to the same index, this is avoided.
-
groupby(str | Sequence[str] | Callable, default:["carrier", "bus_carrier"]) βHow to group components: -
False: No grouping, return all components individually - string or list of strings: Group by column names from c.static - callable: Function that takes network and component name as arguments -
at_port(bool | str | Sequence[str], default:True) βWhich ports to consider: - True: All ports of components - False: Exclude first port ("bus"/"bus0") - str or list of str: Specific ports to include
-
carrier(str | Sequence[str] | None, default:None) βFilter by carrier. If specified, only considers assets with given carrier(s).
-
bus_carrier(str | Sequence[str] | None, default:None) βFilter by carrier of connected buses. If specified, only considers assets connected to buses with the given carrier(s).
-
nice_names(bool | None, default:None) βWhether to use carrier nice names defined in n.carriers.nice_name. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
drop_zero(bool | None, default:None) βWhether to drop zero values from the result. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
round(int | None, default:None) βNumber of decimal places to round the result to. Defaults to module wide option (default: 2). See
https://go.pypsa.org/options-paramsfor more information.
Other Parameters:
-
groupby_time(str | bool) βType of aggregation when aggregating time series. Deactivate by setting to False. Any pandas aggregation function can be used. Note that when aggregating the time series are aggregated to MWh using snapshot weightings. With False the time series is given in MW.
Returns:
-
DataFrameβCurtailment of components in the network with components as rows and either time steps as columns (if aggregate_time=False) or a single column of aggregated values.
Examples:
>>> n.statistics.curtailment()
Series([], Name: generators, dtype: float64)
pypsa.Network.statistics.energy_balance
ΒΆ
energy_balance(
components: str | Sequence[str] | None = None,
groupby_time: str | bool = "sum",
groupby_method: Callable | str = "sum",
aggregate_across_components: bool = False,
groupby: str | Sequence[str] | Callable | None = None,
at_port: bool | str | Sequence[str] = True,
carrier: str | Sequence[str] | None = None,
bus_carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
drop_zero: bool | None = None,
round: int | None = None,
direction: str | None = None,
) -> DataFrame
Calculate the energy balance of components in network.
This method computes the energy balance across various network components, where positive values represent supply and negative values represent withdrawal. Units are inherited from the respective bus carriers.
Parameters:
-
components(str | Sequence[str] | None, default:None) βComponents to include in the calculation. If None, includes all one-port and branch components. Available components are 'Generator', 'StorageUnit', 'Store', 'Load', 'Line', 'Transformer' and'Link'.
-
groupby_method(Callable | str, default:"sum") βFunction to aggregate groups when using the groupby parameter. Any pandas aggregation function can be used.
-
aggregate_across_components(bool, default:False) βWhether to aggregate across components. If there are different components which would be grouped together due to the same index, this is avoided.
-
groupby(str | Sequence[str] | Callable, default:["carrier", "bus_carrier"]) βHow to group components: -
False: No grouping, return all components individually - string or list of strings: Group by column names from c.static - callable: Function that takes network and component name as arguments -
at_port(bool | str | Sequence[str], default:True) βWhich ports to consider: - True: All ports of components - False: Exclude first port ("bus"/"bus0") - str or list of str: Specific ports to include
-
carrier(str | Sequence[str] | None, default:None) βFilter by carrier. If specified, only considers assets with given carrier(s).
-
bus_carrier(str | Sequence[str] | None, default:None) βFilter by carrier of connected buses. If specified, only considers assets connected to buses with the given carrier(s).
-
nice_names(bool | None, default:None) βWhether to use carrier nice names defined in n.carriers.nice_name. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
drop_zero(bool | None, default:None) βWhether to drop zero values from the result. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
round(int | None, default:None) βNumber of decimal places to round the result to. Defaults to module wide option (default: 2). See
https://go.pypsa.org/options-paramsfor more information.
Other Parameters:
-
groupby_time(str | bool) βType of aggregation when aggregating time series. Deactivate by setting to False. Any pandas aggregation function can be used. Note that when aggregating the time series are aggregated to MWh using snapshot weightings. With False the time series is given in MW.
-
direction(str | None) βType of energy balance to calculate: - 'supply': Only consider positive values (energy production) - 'withdrawal': Only consider negative values (energy consumption) - None: Consider both supply and withdrawal
Returns:
-
DataFrameβEnergy balance with components as rows and either time steps as columns (if groupby_time=False) or a single column of aggregated values. Units depend on the bus carrier and aggregation method.
Examples:
>>> n.statistics.energy_balance()
Series([], dtype: float64)
pypsa.Network.statistics.expanded_capacity
ΒΆ
expanded_capacity(
components: str | Sequence[str] | None = None,
groupby_method: Callable | str = "sum",
aggregate_across_components: bool = False,
groupby: str | Sequence[str] | Callable = "carrier",
at_port: str | Sequence[str] | bool | None = None,
carrier: str | Sequence[str] | None = None,
bus_carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
drop_zero: bool | None = None,
round: int | None = None,
) -> DataFrame
Calculate the expanded capacity of the network components in MW.
Positive capacity values correspond to production capacities and negative values to consumption capacities.
Parameters:
-
components(str | Sequence[str] | None, default:None) βComponents to include in the calculation. If None, includes all one-port and branch components. Available components are 'Generator', 'StorageUnit', 'Store', 'Load', 'Line', 'Transformer' and'Link'.
-
groupby_method(Callable | str, default:"sum") βFunction to aggregate groups when using the groupby parameter. Any pandas aggregation function can be used.
-
aggregate_across_components(bool, default:False) βWhether to aggregate across components. If there are different components which would be grouped together due to the same index, this is avoided.
-
groupby(str | Sequence[str] | Callable, default:["carrier", "bus_carrier"]) βHow to group components: -
False: No grouping, return all components individually - string or list of strings: Group by column names from c.static - callable: Function that takes network and component name as arguments -
at_port(bool | str | Sequence[str], default:True) βWhich ports to consider: - True: All ports of components - False: Exclude first port ("bus"/"bus0") - str or list of str: Specific ports to include
-
carrier(str | Sequence[str] | None, default:None) βFilter by carrier. If specified, only considers assets with given carrier(s).
-
bus_carrier(str | Sequence[str] | None, default:None) βFilter by carrier of connected buses. If specified, only considers assets connected to buses with the given carrier(s).
-
nice_names(bool | None, default:None) βWhether to use carrier nice names defined in n.carriers.nice_name. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
drop_zero(bool | None, default:None) βWhether to drop zero values from the result. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
round(int | None, default:None) βNumber of decimal places to round the result to. Defaults to module wide option (default: 2). See
https://go.pypsa.org/options-paramsfor more information.
Returns:
-
DataFrameβExpanded capacity of the network components with components as rows and a single column of aggregated values.
Examples:
>>> n.statistics.expanded_capacity()
Series([], dtype: float64)
pypsa.Network.statistics.expanded_capex
ΒΆ
expanded_capex(
components: str | Sequence[str] | None = None,
groupby_method: Callable | str = "sum",
aggregate_across_components: bool = False,
groupby: str | Sequence[str] | Callable = "carrier",
at_port: bool | str | Sequence[str] = False,
carrier: str | Sequence[str] | None = None,
bus_carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
drop_zero: bool | None = None,
round: int | None = None,
cost_attribute: str = "capital_cost",
) -> DataFrame
Calculate the capital expenditure of expanded capacities.
Parameters:
-
components(str | Sequence[str] | None, default:None) βComponents to include in the calculation. If None, includes all one-port and branch components. Available components are 'Generator', 'StorageUnit', 'Store', 'Load', 'Line', 'Transformer' and'Link'.
-
groupby_method(Callable | str, default:"sum") βFunction to aggregate groups when using the groupby parameter. Any pandas aggregation function can be used.
-
aggregate_across_components(bool, default:False) βWhether to aggregate across components. If there are different components which would be grouped together due to the same index, this is avoided.
-
groupby(str | Sequence[str] | Callable, default:["carrier", "bus_carrier"]) βHow to group components: -
False: No grouping, return all components individually - string or list of strings: Group by column names from c.static - callable: Function that takes network and component name as arguments -
at_port(bool | str | Sequence[str], default:True) βWhich ports to consider: - True: All ports of components - False: Exclude first port ("bus"/"bus0") - str or list of str: Specific ports to include
-
carrier(str | Sequence[str] | None, default:None) βFilter by carrier. If specified, only considers assets with given carrier(s).
-
bus_carrier(str | Sequence[str] | None, default:None) βFilter by carrier of connected buses. If specified, only considers assets connected to buses with the given carrier(s).
-
nice_names(bool | None, default:None) βWhether to use carrier nice names defined in n.carriers.nice_name. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
drop_zero(bool | None, default:None) βWhether to drop zero values from the result. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
round(int | None, default:None) βNumber of decimal places to round the result to. Defaults to module wide option (default: 2). See
https://go.pypsa.org/options-paramsfor more information.
Other Parameters:
-
cost_attribute(str) βNetwork attribute that should be used to calculate Capital Expenditure. Defaults to
capital_cost.
Returns:
-
DataFrameβCapital expenditure of expanded capacities with components as rows and a single column of aggregated values.
Examples:
>>> n.statistics.expanded_capex()
component carrier
Generator gas -2.120994e+07
wind -6.761698e+05
...
pypsa.Network.statistics.installed_capacity
ΒΆ
installed_capacity(
components: str | Sequence[str] | None = None,
groupby_method: Callable | str = "sum",
aggregate_across_components: bool = False,
groupby: str | Sequence[str] | Callable = "carrier",
at_port: str | Sequence[str] | bool | None = None,
carrier: str | Sequence[str] | None = None,
bus_carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
drop_zero: bool | None = None,
round: int | None = None,
storage: bool = False,
) -> DataFrame
Calculate the installed capacity of the network components in MW.
Positive capacity values correspond to production capacities and negative values to consumption capacities.
Parameters:
-
components(str | Sequence[str] | None, default:None) βComponents to include in the calculation. If None, includes all one-port and branch components. Available components are 'Generator', 'StorageUnit', 'Store', 'Load', 'Line', 'Transformer' and'Link'.
-
groupby_method(Callable | str, default:"sum") βFunction to aggregate groups when using the groupby parameter. Any pandas aggregation function can be used.
-
aggregate_across_components(bool, default:False) βWhether to aggregate across components. If there are different components which would be grouped together due to the same index, this is avoided.
-
groupby(str | Sequence[str] | Callable, default:["carrier", "bus_carrier"]) βHow to group components: -
False: No grouping, return all components individually - string or list of strings: Group by column names from c.static - callable: Function that takes network and component name as arguments -
at_port(bool | str | Sequence[str], default:True) βWhich ports to consider: - True: All ports of components - False: Exclude first port ("bus"/"bus0") - str or list of str: Specific ports to include
-
carrier(str | Sequence[str] | None, default:None) βFilter by carrier. If specified, only considers assets with given carrier(s).
-
bus_carrier(str | Sequence[str] | None, default:None) βFilter by carrier of connected buses. If specified, only considers assets connected to buses with the given carrier(s).
-
nice_names(bool | None, default:None) βWhether to use carrier nice names defined in n.carriers.nice_name. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
drop_zero(bool | None, default:None) βWhether to drop zero values from the result. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
round(int | None, default:None) βNumber of decimal places to round the result to. Defaults to module wide option (default: 2). See
https://go.pypsa.org/options-paramsfor more information.
Other Parameters:
-
storage(bool) βWhether to consider only storage capacities of the components
StoreandStorageUnit.
Returns:
-
pd.DataFrameβInstalled capacity of the network components with components as rows and a single column of aggregated values.
Examples:
>>> n.statistics.installed_capacity()
component carrier
Generator gas 150000.0
wind 290.0
Line AC 160000.0
Link DC 4000.0
dtype: float64
pypsa.Network.statistics.installed_capex
ΒΆ
installed_capex(
components: str | Sequence[str] | None = None,
groupby_method: Callable | str = "sum",
aggregate_across_components: bool = False,
groupby: str | Sequence[str] | Callable = "carrier",
at_port: bool | str | Sequence[str] = False,
carrier: str | Sequence[str] | None = None,
bus_carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
drop_zero: bool | None = None,
round: int | None = None,
cost_attribute: str = "capital_cost",
) -> DataFrame
Calculate the capital expenditure of already built capacities.
Parameters:
-
components(str | Sequence[str] | None, default:None) βComponents to include in the calculation. If None, includes all one-port and branch components. Available components are 'Generator', 'StorageUnit', 'Store', 'Load', 'Line', 'Transformer' and'Link'.
-
groupby_method(Callable | str, default:"sum") βFunction to aggregate groups when using the groupby parameter. Any pandas aggregation function can be used.
-
aggregate_across_components(bool, default:False) βWhether to aggregate across components. If there are different components which would be grouped together due to the same index, this is avoided.
-
groupby(str | Sequence[str] | Callable, default:["carrier", "bus_carrier"]) βHow to group components: -
False: No grouping, return all components individually - string or list of strings: Group by column names from c.static - callable: Function that takes network and component name as arguments -
at_port(bool | str | Sequence[str], default:True) βWhich ports to consider: - True: All ports of components - False: Exclude first port ("bus"/"bus0") - str or list of str: Specific ports to include
-
carrier(str | Sequence[str] | None, default:None) βFilter by carrier. If specified, only considers assets with given carrier(s).
-
bus_carrier(str | Sequence[str] | None, default:None) βFilter by carrier of connected buses. If specified, only considers assets connected to buses with the given carrier(s).
-
nice_names(bool | None, default:None) βWhether to use carrier nice names defined in n.carriers.nice_name. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
drop_zero(bool | None, default:None) βWhether to drop zero values from the result. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
round(int | None, default:None) βNumber of decimal places to round the result to. Defaults to module wide option (default: 2). See
https://go.pypsa.org/options-paramsfor more information.
Other Parameters:
-
cost_attribute(str) βNetwork attribute that should be used to calculate Capital Expenditure. Defaults to
capital_cost.
Returns:
-
DataFrameβCapital expenditure of already built capacities with components as rows and a single column of aggregated values.
Examples:
>>> n.statistics.installed_capex()
component carrier
Generator gas 2.120994e+07
wind 6.761698e+05
Line AC 1.653634e+04
Link DC 1.476534e+03
dtype: float64
pypsa.Network.statistics.market_value
ΒΆ
market_value(
components: str | Sequence[str] | None = None,
groupby_time: str | bool = "mean",
groupby_method: Callable | str = "sum",
aggregate_across_components: bool = False,
groupby: str | Sequence[str] | Callable = "carrier",
at_port: bool | str | Sequence[str] = True,
carrier: str | Sequence[str] | None = None,
bus_carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
drop_zero: bool | None = None,
round: int | None = None,
) -> DataFrame
Calculate the market value of components in the network.
Curreny is currency/MWh or currency/unit_{bus_carrier} where unit_{bus_carrier} is the unit of the bus carrier.
Parameters:
-
components(str | Sequence[str] | None, default:None) βComponents to include in the calculation. If None, includes all one-port and branch components. Available components are 'Generator', 'StorageUnit', 'Store', 'Load', 'Line', 'Transformer' and'Link'.
-
groupby_method(Callable | str, default:"sum") βFunction to aggregate groups when using the groupby parameter. Any pandas aggregation function can be used.
-
aggregate_across_components(bool, default:False) βWhether to aggregate across components. If there are different components which would be grouped together due to the same index, this is avoided.
-
groupby(str | Sequence[str] | Callable, default:["carrier", "bus_carrier"]) βHow to group components: -
False: No grouping, return all components individually - string or list of strings: Group by column names from c.static - callable: Function that takes network and component name as arguments -
at_port(bool | str | Sequence[str], default:True) βWhich ports to consider: - True: All ports of components - False: Exclude first port ("bus"/"bus0") - str or list of str: Specific ports to include
-
carrier(str | Sequence[str] | None, default:None) βFilter by carrier. If specified, only considers assets with given carrier(s).
-
bus_carrier(str | Sequence[str] | None, default:None) βFilter by carrier of connected buses. If specified, only considers assets connected to buses with the given carrier(s).
-
nice_names(bool | None, default:None) βWhether to use carrier nice names defined in n.carriers.nice_name. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
drop_zero(bool | None, default:None) βWhether to drop zero values from the result. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
round(int | None, default:None) βNumber of decimal places to round the result to. Defaults to module wide option (default: 2). See
https://go.pypsa.org/options-paramsfor more information.
Other Parameters:
-
groupby_time(str | bool) βType of aggregation when aggregating time series. Deactivate by setting to False. Any pandas aggregation function can be used. Note that when aggregating the time series are aggregated to MWh using snapshot weightings. With False the time series is given in MW.
Returns:
-
DataFrameβMarket value of components in the network with components as rows and either time steps as columns (if groupby_time=False) or a single column of aggregated values.
Examples:
>>> n.statistics.market_value()
Series([], dtype: float64)
pypsa.Network.statistics.opex
ΒΆ
opex(
components: str | Sequence[str] | None = None,
groupby_time: str | bool = "sum",
groupby_method: Callable | str = "sum",
aggregate_across_components: bool = False,
groupby: str | Sequence[str] | Callable = "carrier",
at_port: bool | str | Sequence[str] = False,
carrier: str | Sequence[str] | None = None,
bus_carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
drop_zero: bool | None = None,
round: int | None = None,
cost_types: str | Sequence[str] | None = None,
) -> DataFrame
Calculate the operational expenditure in the network in given currency.
Operational expenditures include the marginal, marginal quadratic, storage holding, spillage, start-up, shut-down and stand-by costs.
Parameters:
-
components(str | Sequence[str] | None, default:None) βComponents to include in the calculation. If None, includes all one-port and branch components. Available components are 'Generator', 'StorageUnit', 'Store', 'Load', 'Line', 'Transformer' and'Link'.
-
groupby_method(Callable | str, default:"sum") βFunction to aggregate groups when using the groupby parameter. Any pandas aggregation function can be used.
-
aggregate_across_components(bool, default:False) βWhether to aggregate across components. If there are different components which would be grouped together due to the same index, this is avoided.
-
groupby(str | Sequence[str] | Callable, default:["carrier", "bus_carrier"]) βHow to group components: -
False: No grouping, return all components individually - string or list of strings: Group by column names from c.static - callable: Function that takes network and component name as arguments -
at_port(bool | str | Sequence[str], default:True) βWhich ports to consider: - True: All ports of components - False: Exclude first port ("bus"/"bus0") - str or list of str: Specific ports to include
-
carrier(str | Sequence[str] | None, default:None) βFilter by carrier. If specified, only considers assets with given carrier(s).
-
bus_carrier(str | Sequence[str] | None, default:None) βFilter by carrier of connected buses. If specified, only considers assets connected to buses with the given carrier(s).
-
nice_names(bool | None, default:None) βWhether to use carrier nice names defined in n.carriers.nice_name. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
drop_zero(bool | None, default:None) βWhether to drop zero values from the result. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
round(int | None, default:None) βNumber of decimal places to round the result to. Defaults to module wide option (default: 2). See
https://go.pypsa.org/options-paramsfor more information.
Other Parameters:
-
groupby_time(str | bool) βType of aggregation when aggregating time series. Deactivate by setting to False. Any pandas aggregation function can be used. Note that when aggregating the time series are aggregated to MWh using snapshot weightings. With False the time series is given in MW.
-
cost_types(str | Sequence[str] | None) βList of cost types to include in the calculation. Available options are: 'marginal_cost', 'marginal_cost_quadratic', 'marginal_cost_storage', 'spill_cost', 'start_up_cost', 'shut_down_cost', 'stand_by_cost'. Defaults to all (when None).
Returns:
-
DataFrameβOngoing operational costs with components as rows and either time steps as columns (if groupby_time=False) or a single column of aggregated values.
Examples:
>>> n.statistics.opex()
Series([], dtype: float64)
pypsa.Network.statistics.optimal_capacity
ΒΆ
optimal_capacity(
components: str | Sequence[str] | None = None,
groupby_method: Callable | str = "sum",
aggregate_across_components: bool = False,
groupby: str | Sequence[str] | Callable = "carrier",
at_port: str | Sequence[str] | bool | None = None,
carrier: str | Sequence[str] | None = None,
bus_carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
drop_zero: bool | None = None,
round: int | None = None,
storage: bool = False,
) -> DataFrame
Calculate the optimal capacity of the network components in MW.
Positive capacity values correspond to production capacities and negative values to consumption capacities.
Parameters:
-
components(str | Sequence[str] | None, default:None) βComponents to include in the calculation. If None, includes all one-port and branch components. Available components are 'Generator', 'StorageUnit', 'Store', 'Load', 'Line', 'Transformer' and'Link'.
-
groupby_method(Callable | str, default:"sum") βFunction to aggregate groups when using the groupby parameter. Any pandas aggregation function can be used.
-
aggregate_across_components(bool, default:False) βWhether to aggregate across components. If there are different components which would be grouped together due to the same index, this is avoided.
-
groupby(str | Sequence[str] | Callable, default:["carrier", "bus_carrier"]) βHow to group components: -
False: No grouping, return all components individually - string or list of strings: Group by column names from c.static - callable: Function that takes network and component name as arguments -
at_port(bool | str | Sequence[str], default:True) βWhich ports to consider: - True: All ports of components - False: Exclude first port ("bus"/"bus0") - str or list of str: Specific ports to include
-
carrier(str | Sequence[str] | None, default:None) βFilter by carrier. If specified, only considers assets with given carrier(s).
-
bus_carrier(str | Sequence[str] | None, default:None) βFilter by carrier of connected buses. If specified, only considers assets connected to buses with the given carrier(s).
-
nice_names(bool | None, default:None) βWhether to use carrier nice names defined in n.carriers.nice_name. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
drop_zero(bool | None, default:None) βWhether to drop zero values from the result. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
round(int | None, default:None) βNumber of decimal places to round the result to. Defaults to module wide option (default: 2). See
https://go.pypsa.org/options-paramsfor more information.
Other Parameters:
-
storage(bool) βWhether to consider only storage capacities of the components
StoreandStorageUnit.
Returns:
-
DataFrameβOptimal capacity of the network components with components as rows and a single column of aggregated values.
Examples:
>>> n.statistics.optimal_capacity()
component carrier
Generator gas 982.03448
wind 7292.13406
Line AC 5613.82931
Link DC 4003.90110
dtype: float64
pypsa.Network.statistics.prices
ΒΆ
prices(
groupby: bool = False,
weighting: str = "load",
groupby_time: bool = True,
bus_carrier: Sequence[str] | str | None = None,
drop_zero: bool | None = None,
round: int | None = None,
) -> Series
Calculate the average marginal prices in the network per bus.
Currency is currency/MWh or currency/unit_{bus_carrier} where unit_{bus_carrier} is the unit of the bus carrier.
Note
The functions signature of n.statistics.prices is different from other statistics functions as it does not take the same parameters, since prices are only defined for buses.
Parameters:
-
groupby(bool | str, default:False) βHow to group components: -
False: No grouping, return all buses individually -"bus_carrier": Prices are aggregated to each bus carrier with weights applied. Other grouping options are not supported and the groupby method can not be set. Seeweightingfor different weighting options. Defaults to False. -
weighting(str, default:'load') βType of weighting to use. If 'load' the prices are weighted by the load of the buses and if time they are weighted by snapshot weightings. Defaults to 'load'.
-
groupby_time(bool, default:True) βWhether to group the time series by time or return the full time series. No aggregation method can be set. Defaults to True.
-
bus_carrier(str | Sequence[str] | None, default:None) βFilter by carrier of buses. If specified, only considers buses with the given carrier(s).
-
drop_zero(bool | None, default:None) βWhether to drop zero values from the result. Defaults to module wide option (default: True). See
pypsa.options.params.statistics.describe()for more information. -
round(int | None, default:None) βNumber of decimal places to round the result to. Defaults to module wide option (default: 2). See
pypsa.options.params.statistics.describe()for more information.
Returns:
-
DataFrameβTime-averaged or load-weighted prices per bus or bus carrier.
Examples:
>>> n.statistics.prices()
Series([], dtype: float64)
pypsa.Network.statistics.revenue
ΒΆ
revenue(
components: str | Sequence[str] | None = None,
groupby_time: str | bool = "sum",
groupby_method: Callable | str = "sum",
aggregate_across_components: bool = False,
groupby: str | Sequence[str] | Callable = "carrier",
at_port: bool | str | Sequence[str] = True,
carrier: str | Sequence[str] | None = None,
bus_carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
drop_zero: bool | None = None,
round: int | None = None,
direction: str | None = None,
) -> DataFrame
Calculate the revenue of components in the network in given currency.
The revenue is defined as the net revenue of an asset, i.e cost of input - revenue of output.
Parameters:
-
components(str | Sequence[str] | None, default:None) βComponents to include in the calculation. If None, includes all one-port and branch components. Available components are 'Generator', 'StorageUnit', 'Store', 'Load', 'Line', 'Transformer' and'Link'.
-
groupby_method(Callable | str, default:"sum") βFunction to aggregate groups when using the groupby parameter. Any pandas aggregation function can be used.
-
aggregate_across_components(bool, default:False) βWhether to aggregate across components. If there are different components which would be grouped together due to the same index, this is avoided.
-
groupby(str | Sequence[str] | Callable, default:["carrier", "bus_carrier"]) βHow to group components: -
False: No grouping, return all components individually - string or list of strings: Group by column names from c.static - callable: Function that takes network and component name as arguments -
at_port(bool | str | Sequence[str], default:True) βWhich ports to consider: - True: All ports of components - False: Exclude first port ("bus"/"bus0") - str or list of str: Specific ports to include
-
carrier(str | Sequence[str] | None, default:None) βFilter by carrier. If specified, only considers assets with given carrier(s).
-
bus_carrier(str | Sequence[str] | None, default:None) βFilter by carrier of connected buses. If specified, only considers assets connected to buses with the given carrier(s).
-
nice_names(bool | None, default:None) βWhether to use carrier nice names defined in n.carriers.nice_name. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
drop_zero(bool | None, default:None) βWhether to drop zero values from the result. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
round(int | None, default:None) βNumber of decimal places to round the result to. Defaults to module wide option (default: 2). See
https://go.pypsa.org/options-paramsfor more information.
Other Parameters:
-
groupby_time(str | bool) βType of aggregation when aggregating time series. Deactivate by setting to False. Any pandas aggregation function can be used. Note that when aggregating the time series are aggregated to MWh using snapshot weightings. With False the time series is given in MW.
-
direction(str) βType of revenue to consider. If 'input' only the revenue of the input is considered. If 'output' only the revenue of the output is considered. Defaults to None.
Returns:
-
DataFrameβRevenue of components in the network with components as rows and either time steps as columns (if groupby_time=False) or a single column of aggregated values.
Examples:
>>> n.statistics.revenue()
Series([], dtype: float64)
pypsa.Network.statistics.supply
ΒΆ
supply(
components: str | Sequence[str] | None = None,
groupby_time: str | bool = "sum",
groupby_method: Callable | str = "sum",
aggregate_across_components: bool = False,
groupby: str | Sequence[str] | Callable = "carrier",
at_port: bool | str | Sequence[str] = True,
carrier: str | Sequence[str] | None = None,
bus_carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
drop_zero: bool | None = None,
round: int | None = None,
) -> DataFrame
Calculate the supply of components in the network.
Units depend on the regarded bus carrier.
Parameters:
-
components(str | Sequence[str] | None, default:None) βComponents to include in the calculation. If None, includes all one-port and branch components. Available components are 'Generator', 'StorageUnit', 'Store', 'Load', 'Line', 'Transformer' and'Link'.
-
groupby_method(Callable | str, default:"sum") βFunction to aggregate groups when using the groupby parameter. Any pandas aggregation function can be used.
-
aggregate_across_components(bool, default:False) βWhether to aggregate across components. If there are different components which would be grouped together due to the same index, this is avoided.
-
groupby(str | Sequence[str] | Callable, default:["carrier", "bus_carrier"]) βHow to group components: -
False: No grouping, return all components individually - string or list of strings: Group by column names from c.static - callable: Function that takes network and component name as arguments -
at_port(bool | str | Sequence[str], default:True) βWhich ports to consider: - True: All ports of components - False: Exclude first port ("bus"/"bus0") - str or list of str: Specific ports to include
-
carrier(str | Sequence[str] | None, default:None) βFilter by carrier. If specified, only considers assets with given carrier(s).
-
bus_carrier(str | Sequence[str] | None, default:None) βFilter by carrier of connected buses. If specified, only considers assets connected to buses with the given carrier(s).
-
nice_names(bool | None, default:None) βWhether to use carrier nice names defined in n.carriers.nice_name. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
drop_zero(bool | None, default:None) βWhether to drop zero values from the result. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
round(int | None, default:None) βNumber of decimal places to round the result to. Defaults to module wide option (default: 2). See
https://go.pypsa.org/options-paramsfor more information.
Other Parameters:
-
groupby_time(str | bool) βType of aggregation when aggregating time series. Deactivate by setting to False. Any pandas aggregation function can be used. Note that when aggregating the time series are aggregated to MWh using snapshot weightings. With False the time series is given in MW.
Returns:
-
DataFrameβSupply of components in the network with components as rows and either time steps as columns (if groupby_time=False) or a single column of aggregated values.
Examples:
>>> n.statistics.supply()
Series([], dtype: float64)
pypsa.Network.statistics.system_cost
ΒΆ
system_cost(
components: str | Sequence[str] | None = None,
groupby_time: str | bool = "sum",
groupby_method: Callable | str = "sum",
aggregate_across_components: bool = False,
groupby: str | Sequence[str] | Callable = "carrier",
at_port: bool | str | Sequence[str] = False,
carrier: str | Sequence[str] | None = None,
bus_carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
drop_zero: bool | None = None,
round: int | None = None,
) -> DataFrame
Calculate the total system cost.
Sum of the capital and operational expenditures.
Parameters:
-
components(str | Sequence[str] | None, default:None) βComponents to include in the calculation. If None, includes all one-port and branch components. Available components are 'Generator', 'StorageUnit', 'Store', 'Load', 'Line', 'Transformer' and'Link'.
-
groupby_method(Callable | str, default:"sum") βFunction to aggregate groups when using the groupby parameter. Any pandas aggregation function can be used.
-
aggregate_across_components(bool, default:False) βWhether to aggregate across components. If there are different components which would be grouped together due to the same index, this is avoided.
-
groupby(str | Sequence[str] | Callable, default:["carrier", "bus_carrier"]) βHow to group components: -
False: No grouping, return all components individually - string or list of strings: Group by column names from c.static - callable: Function that takes network and component name as arguments -
at_port(bool | str | Sequence[str], default:True) βWhich ports to consider: - True: All ports of components - False: Exclude first port ("bus"/"bus0") - str or list of str: Specific ports to include
-
carrier(str | Sequence[str] | None, default:None) βFilter by carrier. If specified, only considers assets with given carrier(s).
-
bus_carrier(str | Sequence[str] | None, default:None) βFilter by carrier of connected buses. If specified, only considers assets connected to buses with the given carrier(s).
-
nice_names(bool | None, default:None) βWhether to use carrier nice names defined in n.carriers.nice_name. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
drop_zero(bool | None, default:None) βWhether to drop zero values from the result. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
round(int | None, default:None) βNumber of decimal places to round the result to. Defaults to module wide option (default: 2). See
https://go.pypsa.org/options-paramsfor more information.
Other Parameters:
-
groupby_time(str | bool) βType of aggregation when aggregating time series. Deactivate by setting to False. Any pandas aggregation function can be used. Note that when aggregating the time series are aggregated to MWh using snapshot weightings. With False the time series is given in MW.
Returns:
-
DataFrameβSystem cost with components as rows and a single column of aggregated values.
Examples:
>>> n.statistics.system_cost()
Series([], dtype: float64)
pypsa.Network.statistics.transmission
ΒΆ
transmission(
components: Collection[str] | str | None = None,
groupby_time: str | bool = "sum",
groupby_method: Callable | str = "sum",
aggregate_across_components: bool = False,
groupby: str
| Sequence[str]
| Callable
| Literal[False] = "carrier",
at_port: bool | str | Sequence[str] = False,
carrier: str | Sequence[str] | None = None,
bus_carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
drop_zero: bool | None = None,
round: int | None = None,
) -> DataFrame
Calculate the transmission of branch components in the network.
Units depend on the regarded bus carrier.
Parameters:
-
components(str | Sequence[str] | None, default:None) βComponents to include in the calculation. If None, includes all one-port and branch components. Available components are 'Generator', 'StorageUnit', 'Store', 'Load', 'Line', 'Transformer' and'Link'.
-
groupby_method(Callable | str, default:"sum") βFunction to aggregate groups when using the groupby parameter. Any pandas aggregation function can be used.
-
aggregate_across_components(bool, default:False) βWhether to aggregate across components. If there are different components which would be grouped together due to the same index, this is avoided.
-
groupby(str | Sequence[str] | Callable, default:["carrier", "bus_carrier"]) βHow to group components: -
False: No grouping, return all components individually - string or list of strings: Group by column names from c.static - callable: Function that takes network and component name as arguments -
at_port(bool | str | Sequence[str], default:True) βWhich ports to consider: - True: All ports of components - False: Exclude first port ("bus"/"bus0") - str or list of str: Specific ports to include
-
carrier(str | Sequence[str] | None, default:None) βFilter by carrier. If specified, only considers assets with given carrier(s).
-
bus_carrier(str | Sequence[str] | None, default:None) βFilter by carrier of connected buses. If specified, only considers assets connected to buses with the given carrier(s).
-
nice_names(bool | None, default:None) βWhether to use carrier nice names defined in n.carriers.nice_name. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
drop_zero(bool | None, default:None) βWhether to drop zero values from the result. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
round(int | None, default:None) βNumber of decimal places to round the result to. Defaults to module wide option (default: 2). See
https://go.pypsa.org/options-paramsfor more information.
Other Parameters:
-
groupby_time(str | bool) βType of aggregation when aggregating time series. Deactivate by setting to False. Any pandas aggregation function can be used. Note that when aggregating the time series are aggregated to MWh using snapshot weightings. With False the time series is given in MW.
Returns:
-
DataFrameβTransmission of branch components in the network with components as rows and either time steps as columns (if groupby_time=False) or a single column of aggregated values.
Examples:
>>> n.statistics.transmission()
Series([], dtype: object)
pypsa.Network.statistics.withdrawal
ΒΆ
withdrawal(
components: str | Sequence[str] | None = None,
groupby_time: str | bool = "sum",
groupby_method: Callable | str = "sum",
aggregate_across_components: bool = False,
groupby: str | Sequence[str] | Callable = "carrier",
at_port: bool | str | Sequence[str] = True,
carrier: str | Sequence[str] | None = None,
bus_carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
drop_zero: bool | None = None,
round: int | None = None,
) -> DataFrame
Calculate the withdrawal of components in the network.
Units depend on the regarded bus carrier.
Parameters:
-
components(str | Sequence[str] | None, default:None) βComponents to include in the calculation. If None, includes all one-port and branch components. Available components are 'Generator', 'StorageUnit', 'Store', 'Load', 'Line', 'Transformer' and'Link'.
-
groupby_method(Callable | str, default:"sum") βFunction to aggregate groups when using the groupby parameter. Any pandas aggregation function can be used.
-
aggregate_across_components(bool, default:False) βWhether to aggregate across components. If there are different components which would be grouped together due to the same index, this is avoided.
-
groupby(str | Sequence[str] | Callable, default:["carrier", "bus_carrier"]) βHow to group components: -
False: No grouping, return all components individually - string or list of strings: Group by column names from c.static - callable: Function that takes network and component name as arguments -
at_port(bool | str | Sequence[str], default:True) βWhich ports to consider: - True: All ports of components - False: Exclude first port ("bus"/"bus0") - str or list of str: Specific ports to include
-
carrier(str | Sequence[str] | None, default:None) βFilter by carrier. If specified, only considers assets with given carrier(s).
-
bus_carrier(str | Sequence[str] | None, default:None) βFilter by carrier of connected buses. If specified, only considers assets connected to buses with the given carrier(s).
-
nice_names(bool | None, default:None) βWhether to use carrier nice names defined in n.carriers.nice_name. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
drop_zero(bool | None, default:None) βWhether to drop zero values from the result. Defaults to module wide option (default: True). See
https://go.pypsa.org/options-paramsfor more information. -
round(int | None, default:None) βNumber of decimal places to round the result to. Defaults to module wide option (default: 2). See
https://go.pypsa.org/options-paramsfor more information.
Other Parameters:
-
groupby_time(str | bool) βType of aggregation when aggregating time series. Deactivate by setting to False. Any pandas aggregation function can be used. Note that when aggregating the time series are aggregated to MWh using snapshot weightings. With False the time series is given in MW.
Returns:
-
DataFrameβWithdrawal of components in the network with components as rows and either time steps as columns (if groupby_time=False) or a single column of aggregated values.
Examples:
>>> n.statistics.withdrawal()
Series([], dtype: float64)
Groupers
ΒΆ
Container for all the get_ methods.
Methods:
-
__getitem__βGet a single or multi-indexed grouper method.
-
__repr__βGet representation of the grouper container.
-
__setitem__βSet a custom grouper method.
-
add_grouperβAdd a custom grouper to groupers on module level.
-
busβGrouper method to group by the attached bus of the components.
-
bus_carrierβGrouper method to group by the carrier of the attached bus of a component.
-
carrierβGrouper method to group by the carrier of the components.
-
countryβGrouper method to group by the country of the components corresponding bus.
-
list_groupersβList all available groupers which are avaliable on the module level.
-
locationβGrouper method to group by the location of the components corresponding bus.
-
nameβGrouper method to group by the name of components.
-
unitβGrouper method to group by the unit of the components corresponding bus.
pypsa.statistics.Groupers.__getitem__
ΒΆ
__getitem__(
keys: str | Callable | Sequence[str | Callable],
) -> Callable
Get a single or multi-indexed grouper method.
Parameters:
-
keys(str | Callable | Sequence[str | Callable]) βSingle or multiple keys to get the grouper method.
Returns:
-
CallableβGrouper method.
Examples:
Single indexed grouper
>>> pypsa.statistics.groupers["carrier"]
<function Groupers._multi_grouper.<locals>.multi_grouper at 0x...>
Multi-indexed grouper
>>> pypsa.statistics.groupers[["carrier", "bus"]]
<function Groupers._multi_grouper.<locals>.multi_grouper at 0x...>
pypsa.statistics.Groupers.__repr__
ΒΆ
__repr__() -> str
Get representation of the grouper container.
Examples:
>>> pypsa.statistics.groupers
Grouper container with the following groupers: bus, bus_carrier, ...
pypsa.statistics.Groupers.__setitem__
ΒΆ
__setitem__(key: str, value: Callable) -> None
Set a custom grouper method.
Parameters:
-
key(str) βName of the custom grouper.
-
value(Callable) βCustom grouper function.
pypsa.statistics.Groupers.add_grouper
ΒΆ
add_grouper(name: str, func: Callable) -> None
Add a custom grouper to groupers on module level.
After registering a custom grouper, it can be accessed via the groupers module level object and used in the statistics methods or as a groupers method.
Parameters:
-
name(str) βName of the custom grouper. This will be used as the key in the groupby argument.
-
func(Callable) βCustom grouper function, which must return a pandas Series with the same length as the component index and accept as arguments: * n (Network): The PyPSA network instance * c (str): Component name * port (str): Component port as integer string * nice_names (bool, optional): Whether to use nice carrier names
pypsa.statistics.Groupers.bus
ΒΆ
bus(n: Network, c: str, port: str = '') -> Series
Grouper method to group by the attached bus of the components.
Parameters:
-
n(Network) βPyPSA network instance.
-
c(str) βComponents type name. E.g. "Generator", "StorageUnit", etc.
-
port(str, default:'') βPort of corresponding bus, which should be used.
Returns:
-
SeriesβSeries with the bus of the components.
pypsa.statistics.Groupers.bus_carrier
ΒΆ
bus_carrier(
n: Network,
c: str,
port: str = "",
nice_names: bool = True,
) -> Series
Grouper method to group by the carrier of the attached bus of a component.
Parameters:
-
n(Network) βPyPSA network instance.
-
c(str) βComponents type name. E.g. "Generator", "StorageUnit", etc.
-
port(str, default:'') βPort of corresponding bus, which should be used.
-
nice_names(bool, default:True) βWhether to use nice carrier names.
Returns:
-
SeriesβSeries with the bus and carrier of the components.
pypsa.statistics.Groupers.carrier
ΒΆ
carrier(
n: Network, c: str, nice_names: bool = True
) -> Series
Grouper method to group by the carrier of the components.
Parameters:
-
n(Network) βPyPSA network instance.
-
c(str) βComponents type name. E.g. "Generator", "StorageUnit", etc.
-
nice_names(bool, default:True) βWhether to use nice carrier names.
Returns:
-
SeriesβSeries with the carrier of the components.
pypsa.statistics.Groupers.country
ΒΆ
country(n: Network, c: str, port: str = '') -> Series
Grouper method to group by the country of the components corresponding bus.
Parameters:
-
n(Network) βPyPSA network instance.
-
c(str) βComponents type name. E.g. "Generator", "StorageUnit", etc.
-
port(str, default:'') βPort of corresponding bus, which should be used.
Returns:
-
SeriesβSeries with the country of the components corresponding bus.
pypsa.statistics.Groupers.list_groupers
ΒΆ
list_groupers() -> dict
List all available groupers which are avaliable on the module level.
Returns:
-
dictβDictionary with all available groupers. The keys are the grouper names and the values are the grouper methods. The keys can be used to directly access the grouper in any
groupbyargument.
Examples:
>>> pypsa.statistics.groupers.list_groupers().keys()
dict_keys(['bus', 'bus_carrier', ...
pypsa.statistics.Groupers.location
ΒΆ
location(n: Network, c: str, port: str = '') -> Series
Grouper method to group by the location of the components corresponding bus.
Parameters:
-
n(Network) βPyPSA network instance.
-
c(str) βComponents type name. E.g. "Generator", "StorageUnit", etc.
-
port(str, default:'') βPort of corresponding bus, which should be used.
Returns:
-
SeriesβSeries with the location of the components corresponding bus.
pypsa.statistics.Groupers.name
ΒΆ
name(n: Network, c: str) -> Series
Grouper method to group by the name of components.
Parameters:
-
n(Network) βPyPSA network instance.
-
c(str) βComponents type name. E.g. "Generator", "StorageUnit", etc.
Returns:
-
SeriesβSeries with the component names.
pypsa.statistics.Groupers.unit
ΒΆ
unit(n: Network, c: str, port: str = '') -> Series
Grouper method to group by the unit of the components corresponding bus.
Parameters:
-
n(Network) βPyPSA network instance.
-
c(str) βComponents type name. E.g. "Generator", "StorageUnit", etc.
-
port(str, default:'') βPort of corresponding bus, which should be used.
Returns:
-
SeriesβSeries with the unit of the components corresponding bus.
StatisticExpressionsAccessor
ΒΆ
StatisticExpressionsAccessor(
n: Network | NetworkCollection,
)
Bases: AbstractStatisticsAccessor
Accessor to calculate different statistical expressions.
This class is used to calculate different statistical expressions like capital expenditure, capacity, energy balance, etc. The results are aggregated by the given groupby function.
Methods:
-
capacityβCalculate the optimal capacity of the network components in MW.
-
capexβCalculate the capital expenditure of the network in given currency.
-
curtailmentβCalculate the curtailment of components in the network in MWh.
-
energy_balanceβCalculate the energy balance of components in the network.
-
operationβCalculate the operation of components in the network.
-
opexβCalculate the operational expenditure in the network in given currency.
-
supplyβCalculate the supply of components in the network.
-
transmissionβCalculate the transmission of branch components in the network.
-
withdrawalβCalculate the withdrawal of components in the network.
pypsa.optimization.expressions.StatisticExpressionsAccessor.capacity
ΒΆ
capacity(
components: str | Sequence[str] | None = None,
groupby_method: str = "sum",
aggregate_across_components: bool = False,
groupby: str | Sequence[str] | Callable = "carrier",
at_port: str | Sequence[str] | bool | None = None,
bus_carrier: str | Sequence[str] | None = None,
carrier: str | Sequence[str] | None = None,
storage: bool = False,
nice_names: bool | None = None,
include_non_extendable: bool = True,
) -> LinearExpression
Calculate the optimal capacity of the network components in MW.
If bus_carrier is given, the capacity is weighed by the output efficiency
of components at buses with carrier bus_carrier.
If storage is set to True, only storage capacities of the component
Store and StorageUnit are taken into account.
For information on the list of arguments, see the docs in
Network.statistics or pypsa.Network.statistics.
pypsa.optimization.expressions.StatisticExpressionsAccessor.capex
ΒΆ
capex(
components: str | Sequence[str] | None = None,
groupby_method: str = "sum",
aggregate_across_components: bool = False,
groupby: str | Sequence[str] | Callable = "carrier",
at_port: bool | str | Sequence[str] = False,
bus_carrier: str | Sequence[str] | None = None,
carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
cost_attribute: str = "capital_cost",
include_non_extendable: bool = True,
) -> LinearExpression
Calculate the capital expenditure of the network in given currency.
If bus_carrier is given, only components which are connected to buses
with carrier bus_carrier are considered.
For information on the list of arguments, see the docs in
Network.statistics or pypsa.Network.statistics.
pypsa.optimization.expressions.StatisticExpressionsAccessor.curtailment
ΒΆ
curtailment(
components: str | Sequence[str] | None = None,
groupby_time: str | bool = "sum",
groupby_method: str = "sum",
aggregate_across_components: bool = False,
groupby: str | Sequence[str] | Callable = "carrier",
at_port: bool | str | Sequence[str] = False,
bus_carrier: str | Sequence[str] | None = None,
carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
) -> LinearExpression
Calculate the curtailment of components in the network in MWh.
The calculation only considers assets with a p_max_pu time
series, which is used to quantify the available power potential.
If bus_carrier is given, only the assets are considered which are
connected to buses with carrier bus_carrier.
For information on the list of arguments, see the docs in
Network.statistics or pypsa.Network.statistics.
Parameters:
-
groupby_time((str, bool), default:'sum') βType of aggregation when aggregating time series. Note that for {'mean', 'sum'} the time series are aggregated to MWh using snapshot weightings. With False the time series is given in MW. Defaults to 'sum'.
pypsa.optimization.expressions.StatisticExpressionsAccessor.energy_balance
ΒΆ
energy_balance(
components: str | Sequence[str] | None = None,
groupby_time: str | bool = "sum",
groupby_method: str = "sum",
aggregate_across_components: bool = False,
groupby: str | Sequence[str] | Callable | None = None,
at_port: bool | str | Sequence[str] = True,
bus_carrier: str | Sequence[str] | None = None,
carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
kind: str | None = None,
) -> LinearExpression
Calculate the energy balance of components in the network.
Positive values represent a supply and negative a withdrawal. Units depend on the regarded bus carrier.
For information on the list of arguments, see the docs in
Network.statistics or pypsa.Network.statistics.
Additional parameter
aggregate_bus: bool, optional Whether to obtain the nodal or carrier-wise energy balance. Default is True, corresponding to the carrier-wise balance. groupby_time : str, bool, optional Type of aggregation when aggregating time series. Note that for {'mean', 'sum'} the time series are aggregated to MWh using snapshot weightings. With False the time series is given in MW. Defaults to 'sum'.
pypsa.optimization.expressions.StatisticExpressionsAccessor.operation
ΒΆ
operation(
components: str | Sequence[str] | None = None,
groupby_time: str | bool = "mean",
groupby_method: str = "sum",
aggregate_across_components: bool = False,
at_port: bool | str | Sequence[str] = False,
groupby: str | Sequence[str] | Callable = "carrier",
bus_carrier: str | Sequence[str] | None = None,
carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
) -> LinearExpression
Calculate the operation of components in the network.
If bus_carrier is given, only the assets are considered which are
connected to buses with carrier bus_carrier.
For information on the list of arguments, see the docs in
Network.statistics or pypsa.Network.statistics.
Parameters:
-
groupby_time((str, bool), default:'mean') βType of aggregation when aggregating time series. Note that for {'mean', 'sum'} the time series are aggregated to using snapshot weightings. With False the time series is given. Defaults to 'mean'.
pypsa.optimization.expressions.StatisticExpressionsAccessor.opex
ΒΆ
opex(
components: str | Sequence[str] | None = None,
groupby_time: str | bool = "sum",
groupby_method: str = "sum",
aggregate_across_components: bool = False,
groupby: str | Sequence[str] | Callable = "carrier",
at_port: bool | str | Sequence[str] = False,
bus_carrier: str | Sequence[str] | None = None,
carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
) -> LinearExpression
Calculate the operational expenditure in the network in given currency.
If bus_carrier is given, only components which are connected to buses
with carrier bus_carrier are considered.
For information on the list of arguments, see the docs in
Network.statistics or pypsa.Network.statistics.
Parameters:
-
groupby_time((str, bool), default:'sum') βType of aggregation when aggregating time series. Note that for {'mean', 'sum'} the time series are aggregated using snapshot weightings. With False the time series is given in currency/hour. Defaults to 'sum'.
pypsa.optimization.expressions.StatisticExpressionsAccessor.supply
ΒΆ
supply(
components: str | Sequence[str] | None = None,
groupby_time: str | bool = "sum",
groupby_method: str = "sum",
aggregate_across_components: bool = False,
groupby: str | Sequence[str] | Callable | None = None,
at_port: bool | str | Sequence[str] = True,
bus_carrier: str | Sequence[str] | None = None,
carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
) -> LinearExpression
Calculate the supply of components in the network.
Units depend on the regarded bus carrier.
If bus_carrier is given, only the supply to buses with carrier
bus_carrier is calculated.
For information on the list of arguments, see the docs in
Network.statistics or pypsa.statitics.StatisticsAccessor.
pypsa.optimization.expressions.StatisticExpressionsAccessor.transmission
ΒΆ
transmission(
components: Collection[str] | str | None = None,
groupby_time: str | bool = "sum",
groupby_method: str = "sum",
aggregate_across_components: bool = False,
groupby: str | Sequence[str] | Callable = "carrier",
at_port: bool | str | Sequence[str] = False,
bus_carrier: str | Sequence[str] | None = None,
carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
) -> LinearExpression
Calculate the transmission of branch components in the network.
Units depend on the regarded bus carrier.
If bus_carrier is given, only the flow between buses with
carrier bus_carrier is calculated.
For information on the list of arguments, see the docs in
Network.statistics or pypsa.Network.statistics.
Parameters:
-
groupby_time((str, bool), default:'sum') βType of aggregation when aggregating time series. Note that for {'mean', 'sum'} the time series are aggregated to MWh using snapshot weightings. With False the time series is given in MW. Defaults to 'sum'.
pypsa.optimization.expressions.StatisticExpressionsAccessor.withdrawal
ΒΆ
withdrawal(
components: str | Sequence[str] | None = None,
groupby_time: str | bool = "sum",
groupby_method: str = "sum",
aggregate_across_components: bool = False,
groupby: str | Sequence[str] | Callable | None = None,
at_port: bool | str | Sequence[str] = True,
bus_carrier: str | Sequence[str] | None = None,
carrier: str | Sequence[str] | None = None,
nice_names: bool | None = None,
) -> LinearExpression
Calculate the withdrawal of components in the network.
Units depend on the regarded bus carrier.
If bus_carrier is given, only the withdrawal from buses with
carrier bus_carrier is calculated.
For information on the list of arguments, see the docs in
Network.statistics or pypsa.statitics.StatisticsAccessor.