build_renewable_profiles: Compute underwater_fraction
This commit is contained in:
parent
4dc8e8fc35
commit
448ba651a0
@ -107,6 +107,7 @@ rule build_renewable_profiles:
|
|||||||
natura="resources/natura.tiff",
|
natura="resources/natura.tiff",
|
||||||
gebco="data/bundle/GEBCO_2014_2D.nc",
|
gebco="data/bundle/GEBCO_2014_2D.nc",
|
||||||
country_shapes='resources/country_shapes.geojson',
|
country_shapes='resources/country_shapes.geojson',
|
||||||
|
offshore_shapes='resources/offshore_shapes.geojson',
|
||||||
regions=lambda wildcards: ("resources/regions_onshore.geojson"
|
regions=lambda wildcards: ("resources/regions_onshore.geojson"
|
||||||
if wildcards.technology in ('onwind', 'solar')
|
if wildcards.technology in ('onwind', 'solar')
|
||||||
else "resources/regions_offshore.geojson"),
|
else "resources/regions_offshore.geojson"),
|
||||||
|
@ -99,7 +99,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
with Pool(initializer=init_globals, initargs=(bounds, dx, dy),
|
with Pool(initializer=init_globals, initargs=(bounds, dx, dy),
|
||||||
maxtasksperchild=20, processes=snakemake.config['atlite'].get('nprocesses', 2)) as pool:
|
maxtasksperchild=20, processes=snakemake.config['atlite'].get('nprocesses', 2)) as pool:
|
||||||
regions = gk.vector.extractFeatures(snakemake.input.regions, onlyAttr=True) #.iloc[:10]
|
regions = gk.vector.extractFeatures(snakemake.input.regions, onlyAttr=True).iloc[:10]
|
||||||
buses = pd.Index(regions['name'], name="bus")
|
buses = pd.Index(regions['name'], name="bus")
|
||||||
widgets = [
|
widgets = [
|
||||||
pgb.widgets.Percentage(),
|
pgb.widgets.Percentage(),
|
||||||
@ -163,6 +163,7 @@ if __name__ == '__main__':
|
|||||||
row = layoutmatrix[i]
|
row = layoutmatrix[i]
|
||||||
distances = haversine(regions.loc[i, ['x', 'y']], cell_coords[row.indices])[0]
|
distances = haversine(regions.loc[i, ['x', 'y']], cell_coords[row.indices])[0]
|
||||||
average_distance.append((distances * (row.data / row.data.sum())).sum())
|
average_distance.append((distances * (row.data / row.data.sum())).sum())
|
||||||
|
|
||||||
average_distance = xr.DataArray(average_distance, [buses])
|
average_distance = xr.DataArray(average_distance, [buses])
|
||||||
|
|
||||||
ds = xr.merge([(correction_factor * profile).rename('profile'),
|
ds = xr.merge([(correction_factor * profile).rename('profile'),
|
||||||
@ -170,5 +171,20 @@ if __name__ == '__main__':
|
|||||||
p_nom_max.rename('p_nom_max'),
|
p_nom_max.rename('p_nom_max'),
|
||||||
layout.rename('potential'),
|
layout.rename('potential'),
|
||||||
average_distance.rename('average_distance')])
|
average_distance.rename('average_distance')])
|
||||||
|
|
||||||
|
if snakemake.wildcards.technology.startswith("offwind"):
|
||||||
|
import geopandas as gpd
|
||||||
|
from shapely.geometry import LineString
|
||||||
|
|
||||||
|
offshore_shape = gpd.read_file(snakemake.input.offshore_shapes).set_index('id').unary_union
|
||||||
|
underwater_fraction = []
|
||||||
|
for i in regions.index:
|
||||||
|
row = layoutmatrix[i]
|
||||||
|
centre_of_mass = (cell_coords[row.indices] * (row.data / row.data.sum())[:,np.newaxis]).sum(axis=0)
|
||||||
|
line = LineString([centre_of_mass, regions.loc[i, ['x', 'y']]])
|
||||||
|
underwater_fraction.append(line.intersection(offshore_shape).length / line.length)
|
||||||
|
|
||||||
|
ds['underwater_fraction'] = xr.DataArray(underwater_fraction, [buses])
|
||||||
|
|
||||||
(ds.sel(bus=(ds['profile'].mean('time') > config.get('min_p_max_pu', 0.)) & (ds['p_nom_max'] > 0.))
|
(ds.sel(bus=(ds['profile'].mean('time') > config.get('min_p_max_pu', 0.)) & (ds['p_nom_max'] > 0.))
|
||||||
.to_netcdf(snakemake.output.profile))
|
.to_netcdf(snakemake.output.profile))
|
||||||
|
Loading…
Reference in New Issue
Block a user