add option to specify any config through sector opts with CF:<label>:...:value
This commit is contained in:
parent
51c76651ba
commit
cb00ba58ce
@ -11,7 +11,7 @@ import yaml
|
||||
import numpy as np
|
||||
|
||||
from add_existing_baseyear import add_build_year_to_new_assets
|
||||
from helper import override_component_attrs
|
||||
from helper import override_component_attrs, update_config_with_sector_opts
|
||||
from solve_network import basename
|
||||
|
||||
|
||||
@ -123,6 +123,8 @@ if __name__ == "__main__":
|
||||
planning_horizons=2030,
|
||||
)
|
||||
|
||||
update_config_with_sector_opts(snakemake.config, snakemake.wildcards.sector_opts)
|
||||
|
||||
print(snakemake.input.network_p)
|
||||
logging.basicConfig(level=snakemake.config['logging_level'])
|
||||
|
||||
|
@ -13,7 +13,7 @@ import pypsa
|
||||
import yaml
|
||||
|
||||
from prepare_sector_network import prepare_costs, define_spatial
|
||||
from helper import override_component_attrs
|
||||
from helper import override_component_attrs, update_config_with_sector_opts
|
||||
|
||||
from types import SimpleNamespace
|
||||
spatial = SimpleNamespace()
|
||||
@ -463,6 +463,8 @@ if __name__ == "__main__":
|
||||
|
||||
logging.basicConfig(level=snakemake.config['logging_level'])
|
||||
|
||||
update_config_with_sector_opts(snakemake.config, snakemake.wildcards.sector_opts)
|
||||
|
||||
options = snakemake.config["sector"]
|
||||
opts = snakemake.wildcards.sector_opts.split('-')
|
||||
|
||||
|
@ -1,7 +1,9 @@
|
||||
import os
|
||||
import yaml
|
||||
import pytz
|
||||
import pandas as pd
|
||||
from pathlib import Path
|
||||
from mergedeep import merge
|
||||
from pypsa.descriptors import Dict
|
||||
from pypsa.components import components, component_attrs
|
||||
|
||||
@ -124,4 +126,18 @@ def generate_periodic_profiles(dt_index, nodes, weekly_profile, localize=None):
|
||||
|
||||
week_df = week_df.tz_localize(localize)
|
||||
|
||||
return week_df
|
||||
return week_df
|
||||
|
||||
|
||||
def parse(l):
|
||||
if len(l) == 1:
|
||||
return yaml.safe_load(l[0])
|
||||
else:
|
||||
return {l.pop(0): parse(l)}
|
||||
|
||||
|
||||
def update_config_with_sector_opts(config, sector_opts):
|
||||
for o in sector_opts.split("-"):
|
||||
if o.startswith("CF:"):
|
||||
l = o.split(":")[1:]
|
||||
merge(config, parse(l))
|
@ -7,6 +7,7 @@ import matplotlib.pyplot as plt
|
||||
plt.style.use('ggplot')
|
||||
|
||||
from prepare_sector_network import co2_emissions_year
|
||||
from helper import update_config_with_sector_opts
|
||||
|
||||
#consolidate and rename
|
||||
def rename_techs(label):
|
||||
@ -437,7 +438,9 @@ if __name__ == "__main__":
|
||||
if 'snakemake' not in globals():
|
||||
from helper import mock_snakemake
|
||||
snakemake = mock_snakemake('plot_summary')
|
||||
|
||||
|
||||
update_config_with_sector_opts(snakemake.config, snakemake.wildcards.sector_opts)
|
||||
|
||||
n_header = 4
|
||||
|
||||
plot_costs()
|
||||
|
@ -14,7 +14,7 @@ from scipy.stats import beta
|
||||
from vresutils.costdata import annuity
|
||||
|
||||
from build_energy_totals import build_eea_co2, build_eurostat_co2, build_co2_totals
|
||||
from helper import override_component_attrs, generate_periodic_profiles
|
||||
from helper import override_component_attrs, generate_periodic_profiles, update_config_with_sector_opts
|
||||
|
||||
from networkx.algorithms.connectivity.edge_augmentation import k_edge_augmentation
|
||||
from networkx.algorithms import complement
|
||||
@ -2339,6 +2339,8 @@ if __name__ == "__main__":
|
||||
|
||||
logging.basicConfig(level=snakemake.config['logging_level'])
|
||||
|
||||
update_config_with_sector_opts(snakemake.config, snakemake.wildcards.sector_opts)
|
||||
|
||||
options = snakemake.config["sector"]
|
||||
|
||||
opts = snakemake.wildcards.sector_opts.split('-')
|
||||
|
@ -11,7 +11,7 @@ from pypsa.linopf import network_lopf, ilopf
|
||||
|
||||
from vresutils.benchmark import memory_logger
|
||||
|
||||
from helper import override_component_attrs
|
||||
from helper import override_component_attrs, update_config_with_sector_opts
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
@ -290,6 +290,8 @@ if __name__ == "__main__":
|
||||
logging.basicConfig(filename=snakemake.log.python,
|
||||
level=snakemake.config['logging_level'])
|
||||
|
||||
update_config_with_sector_opts(snakemake.config, snakemake.wildcards.sector_opts)
|
||||
|
||||
tmpdir = snakemake.config['solving'].get('tmpdir')
|
||||
if tmpdir is not None:
|
||||
from pathlib import Path
|
||||
|
Loading…
Reference in New Issue
Block a user