Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various bug fixes #580

Merged
merged 19 commits into from
Jan 26, 2023
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ rule clean:


rule run_tests:
input:
"",
output:
touch("tests.done"),
run:
import os

Expand Down
3 changes: 3 additions & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ Upcoming Release

* Add pypsa-eur scenario management `PR #577 <https://github.com/pypsa-meets-earth/pypsa-earth/pull/577>`__

* Minor bug fixing and improvements `PR #580 <https://github.com/pypsa-meets-earth/pypsa-earth/pull/580>`__


PyPSA-Earth 0.1.0
=================

Expand Down
7 changes: 5 additions & 2 deletions scripts/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,14 +570,17 @@ def read_csv_nafix(file, **kwargs):
if "na_values" in kwargs:
del kwargs["na_values"]

return pd.read_csv(file, **kwargs, keep_default_na=False, na_values=NA_VALUES)
if os.stat(file).st_size > 0:
return pd.read_csv(file, **kwargs, keep_default_na=False, na_values=NA_VALUES)
else:
return pd.DataFrame()


def to_csv_nafix(df, path, **kwargs):
if "na_rep" in kwargs:
del kwargs["na_rep"]
# if len(df) > 0:
if not df.empty:
if not df.empty or not df.columns.empty:
return df.to_csv(path, **kwargs, na_rep=NA_VALUES[0])
else:
with open(path, "w") as fp:
Expand Down
2 changes: 1 addition & 1 deletion scripts/add_electricity.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ def get_load_paths_gegis(ssp_parentfolder, config):
str(ssp),
str(prediction_year),
"era5_" + str(weather_year),
str(continent).capitalize() + ".nc",
str(continent) + ".nc",
)
load_paths.append(load_path)

Expand Down
24 changes: 13 additions & 11 deletions scripts/add_extra_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
logger = logging.getLogger(__name__)


def attach_storageunits(n, costs):
elec_opts = snakemake.config["electricity"]
def attach_storageunits(n, costs, config):
elec_opts = config["electricity"]
carriers = elec_opts["extendable_carriers"]["StorageUnit"]
max_hours = elec_opts["max_hours"]

Expand Down Expand Up @@ -98,8 +98,8 @@ def attach_storageunits(n, costs):
)


def attach_stores(n, costs):
elec_opts = snakemake.config["electricity"]
def attach_stores(n, costs, config):
elec_opts = config["electricity"]
carriers = elec_opts["extendable_carriers"]["Store"]

_add_missing_carriers_from_costs(n, costs, carriers)
Expand Down Expand Up @@ -185,8 +185,8 @@ def attach_stores(n, costs):
)


def attach_hydrogen_pipelines(n, costs):
elec_opts = snakemake.config["electricity"]
def attach_hydrogen_pipelines(n, costs, config):
elec_opts = config["electricity"]
ext_carriers = elec_opts["extendable_carriers"]
as_stores = ext_carriers.get("Store", [])

Expand Down Expand Up @@ -236,16 +236,18 @@ def attach_hydrogen_pipelines(n, costs):

n = pypsa.Network(snakemake.input.network)
Nyears = n.snapshot_weightings.objective.sum() / 8760.0
config = snakemake.config

costs = load_costs(
snakemake.input.tech_costs,
snakemake.config["costs"],
snakemake.config["electricity"],
config["costs"],
config["electricity"],
Nyears,
)

attach_storageunits(n, costs)
attach_stores(n, costs)
attach_hydrogen_pipelines(n, costs)
attach_storageunits(n, costs, config)
attach_stores(n, costs, config)
attach_hydrogen_pipelines(n, costs, config)

add_nice_carrier_names(n, config=snakemake.config)

Expand Down
2 changes: 1 addition & 1 deletion scripts/augmented_line_connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def haversine(p):
lifetime=costs.at["HVAC overhead", "lifetime"],
)

_set_links_underwater_fraction(n)
_set_links_underwater_fraction(snakemake.input.regions_offshore, n)

n.meta = dict(snakemake.config, **dict(wildcards=dict(snakemake.wildcards)))
n.export_to_netcdf(snakemake.output.network)
Loading