diff --git a/envs/environment.yaml b/envs/environment.yaml index 696eb01f..b9d6e8ad 100644 --- a/envs/environment.yaml +++ b/envs/environment.yaml @@ -55,5 +55,5 @@ dependencies: - pip: - - git+https://github.com/fneum/tsam.git@performance + - tsam>=2.3.1 - pypsa>=0.25.2 diff --git a/scripts/add_brownfield.py b/scripts/add_brownfield.py index 679060b3..74102580 100644 --- a/scripts/add_brownfield.py +++ b/scripts/add_brownfield.py @@ -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 diff --git a/scripts/add_existing_baseyear.py b/scripts/add_existing_baseyear.py index 7cdca5af..1474b004 100644 --- a/scripts/add_existing_baseyear.py +++ b/scripts/add_existing_baseyear.py @@ -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 diff --git a/scripts/build_industrial_distribution_key.py b/scripts/build_industrial_distribution_key.py index 888a1a96..b86d47c2 100644 --- a/scripts/build_industrial_distribution_key.py +++ b/scripts/build_industrial_distribution_key.py @@ -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 diff --git a/scripts/make_summary_perfect.py b/scripts/make_summary_perfect.py index 8bb225ae..7ca4055d 100644 --- a/scripts/make_summary_perfect.py +++ b/scripts/make_summary_perfect.py @@ -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(): diff --git a/scripts/plot_network.py b/scripts/plot_network.py index c2ba72c7..f44bb6de 100644 --- a/scripts/plot_network.py +++ b/scripts/plot_network.py @@ -1060,7 +1060,6 @@ def plot_map_perfect( ) -# %% if __name__ == "__main__": if "snakemake" not in globals(): from _helpers import mock_snakemake diff --git a/scripts/plot_statistics.py b/scripts/plot_statistics.py index 1e75203f..b2728931 100644 --- a/scripts/plot_statistics.py +++ b/scripts/plot_statistics.py @@ -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") diff --git a/scripts/plot_summary.py b/scripts/plot_summary.py index a40563f6..2651878a 100644 --- a/scripts/plot_summary.py +++ b/scripts/plot_summary.py @@ -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 diff --git a/scripts/prepare_network.py b/scripts/prepare_network.py index a5a00a3c..90d6ed2e 100755 --- a/scripts/prepare_network.py +++ b/scripts/prepare_network.py @@ -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 diff --git a/scripts/prepare_perfect_foresight.py b/scripts/prepare_perfect_foresight.py index 73b4d0e1..00f23fab 100644 --- a/scripts/prepare_perfect_foresight.py +++ b/scripts/prepare_perfect_foresight.py @@ -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 diff --git a/scripts/solve_network.py b/scripts/solve_network.py index ed566eaf..224d4714 100644 --- a/scripts/solve_network.py +++ b/scripts/solve_network.py @@ -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