Merge branch 'master' into validation
This commit is contained in:
commit
fcce233a2e
@ -10,7 +10,7 @@ dependencies:
|
|||||||
- python>=3.8
|
- python>=3.8
|
||||||
- pip
|
- pip
|
||||||
|
|
||||||
- pypsa>=0.23
|
# - pypsa>=0.23
|
||||||
- atlite>=0.2.9
|
- atlite>=0.2.9
|
||||||
- dask
|
- dask
|
||||||
|
|
||||||
|
@ -277,23 +277,6 @@ def progress_retrieve(url, file, disable=False):
|
|||||||
urllib.request.urlretrieve(url, file, reporthook=update_to)
|
urllib.request.urlretrieve(url, file, reporthook=update_to)
|
||||||
|
|
||||||
|
|
||||||
def get_aggregation_strategies(aggregation_strategies):
|
|
||||||
# default aggregation strategies that cannot be defined in .yaml format must be specified within
|
|
||||||
# the function, otherwise (when defaults are passed in the function's definition) they get lost
|
|
||||||
# when custom values are specified in the config.
|
|
||||||
|
|
||||||
import numpy as np
|
|
||||||
from pypsa.clustering.spatial import _make_consense
|
|
||||||
|
|
||||||
bus_strategies = dict(country=_make_consense("Bus", "country"))
|
|
||||||
bus_strategies.update(aggregation_strategies.get("buses", {}))
|
|
||||||
|
|
||||||
generator_strategies = {"build_year": lambda x: 0, "lifetime": lambda x: np.inf}
|
|
||||||
generator_strategies.update(aggregation_strategies.get("generators", {}))
|
|
||||||
|
|
||||||
return bus_strategies, generator_strategies
|
|
||||||
|
|
||||||
|
|
||||||
def mock_snakemake(rulename, configfiles=[], **wildcards):
|
def mock_snakemake(rulename, configfiles=[], **wildcards):
|
||||||
"""
|
"""
|
||||||
This function is expected to be executed from the 'scripts'-directory of '
|
This function is expected to be executed from the 'scripts'-directory of '
|
||||||
|
@ -133,7 +133,7 @@ import pandas as pd
|
|||||||
import pyomo.environ as po
|
import pyomo.environ as po
|
||||||
import pypsa
|
import pypsa
|
||||||
import seaborn as sns
|
import seaborn as sns
|
||||||
from _helpers import configure_logging, get_aggregation_strategies, update_p_nom_max
|
from _helpers import configure_logging, update_p_nom_max
|
||||||
from pypsa.clustering.spatial import (
|
from pypsa.clustering.spatial import (
|
||||||
busmap_by_greedy_modularity,
|
busmap_by_greedy_modularity,
|
||||||
busmap_by_hac,
|
busmap_by_hac,
|
||||||
@ -395,10 +395,6 @@ def clustering_for_n_clusters(
|
|||||||
extended_link_costs=0,
|
extended_link_costs=0,
|
||||||
focus_weights=None,
|
focus_weights=None,
|
||||||
):
|
):
|
||||||
bus_strategies, generator_strategies = get_aggregation_strategies(
|
|
||||||
aggregation_strategies
|
|
||||||
)
|
|
||||||
|
|
||||||
if not isinstance(custom_busmap, pd.Series):
|
if not isinstance(custom_busmap, pd.Series):
|
||||||
busmap = busmap_for_n_clusters(
|
busmap = busmap_for_n_clusters(
|
||||||
n, n_clusters, solver_name, focus_weights, algorithm, feature
|
n, n_clusters, solver_name, focus_weights, algorithm, feature
|
||||||
@ -406,15 +402,20 @@ def clustering_for_n_clusters(
|
|||||||
else:
|
else:
|
||||||
busmap = custom_busmap
|
busmap = custom_busmap
|
||||||
|
|
||||||
|
line_strategies = aggregation_strategies.get("lines", dict())
|
||||||
|
generator_strategies = aggregation_strategies.get("generators", dict())
|
||||||
|
one_port_strategies = aggregation_strategies.get("one_ports", dict())
|
||||||
|
|
||||||
clustering = get_clustering_from_busmap(
|
clustering = get_clustering_from_busmap(
|
||||||
n,
|
n,
|
||||||
busmap,
|
busmap,
|
||||||
bus_strategies=bus_strategies,
|
|
||||||
aggregate_generators_weighted=True,
|
aggregate_generators_weighted=True,
|
||||||
aggregate_generators_carriers=aggregate_carriers,
|
aggregate_generators_carriers=aggregate_carriers,
|
||||||
aggregate_one_ports=["Load", "StorageUnit"],
|
aggregate_one_ports=["Load", "StorageUnit"],
|
||||||
line_length_factor=line_length_factor,
|
line_length_factor=line_length_factor,
|
||||||
|
line_strategies=line_strategies,
|
||||||
generator_strategies=generator_strategies,
|
generator_strategies=generator_strategies,
|
||||||
|
one_port_strategies=one_port_strategies,
|
||||||
scale_link_capital_costs=False,
|
scale_link_capital_costs=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -86,17 +86,16 @@ The rule :mod:`simplify_network` does up to four things:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
from functools import reduce
|
from functools import partial, reduce
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import pypsa
|
import pypsa
|
||||||
import scipy as sp
|
import scipy as sp
|
||||||
from _helpers import configure_logging, get_aggregation_strategies, update_p_nom_max
|
from _helpers import configure_logging, update_p_nom_max
|
||||||
from add_electricity import load_costs
|
from add_electricity import load_costs
|
||||||
from cluster_network import cluster_regions, clustering_for_n_clusters
|
from cluster_network import cluster_regions, clustering_for_n_clusters
|
||||||
from pypsa.clustering.spatial import (
|
from pypsa.clustering.spatial import (
|
||||||
aggregategenerators,
|
|
||||||
aggregateoneport,
|
aggregateoneport,
|
||||||
busmap_by_stubs,
|
busmap_by_stubs,
|
||||||
get_clustering_from_busmap,
|
get_clustering_from_busmap,
|
||||||
@ -253,7 +252,7 @@ def _aggregate_and_move_components(
|
|||||||
|
|
||||||
_adjust_capital_costs_using_connection_costs(n, connection_costs_to_bus, output)
|
_adjust_capital_costs_using_connection_costs(n, connection_costs_to_bus, output)
|
||||||
|
|
||||||
_, generator_strategies = get_aggregation_strategies(aggregation_strategies)
|
generator_strategies = aggregation_strategies["generators"]
|
||||||
|
|
||||||
carriers = set(n.generators.carrier) - set(exclude_carriers)
|
carriers = set(n.generators.carrier) - set(exclude_carriers)
|
||||||
generators, generators_pnl = aggregateoneport(
|
generators, generators_pnl = aggregateoneport(
|
||||||
@ -482,19 +481,20 @@ def aggregate_to_substations(n, aggregation_strategies=dict(), buses_i=None):
|
|||||||
busmap = n.buses.index.to_series()
|
busmap = n.buses.index.to_series()
|
||||||
busmap.loc[buses_i] = dist.idxmin(1)
|
busmap.loc[buses_i] = dist.idxmin(1)
|
||||||
|
|
||||||
bus_strategies, generator_strategies = get_aggregation_strategies(
|
line_strategies = aggregation_strategies.get("lines", dict())
|
||||||
aggregation_strategies
|
generator_strategies = aggregation_strategies.get("generators", dict())
|
||||||
)
|
one_port_strategies = aggregation_strategies.get("one_ports", dict())
|
||||||
|
|
||||||
clustering = get_clustering_from_busmap(
|
clustering = get_clustering_from_busmap(
|
||||||
n,
|
n,
|
||||||
busmap,
|
busmap,
|
||||||
bus_strategies=bus_strategies,
|
|
||||||
aggregate_generators_weighted=True,
|
aggregate_generators_weighted=True,
|
||||||
aggregate_generators_carriers=None,
|
aggregate_generators_carriers=None,
|
||||||
aggregate_one_ports=["Load", "StorageUnit"],
|
aggregate_one_ports=["Load", "StorageUnit"],
|
||||||
line_length_factor=1.0,
|
line_length_factor=1.0,
|
||||||
|
line_strategies=line_strategies,
|
||||||
generator_strategies=generator_strategies,
|
generator_strategies=generator_strategies,
|
||||||
|
one_port_strategies=one_port_strategies,
|
||||||
scale_link_capital_costs=False,
|
scale_link_capital_costs=False,
|
||||||
)
|
)
|
||||||
return clustering.network, busmap
|
return clustering.network, busmap
|
||||||
|
Loading…
Reference in New Issue
Block a user