[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] 2024-08-07 09:59:06 +00:00
parent 95903eeca7
commit 6a51a1d94e
3 changed files with 15 additions and 12 deletions

View File

@ -342,5 +342,5 @@ texinfo_documents = [
# Example configuration for intersphinx: refer to the Python standard library. # Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = { intersphinx_mapping = {
'https://docs.python.org/': ('https://docs.python.org/3', None), "https://docs.python.org/": ("https://docs.python.org/3", None),
} }

View File

@ -170,7 +170,7 @@ def eurostat_per_country(input_eurostat: str, country: str) -> pd.DataFrame:
sheet_name=None, sheet_name=None,
skiprows=4, skiprows=4,
index_col=list(range(4)), index_col=list(range(4)),
na_values=":" na_values=":",
) )
sheet.pop("Cover") sheet.pop("Cover")
return pd.concat(sheet) return pd.concat(sheet)
@ -499,8 +499,7 @@ def idees_per_country(ct: str, base_dir: str) -> pd.DataFrame:
assert df.index[9] == "Domestic" assert df.index[9] == "Domestic"
assert df.index[10] == "International - Intra-EEAwUK" assert df.index[10] == "International - Intra-EEAwUK"
ct_totals["total domestic aviation freight"] = df.iloc[[9,10]].sum() ct_totals["total domestic aviation freight"] = df.iloc[[9, 10]].sum()
assert df.index[11] == "International - Extra-EEAwUK" assert df.index[11] == "International - Extra-EEAwUK"
ct_totals["total international aviation freight"] = df.iloc[11] ct_totals["total international aviation freight"] = df.iloc[11]

View File

@ -176,10 +176,11 @@ ch_mapping = {
"Andere NE-Mineralien": "Other non-ferrous metals", "Andere NE-Mineralien": "Other non-ferrous metals",
"Metall / Eisen": "Iron and steel", "Metall / Eisen": "Iron and steel",
"NE-Metall": "Non Ferrous Metals", "NE-Metall": "Non Ferrous Metals",
"Metall / Geräte" : "Transport equipment", "Metall / Geräte": "Transport equipment",
"Maschinen": "Machinery equipment", "Maschinen": "Machinery equipment",
"Andere Industrien": "Other industrial sectors", "Andere Industrien": "Other industrial sectors",
} }
def find_physical_output(df): def find_physical_output(df):
start = np.where(df.index.str.contains("Physical output", na=""))[0][0] start = np.where(df.index.str.contains("Physical output", na=""))[0][0]
@ -191,8 +192,9 @@ def find_physical_output(df):
def get_energy_ratio(country, eurostat_dir, jrc_dir, year): def get_energy_ratio(country, eurostat_dir, jrc_dir, year):
if country == "CH": if country == "CH":
# data ranges between 2014-2023 # data ranges between 2014-2023
e_country = pd.read_csv(snakemake.input.ch_industrial_production, e_country = pd.read_csv(
index_col=0).dropna() snakemake.input.ch_industrial_production, index_col=0
).dropna()
e_country = e_country.rename(index=ch_mapping).groupby(level=0).sum() e_country = e_country.rename(index=ch_mapping).groupby(level=0).sum()
e_country = e_country[str(min(2019, year))] e_country = e_country[str(min(2019, year))]
e_country *= tj_to_ktoe e_country *= tj_to_ktoe
@ -298,7 +300,9 @@ def separate_basic_chemicals(demand, year):
year_to_use = min(max(year, 2018), 2022) year_to_use = min(max(year, 2018), 2022)
if year_to_use != year: if year_to_use != year:
logger.info(f"Year {year} outside data range. Using data from {year_to_use} for ammonia production.") logger.info(
f"Year {year} outside data range. Using data from {year_to_use} for ammonia production."
)
demand.loc[there, "Ammonia"] = ammonia.loc[there, str(year_to_use)] demand.loc[there, "Ammonia"] = ammonia.loc[there, str(year_to_use)]
demand["Basic chemicals"] -= demand["Ammonia"] demand["Basic chemicals"] -= demand["Ammonia"]