Spaces:
Running
Running
[DOCS] README: reorder sections and rename "Custom resources" to "New resources"
Browse files
README.md
CHANGED
|
@@ -20,13 +20,13 @@ A Streamlit app for optimising carbon removal portfolios across different method
|
|
| 20 |
- [Data Maintenance Guide](#data-maintenance-guide)
|
| 21 |
- [How it works](#how-it-works-overview)
|
| 22 |
- [App tabs](#app-tabs)
|
| 23 |
-
- [
|
| 24 |
- [Scenarios (save and compare)](#scenarios-save-and-compare)
|
|
|
|
|
|
|
| 25 |
- [Option 1: Hugging Face](#option-1-edit-directly-on-hugging-face-no-local-setup-needed)
|
| 26 |
- [Option 2: Local](#option-2-work-locally)
|
| 27 |
- [Quick reference](#quick-reference-where-is-each-parameter)
|
| 28 |
-
- [File structure](#file-structure-what-each-file-does)
|
| 29 |
-
- [Understanding inputs.csv](#understanding-inputscsv)
|
| 30 |
- [Maintenance cases](#maintenance-cases)
|
| 31 |
- [Before you start](#before-you-start)
|
| 32 |
- [Case 1 - Modify existing coefficient values](#case-1--modify-existing-coefficient-values)
|
|
@@ -70,7 +70,7 @@ data/inputs.csv
|
|
| 70 |
|
| 71 |
Every time the app starts, it computes a fingerprint (hash) of the CSV and compares it to the last known value. If they differ, meaning the CSV has been modified, it automatically regenerates all the data files used by the application before loading. You do not need to run anything manually.
|
| 72 |
|
| 73 |
-
**Automatic method deactivation:** if a CDR method requires resources that the user has not added in the Resource inputs tab, the method is automatically disabled in the Method constraints and Portfolio generation tabs. A "Why is this method disabled?" indicator is shown next to the method. This is expected behavior
|
| 74 |
|
| 75 |
---
|
| 76 |
|
|
@@ -81,7 +81,7 @@ The app has seven tabs, accessible from the left sidebar:
|
|
| 81 |
| Tab | Name | Purpose |
|
| 82 |
|-----|------|---------|
|
| 83 |
| Welcome | Welcome | Introduction, instructions, and a quick-start guide |
|
| 84 |
-
| Resource inputs | Resource inputs | Set the available quantity of each resource; add
|
| 85 |
| Method constraints | Method constraints | Activate or deactivate CDR methods; set caps and constraints per method |
|
| 86 |
| Resource coefficients | Resource coefficients | View and adjust the coefficient values (min / median / max) used by the optimiser |
|
| 87 |
| Portfolio generation | Portfolio generation | Run the LP optimiser and view results (charts, tables, resource usage) |
|
|
@@ -90,25 +90,73 @@ The app has seven tabs, accessible from the left sidebar:
|
|
| 90 |
|
| 91 |
---
|
| 92 |
|
| 93 |
-
###
|
| 94 |
|
| 95 |
-
In the **Resource inputs** tab, users can add
|
| 96 |
|
| 97 |
-
For example, a user might add a batch called "Basalt A" linked to the reference group "Basalt mineral" and assign it to the Enhanced weathering method. The optimiser will then use the batch's
|
| 98 |
|
| 99 |
-
|
| 100 |
|
| 101 |
---
|
| 102 |
|
| 103 |
### Scenarios (save and compare)
|
| 104 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
In the **Scenario comparison** tab, users can:
|
| 106 |
|
| 107 |
-
-
|
| 108 |
-
|
| 109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
|
| 111 |
-
|
| 112 |
|
| 113 |
---
|
| 114 |
|
|
@@ -120,7 +168,7 @@ This is the simplest option for non-coders with admin access to the Hugging Face
|
|
| 120 |
|
| 121 |
**Steps:**
|
| 122 |
|
| 123 |
-
1. Go to the Hugging Face **Space** (Carbon Dioxide Removal Toolkit) → click the **Files** tab
|
| 124 |
2. Open `data/inputs.csv` and click **Edit** (pencil icon)
|
| 125 |
*OR*
|
| 126 |
Upload a new version of the file: click **Delete** `data/inputs.csv`, then go to **data** folder → click **+ Contribute** → Upload Files
|
|
@@ -145,7 +193,7 @@ Use this option when making bigger changes where you want to preview the result
|
|
| 145 |
|
| 146 |
Before starting, make sure you have **Python** (version 3.9 or later) and **git** installed on your machine:
|
| 147 |
- Python: https://www.python.org/downloads/ (tick *Add Python to PATH* during installation on Windows)
|
| 148 |
-
- git
|
| 149 |
|
| 150 |
Then in a terminal, navigate to the folder where you want to put the project and run:
|
| 151 |
```
|
|
@@ -153,7 +201,7 @@ git clone <repository URL>
|
|
| 153 |
```
|
| 154 |
Example:
|
| 155 |
```
|
| 156 |
-
git clone https://huggingface.co/spaces/CarbonGap/
|
| 157 |
```
|
| 158 |
|
| 159 |
**Step 1b: Set up the Python environment (first time only)**
|
|
@@ -239,56 +287,13 @@ Hugging Face will detect the push and rebuild the Space automatically.
|
|
| 239 |
| The app's UI colours and font (fine-tuned overrides) | `assets/styles.css` | `:root` block at the top of the file - change the hex values next to each variable name |
|
| 240 |
| The tooltip text on a method name | `data/ui_text.xlsx` | Sheet **Methods**: column `Tooltip` |
|
| 241 |
| The tooltip text on a resource name | `data/ui_text.xlsx` | Sheet **Resources**: column `Tooltip` |
|
| 242 |
-
| The text shown in "Why is this method disabled?" for a specific method | `data/ui_text.xlsx` | Sheet **Methods**: column `Note`
|
| 243 |
-
| The "OBJECTIVE" intro paragraph at the top of a tab | `data/ui_text.xlsx` | Sheet **Section Intros**: column `Text`, row selected by `Tab`
|
| 244 |
| UI spacing, font sizes, button styles | `assets/styles.css` | Standard CSS: search for the element name |
|
| 245 |
| Python library versions | `requirements.txt` | One line per library: see Library Maintenance Guide below |
|
| 246 |
|
| 247 |
> After any change to `inputs.csv`, start the app - it detects the change and updates automatically. After changes to `config/config.py`, `assets/styles.css`, or `data/ui_text.xlsx`, simply restart the app.
|
| 248 |
|
| 249 |
-
### File structure (what each file does)
|
| 250 |
-
|
| 251 |
-
| File | What it is | Do you edit it? |
|
| 252 |
-
|------|-----------|-----------------|
|
| 253 |
-
| `data/inputs.csv` | **Main data file**: all methods, resources and coefficients | ✅ Yes |
|
| 254 |
-
| `data/ui_text.xlsx` | Tooltip texts (on hover), "why is this method disabled?" notes, and each tab's intro paragraph | ✅ Yes |
|
| 255 |
-
| `data/update.py` | Orchestration script: runs both generators below and updates the hash file | ❌ No |
|
| 256 |
-
| `data/generate_model_data.py` | Generates `cost_sliders.json`, `method_groups.json`, `secondary_resources.json` from the CSV | ❌ No |
|
| 257 |
-
| `data/generate_resource_template.py` | Generates `resource_template.xlsx` from the CSV | ❌ No |
|
| 258 |
-
| `data/cost_sliders.json` | Auto-generated. Coefficients used by the app | ❌ No (auto) |
|
| 259 |
-
| `data/method_groups.json` | Auto-generated. CDR method categories | ❌ No (auto) |
|
| 260 |
-
| `data/secondary_resources.json` | Auto-generated. Optional resource assignments | ❌ No (auto) |
|
| 261 |
-
| `data/resource_template.xlsx` | Auto-generated. Excel template for users | ❌ No (auto) |
|
| 262 |
-
| `data/.csv_hash` | Auto-generated. Stores a fingerprint of `inputs.csv` to detect changes on restart | ❌ No (auto) |
|
| 263 |
-
|
| 264 |
-
> ⚠️ **Never edit the auto-generated files directly**: your changes will be overwritten the next time `update.py` is run.
|
| 265 |
-
|
| 266 |
-
### Understanding `inputs.csv`
|
| 267 |
-
|
| 268 |
-
Each row represents **one resource used by one CDR method**, with the following columns:
|
| 269 |
-
|
| 270 |
-
| Column | Description | Example |
|
| 271 |
-
|--------|-------------|---------|
|
| 272 |
-
| `Implementation` | Name of the CDR method | `Afforestation/reforestation` |
|
| 273 |
-
| `Method group` | Category the method belongs to | `Forestry` |
|
| 274 |
-
| `Resource` | Name of the resource used | `Other land` |
|
| 275 |
-
| `Resource group` | Category the resource belongs to | `Land` |
|
| 276 |
-
| `Type` | Physical type of the resource | `Physical` |
|
| 277 |
-
| `Unit` | Unit of the coefficient (per MtCO₂) | `Mha/MtCO2` |
|
| 278 |
-
| `min` | Minimum coefficient value | `0.002` |
|
| 279 |
-
| `median` | Default (median) coefficient value | `0.094927` |
|
| 280 |
-
| `max` | Maximum coefficient value | `0.384615` |
|
| 281 |
-
| `Is secondary` | Whether this resource is optional for this method | `FALSE` |
|
| 282 |
-
|
| 283 |
-
> **Primary resources** (`Is secondary = FALSE`) are always active in the model.
|
| 284 |
-
> **Secondary resources** (`Is secondary = TRUE`) are optional: users can toggle them on in the app.
|
| 285 |
-
|
| 286 |
-
> **Naming convention — "Other" resources:** any resource whose name starts with `Other ` (capital O, followed by a space — e.g. `Other land`, `Other water`) is **hidden from the standard resource display** in Tabs 1 and 3. It still functions normally in the model and remains available as a reference group in the "Add resource" dialog. Use this convention intentionally when you want a resource to be inherited by custom user-defined batches but not shown as a standalone input row.
|
| 287 |
-
|
| 288 |
-
> **Naming convention — "Other" methods:** any CDR method whose name starts with `Other` receives special treatment in the optimiser. Instead of appearing as a fixed method, the LP automatically creates **one variant per custom resource batch** the user adds that is linked to that method. This is intended for generic CDR pathways where the type of resource is user-defined. If you add a method using this naming convention, make sure it is intentional.
|
| 289 |
-
|
| 290 |
-
> **Resource group and OR-substitutable resources:** when a CDR method has two or more **primary** resources (`Is secondary = FALSE`) that belong to the same `Resource group`, the optimiser treats them as **interchangeable (OR)**. The method can satisfy its resource need from either one, or any mix of the two, rather than requiring all of them simultaneously. Users will see a hint like *"only one of Other land, Arable land is required"* in the "Why is this method disabled?" panel. This behaviour is automatic: it is triggered purely by two active primary resources sharing the same `Resource group` for the same method. **If you add a resource to an existing group for a method that already has a primary resource in that group, you are creating an OR relationship — make sure this is intentional.** If it is not, create a new resource group instead (see Case 5).
|
| 291 |
-
|
| 292 |
---
|
| 293 |
|
| 294 |
## Maintenance cases
|
|
@@ -344,7 +349,7 @@ You should see `(venv)` at the start of your terminal line.
|
|
| 344 |
|
| 345 |
**When to use:** A CDR method should now also use a resource that is already tracked for other methods (e.g., water is already listed for other methods, and you want to add it to Afforestation/reforestation too). If the resource doesn't exist at all yet, use Case 4 first.
|
| 346 |
|
| 347 |
-
> ⚠️ **This may create an OR relationship:** if the method already has another
|
| 348 |
|
| 349 |
**Option 1 - On Hugging Face**
|
| 350 |
|
|
@@ -370,7 +375,7 @@ You should see `(venv)` at the start of your terminal line.
|
|
| 370 |
|
| 371 |
**When to use:** A new carbon removal approach needs to be added to the tool.
|
| 372 |
|
| 373 |
-
> ⚠️ **"Other" method naming:** if the method name starts with `Other` (e.g. `Other CDR`), the optimiser treats it specially
|
| 374 |
|
| 375 |
**Option 1 - On Hugging Face**
|
| 376 |
|
|
@@ -400,9 +405,9 @@ You should see `(venv)` at the start of your terminal line.
|
|
| 400 |
|
| 401 |
**When to use:** A resource that doesn't exist yet needs to be used (e.g., a new type of mineral or energy).
|
| 402 |
|
| 403 |
-
> ⚠️ **"Other" resource naming:** if you name the resource starting with `Other ` (capital O + space
|
| 404 |
|
| 405 |
-
> ⚠️ **Adding to an existing Resource group may create an OR relationship:** if the method you are adding this resource to already has
|
| 406 |
|
| 407 |
**Option 1 - On Hugging Face**
|
| 408 |
|
|
@@ -432,7 +437,7 @@ You should see `(venv)` at the start of your terminal line.
|
|
| 432 |
|
| 433 |
### Case 5 - Add a new resource group (new category)
|
| 434 |
|
| 435 |
-
**When to use:** Your new resource doesn't fit any existing category. Also use this case when the new resource belongs to the same physical category as an existing one but should **not** be treated as interchangeable with it by the optimiser
|
| 436 |
|
| 437 |
**Option 1 - On Hugging Face**
|
| 438 |
|
|
@@ -448,7 +453,7 @@ Same steps as Case 4, but write a **new group name** in the `Resource group` col
|
|
| 448 |
|
| 449 |
**When to use:** You want to make a resource optional (user can enable/disable it) or make it always required.
|
| 450 |
|
| 451 |
-
> ⚠️ **
|
| 452 |
|
| 453 |
**Option 1 - On Hugging Face**
|
| 454 |
|
|
@@ -516,28 +521,30 @@ Everything is in the same file, `data/ui_text.xlsx`, across three sheets:
|
|
| 516 |
| Sheet | Columns | Controls |
|
| 517 |
|---|---|---|
|
| 518 |
| **Resources** | `Resource`, `Tooltip` | Hover tooltip on a resource name |
|
| 519 |
-
| **Methods** | `Method`, `Tooltip`, `Note` | `Tooltip` = hover tooltip on a method name. `Note` = the message shown at the top of that method's "Why is this method disabled?" panel (Method constraints tab)
|
| 520 |
-
| **Section Intros** | `Tab`, `Text` | The "OBJECTIVE" paragraph shown at the top of a tab. One row per tab
|
| 521 |
|
| 522 |
-
> ℹ️ **The "Why is this method disabled?" panel shows two types of text that come from different sources.** The resource hints
|
| 523 |
|
| 524 |
> ⚠️ **Exact name match:** the name in column `Resource` or `Method` must match **exactly** the name used in `inputs.csv` (same spelling, same capitalisation). If you rename a method or resource in the CSV, remember to update the name in `ui_text.xlsx` too.
|
| 525 |
|
| 526 |
> ⚠️ **`Tab` keys, not tab titles:** the `Tab` column in **Section Intros** uses the internal page name, not the label shown in the sidebar. Use exactly one of:
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
|
|
|
|
|
|
| 534 |
> A row with any other value is simply ignored.
|
| 535 |
|
| 536 |
-
> ⚠️ **These texts contain HTML, not just plain text.** `Tooltip` cells are plain text, but `Note` and `Text` (Section Intros) are rendered as HTML, so you'll see markup like `<strong>bold</strong>`, `<br>` for a line break, and `<li>...</li>` for a bullet-style line. Keep these tags when editing around them
|
| 537 |
|
| 538 |
> ⚠️ **`tab2_constraints`'s text has a placeholder:** its `Text` cell contains `{CO2_UNIT}`, which the app replaces with the actual CO₂ unit (e.g. `MtCO₂`) when displayed. Keep the `{CO2_UNIT}` placeholder (braces included) if you want that value to appear; removing it just removes the unit from the sentence, it won't break anything.
|
| 539 |
|
| 540 |
-
> If a cell is left empty, or a sheet/row is missing entirely, that piece of text is simply skipped (no tooltip / no note / no intro paragraph)
|
| 541 |
|
| 542 |
**Option 1 - On Hugging Face**
|
| 543 |
|
|
@@ -570,7 +577,7 @@ The `.xlsx` file cannot be edited inline on Hugging Face. Instead:
|
|
| 570 |
|
| 571 |
**When to use:** A CDR method or resource is no longer relevant and should be removed from the tool entirely.
|
| 572 |
|
| 573 |
-
> ⚠️ If users have saved scenario files (`.xlsx` or `.zip`) that reference the removed method or resource, those fields will be silently ignored on load
|
| 574 |
|
| 575 |
**Option 1 - On Hugging Face**
|
| 576 |
|
|
@@ -648,12 +655,12 @@ Option 2 (local):
|
|
| 648 |
|
| 649 |
Option 1 (Hugging Face direct):
|
| 650 |
- [ ] Downloaded, edited, and re-uploaded `ui_text.xlsx` on Hugging Face
|
| 651 |
-
- [ ] Space has restarted (no update script runs for this file
|
| 652 |
- [ ] Verified the updated text appears correctly in the app
|
| 653 |
|
| 654 |
Option 2 (local):
|
| 655 |
- [ ] Saved `data/ui_text.xlsx`
|
| 656 |
-
- [ ] Restarted the app (`Ctrl+C` then `streamlit run app.py`)
|
| 657 |
- [ ] Verified the updated text appears correctly in the app
|
| 658 |
- [ ] Committed `data/ui_text.xlsx` and pushed
|
| 659 |
|
|
|
|
| 20 |
- [Data Maintenance Guide](#data-maintenance-guide)
|
| 21 |
- [How it works](#how-it-works-overview)
|
| 22 |
- [App tabs](#app-tabs)
|
| 23 |
+
- [New resources](#new-resources)
|
| 24 |
- [Scenarios (save and compare)](#scenarios-save-and-compare)
|
| 25 |
+
- [File structure](#file-structure-what-each-data-file-does)
|
| 26 |
+
- [Understanding inputs.csv](#understanding-inputscsv)
|
| 27 |
- [Option 1: Hugging Face](#option-1-edit-directly-on-hugging-face-no-local-setup-needed)
|
| 28 |
- [Option 2: Local](#option-2-work-locally)
|
| 29 |
- [Quick reference](#quick-reference-where-is-each-parameter)
|
|
|
|
|
|
|
| 30 |
- [Maintenance cases](#maintenance-cases)
|
| 31 |
- [Before you start](#before-you-start)
|
| 32 |
- [Case 1 - Modify existing coefficient values](#case-1--modify-existing-coefficient-values)
|
|
|
|
| 70 |
|
| 71 |
Every time the app starts, it computes a fingerprint (hash) of the CSV and compares it to the last known value. If they differ, meaning the CSV has been modified, it automatically regenerates all the data files used by the application before loading. You do not need to run anything manually.
|
| 72 |
|
| 73 |
+
**Automatic method deactivation:** if a CDR method requires resources that the user has not added in the Resource inputs tab, the method is automatically disabled in the Method constraints and Portfolio generation tabs. A "Why is this method disabled?" indicator is shown next to the method. This is expected behavior: no data change is needed.
|
| 74 |
|
| 75 |
---
|
| 76 |
|
|
|
|
| 81 |
| Tab | Name | Purpose |
|
| 82 |
|-----|------|---------|
|
| 83 |
| Welcome | Welcome | Introduction, instructions, and a quick-start guide |
|
| 84 |
+
| Resource inputs | Resource inputs | Set the available quantity of each resource; add new resource batches |
|
| 85 |
| Method constraints | Method constraints | Activate or deactivate CDR methods; set caps and constraints per method |
|
| 86 |
| Resource coefficients | Resource coefficients | View and adjust the coefficient values (min / median / max) used by the optimiser |
|
| 87 |
| Portfolio generation | Portfolio generation | Run the LP optimiser and view results (charts, tables, resource usage) |
|
|
|
|
| 90 |
|
| 91 |
---
|
| 92 |
|
| 93 |
+
### New resources
|
| 94 |
|
| 95 |
+
In the **Resource inputs** tab, users can add new resource batches: named resources that substitute for a standard or "Other" reference resource within a specific CDR method.
|
| 96 |
|
| 97 |
+
For example, a user might add a batch called "Basalt A" linked to the reference group "Basalt mineral" and assign it to the Enhanced weathering method. The optimiser will then use the batch's new coefficients instead of the standard reference values for that method.
|
| 98 |
|
| 99 |
+
New batches are stored in the session and saved when exporting a scenario. They do **not** require any change to `inputs.csv`.
|
| 100 |
|
| 101 |
---
|
| 102 |
|
| 103 |
### Scenarios (save and compare)
|
| 104 |
|
| 105 |
+
In the **Portfolio generation** tab (Export & Save sub-tab), users can:
|
| 106 |
+
|
| 107 |
+
- **Export** the current inputs only as an Excel `.xlsx` file, or the full scenario (inputs, constraints, coefficients, and optimisation results) as a `.json` file or a `.zip` of CSVs
|
| 108 |
+
- **Import** a previously exported Excel file to reload inputs into all tabs, or a previously exported `.json`/`.zip` scenario file to restore a complete session and re-run the optimisation
|
| 109 |
+
|
| 110 |
In the **Scenario comparison** tab, users can:
|
| 111 |
|
| 112 |
+
- Upload one or more saved scenario files (`.json` or `.zip`) and **compare** them side by side in the charts
|
| 113 |
+
|
| 114 |
+
Scenario files are standalone and portable. Exporting a `.json` or `.zip` preserves the full state including new resource batches; the Excel format covers only the inputs and can be opened directly in Excel.
|
| 115 |
+
|
| 116 |
+
---
|
| 117 |
+
|
| 118 |
+
### File structure (what each data file does)
|
| 119 |
+
|
| 120 |
+
| File | What it is | Do you edit it? |
|
| 121 |
+
|------|-----------|-----------------|
|
| 122 |
+
| `data/inputs.csv` | **Main data file**: all methods, resources and coefficients | ✅ Yes |
|
| 123 |
+
| `data/ui_text.xlsx` | Tooltip texts (on hover), "why is this method disabled?" notes, and each tab's intro paragraph | ✅ Yes |
|
| 124 |
+
| `data/update.py` | Orchestration script: runs both generators below and updates the hash file | ❌ No |
|
| 125 |
+
| `data/generate_model_data.py` | Generates `cost_sliders.json`, `method_groups.json`, `secondary_resources.json` from the CSV | ❌ No |
|
| 126 |
+
| `data/generate_resource_template.py` | Generates `resource_template.xlsx` from the CSV | ❌ No |
|
| 127 |
+
| `data/cost_sliders.json` | Auto-generated. Coefficients used by the app | ❌ No (auto) |
|
| 128 |
+
| `data/method_groups.json` | Auto-generated. CDR method categories | ❌ No (auto) |
|
| 129 |
+
| `data/secondary_resources.json` | Auto-generated. Optional resource assignments | ❌ No (auto) |
|
| 130 |
+
| `data/resource_template.xlsx` | Auto-generated. Excel template for users | ❌ No (auto) |
|
| 131 |
+
| `data/.csv_hash` | Auto-generated. Stores a fingerprint of `inputs.csv` to detect changes on restart | ❌ No (auto) |
|
| 132 |
+
|
| 133 |
+
> ⚠️ **Never edit the auto-generated files directly**: your changes will be overwritten the next time `update.py` is run.
|
| 134 |
+
|
| 135 |
+
### Understanding `inputs.csv`
|
| 136 |
+
|
| 137 |
+
Each row represents **one resource used by one CDR method**, with the following columns:
|
| 138 |
+
|
| 139 |
+
| Column | Description | Example |
|
| 140 |
+
|--------|-------------|---------|
|
| 141 |
+
| `Implementation` | Name of the CDR method | `Afforestation/reforestation` |
|
| 142 |
+
| `Method group` | Category the method belongs to | `Forestry` |
|
| 143 |
+
| `Resource` | Name of the resource used | `Other land` |
|
| 144 |
+
| `Resource group` | Category the resource belongs to | `Land` |
|
| 145 |
+
| `Type` | Physical type of the resource | `Physical` |
|
| 146 |
+
| `Unit` | Unit of the coefficient (per MtCO₂) | `Mha/MtCO2` |
|
| 147 |
+
| `min` | Minimum coefficient value | `0.002` |
|
| 148 |
+
| `median` | Default (median) coefficient value | `0.094927` |
|
| 149 |
+
| `max` | Maximum coefficient value | `0.384615` |
|
| 150 |
+
| `Is secondary` | Whether this resource is optional for this method | `FALSE` |
|
| 151 |
+
|
| 152 |
+
> **Primary resources** (`Is secondary = FALSE`) are always active in the model.
|
| 153 |
+
> **Secondary resources** (`Is secondary = TRUE`) are optional: users can toggle them on in the app.
|
| 154 |
+
|
| 155 |
+
> **Naming convention: "Other" resources:** any resource whose name starts with `Other ` (capital O, followed by a space - e.g. `Other land`, `Other water`) is **hidden from the standard resource display** in Tabs 1 and 3. It still functions normally in the model and remains available as a reference group in the "Add resource" dialog. Use this convention intentionally when you want a resource to be inherited by new user-defined batches but not shown as a standalone input row.
|
| 156 |
+
|
| 157 |
+
> **Naming convention: "Other" methods:** any CDR method whose name starts with `Other` receives special treatment in the optimiser. Instead of appearing as a fixed method, the LP automatically creates **one variant per new resource batch** the user adds that is linked to that method. This is intended for generic CDR pathways where the type of resource is user-defined. If you add a method using this naming convention, make sure it is intentional.
|
| 158 |
|
| 159 |
+
> **Resource group and OR-substitutable resources:** when a CDR method has two or more **active** resources (primary, or secondary once toggled on) that belong to the same `Resource group`, the optimiser treats them as **interchangeable (OR)**. The method can satisfy its resource need from either one, or any mix of the two, rather than requiring all of them simultaneously. Users will see a hint like *"only one of Other land, Arable land is required"* in the "Why is this method disabled?" panel for primary siblings (secondary siblings are pooled by the optimiser the same way, but this specific hint currently only covers primary resources - see [Case 6](#case-6--change-whether-a-resource-is-optional-secondary-for-a-method)). This behaviour is automatic: it is triggered purely by two active resources sharing the same `Resource group` for the same method, whether or not they are primary. **If you add a resource to an existing group for a method that already has a resource active in that group, you are creating an OR relationship: make sure this is intentional.** If it is not, create a new resource group instead (see Case 5).
|
| 160 |
|
| 161 |
---
|
| 162 |
|
|
|
|
| 168 |
|
| 169 |
**Steps:**
|
| 170 |
|
| 171 |
+
1. Go to the Hugging Face **Space** (https://huggingface.co/CGdev: Carbon Dioxide Removal Toolkit) → click the **Files** tab
|
| 172 |
2. Open `data/inputs.csv` and click **Edit** (pencil icon)
|
| 173 |
*OR*
|
| 174 |
Upload a new version of the file: click **Delete** `data/inputs.csv`, then go to **data** folder → click **+ Contribute** → Upload Files
|
|
|
|
| 193 |
|
| 194 |
Before starting, make sure you have **Python** (version 3.9 or later) and **git** installed on your machine:
|
| 195 |
- Python: https://www.python.org/downloads/ (tick *Add Python to PATH* during installation on Windows)
|
| 196 |
+
- git - Mac: https://git-scm.com/download/mac - Windows: https://git-scm.com/download/win
|
| 197 |
|
| 198 |
Then in a terminal, navigate to the folder where you want to put the project and run:
|
| 199 |
```
|
|
|
|
| 201 |
```
|
| 202 |
Example:
|
| 203 |
```
|
| 204 |
+
git clone https://huggingface.co/spaces/CarbonGap/CRRA_Optimization_Tool_V2
|
| 205 |
```
|
| 206 |
|
| 207 |
**Step 1b: Set up the Python environment (first time only)**
|
|
|
|
| 287 |
| The app's UI colours and font (fine-tuned overrides) | `assets/styles.css` | `:root` block at the top of the file - change the hex values next to each variable name |
|
| 288 |
| The tooltip text on a method name | `data/ui_text.xlsx` | Sheet **Methods**: column `Tooltip` |
|
| 289 |
| The tooltip text on a resource name | `data/ui_text.xlsx` | Sheet **Resources**: column `Tooltip` |
|
| 290 |
+
| The text shown in "Why is this method disabled?" for a specific method | `data/ui_text.xlsx` | Sheet **Methods**: column `Note`, supports basic HTML (see [Case 8](#case-8--edit-tooltip-method-note-and-section-intro-texts)) |
|
| 291 |
+
| The "OBJECTIVE" intro paragraph at the top of a tab | `data/ui_text.xlsx` | Sheet **Section Intros**: column `Text`, row selected by `Tab`, supports basic HTML (see [Case 8](#case-8--edit-tooltip-method-note-and-section-intro-texts)) |
|
| 292 |
| UI spacing, font sizes, button styles | `assets/styles.css` | Standard CSS: search for the element name |
|
| 293 |
| Python library versions | `requirements.txt` | One line per library: see Library Maintenance Guide below |
|
| 294 |
|
| 295 |
> After any change to `inputs.csv`, start the app - it detects the change and updates automatically. After changes to `config/config.py`, `assets/styles.css`, or `data/ui_text.xlsx`, simply restart the app.
|
| 296 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 297 |
---
|
| 298 |
|
| 299 |
## Maintenance cases
|
|
|
|
| 349 |
|
| 350 |
**When to use:** A CDR method should now also use a resource that is already tracked for other methods (e.g., water is already listed for other methods, and you want to add it to Afforestation/reforestation too). If the resource doesn't exist at all yet, use Case 4 first.
|
| 351 |
|
| 352 |
+
> ⚠️ **This may create an OR relationship:** if the method already has another active resource (primary, or secondary and toggled on) in the same `Resource group` as the one you're adding, the optimiser will treat the two as interchangeable (the method can run on either one, not both) as soon as both are active - marking the new row `Is secondary = TRUE` only delays this until a user enables it, it does not prevent it. See [Understanding inputs.csv](#understanding-inputscsv) for details. If this is not the intended behavior, use a different `Resource group` for the new row (Case 5).
|
| 353 |
|
| 354 |
**Option 1 - On Hugging Face**
|
| 355 |
|
|
|
|
| 375 |
|
| 376 |
**When to use:** A new carbon removal approach needs to be added to the tool.
|
| 377 |
|
| 378 |
+
> ⚠️ **"Other" method naming:** if the method name starts with `Other` (e.g. `Other CDR`), the optimiser treats it specially: it creates one variant per new resource batch that the user links to this method, instead of running it as a fixed method. Only use this naming if that expansion behavior is intentional. For a standard CDR method with defined resource inputs, use a name that does not start with `Other`.
|
| 379 |
|
| 380 |
**Option 1 - On Hugging Face**
|
| 381 |
|
|
|
|
| 405 |
|
| 406 |
**When to use:** A resource that doesn't exist yet needs to be used (e.g., a new type of mineral or energy).
|
| 407 |
|
| 408 |
+
> ⚠️ **"Other" resource naming:** if you name the resource starting with `Other ` (capital O + space - e.g. `Other land`, `Other water`), it will be **hidden from the standard resource display** in the app. Users won't see it as a standalone input row, but it will still be available as a reference group when they use the "Add resource" dialog. Only use this prefix if you specifically want the resource to be hidden from direct input.
|
| 409 |
|
| 410 |
+
> ⚠️ **Adding to an existing Resource group may create an OR relationship:** if the method you are adding this resource to already has another active resource (primary, or secondary and toggled on) in the same `Resource group`, the optimiser will treat the two resources as interchangeable as soon as both are active. See [Understanding inputs.csv](#understanding-inputscsv) for details. If this is not the intended behavior, create a new Resource group instead (Case 5).
|
| 411 |
|
| 412 |
**Option 1 - On Hugging Face**
|
| 413 |
|
|
|
|
| 437 |
|
| 438 |
### Case 5 - Add a new resource group (new category)
|
| 439 |
|
| 440 |
+
**When to use:** Your new resource doesn't fit any existing category. Also use this case when the new resource belongs to the same physical category as an existing one but should **not** be treated as interchangeable with it by the optimiser: keeping it in a separate group avoids the automatic OR relationship (see [Understanding inputs.csv](#understanding-inputscsv)).
|
| 441 |
|
| 442 |
**Option 1 - On Hugging Face**
|
| 443 |
|
|
|
|
| 453 |
|
| 454 |
**When to use:** You want to make a resource optional (user can enable/disable it) or make it always required.
|
| 455 |
|
| 456 |
+
> ⚠️ **This may create an OR relationship:** the optimiser pools any two resources that are both active (primary, or secondary and toggled on) in the same `Resource group` for the same method - regardless of which way you're changing `Is secondary`. So toggling a secondary resource on (in the app) can create an OR relationship with a sibling in the same group just as much as setting `Is secondary = FALSE` in the CSV can. See [Understanding inputs.csv](#understanding-inputscsv) for details. If this is not intended, consider moving the resource to a different group (Case 5).
|
| 457 |
|
| 458 |
**Option 1 - On Hugging Face**
|
| 459 |
|
|
|
|
| 521 |
| Sheet | Columns | Controls |
|
| 522 |
|---|---|---|
|
| 523 |
| **Resources** | `Resource`, `Tooltip` | Hover tooltip on a resource name |
|
| 524 |
+
| **Methods** | `Method`, `Tooltip`, `Note` | `Tooltip` = hover tooltip on a method name. `Note` = the message shown at the top of that method's "Why is this method disabled?" panel (Method constraints tab), e.g. explaining that Mineral OAE needs a specific mineral feedstock added as a new resource. Leave empty for no note. |
|
| 525 |
+
| **Section Intros** | `Tab`, `Text` | The "OBJECTIVE" paragraph shown at the top of a tab. One row per tab: see the `Tab` key table below. |
|
| 526 |
|
| 527 |
+
> ℹ️ **The "Why is this method disabled?" panel shows two types of text that come from different sources.** The resource hints, e.g. *"Other land: Add as new resource in Resource inputs"* or *"only one of Other land, Arable land is required"*, are **auto-generated** from `inputs.csv` (based on which resources are missing and whether an OR relationship exists). They cannot be changed in `ui_text.xlsx`. The optional free-text `Note` from `ui_text.xlsx` appears above those hints with a lightbulb icon: that is the only part you can edit here. To change the resource hints, you need to change the resource or group structure in `inputs.csv`.
|
| 528 |
|
| 529 |
> ⚠️ **Exact name match:** the name in column `Resource` or `Method` must match **exactly** the name used in `inputs.csv` (same spelling, same capitalisation). If you rename a method or resource in the CSV, remember to update the name in `ui_text.xlsx` too.
|
| 530 |
|
| 531 |
> ⚠️ **`Tab` keys, not tab titles:** the `Tab` column in **Section Intros** uses the internal page name, not the label shown in the sidebar. Use exactly one of:
|
| 532 |
+
|
| 533 |
+
| `Tab` value | Corresponding tab in the app |
|
| 534 |
+
|---|---|
|
| 535 |
+
| `tab1_inputs` | Resource inputs |
|
| 536 |
+
| `tab2_constraints` | Method constraints |
|
| 537 |
+
| `tab3_coefficients` | Resource coefficients |
|
| 538 |
+
| `tab4_optimisation` | Portfolio generation |
|
| 539 |
+
| `tab5_sensitivity` | Sensitivity analysis |
|
| 540 |
+
|
| 541 |
> A row with any other value is simply ignored.
|
| 542 |
|
| 543 |
+
> ⚠️ **These texts contain HTML, not just plain text.** `Tooltip` cells are plain text, but `Note` and `Text` (Section Intros) are rendered as HTML, so you'll see markup like `<strong>bold</strong>`, `<br>` for a line break, and `<li>...</li>` for a bullet-style line. Keep these tags when editing around them: deleting a `<` or `>` by accident will make the raw tag appear as text on the page instead of being applied as formatting. You can add more of the same tags (`<strong>`, `<br>`, `<li>`) but avoid pasting anything more advanced (scripts, styles, other tags) since it is not sanitised before display.
|
| 544 |
|
| 545 |
> ⚠️ **`tab2_constraints`'s text has a placeholder:** its `Text` cell contains `{CO2_UNIT}`, which the app replaces with the actual CO₂ unit (e.g. `MtCO₂`) when displayed. Keep the `{CO2_UNIT}` placeholder (braces included) if you want that value to appear; removing it just removes the unit from the sentence, it won't break anything.
|
| 546 |
|
| 547 |
+
> If a cell is left empty, or a sheet/row is missing entirely, that piece of text is simply skipped (no tooltip / no note / no intro paragraph): nothing crashes.
|
| 548 |
|
| 549 |
**Option 1 - On Hugging Face**
|
| 550 |
|
|
|
|
| 577 |
|
| 578 |
**When to use:** A CDR method or resource is no longer relevant and should be removed from the tool entirely.
|
| 579 |
|
| 580 |
+
> ⚠️ If users have saved scenario files (`.xlsx` or `.zip`) that reference the removed method or resource, those fields will be silently ignored on load: no error is raised, but the data will be missing from the restored session.
|
| 581 |
|
| 582 |
**Option 1 - On Hugging Face**
|
| 583 |
|
|
|
|
| 655 |
|
| 656 |
Option 1 (Hugging Face direct):
|
| 657 |
- [ ] Downloaded, edited, and re-uploaded `ui_text.xlsx` on Hugging Face
|
| 658 |
+
- [ ] Space has restarted (no update script runs for this file: `Data files updated successfully.` will **not** appear in the logs; this is normal)
|
| 659 |
- [ ] Verified the updated text appears correctly in the app
|
| 660 |
|
| 661 |
Option 2 (local):
|
| 662 |
- [ ] Saved `data/ui_text.xlsx`
|
| 663 |
+
- [ ] Restarted the app (`Ctrl+C` then `streamlit run app.py`): no need to run `update.py`
|
| 664 |
- [ ] Verified the updated text appears correctly in the app
|
| 665 |
- [ ] Committed `data/ui_text.xlsx` and pushed
|
| 666 |
|