Skip to content

Commit

Permalink
Merge pull request #313 from finozzifa/issue_312_use_single_config
Browse files Browse the repository at this point in the history
Issue 312 use single config
  • Loading branch information
davide-f authored Jun 5, 2024
2 parents 5bd4f81 + a366595 commit cad684a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
1 change: 1 addition & 0 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ if not exists("config.yaml"):
copyfile("config.default.yaml", "config.yaml")


configfile: "config.pypsa-earth.yaml"
configfile: "config.yaml"


Expand Down
26 changes: 8 additions & 18 deletions scripts/prepare_gas_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,15 @@
import matplotlib.colors as colors
import matplotlib.pyplot as plt
import pandas as pd
import ruamel.yaml
from helpers import (
progress_retrieve,
three_2_two_digits_country,
two_2_three_digits_country,
)
from matplotlib.lines import Line2D
from packaging.version import Version, parse
from pyproj import CRS
from pypsa.geo import haversine_pts
from shapely import wkt
from shapely.geometry import LineString, MultiLineString, Point
from shapely.geometry import LineString, Point
from shapely.ops import unary_union
from shapely.validation import make_valid

Expand Down Expand Up @@ -532,21 +529,14 @@ def load_bus_region(onshore_path, pipelines):
]

if snakemake.config["clustering_options"]["alternative_clustering"]:
# Read the YAML file
yaml = ruamel.yaml.YAML()
file_path = "./config.pypsa-earth.yaml"
with open(file_path, "r") as file:
config_pypsa_earth = yaml.load(file)

countries_list = snakemake.config["countries"]
layer_id = config_pypsa_earth["build_shape_options"]["gadm_layer_id"]
update = config_pypsa_earth["build_shape_options"]["update_file"]
out_logging = config_pypsa_earth["build_shape_options"]["out_logging"]
year = config_pypsa_earth["build_shape_options"]["year"]
nprocesses = config_pypsa_earth["build_shape_options"]["nprocesses"]
contended_flag = config_pypsa_earth["build_shape_options"]["contended_flag"]
geo_crs = config_pypsa_earth["crs"]["geo_crs"]
distance_crs = config_pypsa_earth["crs"]["distance_crs"]
layer_id = snakemake.config["build_shape_options"]["gadm_layer_id"]
update = snakemake.config["build_shape_options"]["update_file"]
out_logging = snakemake.config["build_shape_options"]["out_logging"]
year = snakemake.config["build_shape_options"]["year"]
nprocesses = snakemake.config["build_shape_options"]["nprocesses"]
contended_flag = snakemake.config["build_shape_options"]["contended_flag"]
geo_crs = snakemake.config["crs"]["geo_crs"]

bus_regions_onshore = gadm(
countries_list,
Expand Down
2 changes: 2 additions & 0 deletions scripts/solve_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,4 +608,6 @@ def add_existing(n):
n.meta = dict(snakemake.config, **dict(wildcards=dict(snakemake.wildcards)))
n.export_to_netcdf(snakemake.output[0])

logger.info("Objective function: {}".format(n.objective))
logger.info("Objective constant: {}".format(n.objective_constant))
logger.info("Maximum memory usage: {}".format(mem.mem_usage))

0 comments on commit cad684a

Please sign in to comment.