Metadata-Version: 2.4
Name: tcaf-model
Version: 1.0.0
Summary: True Cost Accounting of Food (TCAF) build of the Transition Compass model: food, diet, land use and true cost modules
License-Expression: Apache-2.0
Project-URL: Homepage, https://github.com/2050Calculators/transition-compass-model/tree/tcaf
Project-URL: Repository, https://github.com/2050Calculators/transition-compass-model
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: deepl
Requires-Dist: eurostat>=1.1.1
Requires-Dist: faostat>=1.1.2
Requires-Dist: numpy>=2.0
Requires-Dist: openpyxl>=3.1.5
Requires-Dist: pandas==2.2.3
Requires-Dist: pdfplumber
Requires-Dist: plotly==5.18.0
Requires-Dist: pycountry>=26.2.16
Requires-Dist: rapidfuzz>=3.9.0
Requires-Dist: requests
Requires-Dist: scikit-learn>=1.8.0
Requires-Dist: scipy==1.15.3
Requires-Dist: statsmodels>=0.14.0
Requires-Dist: xlrd>=2.0.1
Dynamic: license-file

# tcaf-model

True Cost Accounting of Food (TCAF) build of the Transition Compass model.

It is a **separate build** of [transition-compass-model][model], not a newer
version of it. It keeps the food side (agriculture, crop, livestock, land use,
dietary habits, alcoholic beverages, population, true cost) and drops the other
sectors. Region: Switzerland.

Deployed at <https://transition-compass-tcaf.epfl.ch/>.

## Branches

| Branch | What it is |
|---|---|
| `tcaf` | the working branch, what gets released |
| `tcaf-import` | the raw import, do not touch |

`tcaf-import` is the research work exactly as it was written in
[2050Calculators/tcaf-calc][fork], branch `model`, replayed commit by commit
with the original authors and dates. That fork was taken from the web app
repository before the app and the model were split, so the model code sat in
`backend/model/`. Here it sits in `tcaf_model/model/`, the same
place as in the main model repo, and nothing else changed.

`tcaf` adds what the code needs to be a real python package: the `__init__.py`
files, `pyproject.toml`, the lint setup and the release workflow. The science is
untouched.

The package is called `tcaf_model`, not `transition_compass_model`, on purpose.
The web app installs both, and picks one with `MODEL_PROFILE`. Two packages with
the same import name could not live in the same environment.

See [issue #11][issue] for the background.

## Install

```bash
make install          # uv sync --all-groups + pre-commit
```

## Use it

```python
from tcaf_model.model.interactions import runner
from tcaf_model.model.common.auxiliary_functions import (
    filter_country_and_load_data_from_pickles,
)

DM_input = filter_country_and_load_data_from_pickles(
    country_list=["Switzerland"], modules_list=["population", "agriculture"]
)
output, kpi = runner(lever_setting, years_setting, DM_input, ["agriculture"], logger)
```

Each module also runs on its own, on the pickles in `_database/`:

```bash
python -m tcaf_model.model.crop_module
```

## Release

The package is on PyPI as `tcaf-model`. A `tcaf-v*` tag on branch `tcaf`
publishes it (tags are a human decision):

```bash
git tag tcaf-v1.0.0 && git push origin tcaf-v1.0.0
```

The workflow (`.github/workflows/publish-tcaf-pypi.yml`) lints, builds the wheel
with the pickles inside and publishes it to PyPI. Then it opens a bump PR in
[leure-speed-to-zero][app] that pins the new `tcaf-model` version.

## Working here

- Data files (`*.pickle`, `*.pdf`) are in git LFS. Run `git lfs pull` if you get
  small text files instead of data.
- `make format` before committing, CI runs ruff and codespell.
- Keep the module names importable: no dash in a `.py` file name.

[model]: https://github.com/2050Calculators/transition-compass-model
[fork]: https://github.com/2050Calculators/tcaf-calc
[app]: https://github.com/EPFL-ENAC/leure-speed-to-zero
[issue]: https://github.com/2050Calculators/transition-compass-model/issues/11
