diff --git a/scripts/add_electricity.py b/scripts/add_electricity.py index 64cf442e..83ec4bb9 100755 --- a/scripts/add_electricity.py +++ b/scripts/add_electricity.py @@ -85,17 +85,17 @@ It further adds extendable ``generators`` with **zero** capacity for """ import logging +from itertools import product import geopandas as gpd import numpy as np import pandas as pd import powerplantmatching as pm import pypsa +import scipy.sparse as sparse import xarray as xr from _helpers import configure_logging, update_p_nom_max from powerplantmatching.export import map_country_bus -from itertools import product -import scipy.sparse as sparse from shapely.prepared import prep idx = pd.IndexSlice @@ -217,6 +217,7 @@ def load_powerplants(ppl_fn): .replace({"carrier": carrier_dict}) ) + def Shapes2Shapes(orig, dest): """ Adopted from vresutils.transfer.Shapes2Shapes() @@ -224,10 +225,10 @@ def Shapes2Shapes(orig, dest): orig_prepped = list(map(prep, orig)) transfer = sparse.lil_matrix((len(dest), len(orig)), dtype=float) - for i,j in product(range(len(dest)), range(len(orig))): + for i, j in product(range(len(dest)), range(len(orig))): if orig_prepped[j].intersects(dest[i]): area = orig[j].intersection(dest[i]).area - transfer[i,j] = area/dest[i].area + transfer[i, j] = area / dest[i].area return transfer diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 944c3caa..012c9714 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -22,13 +22,13 @@ from _helpers import ( override_component_attrs, update_config_with_sector_opts, ) +from add_electricity import calculate_annuity from build_energy_totals import build_co2_totals, build_eea_co2, build_eurostat_co2 from networkx.algorithms import complement from networkx.algorithms.connectivity.edge_augmentation import k_edge_augmentation from pypsa.geo import haversine_pts from pypsa.io import import_components_from_dataframe from scipy.stats import beta -from add_electricity import calculate_annuity logger = logging.getLogger(__name__)