line rating assigned in add_electricity.py
This commit is contained in:
parent
7e628f66c5
commit
af4bccfb39
@ -221,7 +221,7 @@ if config['lines'].get('line_rating', False):
|
||||
base_network="networks/base.nc",
|
||||
cutout="cutouts/" + config["lines"]['cutout'] + ".nc"
|
||||
output:
|
||||
output="networks/base_lr.nc"
|
||||
output="resources/line_rating.nc"
|
||||
log: "logs/build_line_rating.log"
|
||||
benchmark: "benchmarks/build_line_rating"
|
||||
threads: 1
|
||||
@ -230,9 +230,10 @@ if config['lines'].get('line_rating', False):
|
||||
|
||||
rule add_electricity:
|
||||
input:
|
||||
base_network = "networks/base_lr.nc" if config['lines'].get('line_rating', False) else "networks/base.nc",
|
||||
base_network = "networks/base.nc",
|
||||
tech_costs=COSTS,
|
||||
regions="resources/regions_onshore.geojson",
|
||||
line_rating="resources/line_rating.nc" if config['lines'].get('line_rating', False) else None,
|
||||
powerplants='resources/powerplants.csv',
|
||||
hydro_capacities='data/bundle/hydro_capacities.csv',
|
||||
geth_hydro_capacities='data/geth2015_hydro_capacities.csv',
|
||||
|
@ -539,6 +539,11 @@ def estimate_renewable_capacities(n, tech_map=None):
|
||||
.where(lambda s: s>0.1, 0.)) # only capacities above 100kW
|
||||
n.generators.loc[tech_i, 'p_nom_min'] = n.generators.loc[tech_i, 'p_nom']
|
||||
|
||||
def attach_line_rating(n):
|
||||
if snakemake.config["lines"]["line_rating"]:
|
||||
s=xr.open_dataarray(snakemake.input.line_rating)
|
||||
n.lines_t.s_max_pu=s.to_pandas().transpose()/n.lines.s_nom
|
||||
n.lines_t.s_max_pu.replace(np.inf, 1.0, inplace=True)
|
||||
|
||||
def add_nice_carrier_names(n, config=None):
|
||||
if config is None: config = snakemake.config
|
||||
@ -575,9 +580,11 @@ if __name__ == "__main__":
|
||||
attach_hydro(n, costs, ppl)
|
||||
attach_extendable_generators(n, costs, ppl)
|
||||
|
||||
|
||||
estimate_renewable_capacities(n)
|
||||
attach_OPSD_renewables(n)
|
||||
update_p_nom_max(n)
|
||||
attach_line_rating(n)
|
||||
|
||||
add_nice_carrier_names(n)
|
||||
|
||||
|
@ -57,6 +57,7 @@ import numpy as np
|
||||
import geopandas as gpd
|
||||
from shapely.geometry import Point, LineString as Line
|
||||
import atlite
|
||||
import xarray as xr
|
||||
|
||||
|
||||
def add_line_rating(n):
|
||||
@ -66,9 +67,12 @@ def add_line_rating(n):
|
||||
shapes = [Line([Point(x[b0], y[b0]), Point(x[b1], y[b1])]) for (b0, b1) in buses]
|
||||
shapes = gpd.GeoSeries(shapes, index=n.lines.index)
|
||||
cutout = atlite.Cutout(snakemake.input.cutout)
|
||||
s = np.sqrt(3) * cutout.line_rating(shapes, n.lines.r/n.lines.length) * 1e3 # in MW
|
||||
n.lines_t.s_max_pu=s.to_pandas().transpose()/n.lines.s_nom
|
||||
n.lines_t.s_max_pu.replace(np.inf, 1.0, inplace=True)
|
||||
da = xr.DataArray(data=np.sqrt(3) * cutout.line_rating(shapes, n.lines.r/n.lines.length) * 1e3,
|
||||
attrs=dict(description="Maximal possible power for given line considering line rating")) # in MW
|
||||
return da
|
||||
#import netcdf file in add electricity.py
|
||||
#n.lines_t.s_max_pu=s.to_pandas().transpose()/n.lines.s_nom
|
||||
#n.lines_t.s_max_pu.replace(np.inf, 1.0, inplace=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
@ -79,6 +83,6 @@ if __name__ == "__main__":
|
||||
configure_logging(snakemake)
|
||||
|
||||
n = pypsa.Network(snakemake.input.base_network)
|
||||
add_line_rating(n)
|
||||
da=add_line_rating(n)
|
||||
|
||||
n.export_to_netcdf(snakemake.output[0])
|
||||
da.to_netcdf(snakemake.output[0])
|
Loading…
Reference in New Issue
Block a user