apply ruff linting

This commit is contained in:
Fabian Neumann 2024-05-21 15:28:24 +02:00
parent 9545b757b0
commit da10374158
8 changed files with 8 additions and 11 deletions

View File

@ -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()
@ -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"

View File

@ -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):
@ -950,7 +950,7 @@ if __name__ == "__main__":
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,

View File

@ -13,10 +13,11 @@ import geopandas as gpd
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):

View File

@ -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

View File

@ -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(

View File

@ -10,10 +10,10 @@ import logging
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

View File

@ -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")

View File

@ -47,6 +47,7 @@ import numpy as np
import pandas as pd
import pypsa
import xarray as xr
import tsam.timeseriesaggregation as tsam
from _helpers import (
configure_logging,
set_scenario_config,