Merge pull request #748 from PyPSA/follow-up-637
follow-up to #637: remove duplicate code and update tsam version
This commit is contained in:
commit
7884392326
@ -55,5 +55,5 @@ dependencies:
|
||||
|
||||
|
||||
- pip:
|
||||
- git+https://github.com/fneum/tsam.git@performance
|
||||
- tsam>=2.3.1
|
||||
- pypsa>=0.25.2
|
||||
|
@ -120,7 +120,6 @@ def add_brownfield(n, n_p, year):
|
||||
n.links.loc[new_pipes, "p_nom_min"] = 0.0
|
||||
|
||||
|
||||
# %%
|
||||
if __name__ == "__main__":
|
||||
if "snakemake" not in globals():
|
||||
from _helpers import mock_snakemake
|
||||
|
@ -630,7 +630,6 @@ def add_heating_capacities_installed_before_baseyear(
|
||||
n.mremove("Link", links_i)
|
||||
|
||||
|
||||
# %%
|
||||
if __name__ == "__main__":
|
||||
if "snakemake" not in globals():
|
||||
from _helpers import mock_snakemake
|
||||
|
@ -96,23 +96,6 @@ def prepare_hotmaps_database(regions):
|
||||
gdf.rename(columns={"index_right": "bus"}, inplace=True)
|
||||
gdf["country"] = gdf.bus.str[:2]
|
||||
|
||||
# the .sjoin can lead to duplicates if a geom is in two regions
|
||||
if gdf.index.duplicated().any():
|
||||
import pycountry
|
||||
|
||||
# get all duplicated entries
|
||||
duplicated_i = gdf.index[gdf.index.duplicated()]
|
||||
# convert from raw data country name to iso-2-code
|
||||
s = df.loc[duplicated_i, "Country"].apply(
|
||||
lambda x: pycountry.countries.lookup(x).alpha_2
|
||||
)
|
||||
# Get a boolean mask where gdf's country column matches s's values for the same index
|
||||
mask = gdf["country"] == gdf.index.map(s)
|
||||
# Filter gdf using the mask
|
||||
gdf_filtered = gdf[mask]
|
||||
# concat not duplicated and filtered gdf
|
||||
gdf = pd.concat([gdf.drop(duplicated_i), gdf_filtered]).sort_index()
|
||||
|
||||
# the .sjoin can lead to duplicates if a geom is in two overlapping regions
|
||||
if gdf.index.duplicated().any():
|
||||
# get all duplicated entries
|
||||
@ -164,7 +147,6 @@ def build_nodal_distribution_key(hotmaps, regions, countries):
|
||||
return keys
|
||||
|
||||
|
||||
# %%
|
||||
if __name__ == "__main__":
|
||||
if "snakemake" not in globals():
|
||||
from _helpers import mock_snakemake
|
||||
|
@ -706,7 +706,6 @@ def to_csv(df):
|
||||
df[key].to_csv(snakemake.output[key])
|
||||
|
||||
|
||||
# %%
|
||||
if __name__ == "__main__":
|
||||
# Detect running outside of snakemake and mock snakemake for testing
|
||||
if "snakemake" not in globals():
|
||||
|
@ -1060,7 +1060,6 @@ def plot_map_perfect(
|
||||
)
|
||||
|
||||
|
||||
# %%
|
||||
if __name__ == "__main__":
|
||||
if "snakemake" not in globals():
|
||||
from _helpers import mock_snakemake
|
||||
|
@ -33,8 +33,6 @@ if __name__ == "__main__":
|
||||
lambda s: s != "", "lightgrey"
|
||||
)
|
||||
|
||||
# %%
|
||||
|
||||
def rename_index(ds):
|
||||
specific = ds.index.map(lambda x: f"{x[1]}\n({x[0]})")
|
||||
generic = ds.index.get_level_values("carrier")
|
||||
|
@ -564,7 +564,6 @@ def plot_carbon_budget_distribution(input_eurostat):
|
||||
plt.savefig(path, bbox_inches="tight")
|
||||
|
||||
|
||||
# %%
|
||||
if __name__ == "__main__":
|
||||
if "snakemake" not in globals():
|
||||
from _helpers import mock_snakemake
|
||||
|
@ -274,7 +274,6 @@ def set_line_nom_max(
|
||||
n.links.p_nom_max.clip(upper=p_nom_max_set, inplace=True)
|
||||
|
||||
|
||||
# %%
|
||||
if __name__ == "__main__":
|
||||
if "snakemake" not in globals():
|
||||
from _helpers import mock_snakemake
|
||||
|
@ -493,7 +493,6 @@ def set_temporal_aggregation_SEG(n, opts, solver_name):
|
||||
return n
|
||||
|
||||
|
||||
# %%
|
||||
if __name__ == "__main__":
|
||||
if "snakemake" not in globals():
|
||||
from _helpers import mock_snakemake
|
||||
|
@ -844,7 +844,6 @@ def solve_network(n, config, solving, opts="", **kwargs):
|
||||
return n
|
||||
|
||||
|
||||
# %%
|
||||
if __name__ == "__main__":
|
||||
if "snakemake" not in globals():
|
||||
from _helpers import mock_snakemake
|
||||
|
Loading…
Reference in New Issue
Block a user