[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2023-04-10 22:02:32 +00:00
parent da844ddd50
commit 460bbd080f
16 changed files with 15 additions and 42 deletions

View File

@ -400,7 +400,6 @@ def override_component_attrs(directory):
-------
Dictionary of overridden component attributes.
"""
attrs = Dict({k: v.copy() for k, v in component_attrs.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
time.
"""
weekly_profile = pd.Series(weekly_profile, range(24 * 7))
week_df = pd.DataFrame(index=dt_index, columns=nodes)

View File

@ -38,7 +38,6 @@ def add_build_year_to_new_assets(n, baseyear):
baseyear : int
year in which optimized assets are built
"""
# Give assets with lifetimes and no build year the build year baseyear
for c in n.iterate_components(["Link", "Generator", "Store"]):
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
power plants.
"""
carriers = {"solar": "solar", "onwind": "onwind", "offwind": "offwind-ac"}
for tech in ["solar", "onwind", "offwind"]:

View File

@ -68,7 +68,6 @@ def enspreso_biomass_potentials(year=2020, scenario="ENS_Low"):
Biomass potentials for given year and scenario
in TWh/a by commodity and NUTS2 region.
"""
glossary = pd.read_excel(
str(snakemake.input.enspreso_biomass),
sheet_name="Glossary",
@ -124,7 +123,6 @@ def disaggregate_nuts0(bio):
-------
pd.DataFrame
"""
pop = build_nuts_population_data()
# get population in nuts2
@ -149,7 +147,6 @@ def build_nuts2_shapes():
- add RS, AL, BA country shapes (not covered in NUTS 2013)
- consistently name ME, MK
"""
nuts2 = gpd.GeoDataFrame(
gpd.read_file(snakemake.input.nuts2).set_index("id").geometry
)
@ -186,7 +183,6 @@ def convert_nuts2_to_regions(bio_nuts2, regions):
-------
gpd.GeoDataFrame
"""
# calculate area of nuts2 regions
bio_nuts2["area_nuts2"] = area(bio_nuts2)

View File

@ -7,10 +7,11 @@
Build coefficient of performance (COP) time series for air- or ground-sourced
heat pumps.
The COP is a function of the temperature difference between
source and sink.
The COP is a function of the temperature difference between source and
sink.
The quadratic regression used is based on Staffell et al. (2012)
https://doi.org/10.1039/C2EE22653G.
"""

View File

@ -124,7 +124,6 @@ def build_eurostat(input_eurostat, countries, report_year, year):
"""
Return multi-index for all countries' energy data in TWh/a.
"""
filenames = {
2016: f"/{year}-Energy-Balances-June2016edition.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.
"""
fn = snakemake.input.swiss
df = pd.read_csv(fn, index_col=[0, 1]).loc["CH", str(year)]

View File

@ -22,14 +22,15 @@ def diameter_to_capacity(pipe_diameter_mm):
"""
Calculate pipe capacity in MW based on diameter in mm.
20 inch (500 mm) 50 bar -> 1.5 GW CH4 pipe capacity (LHV)
24 inch (600 mm) 50 bar -> 5 GW CH4 pipe capacity (LHV)
36 inch (900 mm) 50 bar -> 11.25 GW CH4 pipe capacity (LHV)
48 inch (1200 mm) 80 bar -> 21.7 GW CH4 pipe capacity (LHV)
20 inch (500 mm) 50 bar -> 1.5 GW CH4 pipe capacity (LHV) 24 inch
(600 mm) 50 bar -> 5 GW CH4 pipe capacity (LHV) 36 inch (900
mm) 50 bar -> 11.25 GW CH4 pipe capacity (LHV) 48 inch (1200 mm) 80
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
m0 = (1500 - 0) / (500 - 0)
m1 = (5000 - 1500) / (600 - 500)

View File

@ -27,7 +27,6 @@ def locate_missing_industrial_sites(df):
Should only be used if the model's spatial resolution is coarser
than individual cities.
"""
try:
from geopy.extra.rate_limiter import RateLimiter
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.
"""
df = pd.read_csv(snakemake.input.hotmaps_industrial_database, sep=";", index_col=0)
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.
"""
sectors = hotmaps.Subsector.unique()
keys = pd.DataFrame(index=regions.index, columns=sectors, dtype=float)

View File

@ -247,7 +247,6 @@ def separate_basic_chemicals(demand, year):
"""
Separate basic chemicals into ammonia, chlorine, methanol and HVC.
"""
ammonia = pd.read_csv(snakemake.input.ammonia_production, index_col=0)
there = ammonia.index.intersection(demand.index)

View File

@ -150,7 +150,6 @@ def prepare_building_stock_data():
type and period
"""
building_data = pd.read_csv(snakemake.input.building_stock, usecols=list(range(13)))
# 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
elements) and typical losses through thermal bridging and air ventilation.
"""
data_tabula = pd.read_csv(
snakemake.input.data_tabula,
skiprows=lambda x: x in range(1, 11),

View File

@ -6,8 +6,8 @@
"""
Build salt cavern potentials for hydrogen storage.
Technical Potential of Salt Caverns for Hydrogen Storage in Europe
CC-BY 4.0
Technical Potential of Salt Caverns for Hydrogen Storage in Europe CC-BY
4.0
https://doi.org/10.20944/preprints201910.0187.v1
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.
"""
bus_regions_offshore = gpd.read_file(offshore_path)
bus_regions_onshore = gpd.read_file(onshore_path)
bus_regions = concat_gdf([bus_regions_offshore, bus_regions_onshore])

View File

@ -124,7 +124,6 @@ def bev_availability_profile(fn, snapshots, nodes, options):
"""
Derive plugged-in availability for passenger electric vehicles.
"""
traffic = pd.read_csv(fn, skiprows=2, usecols=["count"]).squeeze("columns")
avail_max = options["bev_avail_max"]

View File

@ -30,7 +30,6 @@ def load_bus_regions(onshore_path, offshore_path):
"""
Load pypsa-eur on- and offshore regions and concat.
"""
bus_regions_offshore = gpd.read_file(offshore_path)
bus_regions_onshore = gpd.read_file(onshore_path)
bus_regions = concat_gdf([bus_regions_offshore, bus_regions_onshore])

View File

@ -320,7 +320,6 @@ def calculate_supply(n, label, supply):
Calculate the max dispatch of each component at the buses aggregated by
carrier.
"""
bus_carriers = n.buses.carrier.unique()
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
aggregated by carrier.
"""
bus_carriers = n.buses.carrier.unique()
for i in bus_carriers:

View File

@ -441,7 +441,6 @@ def plot_carbon_budget_distribution(input_eurostat):
"""
Plot historical carbon emissions in the EU and decarbonization path.
"""
import seaborn as sns
sns.set()

View File

@ -51,7 +51,6 @@ def define_spatial(nodes, options):
----------
nodes : list-like
"""
global spatial
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
cost in the planning year.
"""
# NB: solar costs are also manipulated for rooftop
# when distribution grid is inserted
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.
"""
if nodes is None:
nodes = vars(spatial)[carrier].nodes
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
here differently using links.
"""
for c in n.iterate_components(snakemake.config["pypsa_eur"]):
to_keep = snakemake.config["pypsa_eur"][c.name]
to_remove = pd.Index(c.df.carrier.unique()).symmetric_difference(to_keep)

View File

@ -112,15 +112,12 @@ def simplify_network_to_380(n):
Fix all lines to a voltage level of 380 kV and remove all transformers.
The function preserves the transmission capacity for each line while
updating
its voltage level, line type and number of parallel bundles
updating its voltage level, line type and number of parallel bundles
(num_parallel).
Transformers are removed and connected components are moved from
their
starting bus to their ending bus. The corresponding starting buses
are
removed as well.
their starting bus to their ending bus. The corresponding starting
buses are removed as well.
"""
logger.info("Mapping all network lines onto a single 380kV layer")