move snakemake object out of imap process functions

This commit is contained in:
Fabian 2023-03-07 08:58:07 +01:00
parent 4e719b99a1
commit ba6e0c2e4a
3 changed files with 7 additions and 8 deletions

View File

@ -102,7 +102,8 @@ def voronoi_partition_pts(points, outline):
if not poly.is_valid:
poly = poly.buffer(0)
poly = poly.intersection(outline)
with np.errstate(invalid="ignore"):
poly = poly.intersection(outline)
polygons.append(poly)

View File

@ -196,9 +196,7 @@ def build_swiss(year):
return df
def idees_per_country(ct, year):
base_dir = snakemake.input.idees
def idees_per_country(ct, year, base_dir):
ct_totals = {}
ct_idees = idees_rename.get(ct, ct)
@ -401,7 +399,7 @@ def idees_per_country(ct, year):
def build_idees(countries, year):
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(
ascii=False,
unit=" country",

View File

@ -8,6 +8,7 @@ Build industrial energy demand per country.
"""
import multiprocessing as mp
from functools import partial
import pandas as pd
from tqdm import tqdm
@ -89,8 +90,7 @@ eu28 = [
jrc_names = {"GR": "EL", "GB": "UK"}
def industrial_energy_demand_per_country(country):
jrc_dir = snakemake.input.jrc
def industrial_energy_demand_per_country(country, jrc_dir):
jrc_country = jrc_names.get(country, country)
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):
nprocesses = snakemake.threads
func = industrial_energy_demand_per_country
func = partial(industrial_energy_demand_per_country, jrc_dir=snakemake.input.jrc)
tqdm_kwargs = dict(
ascii=False,
unit=" country",