Merge branch 'eu-energy-security' of github.com:PyPSA/pypsa-eur into eu-energy-security

This commit is contained in:
Fabian 2022-06-09 20:36:35 +02:00
commit 76cd0751b4
6 changed files with 28 additions and 9 deletions

View File

@ -73,6 +73,10 @@ Upcoming Release
* A new section ``conventional`` was added to the config file. This section contains configurations for conventional carriers. Using the ``energy_availibility_factor`` key, the ``p_max_pu`` values for conventional power plants can be defined.
* Fix crs bug. Change crs 4236 to 4326.
* Update rasterio version to correctly calculate exclusion raster
Synchronisation Release - Ukraine and Moldova (17th March 2022)
===============================================================

View File

@ -43,7 +43,7 @@ For more information on the data dependencies of PyPSA-Eur, continue reading :re
How to customise PyPSA-Eur?
===========================
The model can be adapted to only include selected countries (e.g. Germany) instead of all European countries to limit the spatial scope.
The model can be adapted to only include selected countries (e.g. Belgium) instead of all European countries to limit the spatial scope.
.. literalinclude:: ../config.tutorial.yaml
:language: yaml

View File

@ -24,6 +24,7 @@ dependencies:
- yaml
- pytables
- lxml
- powerplantmatching>=0.5.3
- numpy
- pandas
- geopandas
@ -45,7 +46,7 @@ dependencies:
# GIS dependencies:
- cartopy
- descartes
- rasterio
- rasterio<=1.2.9 # 1.2.10 creates error https://github.com/PyPSA/atlite/issues/238
# PyPSA-Eur-Sec Dependencies
- geopy

View File

@ -94,7 +94,6 @@ import geopandas as gpd
import powerplantmatching as pm
from powerplantmatching.export import map_country_bus
from vresutils.costdata import annuity
from vresutils import transfer as vtransfer
idx = pd.IndexSlice
@ -105,6 +104,18 @@ logger = logging.getLogger(__name__)
def normed(s): return s/s.sum()
def calculate_annuity(n, r):
"""Calculate the annuity factor for an asset with lifetime n years and
discount rate of r, e.g. annuity(20, 0.05) * 20 = 1.6"""
if isinstance(r, pd.Series):
return pd.Series(1/n, index=r.index).where(r == 0, r/(1. - 1./(1.+r)**n))
elif r > 0:
return r / (1. - 1./(1.+r)**n)
else:
return 1 / n
def _add_missing_carriers_from_costs(n, costs, carriers):
missing_carriers = pd.Index(carriers).difference(n.carriers.index)
if missing_carriers.empty: return
@ -138,7 +149,7 @@ def load_costs(tech_costs, config, elec_config, Nyears=1.):
"investment" : 0,
"lifetime" : 25})
costs["capital_cost"] = ((annuity(costs["lifetime"], costs["discount rate"]) +
costs["capital_cost"] = ((calculate_annuity(costs["lifetime"], costs["discount rate"]) +
costs["FOM"]/100.) *
costs["investment"] * Nyears)

View File

@ -240,7 +240,7 @@ if __name__ == '__main__':
# use named function np.greater with partially frozen argument instead
# and exclude areas where: -max_depth > grid cell depth
func = functools.partial(np.greater,-config['max_depth'])
excluder.add_raster(snakemake.input.gebco, codes=func, crs=4236, nodata=-1000)
excluder.add_raster(snakemake.input.gebco, codes=func, crs=4326, nodata=-1000)
if 'min_shore_distance' in config:
buffer = config['min_shore_distance']

View File

@ -171,6 +171,9 @@ def calculate_capacity(n,label,capacity):
if 'p_nom_opt' in c.df.columns:
c_capacities = abs(c.df.p_nom_opt.multiply(c.df.sign)).groupby(c.df.carrier).sum()
capacity = include_in_summary(capacity, [c.list_name], label, c_capacities)
elif 'e_nom_opt' in c.df.columns:
c_capacities = abs(c.df.e_nom_opt.multiply(c.df.sign)).groupby(c.df.carrier).sum()
capacity = include_in_summary(capacity, [c.list_name], label, c_capacities)
for c in n.iterate_components(n.passive_branch_components):
c_capacities = c.df['s_nom_opt'].groupby(c.df.carrier).sum()
@ -185,11 +188,11 @@ def calculate_capacity(n,label,capacity):
def calculate_supply(n, label, supply):
"""calculate the max dispatch of each component at the buses where the loads are attached"""
load_types = n.loads.carrier.value_counts().index
load_types = n.buses.carrier.unique()
for i in load_types:
buses = n.loads.bus[n.loads.carrier == i].values
buses = n.buses.query("carrier == @i").index
bus_map = pd.Series(False,index=n.buses.index)
@ -232,11 +235,11 @@ def calculate_supply(n, label, supply):
def calculate_supply_energy(n, label, supply_energy):
"""calculate the total dispatch of each component at the buses where the loads are attached"""
load_types = n.loads.carrier.value_counts().index
load_types = n.buses.carrier.unique()
for i in load_types:
buses = n.loads.bus[n.loads.carrier == i].values
buses = n.buses.query("carrier == @i").index
bus_map = pd.Series(False,index=n.buses.index)