Spaces:
Sleeping
Sleeping
[FIX] No more derived method
Browse files
README.md
CHANGED
|
@@ -29,7 +29,6 @@ A Streamlit app for optimizing carbon removal portfolios across different method
|
|
| 29 |
- [Case 1 - Modify existing coefficient values](#case-1--modify-existing-coefficient-values)
|
| 30 |
- [Case 2 - Add an existing resource to an existing method](#case-2--add-an-existing-resource-to-an-existing-method)
|
| 31 |
- [Case 3 - Add a new CDR method](#case-3--add-a-new-cdr-method)
|
| 32 |
-
- [(OPTIONAL) Case 3b - Add a derived CDR method](#optional-case-3b--add-a-derived-cdr-method-variant-of-an-existing-method)
|
| 33 |
- [Case 4 - Add a new resource](#case-4--add-a-new-resource)
|
| 34 |
- [Case 5 - Add a new resource group](#case-5--add-a-new-resource-group-new-category)
|
| 35 |
- [Case 6 - Change whether a resource is optional](#case-6--change-whether-a-resource-is-optional-secondary-for-a-method)
|
|
@@ -136,6 +135,8 @@ You only need to do this once per machine. After that, just activate the environ
|
|
| 136 |
|
| 137 |
Open `data/inputs_aggregated.csv` in Excel or any spreadsheet editor. Make your changes and save.
|
| 138 |
|
|
|
|
|
|
|
| 139 |
**Step 3: Open a terminal in the project folder**
|
| 140 |
|
| 141 |
You can use any of the following:
|
|
@@ -220,7 +221,7 @@ Each row represents **one resource used by one CDR method**, with the following
|
|
| 220 |
|--------|-------------|---------|
|
| 221 |
| `Implementation` | Name of the CDR method | `Afforestation` |
|
| 222 |
| `Method group` | Category the method belongs to | `Forestry` |
|
| 223 |
-
| `Resource` | Name of the resource used | `
|
| 224 |
| `Resource group` | Category the resource belongs to | `Land` |
|
| 225 |
| `Type` | Physical type of the resource | `Physical` |
|
| 226 |
| `Unit` | Unit of the coefficient (per MtCO₂) | `Mha/MtCO2` |
|
|
@@ -333,62 +334,6 @@ You should see `(venv)` at the start of your terminal line.
|
|
| 333 |
git push
|
| 334 |
```
|
| 335 |
|
| 336 |
-
> ⚠️ **Special case - derived methods:** see Case 3b below.
|
| 337 |
-
|
| 338 |
-
---
|
| 339 |
-
|
| 340 |
-
### (OPTIONAL) Case 3b - Add a derived CDR method (variant of an existing method)
|
| 341 |
-
|
| 342 |
-
**What is a derived method?**
|
| 343 |
-
Some methods in the tool are not standalone entries in the CSV: they are automatically generated as **variants** of a base method. For example:
|
| 344 |
-
- `Bio-char` in the CSV → generates 3 variants in the app: `Bio-char - Forest biomass`, `Bio-char - Non-forest biomass`, `Bio-char - Unspecified biomass`
|
| 345 |
-
- `Enhanced weathering` in the CSV → generates 4 variants: one per mineral type
|
| 346 |
-
|
| 347 |
-
Each variant is identical to the base method **except** it only keeps the resource relevant to that variant.
|
| 348 |
-
|
| 349 |
-
**When to use:** You want to add a new variant of an existing method (e.g. a new mineral type for Enhanced weathering, or a new biomass type for Bio-char).
|
| 350 |
-
|
| 351 |
-
> ⚠️ This case requires editing Python code. If you are not comfortable with this, contact the developer - provide the name of the new variant and which resource it should keep, and they can add the 5–10 lines needed.
|
| 352 |
-
|
| 353 |
-
**Option 1 - On Hugging Face (developers only)**
|
| 354 |
-
|
| 355 |
-
Hugging Face allows editing Python files inline via the pencil icon. Follow the same steps as Option 2 but make all edits directly in the browser. Not recommended for non-coders.
|
| 356 |
-
|
| 357 |
-
**Option 2 - Locally**
|
| 358 |
-
|
| 359 |
-
1. Open `data/inputs_aggregated.csv` and make sure the base method has a row for the new resource.
|
| 360 |
-
|
| 361 |
-
2. Open `data/generate_model_data.py`. Find the two structures at the top of the file:
|
| 362 |
-
|
| 363 |
-
**`REPLACED_BY_DERIVED`**: lists base methods fully replaced by their variants (the base name disappears from the app):
|
| 364 |
-
```
|
| 365 |
-
REPLACED_BY_DERIVED = {"Bio-char", "Enhanced weathering"}
|
| 366 |
-
```
|
| 367 |
-
If your new base method should disappear once variants exist, add its name here.
|
| 368 |
-
|
| 369 |
-
**`DERIVED_FROM`**: maps each base method to its list of variant names (in display order):
|
| 370 |
-
```
|
| 371 |
-
DERIVED_FROM = {
|
| 372 |
-
"Bio-char": ["Bio-char - Forest biomass", ...],
|
| 373 |
-
"Enhanced weathering": ["Enhanced weathering - Basalt mineral", ...],
|
| 374 |
-
...
|
| 375 |
-
}
|
| 376 |
-
```
|
| 377 |
-
Add the new variant name to the relevant list.
|
| 378 |
-
|
| 379 |
-
3. Further down in `create_sliders_inputs()`, add the derivation logic for the new variant: copy the pattern used for Bio-char or Enhanced weathering: copy the base method's coefficients, then remove the resources that don't apply to this variant.
|
| 380 |
-
|
| 381 |
-
4. Save both files and run:
|
| 382 |
-
```
|
| 383 |
-
python data/update.py
|
| 384 |
-
```
|
| 385 |
-
5. Commit and push:
|
| 386 |
-
```
|
| 387 |
-
git add -A -- ':!venv/'
|
| 388 |
-
git commit -m "Add derived method: [variant name]"
|
| 389 |
-
git push
|
| 390 |
-
```
|
| 391 |
-
|
| 392 |
---
|
| 393 |
|
| 394 |
### Case 4 - Add a new resource
|
|
|
|
| 29 |
- [Case 1 - Modify existing coefficient values](#case-1--modify-existing-coefficient-values)
|
| 30 |
- [Case 2 - Add an existing resource to an existing method](#case-2--add-an-existing-resource-to-an-existing-method)
|
| 31 |
- [Case 3 - Add a new CDR method](#case-3--add-a-new-cdr-method)
|
|
|
|
| 32 |
- [Case 4 - Add a new resource](#case-4--add-a-new-resource)
|
| 33 |
- [Case 5 - Add a new resource group](#case-5--add-a-new-resource-group-new-category)
|
| 34 |
- [Case 6 - Change whether a resource is optional](#case-6--change-whether-a-resource-is-optional-secondary-for-a-method)
|
|
|
|
| 135 |
|
| 136 |
Open `data/inputs_aggregated.csv` in Excel or any spreadsheet editor. Make your changes and save.
|
| 137 |
|
| 138 |
+
> ⚠️ **Commas in names:** if a method name, resource name, or group name contains a comma, the CSV parser will misread it. Wrap the value in double quotes in the CSV (e.g. `"Biochar, pyrolysis"`) or, preferably, avoid commas entirely and use a dash or slash instead.
|
| 139 |
+
|
| 140 |
**Step 3: Open a terminal in the project folder**
|
| 141 |
|
| 142 |
You can use any of the following:
|
|
|
|
| 221 |
|--------|-------------|---------|
|
| 222 |
| `Implementation` | Name of the CDR method | `Afforestation` |
|
| 223 |
| `Method group` | Category the method belongs to | `Forestry` |
|
| 224 |
+
| `Resource` | Name of the resource used | `Other land` |
|
| 225 |
| `Resource group` | Category the resource belongs to | `Land` |
|
| 226 |
| `Type` | Physical type of the resource | `Physical` |
|
| 227 |
| `Unit` | Unit of the coefficient (per MtCO₂) | `Mha/MtCO2` |
|
|
|
|
| 334 |
git push
|
| 335 |
```
|
| 336 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 337 |
---
|
| 338 |
|
| 339 |
### Case 4 - Add a new resource
|