Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #639

Merged
merged 2 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ repos:

# Make docstrings PEP 257 compliant
- repo: https://github.com/PyCQA/docformatter
rev: v1.5.1
rev: v1.6.0
hooks:
- id: docformatter
args: ["--in-place", "--make-summary-multi-line", "--pre-summary-newline"]
Expand Down Expand Up @@ -74,7 +74,7 @@ repos:

# Format Snakemake rule / workflow files
- repo: https://github.com/snakemake/snakefmt
rev: v0.8.3
rev: v0.8.4
hooks:
- id: snakefmt

Expand Down
2 changes: 0 additions & 2 deletions scripts/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions scripts/add_existing_baseyear.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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"]:
Expand Down
4 changes: 0 additions & 4 deletions scripts/build_biomass_potentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -124,7 +123,6 @@ def disaggregate_nuts0(bio):
-------
pd.DataFrame
"""

pop = build_nuts_population_data()

# get population in nuts2
Expand All @@ -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
)
Expand Down Expand Up @@ -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)

Expand Down
5 changes: 3 additions & 2 deletions scripts/build_cop_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
"""

Expand Down
2 changes: 0 additions & 2 deletions scripts/build_energy_totals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)]
Expand Down
13 changes: 7 additions & 6 deletions scripts/build_gas_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions scripts/build_industrial_distribution_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion scripts/build_industrial_production_per_country.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions scripts/build_retro_cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down
5 changes: 2 additions & 3 deletions scripts/build_salt_cavern_potentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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])
Expand Down
1 change: 0 additions & 1 deletion scripts/build_transport_demand.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
1 change: 0 additions & 1 deletion scripts/cluster_gas_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
2 changes: 0 additions & 2 deletions scripts/make_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
1 change: 0 additions & 1 deletion scripts/plot_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 0 additions & 4 deletions scripts/prepare_sector_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ def define_spatial(nodes, options):
----------
nodes : list-like
"""

global spatial

spatial.nodes = nodes
Expand Down Expand Up @@ -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[
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 3 additions & 6 deletions scripts/simplify_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down