Skip to content
Merged
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
4 changes: 2 additions & 2 deletions config/config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
projected_crs: "epsg:8857"
crs:
projected: "EPSG:8857"

category:
bioenergy:
Expand Down Expand Up @@ -90,7 +91,6 @@ fuel_mapping:
"fossil gas: unknown": "natural gas"

imputation:
adjustment_year: 2023
shape_overlap_correction: "split_capacity" # strict or split_capacity
scenario: "near-future" # near-future, far-future, far-off-future
lifetime_years:
Expand Down
129 changes: 0 additions & 129 deletions tests/integration/test_config.yaml

This file was deleted.

30 changes: 12 additions & 18 deletions workflow/internal/config.schema.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
$schema: "https://json-schema.org/draft/2020-12/schema"
type: object
required:
- projected_crs
- crs
- category
- imputation
additionalProperties: false
Expand Down Expand Up @@ -37,15 +37,17 @@ $defs:
These names will be reflected in the resulting files, and will also be used during validation.

properties:
projected_crs:
title: Projected CRS
description: CRS to use during projected operations (e.g., polygon centroid calculations).
oneOf:
- type: string
pattern: '^(epsg|EPSG):\d{4}$'
- type: integer
minimum: 1000
maximum: 9999
crs:
description: Coordinate reference system settings in the form 'epsg:xxxx'.
type: object
properties:
projected:
description: CRS to use during operations related to distance / area.
type: string
pattern: '^(epsg|EPSG):\d{4,5}$'
required:
- projected
additionalProperties: false # Ensures no extra properties in "crs"

category:
title: Category
Expand Down Expand Up @@ -351,19 +353,11 @@ properties:
type: object
additionalProperties: false
required:
- adjustment_year
- shape_overlap_correction
- scenario
- lifetime_years
- retirement_delay_years
properties:
adjustment_year:
title: Adjustment year.
description: >
Year to use as reference when adjusting capacities to fit historical country statistics.
type: integer
minimum: 0
maximum: 2023
shape_overlap_correction:
title: Shape overlap correction method
description: |
Expand Down
1 change: 0 additions & 1 deletion workflow/rules/aggregate.smk
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ rule aggregate_capacity:
conda:
"../envs/powerplants.yaml"
params:
year=config["imputation"]["adjustment_year"],
category=lambda wc: wc.category,
message:
"Aggregating capacity for {wildcards.shapes}-{wildcards.adjustment}-{wildcards.category}."
Expand Down
6 changes: 2 additions & 4 deletions workflow/rules/impute.smk
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ rule impute_years:
"../envs/powerplants.yaml"
params:
imputation=config["imputation"],
projected_crs=config["projected_crs"],
projected_crs=config["crs"]["projected"],
tech_map=lambda wc: get_technology_mapping(wc.category),
message:
"National-level imputation of missing years for all powerplants in {wildcards.shapes}-{wildcards.category} dataset."
Expand Down Expand Up @@ -87,9 +87,7 @@ rule impute_capacity_adjustment:
category="|".join(IMPUTED_CAT - IMPUTED_CAT_WITHOUT_ADJUSTMENT),
conda:
"../envs/powerplants.yaml"
params:
year=config["imputation"]["adjustment_year"],
message:
"National-level adjustment of powerplant capacity in {wildcards.shapes}-{wildcards.category} to {params.year} statistics."
"National-level adjustment of powerplant capacity in {wildcards.shapes}-{wildcards.category} to EIA statistics."
script:
"../scripts/impute_capacity_adjustment.py"
2 changes: 1 addition & 1 deletion workflow/rules/prepare.smk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ rule prepare_shapes:
conda:
"../envs/powerplants.yaml"
params:
crs=config["projected_crs"],
crs=config["crs"]["projected"],
message:
"Preparing intermediate shapefile versions to speed up processing."
script:
Expand Down
58 changes: 12 additions & 46 deletions workflow/rules/solar.smk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ To fill solar capacity, we follow these steps:
2. Assume rooftop PV = national solar statistics - large projects.
3. Use a proxy to disaggregate then aggregate assumed rooftop PV capacity per shape.
4. Combine aggregated large pv projects and rooftop PV capacity.
5. Adjust to national statistics.
"""


Expand Down Expand Up @@ -37,14 +36,13 @@ rule proxy_rooftop_pv:
"../envs/powerplants.yaml"
params:
category="solar",
year=config["imputation"]["adjustment_year"],
message:
"Generating proxy for rooftop capacity {wildcards.shapes}."
script:
"../scripts/proxy.py"


rule aggregate_solar_capacity:
rule impute_adjustment_solar:
input:
large_solar=workflow.pathvars.apply("<aggregated_capacity>").format(
shapes="{shapes}",
Expand All @@ -53,65 +51,33 @@ rule aggregate_solar_capacity:
),
proxy=rules.proxy_rooftop_pv.output.proxy,
shapes="<shapes>",
stats=rules.prepare_statistics.output.categories,
output:
aggregated=workflow.pathvars.apply("<aggregated_capacity>").format(
shapes="{shapes}",
adjustment="unadjusted",
adjustment="adjusted",
category="solar",
),
plot=report(
"<results>/{shapes}/aggregated/unadjusted/solar.pdf",
plot_map=report(
"<results>/{shapes}/aggregated/adjusted/solar_map.pdf",
caption="../report/aggregate_capacity.rst",
category="Powerplants module",
subcategory="solar",
),
log:
"<logs>/{shapes}/unadjusted/solar/aggregate_solar_capacity.log",
conda:
"../envs/powerplants.yaml"
params:
technology=config["category"]["solar"]["technology_mapping"]["rooftop_pv"],
category="solar",
message:
"Aggregating capacity for {wildcards.shapes}-unadjusted-solar."
script:
"../scripts/aggregate_capacity.py"


rule impute_capacity_adjustment_solar:
input:
unadjusted=workflow.pathvars.apply("<aggregated_capacity>").format(
shapes="{shapes}",
adjustment="unadjusted",
category="solar",
),
shapes="<shapes>",
stats=rules.prepare_statistics.output.categories,
output:
adjusted=workflow.pathvars.apply("<aggregated_capacity>").format(
shapes="{shapes}",
adjustment="adjusted",
category="solar",
),
adj_plot=report(
"<results>/{shapes}/aggregated/adjusted/solar_adjustment.pdf",
plot_stats=report(
"<results>/{shapes}/aggregated/adjusted/solar_stats.pdf",
caption="../report/impute_capacity_adjustment.rst",
category="Powerplants module",
subcategory="solar",
),
map_plot=report(
"<results>/{shapes}/aggregated/adjusted/solar_map.pdf",
caption="../report/aggregate_capacity.rst",
category="Powerplants module",
subcategory="solar",
),
log:
"<logs>/{shapes}/adjusted/solar/impute_capacity_adjustment_solar.log",
"<logs>/{shapes}/adjusted/solar/aggregate_solar_capacity.log",
conda:
"../envs/powerplants.yaml"
params:
year=config["imputation"]["adjustment_year"],
category="solar",
technology=config["category"]["solar"]["technology_mapping"]["rooftop_pv"],
message:
"Adjusting aggregated capacity of {wildcards.shapes}-solar to {params.year} statistics."
"Aggregating capacity for {wildcards.shapes}-adjusted-solar."
script:
"../scripts/impute_capacity_adjustment_solar.py"
"../scripts/impute_adjustment_solar.py"
5 changes: 2 additions & 3 deletions workflow/scripts/_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,8 @@ def plot_capacity_adjustment(
agg_eia = (
df_eia.groupby([country_col, eia_cat_col])[[eia_cap_col]].sum().reset_index()
)

countries = sorted(agg_dis[country_col].unique())
techs = sorted(agg_dis[dis_tech_col].unique())
countries = sorted(set(agg_dis[country_col]).union(agg_adj[country_col]))
techs = sorted(set(agg_dis[dis_tech_col]).union(agg_adj[dis_tech_col]))
cats = sorted(agg_eia[eia_cat_col].unique())

# Avoid overlaps when techs / cats have the same name
Expand Down
2 changes: 1 addition & 1 deletion workflow/scripts/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# Average year where powerplant datasets were last updated.
# MUST BE ADJUSTED WHENEVER DATASOURCES ARE UPDATED!
DATASET_YEAR = 2024
DATASET_YEAR = 2023


def listify(item) -> list:
Expand Down
Loading
Loading