Skip to content

Commit

Permalink
add_electricity: for current RES use GEM not OPSD
Browse files Browse the repository at this point in the history
  • Loading branch information
fneum committed Jan 4, 2025
1 parent 3cad80b commit 46ccd6d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion config/config.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ electricity:

estimate_renewable_capacities:
enable: true
from_opsd: true
from_gem: true
year: 2020
expansion_limit: false
technology_mapping:
Expand Down
8 changes: 4 additions & 4 deletions doc/configtables/electricity.csv
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ conventional_carriers,--,"Any subset of {nuclear, oil, OCGT, CCGT, coal, lignite
renewable_carriers,--,"Any subset of {solar, onwind, offwind-ac, offwind-dc, offwind-float, hydro}",List of renewable generators to include in the model.
estimate_renewable_capacities,,,
-- enable,,bool,Activate routine to estimate renewable capacities in rule :mod:`add_electricity`. This option should not be used in combination with pathway planning ``foresight: myopic`` or ``foresight: perfect`` as renewable capacities are added differently in :mod:`add_existing_baseyear`.
-- from_opsd,--,bool,Add renewable capacities from `OPSD database <https://data.open-power-system-data.org/renewable_power_plants/2020-08-25>`_. The value is depreciated but still can be used.
-- from_gem,--,bool,Add renewable capacities from `Global Energy Monitor's Global Solar Power Tracker <https://globalenergymonitor.org/projects/global-solar-power-tracker/>`_ and `Global Energy Monitor's Global Wind Power Tracker <https://globalenergymonitor.org/projects/global-wind-power-tracker/>`_.
-- year,--,bool,Renewable capacities are based on existing capacities reported by IRENA (IRENASTAT) for the specified year
-- expansion_limit,--,float or false,"Artificially limit maximum IRENA capacities to a factor. For example, an ``expansion_limit: 1.1`` means 110% of capacities . If false are chosen, the estimated renewable potentials determine by the workflow are used."
-- technology_mapping,,,Mapping between PyPSA-Eur and powerplantmatching technology names
-- -- Offshore,--,"Any subset of {offwind-ac, offwind-dc, offwind-float}","List of PyPSA-Eur carriers that is considered as (IRENA, OPSD) onshore technology."
-- -- Offshore,--,{onwind},"List of PyPSA-Eur carriers that is considered as (IRENA, OPSD) offshore technology."
-- -- PV,--,{solar},"List of PyPSA-Eur carriers that is considered as (IRENA, OPSD) PV technology."
-- -- Offshore,--,"Any subset of {offwind-ac, offwind-dc, offwind-float}","List of PyPSA-Eur carriers that is considered as (IRENA, GEM) onshore technology."
-- -- Offshore,--,{onwind},"List of PyPSA-Eur carriers that is considered as (IRENA, GEM) offshore technology."
-- -- PV,--,{solar},"List of PyPSA-Eur carriers that is considered as (IRENA, GEM) PV technology."
autarky,,,
-- enable,bool,true or false,Require each node to be autarkic by removing all lines and links.
-- by_country,bool,true or false,Require each country to be autarkic by removing all cross-border lines and links. ``electricity: autarky`` must be enabled.
2 changes: 1 addition & 1 deletion scripts/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def handle_exception(exc_type, exc_value, exc_traceback):

def update_p_nom_max(n):
# if extendable carriers (solar/onwind/...) have capacity >= 0,
# e.g. existing assets from the OPSD project are included to the network,
# e.g. existing assets from GEM are included to the network,
# the installed capacity might exceed the expansion limit.
# Hence, we update the assumptions.

Expand Down
15 changes: 8 additions & 7 deletions scripts/add_electricity.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,9 +760,9 @@ def attach_hydro(n, costs, ppl, profile_hydro, hydro_capacities, carriers, **par
)


def attach_OPSD_renewables(n: pypsa.Network, tech_map: dict[str, list[str]]) -> None:
def attach_GEM_renewables(n: pypsa.Network, tech_map: dict[str, list[str]]) -> None:
"""
Attach renewable capacities from the OPSD dataset to the network.
Attach renewable capacities from the GEM dataset to the network.
Args:
- n: The PyPSA network to attach the capacities to.
Expand All @@ -772,21 +772,22 @@ def attach_OPSD_renewables(n: pypsa.Network, tech_map: dict[str, list[str]]) ->
- None
"""
tech_string = ", ".join(sum(tech_map.values(), []))
logger.info(f"Using OPSD renewable capacities for carriers {tech_string}.")
logger.info(f"Using GEM renewable capacities for carriers {tech_string}.")

df = pm.data.OPSD_VRE().powerplant.convert_country_to_alpha2()
df = pm.data.GEM().powerplant.convert_country_to_alpha2()
technology_b = ~df.Technology.isin(["Onshore", "Offshore"])
df["Fueltype"] = df.Fueltype.where(technology_b, df.Technology).replace(
{"Solar": "PV"}
)
df = df.query("Fueltype in @tech_map").powerplant.convert_country_to_alpha2()
df = df.query("Fueltype in @tech_map")
df = df.dropna(subset=["lat", "lon"])

for fueltype, carriers in tech_map.items():
gens = n.generators[lambda df: df.carrier.isin(carriers)]
buses = n.buses.loc[gens.bus.unique()]
gens_per_bus = gens.groupby("bus").p_nom.count()

# assuming equal distribution of capacities per generator at each bus
caps = map_country_bus(df.query("Fueltype == @fueltype"), buses)
caps = caps.groupby(["bus"]).Capacity.sum()
caps = caps / gens_per_bus.reindex(caps.index, fill_value=1)
Expand Down Expand Up @@ -1097,8 +1098,8 @@ def attach_stores(n, costs, extendable_carriers):
expansion_limit = estimate_renewable_caps["expansion_limit"]
year = estimate_renewable_caps["year"]

if estimate_renewable_caps["from_opsd"]:
attach_OPSD_renewables(n, tech_map)
if estimate_renewable_caps["from_gem"]:
attach_GEM_renewables(n, tech_map)

estimate_renewable_capacities(
n, year, tech_map, expansion_limit, params.countries
Expand Down

0 comments on commit 46ccd6d

Please sign in to comment.