Custom Wildcards in PyPSA

105 views
Skip to first unread message

Alexander Meisinger

unread,
Feb 26, 2025, 2:24:15 AM2/26/25
to pypsa
Dear community, 

I wanted to customize my own wildcards to run multiple scenarios at the same time without downloading all data bundles again. For this, I have created different wildcards in _helpers.py (see attachement), like 

```if w.get("sector_opts"):
        opts = w.sector_opts.split("-")

        if "highh2industry" in opts:
            config["industry"]["H2_DRI"] = 17

if "hightransportfuelcellshare" in opts:
            config["sector"]["land_transport_fuel_cell_share"][2020] = 0
            config["sector"]["land_transport_fuel_cell_share"][2025] = 0.15
            config["sector"]["land_transport_fuel_cell_share"][2030] = 0.3
            config["sector"]["land_transport_fuel_cell_share"][2035] = 0.45
            config["sector"]["land_transport_fuel_cell_share"][2040] = 0.7
            config["sector"]["land_transport_fuel_cell_share"][2045] = 0.85
            config["sector"]["land_transport_fuel_cell_share"][2050] = 1

            config["sector"]["land_transport_electric_share"][2020] = 0
            config["sector"]["land_transport_electric_share"][2025] = 0
            config["sector"]["land_transport_electric_share"][2030] = 0
            config["sector"]["land_transport_electric_share"][2035] = 0
            config["sector"]["land_transport_electric_share"][2040] = 0
            config["sector"]["land_transport_electric_share"][2045] = 0
            config["sector"]["land_transport_electric_share"][2050] = 0```

The ran the scenario using following config setting: 
```sector_opts: 
- '144H-hightransportfuelcellshare'
- '144H-highh2industry'```   

When checking my results, I noticed that the transport sector adjustments worked out. However, the industry adjustments can be seen in the result config, but not in the results.

Does someone know, if I can do it in such a way? 

Best regards, 
Alex


_helpers.txt

Fabian Neumann

unread,
Mar 12, 2025, 6:15:32 AM3/12/25
to pypsa
Hi Alex,

I would say it is generally possible to do it in this way, as long as the rule in which the relevant config settings are applied has the {sector_opts} wildcard in its outputs.

A cleaner version would use the scenario management we introduced a couple of versions back:


We will phase out the opts and sector_opts wildcards soon-ish.

Best wishes,

Fabian N

Alexander Meisinger

unread,
Mar 18, 2025, 7:05:37 AM3/18/25
to pypsa
Dear Fabian, 

this helps a lot. Thanks for your answer!

Best regards, 
Alex

Reply all
Reply to author
Forward
0 new messages