Skip to main content

flowmapper

PyPI Status Python Version License

Read the documentation at https://flowmapper.readthedocs.io/ Tests Codecov

pre-commit Black

Flowmapper

This is a tool to automate matching elementary flow lists in life cycle assessment. It can map different lists against each other and generate usable transformation files for those mappings.

It works by starting with the assumption that there is a core underlying ontology for elementary flows, regardless of the expression of that ontology in difference data formats. Here is the core ontology that flowmapper uses:

  • name: str, the canonical name used to identify a substance, e.g. "1,4-Butanediol"
  • identifier: str, or complex type with a string representation, the unique string used to identify the flow, unit, and context combination, e.g. "38a622c6-f086-4763-a952-7c6b3b1c42ba"
  • context: tuple[str], a hierarchical organization into environmental compartments, e.g. ("air", "urban air close to ground")
  • unit: str, or complex type with a string representation, e.g. "kg"
  • sector-specific labels: str, or complex type with a string representation, a set of additional fields which can help identify or further specify a flow, e.g. CAS number 000110-63-4
  • synonyms: list[str], a list of alternative unique names for a substance, e.g. ["Butylene glycol", "butane-1,4-diol"]

Flowmapper assumes that the source and target lists are given in this format; it comes with or plays well with conversion software for data formats like ecospold, FEDEFL, and SimaPro CSV.

Chemical formulas are not currently used - they can be expressed in too many different ways, and haven't proven useful for matching.

Matching across the two lists is defined by a set of strategy functions; matching can take some or all ontological elements into account. Due to the sometimes chaotic nature of the input data, matching usually needs to be customized for the specific source and target lists.

For example, a matching strategy could say that two flows are the same if their name and context are equal, or if their CAS number and context are equal. Units are rarely compared directly; instead, after a match is found we check that the units have the same dimension, and apply unit conversions using pint if necessary.

This library does not generate partial matches (i.e. "1,4-Butanediol" is always the same as "butane-1,4-diol", but the separate contexts would need to be matched afterwards). Partial matches could be used to reduce the size of the matching file, as one could store name matches in one partial match and context matches in another partial match, but we prefer the explicit enumeration of all matches of flows present in the source and target lists.

Matching is usually done by checking for equality. Instead of forcing conversion and then testing, flowmapper comes with custom classes for these ontological elements which allow for a flexible definition of equality, and the testing of logical relationships. For example, you can do this:

from flowmapper import CAS
first = CAS("   007440-05-3")
second = CAS("7440-05-3")
first == second
>>> True

Installation

You can install flowmapper via [pip] from [PyPI]:

$ pip install flowmapper

Contributing

Contributions are very welcome. To learn more, see the Contributor Guide.

License

Distributed under the terms of the MIT license, flowmapper is free and open source software.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Metadata

Release files for flowmapper 0.4

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

Source distribution (sdist)

Source distribution for flowmapper 0.4
File Size Uploaded Provenance Actions
flowmapper-0.4.tar.gz 54.4 kB Without provenance Details for flowmapper-0.4.tar.gz

Built distribution (wheel)

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

Total release size: 104.9 kB

Release files / flowmapper-0.4.tar.gz

Download URL flowmapper-0.4.tar.gz
Size 54.4 kB
Tags Source
SHA-256 checksum
How to use checksums
416dd1676fd7e1c6a50ca5f00ce136a82c4ae21898d228e72675e8d1f1d68bfa
BLAKE2b-256 checksum
How to use checksums
9fa757f82a724a403ea57c325875dd03f52704945533fd2973db252957eb6e98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.4

Release files / flowmapper-0.4-py3-none-any.whl

Download URL flowmapper-0.4-py3-none-any.whl
Size 50.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b7f0648fd6dcfe92951a11cc45fd50c7a585721e8ca62b529946ccc397a3c31d
BLAKE2b-256 checksum
How to use checksums
1ad89401efb64d60e59c8d5c9b23eb3e7a6d393de6b89d1223e823d833fc2368
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.4

Security for flowmapper 0.4

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.

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