Skip to content

Commit

Permalink
Merge branch 'develop' into flow_updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bl-young committed Nov 6, 2024
2 parents 64352d7 + 06ef94f commit 6b21498
Show file tree
Hide file tree
Showing 16 changed files with 242 additions and 57 deletions.
28 changes: 28 additions & 0 deletions .zenodo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"description": "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.",
"license": "MIT",
"title": "fedelemflowlist",
"upload_type": "software",
"creators": [
{
"affiliation": "US Environmental Protection Agency",
"name": "Wesley Ingwersen",
"orcid": "https://orcid.org/0000-0002-9614-701X"
},
{
"affiliation": "Eastern Research Group, Inc.",
"name": "Ben Young",
"orcid": "https://orcid.org/0000-0001-6276-8670"
},
{
"affiliation": "Eastern Research Group, Inc.",
"name": "Ashley Edelen"
},
{
"affiliation": "Eastern Research Group, Inc.",
"name": "Sarah Cashman",
"orcid": "https://orcid.org/0000-0001-9859-9557"
}
],
"access_right": "open"
}
2 changes: 1 addition & 1 deletion Jupyter/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Create a mapping file for use in openLCA through Binder

[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/USEPA/Federal-LCA-Commons-Elementary-Flow-List/HEAD?labpath=Jupyter%2Frun_mappings.ipynb)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/USEPA/fedelemflowlist/HEAD?labpath=Jupyter%2Frun_mappings.ipynb)
37 changes: 23 additions & 14 deletions Jupyter/run_mappings.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,24 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"scrolled": false
},
"metadata": {},
"outputs": [],
"source": [
"## Step 1\n",
"import pandas as pd\n",
"import fedelemflowlist\n",
"from fedelemflowlist.globals import flowmappingpath, flowmapping_fields\n",
"import os\n",
"from pathlib import Path\n",
"import ipywidgets as widgets\n",
"from IPython.display import display, FileLink\n",
"\n",
"if not os.path.exists('./scratch'):\n",
" os.mkdir('./scratch')\n",
"\n",
"uploader = widgets.FileUpload(\n",
" accept = '.csv'\n",
" ,multiple = False\n",
" accept = '.csv',\n",
" multiple = False\n",
")\n",
"\n",
"display(uploader)"
Expand All @@ -59,14 +58,14 @@
"if not uploader.value:\n",
" raise ValueError('Input Excel file is required to continue. Make sure to select the Upload button above before continuing.')\n",
"\n",
"input_file = next(iter(uploader.value))\n",
"input_full = r\"./scratch/\" + input_file\n",
"input_file = uploader.value[0]\n",
"input_full = r\"./scratch/\" + input_file['name']\n",
"\n",
"if os.path.exists(input_full):\n",
" os.remove(input_full)\n",
" \n",
"with open(input_full,\"wb\") as fp:\n",
" fp.write(uploader.value[input_file]['content'])\n",
" fp.write(input_file['content'])\n",
"\n",
"mapping = pd.read_csv(input_full)\n",
"mapping_length = len(mapping)\n",
Expand Down Expand Up @@ -126,17 +125,27 @@
"#Subset all flows to get just those used in selected mapping\n",
"flows_used_in_mapping = pd.merge(all_flows,mapping_flow_uuids)\n",
"\n",
"fedelemflowlist.write_jsonld(flows_used_in_mapping,output_full,mapping_w_conversion)\n",
"print(\"mapping file created as json\")\n",
"download = FileLink(output_full,result_html_prefix=\"Click here to download: \")\n",
"display(download)\n"
"fedelemflowlist.write_jsonld(flows = flows_used_in_mapping,\n",
" path = Path(output_full),\n",
" mappings = mapping_w_conversion)\n",
"print(\"mapping file created as json\")\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%%html\n",
"<a href=\"scratch/flows_w_mappings.zip\" download=\"flows_w_mappings.zip\">Download Mapping File</a>"
]
}
],
"metadata": {
"celltoolbar": "Tags",
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -150,7 +159,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5"
"version": "3.12.3"
}
},
"nbformat": 4,
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!-- badges: start -->
[![Applied Sciences](http://img.shields.io/badge/Applied%20Sciences-10.3390/app12199687-blue.svg)](https://doi.org/10.3390/app12199687)
[![DOI](https://zenodo.org/badge/120324037.svg)](https://zenodo.org/doi/10.5281/zenodo.6604309)
<!-- badges: end -->

# fedelemflowlist
Expand All @@ -12,9 +13,9 @@
and a [Flow Mapping](./format%20specs/FlowMapping.md) are defined and provided by `fedelemflowlist`.
They are implemented as [pandas](https://pandas.pydata.org/) dataframes.
Standard formats are also described for the input files used in building the flow list, and implemented as .csv files
in the [input](https://github.com/USEPA/Federal-LCA-Commons-Elementary-Flow-List/tree/master/fedelemflowlist/input) directory.
in the [input](https://github.com/USEPA/fedelemflowlist/tree/master/fedelemflowlist/input) directory.

The version of the package (see [Releases](https://github.com/USEPA/Federal-LCA-Commons-Elementary-Flow-List/releases/))
The version of the package (see [Releases](https://github.com/USEPA/fedelemflowlist/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.

Expand All @@ -25,7 +26,7 @@ The background and methodology behind creation of the flow list, as well as a su
['The Federal LCA Commons Elementary Flow List: Background, Approach, Description and Recommendations for Use'](https://cfpub.epa.gov/si/si_public_record_report.cfm?Lab=NRMRL&dirEntryId=347251).
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](https://sor.epa.gov/sor_internet/registry/termreg/searchandretrieve/glossariesandkeywordlists/search.do?details=&vocabName=FEDEFL).

See the [Wiki](https://github.com/USEPA/Federal-LCA-Commons-Elementary-Flow-List/wiki/) for installation, more info on repository
See the [Wiki](https://github.com/USEPA/fedelemflowlist/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
Expand Down
6 changes: 3 additions & 3 deletions fedelemflowlist/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from fedelemflowlist.subset_list import subsets
import fedelemflowlist.subset_list as subset_list

def get_flows(preferred_only=None, subset=None, download_if_missing=True):
def get_flows(preferred_only=False, subset=None, download_if_missing=True):
"""Gets a flow list in a standard format
Returns the full master flow list unless preferred flows is lists
Expand Down Expand Up @@ -66,7 +66,7 @@ def get_flowmapping(source=None):
return flowmappings


def write_jsonld(flows, path: Path, mappings=None):
def write_jsonld(flows, path: Path, mappings=None, **kwargs):
""" Writes a standard openLCA JSON-LD zip archive with elementary flows and optionally
flowmappings
Expand All @@ -76,7 +76,7 @@ def write_jsonld(flows, path: Path, mappings=None):
:return: writes out .zip file
"""
writer = jsonld.Writer(flow_list=flows, flow_mapping=mappings)
writer.write_to(path)
writer.write_to(path, zw=kwargs.get('zw'))

def get_alt_conversion():
"""returns a dataframe of all flowables with altunits and alt conversion factors
Expand Down
2 changes: 1 addition & 1 deletion fedelemflowlist/contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
context_list_na_removed = list()
for index, row in contexts.iterrows():
pattern = [compartment_classes[x] for x in range(0, max_compartment_classes)
if str(row[x]) != 'nan']
if str(row.iloc[x]) != 'nan']
pattern = ','.join(pattern)
context_patterns.append(pattern)
row_list = row.values
Expand Down
4 changes: 4 additions & 0 deletions fedelemflowlist/flowmapping/EIA_MER.csv
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ EIA_MER,Primary energy - biomass,,resource,MJ,=,0.0612,Biomass,7feeb363-fbeb-37a
EIA_MER,Primary energy - hydro,,resource/in water,MJ,=,1,"Energy, hydro",5af7a834-bf92-32eb-a0b2-2f2dcdc9f3d9,resource/water,MJ,Young,Edelen,2/2/2021
EIA_MER,Primary energy - solar,,resource/in air,MJ,=,1,"Energy, solar",4d1571a6-ffff-3a36-82df-224ed975a094,resource/air,MJ,Young,Edelen,2/2/2021
EIA_MER,Primary energy - wind,,resource/in air,MJ,=,1,"Energy, wind",35962866-662b-3817-a2a7-39375c7e6a3c,resource/air,MJ,Young,Edelen,2/2/2021
EIA_MER,Coal,,resource,Quadrillion Btu,=,1.06E+12,Coal,39a07dad-33e8-3644-b6a5-2054c3d53fa9,resource/ground,MJ,Young,,5/15/2024
EIA_MER,"Natural Gas, Dry",,resource,Quadrillion Btu,=,1.06E+12,Natural gas,ae604834-c49a-3ebb-b15b-06e6e89e427e,resource/air,MJ,Young,,5/15/2024
EIA_MER,Natural Gas Plant Liquids,,resource,Quadrillion Btu,=,1.06E+12,Natural gas,ae604834-c49a-3ebb-b15b-06e6e89e427e,resource/air,MJ,Young,,5/15/2024
EIA_MER,Crude Oil,,resource,Quadrillion Btu,=,1.06E+12,Crude oil,4aca0c2c-6e1a-3d90-956c-7141ca8932ce,resource/water,MJ,Young,,5/15/2024
9 changes: 9 additions & 0 deletions fedelemflowlist/flowmapping/GHGI.csv
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ GHGI,HFC-236fa,,air,MMTCO2e,=,101937,HFC-236fa,32057bc6-6839-3dbc-b33d-5b72e542e
GHGI,HFC-32,,air,MMTCO2e,=,1481481,HFC-32,747fa9a4-559b-37a4-ac9b-5ca630274739,emission/air,kg,Bell,,10/20/2022
GHGI,NF3,,air,MTCO2e,=,0.05814,Nitrogen trifluoride,80d4ef62-ca97-37d6-87ac-83233956c063,emission/air,kg,Bell,,9/28/2022
GHGI,SF6,,air,MTCO2e,=,0.04386,Sulfur hexafluoride,8334c424-1603-3274-bec1-15a7bd5c8e86,emission/air,kg,Bell,,9/28/2022
GHGI,N2O,,air,MTCO2e,=,3.356,Nitrous oxide,cfee0524-7ad6-300b-b050-6249135a2492,emission/air,kg,Young,,6/19/2024
GHGI,HFE,,air,MTCO2e,=,1000,"HFCs and PFCs, unspecified",n.a.,emission/air,kg CO2e,Young,,6/19/2024
GHGI,PFC-116 <Perfluoroethane>,,air,MMT CO2e,=,81967,Hexafluoroethane,b24a2de2-da9b-30b8-ae33-3d4ffa692029,emission/air,kg,Young,,10/18/2022
GHGI,PFC-14 <Perfluoromethane>,,air,MMT CO2e,=,135318,Carbon tetrafluoride,fbfa508b-f3c9-3977-a47d-1138e96914a3,emission/air,kg,Young,,10/18/2022
GHGI,C2F6,,air,MT,=,1000,Hexafluoroethane,b24a2de2-da9b-30b8-ae33-3d4ffa692029,emission/air,kg,Bell,,11/16/2022
Expand All @@ -81,3 +83,10 @@ GHGI,Unspecified mix of PFCs,,air,MMT CO2e,=,1000000000,"HFCs and PFCs, unspecif
GHGI,Unspecified mix of HFCs and PFCs,,air,MMT CO2e,=,1000000000,"HFCs and PFCs, unspecified",n.a.,emission/air,kg CO2e,Young,,4/25/2023
GHGI,HFC-41,,air,MMT CO2e,=,1000000000,"HFCs and PFCs, unspecified",n.a.,emission/air,kg CO2e,Young,,4/25/2023
GHGI,C4F6,,air,MMT CO2e,=,1000000000,"HFCs and PFCs, unspecified",n.a.,emission/air,kg CO2e,Young,,4/25/2023
GHGI,CO2,,air,MT CO2e (AR5-20),,1000,Carbon dioxide,b6f010fb-a764-3063-af2d-bcb8309a97b7,emission/air,kg,Young,,6/19/2024
GHGI,CH4,,air,MT CO2e (AR5-20),,11.9047619,Methane,aab83476-ec6c-3742-af85-15d320b7ce80,emission/air,kg,Young,,6/19/2024
GHGI,N2O,,air,MT CO2e (AR5-20),,3.78788,Nitrous oxide,cfee0524-7ad6-300b-b050-6249135a2492,emission/air,kg,Young,,6/19/2024
GHGI,HFCs,,air,MT CO2e (AR5-20),,1000,"HFCs and PFCs, unspecified",n.a.,emission/air,kg CO2e,Young,,6/19/2024
GHGI,SF6,,air,MT CO2e (AR5-20),,0.057143,Sulfur hexafluoride,8334c424-1603-3274-bec1-15a7bd5c8e86,emission/air,kg,Young,,6/19/2024
GHGI,NF3,,air,MT CO2e (AR5-20),,0.078125,Nitrogen trifluoride,80d4ef62-ca97-37d6-87ac-83233956c063,emission/air,kg,Young,,6/19/2024
GHGI,PFCs,,air,MT CO2e (AR5-20),,1000,"HFCs and PFCs, unspecified",n.a.,emission/air,kg CO2e,Young,,6/19/2024
Loading

0 comments on commit 6b21498

Please sign in to comment.