Used to create balanced LCA land transformation exchange samples to override unbalanced samples in Brightway2.
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file bw2landbalancer-0.1.tar.gz
.
File metadata
- Download URL: bw2landbalancer-0.1.tar.gz
- Upload date:
- Size: 12.3 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40ab6e7d910f0c2bda3966208876d1b537b4fdd4e6d2e62cefb58f208a371600 |
|
MD5 | 5bc3ea6ad31d9e2acc3bef75b6695fdc |
|
BLAKE2b-256 | 19977074d547e267f103a86291fa328ae4da630e003a155738443f41d0c8a9e6 |
File details
Details for the file bw2landbalancer-0.1-py3-none-any.whl
.
File metadata
- Download URL: bw2landbalancer-0.1-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2eb621dcadd326aa70ca2933c2384630ec09ee7bd81ca8405527b23f9090413 |
|
MD5 | 0babdfaff4bede041582ba920587e129 |
|
BLAKE2b-256 | b977af528b02318e0632f395a4d12c87b45ff4fb0c3bd2f631d3e61c53d703f8 |