Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
18 changes: 9 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exclude: "^LICENSES"

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v6.0.0
hooks:
- id: check-merge-conflict
- id: end-of-file-fixer
Expand All @@ -19,51 +19,51 @@ repos:

# Sort package imports alphabetically
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 7.0.0
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]

# Find common spelling mistakes in comments and docstrings
- repo: https://github.com/codespell-project/codespell
rev: v2.2.2
rev: v2.4.1
hooks:
- id: codespell
args: ['--ignore-regex="\b[A-Z]+\b"'] # Ignore capital case words, e.g. country codes
types_or: [python, rst, markdown]
files: ^(actions|doc)/

# Formatting with "black" coding style
- repo: https://github.com/psf/black
rev: 22.10.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.1.0
hooks:
# Format Python files
- id: black
# Format Jupyter Python notebooks
- id: black-jupyter

- repo: https://github.com/nbQA-dev/nbQA
rev: 1.5.3
rev: 1.9.1
hooks:
# Apply isort to Jupyter Python notebooks
- id: nbqa-isort

# Do YAML formatting (before the linter checks it for misses)
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.4.0
rev: v2.16.0
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, '2', --preserve-quotes]

# Format Snakemake rule / workflow files
- repo: https://github.com/snakemake/snakefmt
rev: v0.7.0
rev: v0.11.4
hooks:
- id: snakefmt

# Check for FSFE REUSE compliance (licensing)
- repo: https://github.com/fsfe/reuse-tool
rev: v1.0.0
rev: v6.2.0
hooks:
- id: reuse

Expand Down
7 changes: 3 additions & 4 deletions actions/create_network.py.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@
"def scale_transportation_with_distance(\n",
" n, link_types=[\"HVDC overhead\", \"HVDC submarine\", \"pipeline\", \"submarine pipeline\"]\n",
"):\n",
"\n",
" \"\"\"Scales the cost and efficiency of specific links (transport options) by distance.\n",
"\n",
" Only implemented for:\n",
Expand Down Expand Up @@ -752,9 +751,9 @@
" & (loaded_unloaded_ratio[\"from\"] == \"LOHC (loaded)\")\n",
" & (loaded_unloaded_ratio[\"to\"] == \"LOHC (used)\")\n",
" ][\"efficiency\"].item()\n",
" n.links.loc[\n",
" f\"{ship_bus} trip demand & losses\", \"bus2\"\n",
" ] = f\"{ship_bus} LOHC (used)\"\n",
" n.links.loc[f\"{ship_bus} trip demand & losses\", \"bus2\"] = (\n",
" f\"{ship_bus} LOHC (used)\"\n",
" )\n",
" n.links.loc[f\"{ship_bus} trip demand & losses\", \"efficiency2\"] = (\n",
" 1 - shipping_efficiency\n",
" ) * loaded_unloaded_ratio\n",
Expand Down
2 changes: 1 addition & 1 deletion actions/solve_network.py.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
" (\"links\", \"pipeline\", \"CAPEX_pipeline\"),\n",
" (\"links\", \"methanolisation\", \"CAPEX_MeOHSynthesis\"),\n",
" ]\n",
" for (components_name, search_string, modifier_name) in mapping:\n",
" for components_name, search_string, modifier_name in mapping:\n",
" c = getattr(n, components_name)\n",
" c.loc[c.index.str.contains(search_string), \"capital_cost\"] *= scenario[\n",
" \"modifiers\"\n",
Expand Down
22 changes: 12 additions & 10 deletions analysis/plot_paper_figures.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
"source": [
"# Take a list of labels and rename the ESCs from that list\n",
"# to more prettier (and shorter) names\n",
"\n",
"\n",
"def prettiefy_esc_names(labels):\n",
"\n",
" prettier_names = {\n",
Expand Down Expand Up @@ -628,8 +630,8 @@
"fig = plt.figure(figsize=(12, 4))\n",
"ax = plt.gca()\n",
"\n",
"for (esc, x) in zip(esc_markers.keys(), xs):\n",
" for ((idx, row), xx) in zip(df.loc[esc].sort_values(\"value\").iterrows(), xxs):\n",
"for esc, x in zip(esc_markers.keys(), xs):\n",
" for (idx, row), xx in zip(df.loc[esc].sort_values(\"value\").iterrows(), xxs):\n",
" ax.bar(\n",
" x + xx * width - (xxs.shape[0] - 1) * width / 2,\n",
" row[\"value\"],\n",
Expand Down Expand Up @@ -694,8 +696,8 @@
"fig = plt.figure(figsize=(10, 6))\n",
"ax = plt.gca()\n",
"\n",
"for (esc, x) in zip(esc_markers.keys(), xs):\n",
" for (year, xx) in zip(years, xxs):\n",
"for esc, x in zip(esc_markers.keys(), xs):\n",
" for year, xx in zip(years, xxs):\n",
" for idx, row in df.loc[esc, year].iterrows():\n",
" # Single value dots\n",
" ax.scatter(\n",
Expand Down Expand Up @@ -777,8 +779,8 @@
"fig = plt.figure(figsize=(10, 6))\n",
"ax = plt.gca()\n",
"\n",
"for (esc, x) in zip(esc_markers.keys(), xs):\n",
" for (year, xx) in zip(years, xxs):\n",
"for esc, x in zip(esc_markers.keys(), xs):\n",
" for year, xx in zip(years, xxs):\n",
" for idx, row in df.loc[esc, year].iterrows():\n",
" # Individual dots\n",
" ax.scatter(\n",
Expand Down Expand Up @@ -888,8 +890,8 @@
"ax = plt.gca()\n",
"\n",
"# Plot each vertical year line and each scatter point separately\n",
"for (esc, x) in zip(conversion_factors.keys(), xs):\n",
" for (year, xx) in zip(years, xxs):\n",
"for esc, x in zip(conversion_factors.keys(), xs):\n",
" for year, xx in zip(years, xxs):\n",
" for idx, row in df.loc[esc, year].iterrows():\n",
" # each scatter/data point. Marked by color of exporter\n",
" ax.scatter(\n",
Expand Down Expand Up @@ -1000,8 +1002,8 @@
"ax = plt.gca()\n",
"\n",
"# Plot each vertical year line and each scatter point separately\n",
"for (esc, x) in zip(conversion_factors.keys(), xs):\n",
" for (year, xx) in zip(years, xxs):\n",
"for esc, x in zip(conversion_factors.keys(), xs):\n",
" for year, xx in zip(years, xxs):\n",
" for idx, row in df.loc[esc, year].iterrows():\n",
" # each scatter/data point. Marked by color of exporter\n",
" ax.scatter(\n",
Expand Down
12 changes: 6 additions & 6 deletions analysis/results-plotting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"source": [
"# Plot all ESCs per exporter\n",
"for name, group in df.groupby(df.index.names[:3]):\n",
" (year, wacc, importer) = name\n",
" year, wacc, importer = name\n",
"\n",
" tmp = group.loc[name].loc[:, :, \"general\", \"Cost per MWh delivered\"]\n",
" tmp.reset_index().pivot(index=\"exporter\", columns=\"esc\", values=\"value\").plot(\n",
Expand Down Expand Up @@ -118,7 +118,7 @@
"source": [
"# Plot per ESC all exporters\n",
"for name, group in df.groupby(df.index.names[:3]):\n",
" (year, wacc, importer) = name\n",
" year, wacc, importer = name\n",
"\n",
" tmp = group.loc[name].loc[:, :, \"general\", \"Cost per MWh delivered\"]\n",
" tmp.reset_index().pivot(index=\"esc\", columns=\"exporter\", values=\"value\").plot(\n",
Expand Down Expand Up @@ -146,7 +146,7 @@
"source": [
"# Energy surplus factor by ESC for each exporter\n",
"for name, group in df.groupby(df.index.names[:3]):\n",
" (year, wacc, importer) = name\n",
" year, wacc, importer = name\n",
"\n",
" tmp = group.loc[name].loc[:, :, \"general\", \"Energy surplus factor\"]\n",
" tmp.reset_index().pivot(index=\"exporter\", columns=\"esc\", values=\"value\").plot(\n",
Expand Down Expand Up @@ -189,7 +189,7 @@
"cutoff = 0.1\n",
"\n",
"for name, group in df.groupby(df.index.names[:4]):\n",
" (year, wacc, importer, esc) = name\n",
" year, wacc, importer, esc = name\n",
"\n",
" group = group.loc[name].loc[:, \"cost\", :] # Select cost only\n",
"\n",
Expand Down Expand Up @@ -289,7 +289,7 @@
"}\n",
"\n",
"for name, group in df.groupby(df.index.names[:4]):\n",
" (year, wacc, importer, esc) = name\n",
" year, wacc, importer, esc = name\n",
"\n",
" group = group.loc[name].loc[:, \"capacity factor\", :] # Select CFs only\n",
"\n",
Expand Down Expand Up @@ -359,7 +359,7 @@
"brk = False\n",
"\n",
"for name, group in df.groupby(df.index.names[:4]):\n",
" (year, wacc, importer, esc) = name\n",
" year, wacc, importer, esc = name\n",
"\n",
" group = group.loc[name].loc[:, \"installed capacity\", :] # Select capacities only\n",
"\n",
Expand Down
4 changes: 2 additions & 2 deletions rules/gegis.smk
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ if config["GlobalEnergyGIS"].get("init_gegis", False) is True:
script:
"../actions/set_GEGIS_base_dir.jl"

# Download auxiliary datasets for GEGIS
# Download auxiliary datasets for GEGIS
rule download_GEGIS_dataset:
output:
Path(config["GlobalEnergyGIS"]["base_dir"]) / "protected.jld", # not full list, only dependencies for rules below (proxy all others)
Path(config["GlobalEnergyGIS"]["base_dir"]) / "gadm.tif",
script:
"../actions/download_GEGIS_datasets.jl"

# Download ERA5 data for wind/solar/synthetic demand for GEGIS
# Download ERA5 data for wind/solar/synthetic demand for GEGIS
rule download_GEGIS_era5:
output:
Path(config["GlobalEnergyGIS"]["base_dir"]) / "era5wind{year}.h5",
Expand Down
1 change: 1 addition & 0 deletions rules/results.smk
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Use paramspace to evaluate which scenarios to run
scenarios = Paramspace(pd.read_csv("scenarios/default.csv", dtype=str))


# Custom pattern for formatting Paramspace, as snakemake
# does currently not allow for patterns without the wildcard_name included
# see: https://stackoverflow.com/questions/71293563/custom-patterns-with-snakemakes-paramspace/71296522#71296522
Expand Down