Code Monkey home page Code Monkey logo

fedelemflowlist's Introduction

Applied Sciences

fedelemflowlist

fedelemflowlist is a Python package that generates and provides a standardized elementary flow list for use in life cycle assessment (LCA) data as well as mappings to convert data from other sources. This list supports the Federal LCA Commons, where preferred flows from the active version of the flow list produced by this package can be found in formats for use in LCA software.

Standard formats for a Flow List and a Flow Mapping are defined and provided by fedelemflowlist. They are implemented as pandas dataframes. Standard formats are also described for the input files used in building the flow list, and implemented as .csv files in the input directory.

The version of the package (see Releases) corresponds to the version of the flow list that it provides. The complete or 'master' list contains all valid flows, where the 'preferred' flows are the recommended flows for use in LCA data.

fedelemflowlist can export complete or subsets of the flow list and mapping files as a .zip archive of JSON-LD files conforming to the openLCA schema.

The background and methodology behind creation of the flow list, as well as a summary of the flow list itself can be found in the USEPA Report 'The Federal LCA Commons Elementary Flow List: Background, Approach, Description and Recommendations for Use'. Definitions for terms used in the flow list can be found in on EPA's Terminology Services in the Federal LCA Commons Elementary Flow List for Life Cycle Assessment vocabulary.

See the Wiki for installation, more info on repository contents, use examples, and for instructions on how to contribute to the flow list through additions or edits to flows or flow mappings.

Disclaimer

The United States Environmental Protection Agency (EPA) GitHub project code is provided on an "as is" basis and the user assumes responsibility for its use. EPA has relinquished control of the information and no longer has responsibility to protect the integrity , confidentiality, or availability of the information. Any reference to specific commercial products, processes, or services by service mark, trademark, manufacturer, or otherwise, does not constitute or imply their endorsement, recommendation or favoring by EPA. The EPA seal and logo shall not be used in any manner to imply endorsement of any commercial product or activity by EPA or the United States Government.

fedelemflowlist's People

Contributors

ashleyedelen avatar bl-young avatar catherinebirney avatar dyoung11 avatar edelenas avatar ericmbell1 avatar fchichorro avatar hottleta avatar m-jamieson avatar msrocka avatar oftheheadland avatar rwashing523 avatar wesingwersen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fedelemflowlist's Issues

new context suggested

To address surface water flows. Previously only available designation is resource/water or emission/water, which is not specific enough because it is inclusive of subterranean flows.

Recommended replacing some existing contexts by adding the surface designation, eg:

  • emission/water/fresh water body
    to
  • emission/water/surface/fresh water body

Would also need to generate new contexts for:

  • resource/water/surface
  • emission/water/surface

Hardwood & softwood - dry or wet elem flows?

This issue has been brought up by USLCI end-users regarding the moisture content of 'hardwood', 'softwood' biomass resource flows Users ask whether these flows refer to dry or wet mass? Of course, in USLCI (especially CORRIM-relevant flows as in the CORRIM repo itself), this isn't straightforward. Usually, the density varies by species mix/region and which process it's flowing into. Through the years, practitioners compiling & submitting data using these flows have not necessarily used them in a consistent manner--sometimes bringing it in with 50% moisture, some bringing it in at 80% moisture. Note, in some CORRIM flows, biomass elementary flows are completely missing but might be implied by technosphere flow description comment field text. I'm still not sure what the best solution for these aspects --2 possible routes are:

  1. ideally, designate in elementary flow list flow context & properties: including geography but what are the default flow properties conversion factors?
  2. another option, elementary flow nomenclature: expand FEDEFL nomenclature to have species/region specific flows with default densities in flow properties (reflecting average moisture content for freshly harvested resources)
  3. unideal/kluge method - designate in technosphere: pick some baseline density and max moisture content for each of softwood and hardwood and then comb through all relevant processes (e.g., in USLCI) to update their supply chain, i.e., send the elementary flows through a dummy process that converts the elementary flows into technosphere flows with weight factors that reflect the moisture loss and region/species mix-specific density specific to their use in subsequent processes that reflects the intended demand matrix going forward?

This problem is similar to the issue that was occurring in years prior when CED method combustion HHV factors were applied to elementary flows in mass units before the fuels entered the technosphere and lost mass due to purification to their actual combustion quality ---artificially overestimating CED because no mass loss and heating value gain of fuels via beneficiation/processing were accounted for. This is no longer an issue in FEDEFL-adapted USLCI raw fuel elementary flows are in energy (MJ) instead of mass (kg) units (which took care of that little LCI-LCIA connection oversight but only works in that context). I can't think of an easy fix for biomass flows destined for fuel and material use and having such varying flow property factors (e.g., MJ/kg, kg/m3) depending on species, regional species mix, resource type, and factors that moisture content such as regional harvest location.

Inconvenient CRLF in Synonyms

A few of the synonyms entries have CRLFs (/r/n) encoded within the text which makes for some odd CSV exports. See Lasiocarpine for an example.

Incorrect conversion in mapping file for ImpactWorld+

A subset of flows have the incorrect conversion factor applied in ImpactWorld+

Conversion factor is typically added via alternate units, but in the case of ImpactWorld+ is supplied in the flowables file. This gets overridden here.

Primarily impacts mappings in Bq for isotopes, where Bq are converted to kBq with no conversion.

Identified by @pweiler2

Flow mapping

When using the flow mapping feature (in v1.10 or the public version of 1.9) the source category and target category fields add extra spaces even if no spaces are included in the mapping csv file. This causes openLCA not to recognize the category correctly

When editing the source flow and target flow manually and selecting the flow in the database, the category is fixed (see highlighted row in image) and the status is confirmed. This does not seem to impact the actual mapping, only the status.

image

Updating List

Flows that have been updated in our defining sources that are in our list in a as the systematic name and not the chemistry dashboard name

Allyl alcohol versus 2-Propen-1-ol
Cuprammonium acetate versus Copper, bis(acetato-.kappa.O)diammine-

Pyarrow dependency

The pyarrow dependency is still causing install problems affecting downstream uses of the package. In particular it doesn't seem to be supported on 32-bit versions of Python for Windows. We need to explore how we can remove it and still maintain Parquet read and write without creating another dependency problem.

Water flowables and resource context combinations

Due to the way secondary context mappings are applied to both resources and emissions for flowabes, we have some combinations of water flowables that are mapped with contexts that don't make sense (e.g. flowable: 'water, fresh' context: 'resource/water/saline water body/ocean'). May want to write in some logic to code out resource contexts that don't make sense.

However, it should be noted that the flows do make sense as emissions (eg. flowable: 'water, fresh' context: 'emission/water/saline water body/ocean').

problems installing

Hi!

I have tried to install the package as outlined in the instructions in a new conda virtual environment and I get the following error message:

pip install git+https://github.com/USEPA/[email protected]#egg=Federal-LCA-Commons-Elementary-Flow-List

Collecting Federal-LCA-Commons-Elementary-Flow-List
Cloning https://github.com/USEPA/Federal-LCA-Commons-Elementary-Flow-List.git (to revision v1.0) to c:\users\migue\appdata\local\temp\pip-install-1omv9nzh\federal-lca-commons-elementary-flow-list_7cc046fedf48446e99192e8920d09c60
Running command git clone -q https://github.com/USEPA/Federal-LCA-Commons-Elementary-Flow-List.git 'C:\Users\migue\AppData\Local\Temp\pip-install-1omv9nzh\federal-lca-commons-elementary-flow-list_7cc046fedf48446e99192e8920d09c60'
Running command git checkout -q d3cba44
WARNING: Generating metadata for package Federal-LCA-Commons-Elementary-Flow-List produced metadata for project name fedelemflowlist. Fix your #egg=Federal-LCA-Commons-Elementary-Flow-List fragments.
WARNING: Discarding git+https://github.com/USEPA/[email protected]#egg=Federal-LCA-Commons-Elementary-Flow-List. Requested fedelemflowlist from git+https://github.com/USEPA/[email protected]#egg=Federal-LCA-Commons-Elementary-Flow-List has inconsistent name: filename has 'federal-lca-commons-elementary-flow-list', but metadata has 'fedelemflowlist'
ERROR: Could not find a version that satisfies the requirement federal-lca-commons-elementary-flow-list (unavailable) (from versions: none)
ERROR: No matching distribution found for federal-lca-commons-elementary-flow-list (unavailable)

I get a similar error if I try to install version 1.0.7 . The environment has already an updated version of pip and pyarrow installed. (python version 3.9.5)

TypeError: unsupported operand types for +: "PosixPath" and "str"

Failing to import fedelemflowlist version 1.1.1 due to the following error:

>>> import fedelemflowlist
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "~/Envs/ebm/lib/python3.11/site-packages/fedelemflowlist/__init__.py", line 11, in <module>
    from fedelemflowlist.flowlist import read_in_flowclass_file
  File "~/Envs/ebm/lib/python3.11/site-packages/fedelemflowlist/flowlist.py", line 8, in <module>
    from fedelemflowlist.globals import log, inputpath, flow_list_specs,\
  File "~/Envs/ebm/lib/python3.11/site-packages/fedelemflowlist/globals.py", line 23, in <module>
    fedefl_path.local_path + "/fedelemflowlist/")
    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
TypeError: unsupported operand type(s) for +: 'PosixPath' and 'str'

I solved this error in ElectricityLCI by wrapping paths.local_path with str method:

paths=Paths()
paths.local_path = os.path.realpath(str(paths.local_path) + "/electricitylci")

https://github.com/USEPA/Federal-LCA-Commons-Elementary-Flow-List/blob/ff7e31667c2c559a45ae5bbbe2ec2280cd851b45/fedelemflowlist/globals.py#L23C12-L23C12

Water compartment duplication error

UserWarning: Duplicate name: 'categories/c2433915-9ca3-3933-a64d-68d67e3e3281.json'
return self._open_to_write(zinfo, force_zip64=force_zip

Long term emission contexts

Hello,
I think contexts for long term emissions could be included in the FEDEFL to match with what the ecoinvent database uses as elementary flows.
Currently, as LCIA method developers wanting to connect to the FEDEFL, we can only assign the same characterization factor for both long term and unspecified term emissions. For LCIA methods which differentiate short and long term impact categories (like Impact World+) it leads to an overestimation, since long term emissions are not forced to zero in short term impact categories.
Thank you :)

Check TRACI metal mappings

TRACI generally has metal ions and FEDEFL metals without charge. This results in a lack of mapping to a number of CFs in TRACI for these ions. Some examples

LEAD(II) - TRACI
Lead - FEDEFL

ANTIMONY(III), ANTIMONY(V) - TRACI
Antimony - FEDEFL

This needs to be consider for mapping purposes.

SimaPro/brightway2/ecoinvent support?

Hello,
I was wondering if there already are mappings from the FEDEFL flows to the flow nomenclature used in SimaPro and brightway2/ecoinvent?
For some context, I am looking to connect an LCIA method to the FEDEFL list (through LCIAformatter) to then easily be able to distribute the LCIA method to the different LCA software. So if the work, or at least a part of the work, has already been done that would help me out greatly.
Thanks!

Flow property mismatch in mapping

In rare cases, flows will have the same unit but different flow properties (e.g. net caloric value v. energy). Mapping files, nor the FEDEFL specify the flow property, I believe it is assumed from the unit.

When flow properties don't match when performing a mapping using the flow tool, it triggers an error

Installation issues with git lfs

We no longer host large objects within the repository and git lfs increasingly causes install issues. Can we determine a way to remove it from the install process?

Multiple alt units creates errors in test_flow_list.py

Listing more than one alt unit for a flowable triggers an error upon testing the flow list due to duplicate UUIDs. This manifests as duplicate records in the flow list, one for each alt unit and conversion factor. This does not impact the import of flows into openLCA.

Mapping to alt units

It would be nice to be able to map to alternate units in the mapping files. This would reduce the need for conversion factors and keep flows in the original units from the source database.

My sense is that because the mapping files require the UUIDs for target flows, and UUIDs are based on the units in the flow, this may be challenging.

Perhaps add_uuid_to_flowmapping.py could be modified to check for alternate units when a UUID can't be identified.

AttributeError: 'Ref' object has no attribute 'to_json' when calling `write_jsonld` with flowmappings

I'm trying to generate openLCA JSON-LD zip archive with elementary flows and flowmappings and I'm get the error "AttributeError: 'Ref' object has no attribute 'to_json'". Here a snippet reproducing the error:

import fedelemflowlist
from pathlib import Path

output_path = Path('flows_w_mappings.zip')
flowlist = fedelemflowlist.get_flows(preferred_only=False)
flowlist = flowlist.iloc[0:100]
flowmapping = fedelemflowlist.get_flowmapping('ImpactWorld+')
fedelemflowlist.write_jsonld(flowlist,output_path, flowmapping)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/fjunior/Projects/cauldron/Federal-LCA-Commons-Elementary-Flow-List/fedelemflowlist/__init__.py", line 79, in write_jsonld
    writer.write_to(path)
  File "/Users/fjunior/Projects/cauldron/Federal-LCA-Commons-Elementary-Flow-List/fedelemflowlist/jsonld.py", line 146, in write_to
    self._write_mappings(zw)
  File "/Users/fjunior/Projects/cauldron/Federal-LCA-Commons-Elementary-Flow-List/fedelemflowlist/jsonld.py", line 224, in _write_mappings
    mappings.append(e.to_json())
                    ^^^^^^^^^^^
  File "/Users/fjunior/Projects/cauldron/Federal-LCA-Commons-Elementary-Flow-List/fedelemflowlist/jsonld.py", line 119, in to_json
    'from': self.source_flow.to_json(),
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/fjunior/Projects/cauldron/Federal-LCA-Commons-Elementary-Flow-List/fedelemflowlist/jsonld.py", line 74, in to_json
    'flow': flow_ref.to_json()
            ^^^^^^^^^^^^^^^^
AttributeError: 'Ref' object has no attribute 'to_json'

I got the same error running the the run_mappings.ipynb notebook locally1.

Footnotes

  1. I did not manage to make it work in Binder. โ†ฉ

Consistent formatting for chemical naming

I'll admit I'm pretty ignorant here. Should there be a consistent naming convention for things like Benzo(b)fluoranthene and Benzo[j]fluoranthene? Should they both use parentheses or both use brackets?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.