Merge branch 'master' into configs-in-one-folder
This commit is contained in:
commit
eca0a89152
@ -39,7 +39,7 @@ repos:
|
|||||||
|
|
||||||
# Make docstrings PEP 257 compliant
|
# Make docstrings PEP 257 compliant
|
||||||
- repo: https://github.com/PyCQA/docformatter
|
- repo: https://github.com/PyCQA/docformatter
|
||||||
rev: v1.5.1
|
rev: v1.6.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: docformatter
|
- id: docformatter
|
||||||
args: ["--in-place", "--make-summary-multi-line", "--pre-summary-newline"]
|
args: ["--in-place", "--make-summary-multi-line", "--pre-summary-newline"]
|
||||||
@ -74,7 +74,7 @@ repos:
|
|||||||
|
|
||||||
# Format Snakemake rule / workflow files
|
# Format Snakemake rule / workflow files
|
||||||
- repo: https://github.com/snakemake/snakefmt
|
- repo: https://github.com/snakemake/snakefmt
|
||||||
rev: v0.8.3
|
rev: v0.8.4
|
||||||
hooks:
|
hooks:
|
||||||
- id: snakefmt
|
- id: snakefmt
|
||||||
|
|
||||||
|
@ -400,7 +400,6 @@ def override_component_attrs(directory):
|
|||||||
-------
|
-------
|
||||||
Dictionary of overridden component attributes.
|
Dictionary of overridden component attributes.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
attrs = Dict({k: v.copy() for k, v in component_attrs.items()})
|
attrs = Dict({k: v.copy() for k, v in component_attrs.items()})
|
||||||
|
|
||||||
for component, list_name in components.list_name.items():
|
for component, list_name in components.list_name.items():
|
||||||
@ -418,7 +417,6 @@ def generate_periodic_profiles(dt_index, nodes, weekly_profile, localize=None):
|
|||||||
country for the period dt_index, taking account of time zones and summer
|
country for the period dt_index, taking account of time zones and summer
|
||||||
time.
|
time.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
weekly_profile = pd.Series(weekly_profile, range(24 * 7))
|
weekly_profile = pd.Series(weekly_profile, range(24 * 7))
|
||||||
|
|
||||||
week_df = pd.DataFrame(index=dt_index, columns=nodes)
|
week_df = pd.DataFrame(index=dt_index, columns=nodes)
|
||||||
|
@ -38,7 +38,6 @@ def add_build_year_to_new_assets(n, baseyear):
|
|||||||
baseyear : int
|
baseyear : int
|
||||||
year in which optimized assets are built
|
year in which optimized assets are built
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Give assets with lifetimes and no build year the build year baseyear
|
# Give assets with lifetimes and no build year the build year baseyear
|
||||||
for c in n.iterate_components(["Link", "Generator", "Store"]):
|
for c in n.iterate_components(["Link", "Generator", "Store"]):
|
||||||
assets = c.df.index[(c.df.lifetime != np.inf) & (c.df.build_year == 0)]
|
assets = c.df.index[(c.df.lifetime != np.inf) & (c.df.build_year == 0)]
|
||||||
@ -62,7 +61,6 @@ def add_existing_renewables(df_agg):
|
|||||||
Append existing renewables to the df_agg pd.DataFrame with the conventional
|
Append existing renewables to the df_agg pd.DataFrame with the conventional
|
||||||
power plants.
|
power plants.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
carriers = {"solar": "solar", "onwind": "onwind", "offwind": "offwind-ac"}
|
carriers = {"solar": "solar", "onwind": "onwind", "offwind": "offwind-ac"}
|
||||||
|
|
||||||
for tech in ["solar", "onwind", "offwind"]:
|
for tech in ["solar", "onwind", "offwind"]:
|
||||||
|
@ -68,7 +68,6 @@ def enspreso_biomass_potentials(year=2020, scenario="ENS_Low"):
|
|||||||
Biomass potentials for given year and scenario
|
Biomass potentials for given year and scenario
|
||||||
in TWh/a by commodity and NUTS2 region.
|
in TWh/a by commodity and NUTS2 region.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
glossary = pd.read_excel(
|
glossary = pd.read_excel(
|
||||||
str(snakemake.input.enspreso_biomass),
|
str(snakemake.input.enspreso_biomass),
|
||||||
sheet_name="Glossary",
|
sheet_name="Glossary",
|
||||||
@ -124,7 +123,6 @@ def disaggregate_nuts0(bio):
|
|||||||
-------
|
-------
|
||||||
pd.DataFrame
|
pd.DataFrame
|
||||||
"""
|
"""
|
||||||
|
|
||||||
pop = build_nuts_population_data()
|
pop = build_nuts_population_data()
|
||||||
|
|
||||||
# get population in nuts2
|
# get population in nuts2
|
||||||
@ -149,7 +147,6 @@ def build_nuts2_shapes():
|
|||||||
- add RS, AL, BA country shapes (not covered in NUTS 2013)
|
- add RS, AL, BA country shapes (not covered in NUTS 2013)
|
||||||
- consistently name ME, MK
|
- consistently name ME, MK
|
||||||
"""
|
"""
|
||||||
|
|
||||||
nuts2 = gpd.GeoDataFrame(
|
nuts2 = gpd.GeoDataFrame(
|
||||||
gpd.read_file(snakemake.input.nuts2).set_index("id").geometry
|
gpd.read_file(snakemake.input.nuts2).set_index("id").geometry
|
||||||
)
|
)
|
||||||
@ -186,7 +183,6 @@ def convert_nuts2_to_regions(bio_nuts2, regions):
|
|||||||
-------
|
-------
|
||||||
gpd.GeoDataFrame
|
gpd.GeoDataFrame
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# calculate area of nuts2 regions
|
# calculate area of nuts2 regions
|
||||||
bio_nuts2["area_nuts2"] = area(bio_nuts2)
|
bio_nuts2["area_nuts2"] = area(bio_nuts2)
|
||||||
|
|
||||||
|
@ -7,10 +7,11 @@
|
|||||||
Build coefficient of performance (COP) time series for air- or ground-sourced
|
Build coefficient of performance (COP) time series for air- or ground-sourced
|
||||||
heat pumps.
|
heat pumps.
|
||||||
|
|
||||||
The COP is a function of the temperature difference between
|
The COP is a function of the temperature difference between source and
|
||||||
source and sink.
|
sink.
|
||||||
|
|
||||||
The quadratic regression used is based on Staffell et al. (2012)
|
The quadratic regression used is based on Staffell et al. (2012)
|
||||||
|
|
||||||
https://doi.org/10.1039/C2EE22653G.
|
https://doi.org/10.1039/C2EE22653G.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -124,7 +124,6 @@ def build_eurostat(input_eurostat, countries, report_year, year):
|
|||||||
"""
|
"""
|
||||||
Return multi-index for all countries' energy data in TWh/a.
|
Return multi-index for all countries' energy data in TWh/a.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
filenames = {
|
filenames = {
|
||||||
2016: f"/{year}-Energy-Balances-June2016edition.xlsx",
|
2016: f"/{year}-Energy-Balances-June2016edition.xlsx",
|
||||||
2017: f"/{year}-ENERGY-BALANCES-June2017edition.xlsx",
|
2017: f"/{year}-ENERGY-BALANCES-June2017edition.xlsx",
|
||||||
@ -163,7 +162,6 @@ def build_swiss(year):
|
|||||||
"""
|
"""
|
||||||
Return a pd.Series of Swiss energy data in TWh/a.
|
Return a pd.Series of Swiss energy data in TWh/a.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
fn = snakemake.input.swiss
|
fn = snakemake.input.swiss
|
||||||
|
|
||||||
df = pd.read_csv(fn, index_col=[0, 1]).loc["CH", str(year)]
|
df = pd.read_csv(fn, index_col=[0, 1]).loc["CH", str(year)]
|
||||||
|
@ -22,14 +22,15 @@ def diameter_to_capacity(pipe_diameter_mm):
|
|||||||
"""
|
"""
|
||||||
Calculate pipe capacity in MW based on diameter in mm.
|
Calculate pipe capacity in MW based on diameter in mm.
|
||||||
|
|
||||||
20 inch (500 mm) 50 bar -> 1.5 GW CH4 pipe capacity (LHV)
|
20 inch (500 mm) 50 bar -> 1.5 GW CH4 pipe capacity (LHV) 24 inch
|
||||||
24 inch (600 mm) 50 bar -> 5 GW CH4 pipe capacity (LHV)
|
(600 mm) 50 bar -> 5 GW CH4 pipe capacity (LHV) 36 inch (900
|
||||||
36 inch (900 mm) 50 bar -> 11.25 GW CH4 pipe capacity (LHV)
|
mm) 50 bar -> 11.25 GW CH4 pipe capacity (LHV) 48 inch (1200 mm) 80
|
||||||
48 inch (1200 mm) 80 bar -> 21.7 GW CH4 pipe capacity (LHV)
|
bar -> 21.7 GW CH4 pipe capacity (LHV)
|
||||||
|
|
||||||
Based on p.15 of https://gasforclimate2050.eu/wp-content/uploads/2020/07/2020_European-Hydrogen-Backbone_Report.pdf
|
Based on p.15 of
|
||||||
|
|
||||||
|
https://gasforclimate2050.eu/wp-content/uploads/2020/07/2020_European-Hydrogen-Backbone_Report.pdf
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# slopes definitions
|
# slopes definitions
|
||||||
m0 = (1500 - 0) / (500 - 0)
|
m0 = (1500 - 0) / (500 - 0)
|
||||||
m1 = (5000 - 1500) / (600 - 500)
|
m1 = (5000 - 1500) / (600 - 500)
|
||||||
|
@ -27,7 +27,6 @@ def locate_missing_industrial_sites(df):
|
|||||||
Should only be used if the model's spatial resolution is coarser
|
Should only be used if the model's spatial resolution is coarser
|
||||||
than individual cities.
|
than individual cities.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from geopy.extra.rate_limiter import RateLimiter
|
from geopy.extra.rate_limiter import RateLimiter
|
||||||
from geopy.geocoders import Nominatim
|
from geopy.geocoders import Nominatim
|
||||||
@ -71,7 +70,6 @@ def prepare_hotmaps_database(regions):
|
|||||||
"""
|
"""
|
||||||
Load hotmaps database of industrial sites and map onto bus regions.
|
Load hotmaps database of industrial sites and map onto bus regions.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
df = pd.read_csv(snakemake.input.hotmaps_industrial_database, sep=";", index_col=0)
|
df = pd.read_csv(snakemake.input.hotmaps_industrial_database, sep=";", index_col=0)
|
||||||
|
|
||||||
df[["srid", "coordinates"]] = df.geom.str.split(";", expand=True)
|
df[["srid", "coordinates"]] = df.geom.str.split(";", expand=True)
|
||||||
@ -103,7 +101,6 @@ def build_nodal_distribution_key(hotmaps, regions, countries):
|
|||||||
"""
|
"""
|
||||||
Build nodal distribution keys for each sector.
|
Build nodal distribution keys for each sector.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
sectors = hotmaps.Subsector.unique()
|
sectors = hotmaps.Subsector.unique()
|
||||||
|
|
||||||
keys = pd.DataFrame(index=regions.index, columns=sectors, dtype=float)
|
keys = pd.DataFrame(index=regions.index, columns=sectors, dtype=float)
|
||||||
|
@ -247,7 +247,6 @@ def separate_basic_chemicals(demand, year):
|
|||||||
"""
|
"""
|
||||||
Separate basic chemicals into ammonia, chlorine, methanol and HVC.
|
Separate basic chemicals into ammonia, chlorine, methanol and HVC.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ammonia = pd.read_csv(snakemake.input.ammonia_production, index_col=0)
|
ammonia = pd.read_csv(snakemake.input.ammonia_production, index_col=0)
|
||||||
|
|
||||||
there = ammonia.index.intersection(demand.index)
|
there = ammonia.index.intersection(demand.index)
|
||||||
|
@ -150,7 +150,6 @@ def prepare_building_stock_data():
|
|||||||
type and period
|
type and period
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
building_data = pd.read_csv(snakemake.input.building_stock, usecols=list(range(13)))
|
building_data = pd.read_csv(snakemake.input.building_stock, usecols=list(range(13)))
|
||||||
|
|
||||||
# standardize data
|
# standardize data
|
||||||
@ -318,7 +317,6 @@ def prepare_building_topology(u_values, same_building_topology=True):
|
|||||||
Reads in typical building topologies (e.g. average surface of building
|
Reads in typical building topologies (e.g. average surface of building
|
||||||
elements) and typical losses through thermal bridging and air ventilation.
|
elements) and typical losses through thermal bridging and air ventilation.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
data_tabula = pd.read_csv(
|
data_tabula = pd.read_csv(
|
||||||
snakemake.input.data_tabula,
|
snakemake.input.data_tabula,
|
||||||
skiprows=lambda x: x in range(1, 11),
|
skiprows=lambda x: x in range(1, 11),
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
"""
|
"""
|
||||||
Build salt cavern potentials for hydrogen storage.
|
Build salt cavern potentials for hydrogen storage.
|
||||||
|
|
||||||
Technical Potential of Salt Caverns for Hydrogen Storage in Europe
|
Technical Potential of Salt Caverns for Hydrogen Storage in Europe CC-BY
|
||||||
CC-BY 4.0
|
4.0
|
||||||
https://doi.org/10.20944/preprints201910.0187.v1
|
https://doi.org/10.20944/preprints201910.0187.v1
|
||||||
https://doi.org/10.1016/j.ijhydene.2019.12.161
|
https://doi.org/10.1016/j.ijhydene.2019.12.161
|
||||||
|
|
||||||
@ -39,7 +39,6 @@ def load_bus_regions(onshore_path, offshore_path):
|
|||||||
"""
|
"""
|
||||||
Load pypsa-eur on- and offshore regions and concat.
|
Load pypsa-eur on- and offshore regions and concat.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
bus_regions_offshore = gpd.read_file(offshore_path)
|
bus_regions_offshore = gpd.read_file(offshore_path)
|
||||||
bus_regions_onshore = gpd.read_file(onshore_path)
|
bus_regions_onshore = gpd.read_file(onshore_path)
|
||||||
bus_regions = concat_gdf([bus_regions_offshore, bus_regions_onshore])
|
bus_regions = concat_gdf([bus_regions_offshore, bus_regions_onshore])
|
||||||
|
@ -124,7 +124,6 @@ def bev_availability_profile(fn, snapshots, nodes, options):
|
|||||||
"""
|
"""
|
||||||
Derive plugged-in availability for passenger electric vehicles.
|
Derive plugged-in availability for passenger electric vehicles.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
traffic = pd.read_csv(fn, skiprows=2, usecols=["count"]).squeeze("columns")
|
traffic = pd.read_csv(fn, skiprows=2, usecols=["count"]).squeeze("columns")
|
||||||
|
|
||||||
avail_max = options["bev_avail_max"]
|
avail_max = options["bev_avail_max"]
|
||||||
|
@ -30,7 +30,6 @@ def load_bus_regions(onshore_path, offshore_path):
|
|||||||
"""
|
"""
|
||||||
Load pypsa-eur on- and offshore regions and concat.
|
Load pypsa-eur on- and offshore regions and concat.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
bus_regions_offshore = gpd.read_file(offshore_path)
|
bus_regions_offshore = gpd.read_file(offshore_path)
|
||||||
bus_regions_onshore = gpd.read_file(onshore_path)
|
bus_regions_onshore = gpd.read_file(onshore_path)
|
||||||
bus_regions = concat_gdf([bus_regions_offshore, bus_regions_onshore])
|
bus_regions = concat_gdf([bus_regions_offshore, bus_regions_onshore])
|
||||||
|
@ -320,7 +320,6 @@ def calculate_supply(n, label, supply):
|
|||||||
Calculate the max dispatch of each component at the buses aggregated by
|
Calculate the max dispatch of each component at the buses aggregated by
|
||||||
carrier.
|
carrier.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
bus_carriers = n.buses.carrier.unique()
|
bus_carriers = n.buses.carrier.unique()
|
||||||
|
|
||||||
for i in bus_carriers:
|
for i in bus_carriers:
|
||||||
@ -372,7 +371,6 @@ def calculate_supply_energy(n, label, supply_energy):
|
|||||||
Calculate the total energy supply/consuption of each component at the buses
|
Calculate the total energy supply/consuption of each component at the buses
|
||||||
aggregated by carrier.
|
aggregated by carrier.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
bus_carriers = n.buses.carrier.unique()
|
bus_carriers = n.buses.carrier.unique()
|
||||||
|
|
||||||
for i in bus_carriers:
|
for i in bus_carriers:
|
||||||
|
@ -441,7 +441,6 @@ def plot_carbon_budget_distribution(input_eurostat):
|
|||||||
"""
|
"""
|
||||||
Plot historical carbon emissions in the EU and decarbonization path.
|
Plot historical carbon emissions in the EU and decarbonization path.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import seaborn as sns
|
import seaborn as sns
|
||||||
|
|
||||||
sns.set()
|
sns.set()
|
||||||
|
@ -51,7 +51,6 @@ def define_spatial(nodes, options):
|
|||||||
----------
|
----------
|
||||||
nodes : list-like
|
nodes : list-like
|
||||||
"""
|
"""
|
||||||
|
|
||||||
global spatial
|
global spatial
|
||||||
|
|
||||||
spatial.nodes = nodes
|
spatial.nodes = nodes
|
||||||
@ -362,7 +361,6 @@ def update_wind_solar_costs(n, costs):
|
|||||||
Update costs for wind and solar generators added with pypsa-eur to those
|
Update costs for wind and solar generators added with pypsa-eur to those
|
||||||
cost in the planning year.
|
cost in the planning year.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# NB: solar costs are also manipulated for rooftop
|
# NB: solar costs are also manipulated for rooftop
|
||||||
# when distribution grid is inserted
|
# when distribution grid is inserted
|
||||||
n.generators.loc[n.generators.carrier == "solar", "capital_cost"] = costs.at[
|
n.generators.loc[n.generators.carrier == "solar", "capital_cost"] = costs.at[
|
||||||
@ -440,7 +438,6 @@ def add_carrier_buses(n, carrier, nodes=None):
|
|||||||
"""
|
"""
|
||||||
Add buses to connect e.g. coal, nuclear and oil plants.
|
Add buses to connect e.g. coal, nuclear and oil plants.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if nodes is None:
|
if nodes is None:
|
||||||
nodes = vars(spatial)[carrier].nodes
|
nodes = vars(spatial)[carrier].nodes
|
||||||
location = vars(spatial)[carrier].locations
|
location = vars(spatial)[carrier].locations
|
||||||
@ -487,7 +484,6 @@ def remove_elec_base_techs(n):
|
|||||||
batteries and H2) from base electricity-only network, since they're added
|
batteries and H2) from base electricity-only network, since they're added
|
||||||
here differently using links.
|
here differently using links.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for c in n.iterate_components(snakemake.config["pypsa_eur"]):
|
for c in n.iterate_components(snakemake.config["pypsa_eur"]):
|
||||||
to_keep = snakemake.config["pypsa_eur"][c.name]
|
to_keep = snakemake.config["pypsa_eur"][c.name]
|
||||||
to_remove = pd.Index(c.df.carrier.unique()).symmetric_difference(to_keep)
|
to_remove = pd.Index(c.df.carrier.unique()).symmetric_difference(to_keep)
|
||||||
|
@ -112,15 +112,12 @@ def simplify_network_to_380(n):
|
|||||||
Fix all lines to a voltage level of 380 kV and remove all transformers.
|
Fix all lines to a voltage level of 380 kV and remove all transformers.
|
||||||
|
|
||||||
The function preserves the transmission capacity for each line while
|
The function preserves the transmission capacity for each line while
|
||||||
updating
|
updating its voltage level, line type and number of parallel bundles
|
||||||
its voltage level, line type and number of parallel bundles
|
|
||||||
(num_parallel).
|
(num_parallel).
|
||||||
|
|
||||||
Transformers are removed and connected components are moved from
|
Transformers are removed and connected components are moved from
|
||||||
their
|
their starting bus to their ending bus. The corresponding starting
|
||||||
starting bus to their ending bus. The corresponding starting buses
|
buses are removed as well.
|
||||||
are
|
|
||||||
removed as well.
|
|
||||||
"""
|
"""
|
||||||
logger.info("Mapping all network lines onto a single 380kV layer")
|
logger.info("Mapping all network lines onto a single 380kV layer")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user