Skip to content

Commit

Permalink
apply ruff linting
Browse files Browse the repository at this point in the history
  • Loading branch information
fneum committed May 21, 2024
1 parent 9545b75 commit da10374
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 11 deletions.
4 changes: 1 addition & 3 deletions scripts/add_existing_baseyear.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def add_existing_renewables(df_agg, costs):
"""
tech_map = {"solar": "PV", "onwind": "Onshore", "offwind": "Offshore"}

countries = snakemake.config["countries"]
countries = snakemake.config["countries"] # noqa: F841
irena = pm.data.IRENASTAT().powerplant.convert_country_to_alpha2()
irena = irena.query("Country in @countries")
irena = irena.groupby(["Technology", "Country", "Year"]).Capacity.sum()
Expand Down Expand Up @@ -440,8 +440,6 @@ def add_heating_capacities_installed_before_baseyear(
snakemake.input.existing_heating_distribution, header=[0, 1], index_col=0
)

techs = existing_heating.columns.get_level_values(1).unique()

for name in existing_heating.columns.get_level_values(0).unique():
name_type = "central" if name == "urban central" else "decentral"

Expand Down
4 changes: 2 additions & 2 deletions scripts/base_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ def build_bus_shapes(n, country_shapes, offshore_shapes, countries):

shapes = pd.concat(onshore_regions, ignore_index=True)

return onshore_regions, offshore_regions, shapes
return onshore_regions, offshore_regions, shapes, offshore_shapes


def append_bus_shapes(n, shapes, type):
Expand Down Expand Up @@ -950,7 +950,7 @@ def append_bus_shapes(n, shapes, type):
snakemake.config,
)

onshore_regions, offshore_regions, shapes = build_bus_shapes(
onshore_regions, offshore_regions, shapes, offshore_shapes = build_bus_shapes(
n,
snakemake.input.country_shapes,
snakemake.input.offshore_shapes,
Expand Down
3 changes: 2 additions & 1 deletion scripts/build_biomass_potentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
import numpy as np
import pandas as pd

from _helpers import configure_logging, set_scenario_config

logger = logging.getLogger(__name__)
AVAILABLE_BIOMASS_YEARS = [2010, 2020, 2030, 2040, 2050]

from _helpers import configure_logging, set_scenario_config


def build_nuts_population_data(year=2013):
Expand Down
1 change: 0 additions & 1 deletion 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, nprocesses=1, disable_progressbar=
df = pd.concat([temp, df.loc[~int_avia]])

# Fill in missing data on "Domestic aviation" for each country.
domestic_avia = df.index.get_level_values(4) == "Domestic aviation"
for country in countries:
slicer = idx[country, :, :, :, "Domestic aviation"]
# For the Total and Fossil energy columns, fill in zeros with
Expand Down
1 change: 0 additions & 1 deletion scripts/build_existing_heating_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def build_existing_heating():
nodal_heating = nodal_heating.multiply(pop_layout.fraction, axis=0)

district_heat_info = pd.read_csv(snakemake.input.district_heat_share, index_col=0)
dist_fraction = district_heat_info["district fraction of node"]
urban_fraction = district_heat_info["urban fraction"]

energy_layout = pd.read_csv(
Expand Down
4 changes: 2 additions & 2 deletions scripts/retrieve_electricity_demand.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

import pandas as pd

logger = logging.getLogger(__name__)

from _helpers import configure_logging, set_scenario_config

logger = logging.getLogger(__name__)

if __name__ == "__main__":
if "snakemake" not in globals():
from _helpers import mock_snakemake
Expand Down
1 change: 0 additions & 1 deletion scripts/solve_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,6 @@ def add_BAU_constraints(n, config):
ext_i = n.generators.query("p_nom_extendable")
ext_carrier_i = xr.DataArray(ext_i.carrier.rename_axis("Generator-ext"))
lhs = p_nom.groupby(ext_carrier_i).sum()
index = mincaps.index.intersection(lhs.indexes["carrier"])
rhs = mincaps[lhs.indexes["carrier"]].rename_axis("carrier")
n.model.add_constraints(lhs >= rhs, name="bau_mincaps")

Expand Down
1 change: 1 addition & 0 deletions scripts/time_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import pandas as pd
import pypsa
import xarray as xr
import tsam.timeseriesaggregation as tsam
from _helpers import (
configure_logging,
set_scenario_config,
Expand Down

0 comments on commit da10374

Please sign in to comment.