Skip to content

Commit de2d413

Browse files
committed
add weather year config to scenarios
1 parent 37c5554 commit de2d413

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

scripts/pypsa-de/build_scenarios.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,47 @@ def get_co2_budget(df, source):
129129
return target_fractions_pypsa.round(3)
130130

131131

132+
def write_weather_dependent_config(config, scenario, weather_year):
133+
# Insert weather-dependent configuration dynamically
134+
cutout_name = f"europe-{weather_year}-sarah3-era5"
135+
136+
# atlite section
137+
config[scenario]["atlite"] = {
138+
"default_cutout": cutout_name,
139+
"cutouts": {
140+
cutout_name: {
141+
"module": ["sarah", "era5"],
142+
"x": [-12.0, 42.0],
143+
"y": [33.0, 72.0],
144+
"dx": 0.3,
145+
"dy": 0.3,
146+
"time": [str(weather_year), str(weather_year)],
147+
}
148+
},
149+
}
150+
151+
# snapshots section
152+
config[scenario]["snapshots"] = {
153+
"start": f"{weather_year}-01-01",
154+
"end": f"{int(weather_year) + 1}-01-01",
155+
"inclusive": "left",
156+
}
157+
158+
# renewable section
159+
config[scenario]["renewable"] = {
160+
"onwind": {"cutout": cutout_name},
161+
"offwind-ac": {"cutout": cutout_name},
162+
"offwind-dc": {"cutout": cutout_name},
163+
"offwind-float": {"cutout": cutout_name},
164+
"solar": {"cutout": cutout_name},
165+
"solar-hsat": {"cutout": cutout_name},
166+
"hydro": {"cutout": cutout_name},
167+
}
168+
169+
# lines section
170+
config[scenario]["lines"] = {"dynamic_line_rating": {"cutout": cutout_name}}
171+
172+
132173
def write_to_scenario_yaml(input, output, scenarios, df):
133174
# read in yaml file
134175
yaml = ruamel.yaml.YAML()
@@ -140,6 +181,13 @@ def write_to_scenario_yaml(input, output, scenarios, df):
140181
f"Found an empty scenario config for {scenario}. Using default config `pypsa.de.yaml`."
141182
)
142183
config[scenario] = {}
184+
if config[scenario].get("weather_year", False):
185+
if snakemake.config["run"]["shared_resources"]["policy"] != False:
186+
logger.warning(
187+
"If you are running scenarios with multiple weather years, make sure to deactivate shared_resources!"
188+
)
189+
weather_year = config[scenario]["weather_year"]
190+
write_weather_dependent_config(config, scenario, weather_year)
143191

144192
reference_scenario = (
145193
config[scenario]

0 commit comments

Comments
 (0)