build industrial production: fix partial function in imap
This commit is contained in:
parent
e6d1d43555
commit
6761c50782
@ -8,6 +8,7 @@ Build industrial production per country.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
from functools import partial
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -185,7 +186,7 @@ def find_physical_output(df):
|
|||||||
return slice(start, end)
|
return slice(start, end)
|
||||||
|
|
||||||
|
|
||||||
def get_energy_ratio(country):
|
def get_energy_ratio(country, eurostat_dir, jrc_dir):
|
||||||
if country == "CH":
|
if country == "CH":
|
||||||
e_country = e_switzerland * tj_to_ktoe
|
e_country = e_switzerland * tj_to_ktoe
|
||||||
else:
|
else:
|
||||||
@ -214,7 +215,7 @@ def get_energy_ratio(country):
|
|||||||
return pd.Series({k: e_ratio[v] for k, v in sub2sect.items()})
|
return pd.Series({k: e_ratio[v] for k, v in sub2sect.items()})
|
||||||
|
|
||||||
|
|
||||||
def industry_production_per_country(country):
|
def industry_production_per_country(country, eurostat_dir, jrc_dir):
|
||||||
def get_sector_data(sector, country):
|
def get_sector_data(sector, country):
|
||||||
jrc_country = jrc_names.get(country, country)
|
jrc_country = jrc_names.get(country, country)
|
||||||
fn = f"{jrc_dir}/JRC-IDEES-2015_Industry_{jrc_country}.xlsx"
|
fn = f"{jrc_dir}/JRC-IDEES-2015_Industry_{jrc_country}.xlsx"
|
||||||
@ -236,16 +237,16 @@ def industry_production_per_country(country):
|
|||||||
demand = pd.concat([get_sector_data(s, ct) for s in sect2sub.keys()])
|
demand = pd.concat([get_sector_data(s, ct) for s in sect2sub.keys()])
|
||||||
|
|
||||||
if country in non_EU:
|
if country in non_EU:
|
||||||
demand *= get_energy_ratio(country)
|
demand *= get_energy_ratio(country, eurostat_dir, jrc_dir)
|
||||||
|
|
||||||
demand.name = country
|
demand.name = country
|
||||||
|
|
||||||
return demand
|
return demand
|
||||||
|
|
||||||
|
|
||||||
def industry_production(countries):
|
def industry_production(countries, eurostat_dir, jrc_dir):
|
||||||
nprocesses = snakemake.threads
|
nprocesses = 1 #snakemake.threads
|
||||||
func = industry_production_per_country
|
func = partial(industry_production_per_country, eurostat_dir=eurostat_dir, jrc_dir=jrc_dir)
|
||||||
tqdm_kwargs = dict(
|
tqdm_kwargs = dict(
|
||||||
ascii=False,
|
ascii=False,
|
||||||
unit=" country",
|
unit=" country",
|
||||||
@ -309,7 +310,7 @@ if __name__ == "__main__":
|
|||||||
jrc_dir = snakemake.input.jrc
|
jrc_dir = snakemake.input.jrc
|
||||||
eurostat_dir = snakemake.input.eurostat
|
eurostat_dir = snakemake.input.eurostat
|
||||||
|
|
||||||
demand = industry_production(countries)
|
demand = industry_production(countries, eurostat_dir, jrc_dir)
|
||||||
|
|
||||||
separate_basic_chemicals(demand)
|
separate_basic_chemicals(demand)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user