move snakemake object out of imap process functions
This commit is contained in:
parent
4e719b99a1
commit
ba6e0c2e4a
@ -102,7 +102,8 @@ def voronoi_partition_pts(points, outline):
|
|||||||
if not poly.is_valid:
|
if not poly.is_valid:
|
||||||
poly = poly.buffer(0)
|
poly = poly.buffer(0)
|
||||||
|
|
||||||
poly = poly.intersection(outline)
|
with np.errstate(invalid="ignore"):
|
||||||
|
poly = poly.intersection(outline)
|
||||||
|
|
||||||
polygons.append(poly)
|
polygons.append(poly)
|
||||||
|
|
||||||
|
@ -196,9 +196,7 @@ def build_swiss(year):
|
|||||||
return df
|
return df
|
||||||
|
|
||||||
|
|
||||||
def idees_per_country(ct, year):
|
def idees_per_country(ct, year, base_dir):
|
||||||
base_dir = snakemake.input.idees
|
|
||||||
|
|
||||||
ct_totals = {}
|
ct_totals = {}
|
||||||
|
|
||||||
ct_idees = idees_rename.get(ct, ct)
|
ct_idees = idees_rename.get(ct, ct)
|
||||||
@ -401,7 +399,7 @@ def idees_per_country(ct, year):
|
|||||||
def build_idees(countries, year):
|
def build_idees(countries, year):
|
||||||
nprocesses = snakemake.threads
|
nprocesses = snakemake.threads
|
||||||
|
|
||||||
func = partial(idees_per_country, year=year)
|
func = partial(idees_per_country, year=year, base_dir=snakemake.input.idees)
|
||||||
tqdm_kwargs = dict(
|
tqdm_kwargs = dict(
|
||||||
ascii=False,
|
ascii=False,
|
||||||
unit=" country",
|
unit=" country",
|
||||||
|
@ -8,6 +8,7 @@ Build industrial energy demand per country.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import multiprocessing as mp
|
import multiprocessing as mp
|
||||||
|
from functools import partial
|
||||||
|
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
@ -89,8 +90,7 @@ eu28 = [
|
|||||||
jrc_names = {"GR": "EL", "GB": "UK"}
|
jrc_names = {"GR": "EL", "GB": "UK"}
|
||||||
|
|
||||||
|
|
||||||
def industrial_energy_demand_per_country(country):
|
def industrial_energy_demand_per_country(country, jrc_dir):
|
||||||
jrc_dir = snakemake.input.jrc
|
|
||||||
jrc_country = jrc_names.get(country, country)
|
jrc_country = jrc_names.get(country, country)
|
||||||
fn = f"{jrc_dir}/JRC-IDEES-2015_EnergyBalance_{jrc_country}.xlsx"
|
fn = f"{jrc_dir}/JRC-IDEES-2015_EnergyBalance_{jrc_country}.xlsx"
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ def add_non_eu28_industrial_energy_demand(demand):
|
|||||||
|
|
||||||
def industrial_energy_demand(countries):
|
def industrial_energy_demand(countries):
|
||||||
nprocesses = snakemake.threads
|
nprocesses = snakemake.threads
|
||||||
func = industrial_energy_demand_per_country
|
func = partial(industrial_energy_demand_per_country, jrc_dir=snakemake.input.jrc)
|
||||||
tqdm_kwargs = dict(
|
tqdm_kwargs = dict(
|
||||||
ascii=False,
|
ascii=False,
|
||||||
unit=" country",
|
unit=" country",
|
||||||
|
Loading…
Reference in New Issue
Block a user