add weather_year wildcard to mock_snakemake objects

This commit is contained in:
Fabian Neumann 2022-06-15 15:03:17 +02:00
parent 0b27e40710
commit ec4a45b46b
15 changed files with 20 additions and 20 deletions

View File

@ -550,7 +550,7 @@ def add_nice_carrier_names(n, config):
if __name__ == "__main__": if __name__ == "__main__":
if 'snakemake' not in globals(): if 'snakemake' not in globals():
from _helpers import mock_snakemake from _helpers import mock_snakemake
snakemake = mock_snakemake('add_electricity') snakemake = mock_snakemake('add_electricity', weather_year='')
configure_logging(snakemake) configure_logging(snakemake)
n = pypsa.Network(snakemake.input.base_network) n = pypsa.Network(snakemake.input.base_network)

View File

@ -189,7 +189,7 @@ def attach_hydrogen_pipelines(n, costs, elec_opts):
if __name__ == "__main__": if __name__ == "__main__":
if 'snakemake' not in globals(): if 'snakemake' not in globals():
from _helpers import mock_snakemake from _helpers import mock_snakemake
snakemake = mock_snakemake('add_extra_components', network='elec', snakemake = mock_snakemake('add_extra_components', weather_year='',
simpl='', clusters=5) simpl='', clusters=5)
configure_logging(snakemake) configure_logging(snakemake)

View File

@ -71,7 +71,7 @@ logger = logging.getLogger(__name__)
if __name__ == "__main__": if __name__ == "__main__":
if 'snakemake' not in globals(): if 'snakemake' not in globals():
from _helpers import mock_snakemake from _helpers import mock_snakemake
snakemake = mock_snakemake('build_hydro_profile') snakemake = mock_snakemake('build_hydro_profile', weather_year='')
configure_logging(snakemake) configure_logging(snakemake)
config_hydro = snakemake.config['renewable']['hydro'] config_hydro = snakemake.config['renewable']['hydro']

View File

@ -192,11 +192,11 @@ if __name__ == "__main__":
if 'snakemake' not in globals(): if 'snakemake' not in globals():
from _helpers import mock_snakemake from _helpers import mock_snakemake
snakemake = mock_snakemake('build_load_data') snakemake = mock_snakemake('build_load_data', weather_year='')
configure_logging(snakemake) configure_logging(snakemake)
weather_year = snakemake.wildcard.weather_year weather_year = snakemake.wildcards.weather_year
if weather_year: if weather_year:
snapshots = dict( snapshots = dict(
start=weather_year, start=weather_year,

View File

@ -198,7 +198,7 @@ logger = logging.getLogger(__name__)
if __name__ == '__main__': if __name__ == '__main__':
if 'snakemake' not in globals(): if 'snakemake' not in globals():
from _helpers import mock_snakemake from _helpers import mock_snakemake
snakemake = mock_snakemake('build_renewable_profiles', technology='solar') snakemake = mock_snakemake('build_renewable_profiles', technology='solar', weather_year='')
configure_logging(snakemake) configure_logging(snakemake)
pgb.streams.wrap_stderr() pgb.streams.wrap_stderr()

View File

@ -329,7 +329,7 @@ def plot_busmap_for_n_clusters(n, n_clusters, fn=None):
if __name__ == "__main__": if __name__ == "__main__":
if 'snakemake' not in globals(): if 'snakemake' not in globals():
from _helpers import mock_snakemake from _helpers import mock_snakemake
snakemake = mock_snakemake('cluster_network', network='elec', simpl='', clusters='5') snakemake = mock_snakemake('cluster_network', simpl='', clusters='5', weather_year='')
configure_logging(snakemake) configure_logging(snakemake)
n = pypsa.Network(snakemake.input.network) n = pypsa.Network(snakemake.input.network)

View File

@ -426,8 +426,8 @@ def to_csv(dfs, dir):
if __name__ == "__main__": if __name__ == "__main__":
if 'snakemake' not in globals(): if 'snakemake' not in globals():
from _helpers import mock_snakemake from _helpers import mock_snakemake
snakemake = mock_snakemake('make_summary', network='elec', simpl='', snakemake = mock_snakemake('make_summary', simpl='',
clusters='5', ll='copt', opts='Co2L-24H', country='all') clusters='5', ll='copt', opts='Co2L-24H', country='all', weather_year='')
network_dir = os.path.join('..', 'results', 'networks') network_dir = os.path.join('..', 'results', 'networks')
else: else:
network_dir = os.path.join('results', 'networks') network_dir = os.path.join('results', 'networks')

View File

@ -251,9 +251,9 @@ def plot_total_cost_bar(n, opts, ax=None):
if __name__ == "__main__": if __name__ == "__main__":
if 'snakemake' not in globals(): if 'snakemake' not in globals():
from _helpers import mock_snakemake from _helpers import mock_snakemake
snakemake = mock_snakemake('plot_network', network='elec', simpl='', snakemake = mock_snakemake('plot_network', simpl='',
clusters='5', ll='copt', opts='Co2L-24H', clusters='5', ll='copt', opts='Co2L-24H',
attr='p_nom', ext="pdf") attr='p_nom', ext="pdf", weather_year='')
configure_logging(snakemake) configure_logging(snakemake)
set_plot_style() set_plot_style()

View File

@ -48,9 +48,9 @@ def cum_p_nom_max(net, tech, country=None):
if __name__ == "__main__": if __name__ == "__main__":
if 'snakemake' not in globals(): if 'snakemake' not in globals():
from _helpers import mock_snakemake from _helpers import mock_snakemake
snakemake = mock_snakemake('plot_p_nom_max', network='elec', simpl='', snakemake = mock_snakemake('plot_p_nom_max', simpl='',
techs='solar,onwind,offwind-dc', ext='png', techs='solar,onwind,offwind-dc', ext='png',
clusts= '5,full', country= 'all') clusts= '5,full', country= 'all', weather_year='')
configure_logging(snakemake) configure_logging(snakemake)
plot_kwds = dict(drawstyle="steps-post") plot_kwds = dict(drawstyle="steps-post")

View File

@ -165,9 +165,9 @@ def plot_energy(infn, config, fn=None):
if __name__ == "__main__": if __name__ == "__main__":
if 'snakemake' not in globals(): if 'snakemake' not in globals():
from _helpers import mock_snakemake from _helpers import mock_snakemake
snakemake = mock_snakemake('plot_summary', summary='energy', network='elec', snakemake = mock_snakemake('plot_summary', summary='energy',
simpl='', clusters=5, ll='copt', opts='Co2L-24H', simpl='', clusters=5, ll='copt', opts='Co2L-24H',
attr='', ext='png', country='all') attr='', ext='png', country='all', weather_year='')
configure_logging(snakemake) configure_logging(snakemake)
config = snakemake.config config = snakemake.config

View File

@ -60,7 +60,7 @@ def extract_coordinates(s):
if __name__ == "__main__": if __name__ == "__main__":
if 'snakemake' not in globals(): if 'snakemake' not in globals():
from _helpers import mock_snakemake #rule must be enabled in config from _helpers import mock_snakemake #rule must be enabled in config
snakemake = mock_snakemake('prepare_links_p_nom', simpl='', network='elec') snakemake = mock_snakemake('prepare_links_p_nom', simpl='', weather_year='')
configure_logging(snakemake) configure_logging(snakemake)
links_p_nom = pd.read_html('https://en.wikipedia.org/wiki/List_of_HVDC_projects', header=0, match="SwePol")[0] links_p_nom = pd.read_html('https://en.wikipedia.org/wiki/List_of_HVDC_projects', header=0, match="SwePol")[0]

View File

@ -202,7 +202,7 @@ def set_line_nom_max(n, s_nom_max_set=np.inf, p_nom_max_set=np.inf):
if __name__ == "__main__": if __name__ == "__main__":
if 'snakemake' not in globals(): if 'snakemake' not in globals():
from _helpers import mock_snakemake from _helpers import mock_snakemake
snakemake = mock_snakemake('prepare_network', network='elec', simpl='', snakemake = mock_snakemake('prepare_network', weather_year='', simpl='',
clusters='40', ll='v0.3', opts='Co2L-24H') clusters='40', ll='v0.3', opts='Co2L-24H')
configure_logging(snakemake) configure_logging(snakemake)

View File

@ -384,7 +384,7 @@ def cluster(n, n_clusters, config):
if __name__ == "__main__": if __name__ == "__main__":
if 'snakemake' not in globals(): if 'snakemake' not in globals():
from _helpers import mock_snakemake from _helpers import mock_snakemake
snakemake = mock_snakemake('simplify_network', simpl='', network='elec') snakemake = mock_snakemake('simplify_network', weather_year='', simpl='')
configure_logging(snakemake) configure_logging(snakemake)
n = pypsa.Network(snakemake.input.network) n = pypsa.Network(snakemake.input.network)

View File

@ -274,7 +274,7 @@ def solve_network(n, config, opts='', **kwargs):
if __name__ == "__main__": if __name__ == "__main__":
if 'snakemake' not in globals(): if 'snakemake' not in globals():
from _helpers import mock_snakemake from _helpers import mock_snakemake
snakemake = mock_snakemake('solve_network', network='elec', simpl='', snakemake = mock_snakemake('solve_network', weather_year='', simpl='',
clusters='5', ll='copt', opts='Co2L-BAU-CCL-24H') clusters='5', ll='copt', opts='Co2L-BAU-CCL-24H')
configure_logging(snakemake) configure_logging(snakemake)

View File

@ -96,7 +96,7 @@ def set_parameters_from_optimized(n, n_optim):
if __name__ == "__main__": if __name__ == "__main__":
if 'snakemake' not in globals(): if 'snakemake' not in globals():
from _helpers import mock_snakemake from _helpers import mock_snakemake
snakemake = mock_snakemake('solve_operations_network', network='elec', snakemake = mock_snakemake('solve_operations_network', weather_year='',
simpl='', clusters='5', ll='copt', opts='Co2L-BAU-24H') simpl='', clusters='5', ll='copt', opts='Co2L-BAU-24H')
configure_logging(snakemake) configure_logging(snakemake)