From f28a088ea3b1f49214e82dde5ccddcfb93c2d0db Mon Sep 17 00:00:00 2001 From: martacki Date: Fri, 14 Jan 2022 11:30:15 +0100 Subject: [PATCH] arguments in function calls instead of kwarg-style --- scripts/add_electricity.py | 4 ++-- scripts/add_extra_components.py | 2 +- scripts/cluster_network.py | 8 +++----- scripts/prepare_network.py | 10 ++++------ scripts/solve_network.py | 3 +-- scripts/solve_operations_network.py | 5 ++--- 6 files changed, 13 insertions(+), 19 deletions(-) diff --git a/scripts/add_electricity.py b/scripts/add_electricity.py index cbefba2f..fcddea8c 100755 --- a/scripts/add_electricity.py +++ b/scripts/add_electricity.py @@ -549,11 +549,11 @@ if __name__ == "__main__": n = pypsa.Network(paths.base_network) Nyears = n.snapshot_weightings.objective.sum() / 8760. - costs = load_costs(paths.tech_costs, config['costs'], config['electricity'], Nyears=Nyears) + costs = load_costs(paths.tech_costs, config['costs'], config['electricity'], Nyears) ppl = load_powerplants(paths.powerplants) attach_load(n, paths.regions, paths.load, paths.nuts3_shapes, config['countries'], - scaling=config['load']['scaling_factor']) + config['load']['scaling_factor']) update_transmission_costs(n, costs, config['lines']['length_factor']) diff --git a/scripts/add_extra_components.py b/scripts/add_extra_components.py index 35947aee..0531c9fa 100644 --- a/scripts/add_extra_components.py +++ b/scripts/add_extra_components.py @@ -199,7 +199,7 @@ if __name__ == "__main__": elec_config = config['electricity'] Nyears = n.snapshot_weightings.objective.sum() / 8760. - costs = load_costs(paths.tech_costs, config['costs'], elec_config, Nyears=Nyears) + costs = load_costs(paths.tech_costs, config['costs'], elec_config, Nyears) attach_storageunits(n, costs, elec_config) attach_stores(n, costs, elec_config) diff --git a/scripts/cluster_network.py b/scripts/cluster_network.py index 71dd1746..041fb259 100644 --- a/scripts/cluster_network.py +++ b/scripts/cluster_network.py @@ -374,12 +374,10 @@ if __name__ == "__main__": custom_busmap = pd.read_csv(paths.custom_busmap, index_col=0, squeeze=True) custom_busmap.index = custom_busmap.index.astype(str) logger.info(f"Imported custom busmap from {paths.custom_busmap}") + clustering = clustering_for_n_clusters(n, n_clusters, custom_busmap, aggregate_carriers, - line_length_factor=line_length_factor, - potential_mode=potential_mode, - solver_name=config['solving']['solver']['name'], - extended_link_costs=hvac_overhead_cost, - focus_weights=focus_weights) + line_length_factor, potential_mode, config['solving']['solver']['name'], + "kmeans", hvac_overhead_cost, focus_weights) update_p_nom_max(n) diff --git a/scripts/prepare_network.py b/scripts/prepare_network.py index 19a395ea..e0b488f5 100755 --- a/scripts/prepare_network.py +++ b/scripts/prepare_network.py @@ -140,7 +140,7 @@ def average_every_nhours(n, offset): return m -def apply_time_segmentation(n, segments, solver_name="cplex"): +def apply_time_segmentation(n, segments, solver_name="cbc"): logger.info(f"Aggregating time series to {segments} segments.") try: import tsam.timeseriesaggregation as tsam @@ -212,11 +212,9 @@ if __name__ == "__main__": n = pypsa.Network(paths[0]) Nyears = n.snapshot_weightings.objective.sum() / 8760. - costs = load_costs(tech_costs = paths.tech_costs, - config = config['costs'], - elec_config = config['electricity'], Nyears = Nyears) + costs = load_costs(paths.tech_costs, config['costs'], config['electricity'], Nyears) - set_line_s_max_pu(n, s_max_pu=config['lines']['s_max_pu']) + set_line_s_max_pu(n, config['lines']['s_max_pu']) for o in opts: m = re.match(r'^\d+h$', o, re.IGNORECASE) @@ -228,7 +226,7 @@ if __name__ == "__main__": m = re.match(r'^\d+seg$', o, re.IGNORECASE) if m is not None: solver_name = config["solving"]["solver"]["name"] - n = apply_time_segmentation(n, m.group(0)[:-3], solver_name=solver_name) + n = apply_time_segmentation(n, m.group(0)[:-3], solver_name) break for o in opts: diff --git a/scripts/solve_network.py b/scripts/solve_network.py index 1aaf4970..6f2124da 100755 --- a/scripts/solve_network.py +++ b/scripts/solve_network.py @@ -285,8 +285,7 @@ if __name__ == "__main__": with memory_logger(filename=fn, interval=30.) as mem: n = pypsa.Network(paths[0]) n = prepare_network(n, solve_opts) - n = solve_network(n, config=config, opts=opts, - solver_dir=tmpdir, + n = solve_network(n, config, opts, solver_dir=tmpdir, solver_logfile=logs.solver) n.export_to_netcdf(out[0]) diff --git a/scripts/solve_operations_network.py b/scripts/solve_operations_network.py index baea5a5c..6490ce51 100644 --- a/scripts/solve_operations_network.py +++ b/scripts/solve_operations_network.py @@ -116,9 +116,8 @@ if __name__ == "__main__": fn = getattr(logs, 'memory', None) with memory_logger(filename=fn, interval=30.) as mem: - n = prepare_network(n, solve_opts=config['solving']['options']) - n = solve_network(n, config=config, opts=opts, - solver_dir=tmpdir, + n = prepare_network(n, config['solving']['options']) + n = solve_network(n, config, opts, solver_dir=tmpdir, solver_logfile=logs.solver) n.export_to_netcdf(out[0])