Spaces:
Sleeping
Sleeping
[FIX] input template removed
Browse files- data/generate_input_template.py +0 -106
- data/inputs_template.xlsx +0 -0
data/generate_input_template.py
DELETED
|
@@ -1,106 +0,0 @@
|
|
| 1 |
-
import json
|
| 2 |
-
import sys
|
| 3 |
-
import pandas as pd
|
| 4 |
-
import openpyxl
|
| 5 |
-
from openpyxl.styles import Font
|
| 6 |
-
|
| 7 |
-
from pathlib import Path
|
| 8 |
-
|
| 9 |
-
sys.path.insert(0, str(Path(__file__).parent.parent))
|
| 10 |
-
from config.config import (resource_order, method_order, resource_unit_map, resource_groups)
|
| 11 |
-
from utils.data_utils import strip_unit_suffix
|
| 12 |
-
|
| 13 |
-
# Data
|
| 14 |
-
with open("data/cost_sliders.json") as f:
|
| 15 |
-
cost_sliders = json.load(f)
|
| 16 |
-
|
| 17 |
-
with open("data/secondary_resources.json") as _f:
|
| 18 |
-
secondary_resources = {tuple(p) for p in json.load(_f)}
|
| 19 |
-
|
| 20 |
-
wb = openpyxl.Workbook()
|
| 21 |
-
|
| 22 |
-
resource_to_unit = {
|
| 23 |
-
r: resource_unit_map[group]
|
| 24 |
-
for group, resources in resource_groups.items()
|
| 25 |
-
for r in resources
|
| 26 |
-
}
|
| 27 |
-
|
| 28 |
-
# instructions
|
| 29 |
-
ws0 = wb.active
|
| 30 |
-
ws0.title = "instructions"
|
| 31 |
-
ws0.column_dimensions["A"].width = 25
|
| 32 |
-
ws0.column_dimensions["B"].width = 80
|
| 33 |
-
header_font = Font(bold=True)
|
| 34 |
-
ws0.append(["Sheet", "Description", "Columns to edit", "Do not modify"])
|
| 35 |
-
ws0["A1"].font = header_font
|
| 36 |
-
ws0["B1"].font = header_font
|
| 37 |
-
ws0["C1"].font = header_font
|
| 38 |
-
ws0["D1"].font = header_font
|
| 39 |
-
ws0.column_dimensions["C"].width = 35
|
| 40 |
-
ws0.column_dimensions["D"].width = 30
|
| 41 |
-
ws0.append(["resource_caps",
|
| 42 |
-
"Total available quantities of each resource for 1 year of optimization. Leave blank to exclude a resource.",
|
| 43 |
-
"Available Amount",
|
| 44 |
-
"Resource, Unit"])
|
| 45 |
-
ws0.append(["constraints",
|
| 46 |
-
"Which CDR methods are active and their maximum deployment cap (percent of total potential, or absolute value in MtCO2/yr).",
|
| 47 |
-
"active (TRUE/FALSE), cap_type (percent or absolute), cap_value",
|
| 48 |
-
"method"])
|
| 49 |
-
ws0.append(["coefficients",
|
| 50 |
-
"Resource usage coefficients for each CDR method. Adjust to reflect your country conditions.",
|
| 51 |
-
"value",
|
| 52 |
-
"method, resource, secondary"])
|
| 53 |
-
ws0.append(["custom_resources",
|
| 54 |
-
"User-defined resource batches: sub-types of an existing resource group (e.g. 'Forest biomass - Eucalyptus' within 'Forest biomass'), with their own availability and per-method coefficients. Add one row per method linked to the resource.",
|
| 55 |
-
"All columns (add new rows)",
|
| 56 |
-
"—"])
|
| 57 |
-
ws0.append(["enabled_methods",
|
| 58 |
-
"Which CDR methods are allowed to use each standard resource. Set to FALSE to prevent a method from using a resource.",
|
| 59 |
-
"enabled (TRUE/FALSE)",
|
| 60 |
-
"resource, method"])
|
| 61 |
-
|
| 62 |
-
# resource_caps
|
| 63 |
-
ws1 = wb.create_sheet("resource_caps")
|
| 64 |
-
ws1.append(["Resource", "Unit", "Available Amount"])
|
| 65 |
-
ws1["A1"].font = Font(bold=True)
|
| 66 |
-
ws1["B1"].font = Font(bold=True)
|
| 67 |
-
ws1["C1"].font = Font(bold=True)
|
| 68 |
-
for r in resource_order:
|
| 69 |
-
ws1.append([r, resource_to_unit.get(r, ""), float("nan")])
|
| 70 |
-
|
| 71 |
-
# constraints
|
| 72 |
-
ws2 = wb.create_sheet("constraints")
|
| 73 |
-
ws2.append(["method", "active", "cap_type (percent or absolute)", "cap_value"])
|
| 74 |
-
ws2["A1"].font = Font(bold=True)
|
| 75 |
-
ws2["B1"].font = Font(bold=True)
|
| 76 |
-
ws2["C1"].font = Font(bold=True)
|
| 77 |
-
ws2["D1"].font = Font(bold=True)
|
| 78 |
-
for m in method_order:
|
| 79 |
-
ws2.append([m, True, "percent", 100])
|
| 80 |
-
|
| 81 |
-
ws3 = wb.create_sheet("coefficients")
|
| 82 |
-
ws3.append(["method", "resource", "value", "secondary"])
|
| 83 |
-
for cell in ws3[1]:
|
| 84 |
-
cell.font = Font(bold=True)
|
| 85 |
-
for m in method_order:
|
| 86 |
-
for r, conf in cost_sliders.get(m, {}).items():
|
| 87 |
-
is_secondary = (m, strip_unit_suffix(r)) in secondary_resources
|
| 88 |
-
ws3.append([m, strip_unit_suffix(r), conf["median"], True if is_secondary else False])
|
| 89 |
-
|
| 90 |
-
ws4 = wb.create_sheet("custom_resources")
|
| 91 |
-
ws4.append(["name", "group", "amount", "unit", "method", "min", "median", "max"])
|
| 92 |
-
for cell in ws4[1]:
|
| 93 |
-
cell.font = Font(bold=True)
|
| 94 |
-
ws4.append(["(Example) Forest biomass - Eucalyptus", "Forest biomass", 5.0, "Mt", "Bio-char - Forest biomass", 0.33, 0.37, 0.82])
|
| 95 |
-
|
| 96 |
-
ws5 = wb.create_sheet("enabled_methods")
|
| 97 |
-
ws5.append(["resource", "method", "enabled"])
|
| 98 |
-
for cell in ws5[1]:
|
| 99 |
-
cell.font = Font(bold=True)
|
| 100 |
-
for m in method_order:
|
| 101 |
-
for r_with_unit in cost_sliders.get(m, {}):
|
| 102 |
-
r = strip_unit_suffix(r_with_unit)
|
| 103 |
-
ws5.append([r, m, True])
|
| 104 |
-
|
| 105 |
-
wb.save("data/inputs_template.xlsx")
|
| 106 |
-
print("Template generated: data/inputs_template.xlsx")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data/inputs_template.xlsx
DELETED
|
Binary file (14.2 kB)
|
|
|