Skip to content

Commit

Permalink
Merge branch 'master' into fneum/import-benefits
Browse files Browse the repository at this point in the history
  • Loading branch information
fneum committed Sep 18, 2024
2 parents cdf9455 + 38f2dc7 commit 8cdb8a1
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
activate-environment: pypsa-eur

- name: Cache Conda env
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ env.CONDA }}/envs
key: conda-${{ runner.os }}--${{ runner.arch }}--${{ env.today }}-${{ hashFiles('envs/environment.yaml') }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@ jobs:
graphs/energy.svg
graphs/costs.svg
graphs/balances-energy.svg
graphs/balances-urban_central_heat.svg
graphs/balances-urban_decentral_heat.svg
graphs/balances-rural_heat.svg
"
validator_key: ${{ secrets.VALIDATOR_KEY }}
2 changes: 2 additions & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ Upcoming Release

* Added 98% imperfect capture rate of Allam cycle gas turbine.

* Resolved a problem where excluding certain countries from `countries` configuration led to clustering errors.

PyPSA-Eur 0.13.0 (13th September 2024)
======================================

Expand Down
8 changes: 4 additions & 4 deletions rules/build_sector.smk
Original file line number Diff line number Diff line change
Expand Up @@ -944,15 +944,15 @@ rule time_aggregation:
),
output:
snapshot_weightings=resources(
"snapshot_weightings_base_s_{clusters}_elec_l{ll}_{opts}.csv"
"snapshot_weightings_base_s_{clusters}_elec_l{ll}_{opts}_{sector_opts}.csv"
),
threads: 1
resources:
mem_mb=5000,
log:
logs("time_aggregation_base_s_{clusters}_elec_l{ll}_{opts}.log"),
logs("time_aggregation_base_s_{clusters}_elec_l{ll}_{opts}_{sector_opts}.log"),
benchmark:
benchmarks("time_aggregation_base_s_{clusters}_elec_l{ll}_{opts}")
benchmarks("time_aggregation_base_s_{clusters}_elec_l{ll}_{opts}_{sector_opts}")
conda:
"../envs/environment.yaml"
script:
Expand Down Expand Up @@ -1024,7 +1024,7 @@ rule prepare_sector_network:
**rules.cluster_gas_network.output,
**rules.build_gas_input_locations.output,
snapshot_weightings=resources(
"snapshot_weightings_base_s_{clusters}_elec_l{ll}_{opts}.csv"
"snapshot_weightings_base_s_{clusters}_elec_l{ll}_{opts}_{sector_opts}.csv"
),
retro_cost=lambda w: (
resources("retro_cost_base_s_{clusters}.csv")
Expand Down
16 changes: 13 additions & 3 deletions scripts/base_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def _find_closest_links(links, new_links, distance_upper_bound=1.5):
)


def _load_buses(buses, europe_shape, config):
def _load_buses(buses, europe_shape, countries, config):
buses = (
pd.read_csv(
buses,
Expand All @@ -161,6 +161,12 @@ def _load_buses(buses, europe_shape, config):
lambda p: europe_shape_prepped.contains(Point(p)), axis=1
)

buses_in_countries_b = (
buses.country.isin(countries)
if "country" in buses
else pd.Series(True, buses.index)
)

v_nom_min = min(config["electricity"]["voltages"])
v_nom_max = max(config["electricity"]["voltages"])

Expand All @@ -173,7 +179,9 @@ def _load_buses(buses, europe_shape, config):
)

logger.info(f"Removing buses outside of range AC {v_nom_min} - {v_nom_max} V")
return pd.DataFrame(buses.loc[buses_in_europe_b & buses_with_v_nom_to_keep_b])
return pd.DataFrame(
buses.loc[buses_in_europe_b & buses_in_countries_b & buses_with_v_nom_to_keep_b]
)


def _load_transformers(buses, transformers):
Expand Down Expand Up @@ -712,6 +720,7 @@ def base_network(
europe_shape,
country_shapes,
offshore_shapes,
countries,
parameter_corrections,
config,
):
Expand All @@ -736,7 +745,7 @@ def base_network(
)
logger.info(logger_str)

buses = _load_buses(buses, europe_shape, config)
buses = _load_buses(buses, europe_shape, countries, config)
transformers = _load_transformers(buses, transformers)
lines = _load_lines(buses, lines)

Expand Down Expand Up @@ -1006,6 +1015,7 @@ def append_bus_shapes(n, shapes, type):
europe_shape,
country_shapes,
offshore_shapes,
countries,
parameter_corrections,
config,
)
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_district_heat_share.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
configure_logging(snakemake)
set_scenario_config(snakemake)

investment_year = int(snakemake.wildcards.planning_horizons[-4:])
investment_year = int(snakemake.wildcards.planning_horizons)

pop_layout = pd.read_csv(snakemake.input.clustered_pop_layout, index_col=0)

Expand Down
2 changes: 1 addition & 1 deletion scripts/build_industry_sector_ratios_intermediate.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def build_industry_sector_ratios_intermediate():
planning_horizons="2030",
)

year = int(snakemake.wildcards.planning_horizons[-4:])
year = int(snakemake.wildcards.planning_horizons)

params = snakemake.params.industry

Expand Down
2 changes: 1 addition & 1 deletion scripts/prepare_sector_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -5165,7 +5165,7 @@ def add_enhanced_geothermal(n, egs_potentials, egs_overlap, costs):
options = snakemake.params.sector
cf_industry = snakemake.params.industry

investment_year = int(snakemake.wildcards.planning_horizons[-4:])
investment_year = int(snakemake.wildcards.planning_horizons)

n = pypsa.Network(snakemake.input.network)

Expand Down

0 comments on commit 8cdb8a1

Please sign in to comment.