SALCA-BD (extract)
Standalone copy of the SALCA-BD biodiversity model, extracted from the
agroscope-ch/salca repository
(SALCA-BD/salcabd, commit 2cf3c75). The other SALCA models and the
SALCA-framework scripts (salcabd_farm.py, salcabd_horti.py, which need the
external salcaconnector) are not included.
The SALCA-BD model and its code are the work of Agroscope. This package only repackages them: packaging, dependency updates and tests by vanakenm (Open Compass). The package version follows the SALCA-BD model version (2.0.0 = model 2.0); packaging-only fixes are released as post-releases (2.0.0.post1, ...). Questions about the model itself belong upstream; questions about the packaging go to BeOpenCompass/salca-bd-extract.
Licence: GNU LGPLv3 (see LICENCE.txt).
Why
We want to use SALCA-BD from another python app. The current code as provided makes this difficult (no python package, some oudated librairies, no tests). This package is just that - an extract, made as a PyPi package with some dependencies update and tests to help ensure full parity with the reference package.
Install
Requires Python 3.11+ (tested with pandas 2.0.3, 2.2 and 3.1).
pip install salca-bd
The package is imported as salcabd:
import salcabd
ct = salcabd.get_default_control_table()
For development:
py -3.11 -m venv .venv311
.venv311\Scripts\activate
pip install -r requirements-lock.txt # optional: exact verified versions
pip install -e .
Control table
The default control table (coefficients, validation rules, min/max scenarios) is shipped as
plain CSV files in salcabd/pkg_resources/control_table/. Upstream ships it as a pickle,
which only loads with pandas 1.x. The CSVs were exported from that pickle
(tools/export_control_table.py) and load into an identical ControlTable. The tests check
this exactly, against the pickle in a pandas 1.x environment and against pinned fingerprints
on any pandas version.
salcabd.load_control_table(folder) / salcabd.save_control_table(ct, folder) read and write
the same CSV format.
The original pickle is kept as a reference in tools/control_table_original.ct. To use it
(export again, or run the exact comparison test), set up the legacy environment described in
requirements-lock-py39.txt (Python 3.9 + pandas 1.2.4).
Run
python -m salcabd samples\salcasample_fixed.xlsm
(salcabd <file> also works after install.) Results are written to a
Results folder next to the input.
Input file rules (Produktionsinventar sheet)
The importer reads fixed positions of the template (samples/salcaempty.xlsm):
- Don't delete columns or rows of the template (data starts in column H, row 16).
- Field names (row 6) must contain a number, e.g.
Parzelle 1 - Terre Bon-Dieu. - Year labels (row 10) are text like
1. Jahr; no plain numbers (e.g.2024) in that row. - Scenario labels (row 13) must contain their number, e.g.
Szenario 1 (TWI konform). - Each culture's first scenario column must have measures marked with
1; the first marked row determines the habitat, so don't mark ecological-infrastructure rows (top of the sheet) there. - Every field needs at least one culture with measures.
- Zero options (e.g. "a. 0" applications) can't be combined with other options of the same group.
Tests
pip install -e .[test]
pytest
tests/test_samples.py checks the farm-level summaries (Total/Mean, GAV/HÖA)
of both sample files against the values produced by the original CLI, both
through the Python API and by running the CLI end to end.
Changes compared to upstream
Upstream (Python 3.9, pandas 1.2.4) doesn't run on pandas 2+. Changes to make it run on Python 3.11 with current dependencies, without changing results (Excel output verified identical cell by cell to the upstream code on both samples):
- Default control table: pickle → CSV (see above).
DataFrame.iteritems()→.items()(removed in pandas 2).- Blank separator row in result tables: column converted to
objectbefore writing''(pandas 3 refuses strings in float columns). - Single-column assignments use a 1-D array instead of an n×1 array.
- Excel export unwraps one-element Series before writing (
float(Series)removed in pandas 3). inplace=Truecalls replaced by assignments; full-length tuple key for a MultiIndex column (both deprecated, to be removed in pandas 4).- Fields with a border ("Rand" columns, border area > 0):
DataFrame.append→pd.concat(removed in pandas 2) when building the R2 detail, andseries[0]→series.iloc[0]for the habitat min/max in field aggregation (positional fallback removed in pandas 3). Output verified identical to upstream, except the farmMeancan differ in the last bits: pandas 3 sums it pairwise (the more accurate result) where pandas 1.x summed sequentially.
Metadata
Release files for salca-bd 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| salca_bd-2.0.0.tar.gz | 266.9 kB | With provenance | Details for salca_bd-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| salca_bd-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for salca_bd-2.0.0-py3-none-any.whl |
Total release size: 557.5 kB
Release files / salca_bd-2.0.0.tar.gz
| Download URL | salca_bd-2.0.0.tar.gz |
|---|---|
| Size | 266.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5062f61a638972f596f4c8f877a6678a2eea5f4892619698650dfb2374937c9e
|
|
BLAKE2b-256 checksum How to use checksums |
3886644513ed1764489e172ab17d3f85d1eee39a7919e635e4c492af190e2f68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logRelease files / salca_bd-2.0.0-py3-none-any.whl
| Download URL | salca_bd-2.0.0-py3-none-any.whl |
|---|---|
| Size | 290.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a3c7c635501ccf232960f94db357cf17a92d4a61171c8f94eaa60c4cdfa2c03c
|
|
BLAKE2b-256 checksum How to use checksums |
6b91e8850c53c9e0ffb073d4de970b5bc787269d3ea00a0e9961178af1ec1034
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logSecurity for salca-bd 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for salca_bd-2.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.