-
Notifications
You must be signed in to change notification settings - Fork 456
add Perennialisation as Carbon Dioxide Removal Technology and Biogas producer #2274
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
base: master
Are you sure you want to change the base?
Changes from all commits
0a0248e
0e1e7be
5695684
9de8c9e
e17bcd5
c89771c
7e24967
9d746fc
4f0dc37
f6490e3
4c85cf5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -741,3 +741,4 @@ plotting: | |
| import NH3: '#e2ed74' | ||
| import oil: '#93eda2' | ||
| import methanol: '#87d0e6' | ||
| co2 perennials: '#008ffc' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1629,3 +1629,61 @@ if (MOBILITY_PROFILES_DATASET := dataset_version("mobility_profiles"))["source"] | |
| run: | ||
| copy2(input["kfz"], output["kfz"]) | ||
| copy2(input["pkw"], output["pkw"]) | ||
|
|
||
|
|
||
| if (CO2_REMOVAL_DATASET := dataset_version("co2_removal_data"))["source"] in [ | ||
| "primary", | ||
| "archive", | ||
| ]: | ||
|
|
||
| rule retrieve_co2_removal_data: | ||
| input: | ||
| zip=storage(CO2_REMOVAL_DATASET["url"]), | ||
| output: | ||
| afforestation_nuts_biomass_densities=resources( | ||
| "afforestation_nuts_biomass_densities.xlsx" | ||
| ), | ||
| afforestation_nuts2_afforestation_rates=resources( | ||
| "afforestation_rates_nuts2_full.csv" | ||
| ), | ||
| afforestation_nuts2_monthly_weights=resources( | ||
| "afforestation_nuts2_monthly_weights.csv" | ||
| ), | ||
| eurostat_crops_nuts2=resources("eurostat_apro_cpshr_nuts2_raw.csv"), | ||
| eurostat_crops_nuts0=resources("eurostat_apro_cpshr_nuts0_raw.csv"), | ||
| retries: 2 | ||
| message: | ||
| "Downloading carbon dioxide removal data (afforestation, perennialisation inputs)" | ||
| run: | ||
| with ZipFile(input.zip) as z: | ||
| # GitHub's release archive nests everything under a single | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can remove these commented lines |
||
| # top-level "<owner>-<repo>-<commit-sha>/" folder whose name | ||
| # changes with every release, so resolve it at runtime. | ||
| top_dir = z.namelist()[0].split("/")[0] | ||
| for src_path, dest in [ | ||
| ( | ||
| "outputs/afforestation/afforestation_nuts_biomass_densities.xlsx", | ||
| output.afforestation_nuts_biomass_densities, | ||
| ), | ||
| ( | ||
| "outputs/afforestation/afforestation_rates_nuts2_full.csv", | ||
| output.afforestation_nuts2_afforestation_rates, | ||
| ), | ||
| ( | ||
| "outputs/afforestation/afforestation_nuts2_monthly_weights.csv", | ||
| output.afforestation_nuts2_monthly_weights, | ||
| ), | ||
| ( | ||
| "outputs/perennialisation/eurostat_apro_cpshr_nuts2_raw.csv", | ||
| output.eurostat_crops_nuts2, | ||
| ), | ||
| ( | ||
| "outputs/perennialisation/eurostat_apro_cpshr_nuts0_raw.csv", | ||
| output.eurostat_crops_nuts0, | ||
| ), | ||
| ]: | ||
| with ( | ||
| z.open(f"{top_dir}/{src_path}") as src, | ||
| open(dest, "wb") as dst, | ||
| ): | ||
| dst.write(src.read()) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1093,6 +1093,51 @@ def load_costs(cost_file: str) -> pd.DataFrame: | |
| return pd.read_csv(cost_file, index_col=0) | ||
|
|
||
|
|
||
| # 1G biofuel crop groups and their target biomass class names. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest moving the additions in _helpers.py to build_biomass_potentials. py |
||
| # In the upstream default config these sit in "not included". | ||
| # When sector: perennials=True, resolve_biomass_classes() moves them automatically. | ||
| ONE_G_BIOFUEL_CLASSES = { | ||
| "Bioethanol barley, wheat, grain maize, oats, other cereals and rye": "biofuels_1G_bioethanol_cereals", | ||
| "Sugar from sugar beet": "biofuels_1G_bioethanol_sugar", | ||
| "Rape seed": "biofuels_1G_biodiesel", | ||
| "Sunflower, soya seed ": "biofuels_1G_biodiesel", | ||
| } | ||
|
|
||
|
|
||
| def resolve_biomass_classes(classes, perennials_enabled): | ||
| """ | ||
| Auto-reallocate 1G biofuel crop groups from 'not included' into their | ||
| biofuels_1G_* target classes when perennials are enabled. | ||
|
|
||
| Cases: | ||
| perennials=False → return classes unchanged. | ||
| perennials=True, all groups in 'not included' → move them (normal case). | ||
| perennials=True, no groups in 'not included' → raise AssertionError. | ||
| perennials=True, some groups elsewhere → move available ones, warn about rest. | ||
| """ | ||
| if not perennials_enabled: | ||
| return classes | ||
| classes = copy.deepcopy(classes) | ||
| not_incl = classes.get("not included", []) | ||
| in_ni = [g for g in ONE_G_BIOFUEL_CLASSES if g in not_incl] | ||
| elsewhere = [g for g in ONE_G_BIOFUEL_CLASSES if g not in not_incl] | ||
| if not in_ni: | ||
| raise AssertionError( | ||
| "sector: perennials=true but no 1G-biofuel groups are in " | ||
| "biomass: classes: 'not included'. Restore upstream defaults " | ||
| "so the groups can be reallocated automatically." | ||
| ) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this AssertionError is difficult to understand, I suggest something like: |
||
| if elsewhere: | ||
| logger.warning( | ||
| "perennials: 1G groups already allocated outside 'not included' " | ||
| f"— skipped (running perennials only for available groups): {elsewhere}" | ||
| ) | ||
| for g in in_ni: | ||
| classes["not included"].remove(g) | ||
| classes.setdefault(ONE_G_BIOFUEL_CLASSES[g], []).append(g) | ||
| return classes | ||
|
|
||
|
|
||
| def _simplify_polys( | ||
| polys, minarea=100 * 1e6, maxdistance=None, tolerance=None, filterremote=True | ||
| ): # 100*1e6 = 100 km² if CRS is DISTANCE_CRS | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good and concise. Can we add the following sentence for completeness?
Perennialisation also provideds biogas, which is added to the biogas potential.