bw2landbalancer
bw2landbalancer is a Python library used to create balanced land transformation samples to override unbalanced sample.
Unbalanced samples arise when land transformation exchanges are independently sampled.
bw2landbalancer rescales certain land transformation exchanges to ensure that the ratio of
land transformation from exchanges and land transformation to exchanges is conserved. It is based on the
Brightway2 LCA framework, and is meant to be used with
presamples.
It was developped with ecoinvent in mind, though the modifications required to make it useful for other databases would be minimal. Currently, elementary flows (biosphere exchanges in Brightway2) are identified as land transformation inputs or outputs based on the patterns "Transformation, from" and "Transformation, to", respectively. Other patterns can be added.
Installation
Use the package manager pip to install bw2landbalancer:
pip install bw2landbalancer
or use conda:
conda install --channel pascallesage bw2landbalancer
Usage
from bw2landbalancer import DatabaseLandBalancer
from brightway2 import projects
projects.set_current("my project")
dlb = DatabaseLandBalancer(
database_name="ecoinvent_cutoff", #name the LCI db was given on import
)
Note: This is where one could add additional patters to identify land transformation exchanges, via the land_from_patterns and land_to_patterns (lists of strings).
# Generate samples, and format as matrix_data for use in presamples
dlb.add_samples_for_all_acts(iterations=1000)
0% [##############################] 100% | ETA: 00:00:00 Total time elapsed: 00:18:11
# Create presamples package
dlb.create_presamples(
name='some name',
dirpath=some/path,
id_='some id',
seed='sequential', #or None, or int
)
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
Acknowledgment
Special thanks to Quantis US for having funded the early iterations of this work.
Metadata
Release files for bw2landbalancer 0.1.1
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 | |
|---|---|---|---|---|
| bw2landbalancer-0.1.1.tar.gz | 12.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bw2landbalancer-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.2 kB
Release files / bw2landbalancer-0.1.1.tar.gz
| Download URL | bw2landbalancer-0.1.1.tar.gz |
|---|---|
| Size | 12.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
42f5b8f362973ae6fe3814b665b2cc514be11c8cd86f86315e4b6a66b2e2536b
|
|
BLAKE2b-256 checksum How to use checksums |
ea936e1ae6445fd482c9f4f53a60739cdb579bee4ee348bcdc5a19518fa02b21
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.3
|
Release files / bw2landbalancer-0.1.1-py3-none-any.whl
| Download URL | bw2landbalancer-0.1.1-py3-none-any.whl |
|---|---|
| Size | 13.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2cb895f06f8b8e73d6cba4b9f2ff1eafbef4415f4ec0f079f7e41a09b62fd35e
|
|
BLAKE2b-256 checksum How to use checksums |
b5ca6c9858963342895b356fb1d8bac5aef8770599874b52964f02c8c66f6481
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.3
|
Security for bw2landbalancer 0.1.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.