Skip to main content

bw2waterbalancer

bw2waterbalancer is a Python library used to create balanced water samples to override unbalanced sample.

Unbalanced samples arise when water exchanges are independently sampled. bw2waterbalancer rescales certain exchanges to ensure that the ratio of water inputs to water outputs is conserved. It is based on the Brightway2 LCA framework, and is meant to be used with presamples.

The rescaling is done according to three different strategy, depending on the nature of the exchanges: * default: rescale sampled inputs so that mass ratio of sampled input to sampled output is same as in static activity
* inverse: rescale sampled outputs so that mass ratio of sampled input to sampled output is same as in static activity
* set_static: replace sampled exchanges with value in static activity

It was developped with ecoinvent in mind, though the modifications required to make it useful for other databases would be minimal.

pipeline status coverage report

Installation

Use the package manager pip to install bw2waterbalancer:

pip install bw2waterbalancer

or use conda:

conda install --channel pascallesage bw2waterbalancer

Usage

from bw2waterbalancer import DatabaseWaterBalancer
from brightway2 import projects

projects.set_current("my project")

dwb = DatabaseWaterBalancer(
    ecoinvent_version="3.6", # used to identify activities with water production exchanges
    database_name="ei36_cutoff", #name the LCI db in the brightway2 project
)

Validating data Getting information on technosphere water exchanges 0% [##############################] 100% | ETA: 00:00:00 Total time elapsed: 00:00:00 Getting information on biosphere water exchanges 0% [##############################] 100% | ETA: 00:00:00 Total time elapsed: 00:01:09

# Generate samples, and format as matrix_data for use in presamples
dwb.add_samples_for_all_acts(iterations=1000)

0% [##############################] 100% | ETA: 00:00:00 Total time elapsed: 00:18:11

# Create presamples package
dwb.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.

License

MIT

Metadata

Release files for bw2waterbalancer 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bw2waterbalancer 0.1.1
File Size Uploaded Provenance
bw2waterbalancer-0.1.1.tar.gz 16.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for bw2waterbalancer 0.1.1
File Interpreter ABI Platform
bw2waterbalancer-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 35.6 kB

Release files / bw2waterbalancer-0.1.1.tar.gz

Download URL bw2waterbalancer-0.1.1.tar.gz
Size 16.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d0983781e24d2a171d977ef82e9fb419af29a78e2158e29ce628f79161866812
BLAKE2b-256 checksum
How to use checksums
e13259e926d66285b5fdfd69fa2518abf9fc82338911ca4306b22605be6bf90c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

Release files / bw2waterbalancer-0.1.1-py3-none-any.whl

Download URL bw2waterbalancer-0.1.1-py3-none-any.whl
Size 18.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
53bbc09cc1edec0a1c77b687678cd2848164d6f7eb309e1015bef9d93a651149
BLAKE2b-256 checksum
How to use checksums
3fa4bf8c82a8c0d35ca1a04a3bdb2e324b089d71d53b0e4388edf6a1b75d2269
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6

Security for bw2waterbalancer 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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page