def main():
    os.makedirs(outputpath, exist_ok=True)
    log.basicConfig(level=log.INFO)

    file = method.get_filename()

    data = lciafmt.get_method(method, endpoint=False)
    data_endpoint = lciafmt.get_method(method, endpoint=True)
    data = data.append(data_endpoint, ignore_index=True)

    # map the flows to the Fed.LCA commons flows
    # set preserve_unmapped=True if you want to keep unmapped
    # flows in the resulting data frame
    mapping = method.get_metadata()['mapping']
    mapped_data = lciafmt.map_flows(data, system=mapping)

    mapped_data = collapse_indicators(mapped_data)

    # write the result to parquet and JSON-LD
    store_method(mapped_data, method)

    for m in mapped_data['Method'].unique():
        json_pack = outputpath + m + "_json.zip"
        if os.path.exists(json_pack):
            os.remove(json_pack)
        data_for_json = mapped_data[mapped_data['Method'] == m]
        lciafmt.to_jsonld(data_for_json, json_pack)
示例#2
0
def main():
    os.makedirs(outputpath, exist_ok=True)

    log.basicConfig(level=log.INFO)
    data = lciafmt.get_method(method, endpoint=False, summary=False)
    data_endpoint = lciafmt.get_method(method,
                                       endpoint=True,
                                       summary=apply_summary)
    data = data.append(data_endpoint, ignore_index=True)

    # make flowables case insensitive to handle lack of consistent structure in source file
    data['Flowable'] = data['Flowable'].str.lower()

    # map the flows to the Fed.LCA commons flows
    # set preserve_unmapped=True if you want to keep unmapped
    # flows in the resulting data frame
    mapping = method.get_metadata()['mapping']
    mapped_data = lciafmt.map_flows(data,
                                    system=mapping,
                                    case_insensitive=True)

    # write the result to parquet and JSON-LD
    store_method(mapped_data, method)

    for m in mapped_data['Method'].unique():
        mapped_data[mapped_data['Method'] == m].to_csv(
            outputpath + m.replace('/', '_') + ".csv", index=False)
        json_pack = outputpath + m.replace('/', '_') + "_json.zip"
        if os.path.exists(json_pack):
            os.remove(json_pack)
        data_for_json = mapped_data[mapped_data['Method'] == m]
        lciafmt.to_jsonld(data_for_json, json_pack)
示例#3
0
def main():
    modulepath = os.path.dirname(os.path.realpath(__file__)).replace('\\', '/')
    outputpath = modulepath + '/../output/'
    os.makedirs(outputpath, exist_ok=True)

    log.basicConfig(level=log.INFO)
    data = lciafmt.get_method(lciafmt.Method.TRACI)

    if mod is not None:
        log.info("getting modified CFs")
        modified_cfs = lciafmt.get_modification(mod, "TRACI2.1")
        data = data.merge(modified_cfs,
                          how='left',
                          on=['Flowable', 'Context', 'Indicator'])
        data.loc[data['Updated CF'].notnull(),
                 'Characterization Factor'] = data['Updated CF']
        data = data.drop(columns=['Updated CF', 'Note'])
        data['Method'] = "TRACI 2.1 (" + mod + " mod)"

    # map the flows to the Fed.LCA commons flows
    # set preserve_unmapped=True if you want to keep unmapped
    # flows in the resulting data frame
    mapped_data = lciafmt.map_flows(data, system="TRACI2.1")

    # write the result to JSON-LD and CSV
    if mod is not None:
        outputpath = outputpath + mod + "_"
    mapped_data.to_csv(outputpath + "traci_2.1.csv", index=False)
    json_pack = outputpath + "traci_2.1_json.zip"
    if os.path.exists(json_pack):
        os.remove(json_pack)
    lciafmt.to_jsonld(mapped_data, json_pack)
示例#4
0
def main():
    modulepath = os.path.dirname(os.path.realpath(__file__)).replace('\\', '/')
    outputpath = modulepath + '/../output/'
    os.makedirs(outputpath, exist_ok=True)

    log.basicConfig(level=log.INFO)
    data = lciafmt.get_method(lciafmt.Method.RECIPE_2016)

    #export lcia to csv before mapping
    data.to_csv(outputpath + 'Recipe_source.csv', index=False)

    # make flowables case insensitive to handle lack of consistent structure in source file
    data['Flowable'] = data['Flowable'].str.lower()

    # map the flows to the Fed.LCA commons flows
    # set preserve_unmapped=True if you want to keep unmapped
    # flows in the resulting data frame
    mapped_data = lciafmt.map_flows(data,
                                    system="ReCiPe2016",
                                    case_insensitive=True)

    # write the result to JSON-LD and CSV
    for method in mapped_data['Method'].unique():
        mapped_data[mapped_data['Method'] == method].to_csv(
            outputpath + method.replace('/', '_') + ".csv", index=False)
    json_pack = outputpath + "recipe_2016_json.zip"
    if os.path.exists(json_pack):
        os.remove(json_pack)
    lciafmt.to_jsonld(mapped_data, json_pack)
示例#5
0
def main():
    os.makedirs(outputpath, exist_ok=True)
    log.basicConfig(level=log.INFO)
    file = method.get_filename()

    data = lciafmt.get_method(method)
    
    if mod is not None:
        log.info("getting modified CFs")
        modified_cfs=lciafmt.get_modification(mod,"TRACI2.1")
        data = data.merge(modified_cfs,how='left',on=['Flowable','Context','Indicator'])
        data.loc[data['Updated CF'].notnull(),'Characterization Factor']=data['Updated CF']
        data = data.drop(columns=['Updated CF','Note'])
        data['Method']="TRACI 2.1 ("+mod+" mod)"
    
    # map the flows to the Fed.LCA commons flows
    # set preserve_unmapped=True if you want to keep unmapped
    # flows in the resulting data frame
    mapping = method.get_metadata()['mapping']
    mapped_data = lciafmt.map_flows(data, system=mapping)

    # write the result to parquet and JSON-LD
    store_method(mapped_data, method)
    if mod is not None:
        file=mod+"_"+file
    json_pack = outputpath+file+"_json.zip"
    if os.path.exists(json_pack):
        os.remove(json_pack)
    lciafmt.to_jsonld(mapped_data, json_pack)
示例#6
0
def main():

    log.debug('Subsets available: ' + ", ".join(map(str, fedefl.subset_list.get_subsets())))

    subsets = None

    inventory_methods = lciafmt.get_method(method_id='FEDEFL Inventory',subset=subsets)
    
    store_method(inventory_methods, method)
    save_json(method, inventory_methods)
示例#7
0
def main():

    data = lciafmt.get_method(method, endpoint=False, summary=False)
    data_endpoint = lciafmt.get_method(method,
                                       endpoint=True,
                                       summary=apply_summary)
    data = data.append(data_endpoint, ignore_index=True)

    # make flowables case insensitive to handle lack of consistent structure in source file
    data['Flowable'] = data['Flowable'].str.lower()

    # map the flows to the Fed.LCA commons flows
    # set preserve_unmapped=True if you want to keep unmapped
    # flows in the resulting data frame
    mapping = method.get_metadata()['mapping']
    mapped_data = lciafmt.map_flows(data,
                                    system=mapping,
                                    case_insensitive=True)

    # write the result to parquet and JSON-LD
    store_method(mapped_data, method)
    for m in mapped_data['Method'].unique():
        save_json(method, mapped_data, m)
示例#8
0
def main():

    os.makedirs(outputpath, exist_ok=True)
    log.basicConfig(level=log.INFO)
    file = method.get_filename()
    log.info(fedefl.subset_list.get_subsets())
    subsets = None

    inventory_methods = lciafmt.get_method(method_id='FEDEFL Inventory',subset=subsets)
    
    store_method(inventory_methods, method)
    json_pack = outputpath+file+"_json.zip"
    if os.path.exists(json_pack):
        os.remove(json_pack)
示例#9
0
def main():

    data = lciafmt.get_method(method)

    # map the flows to the Fed.LCA commons flows
    # set preserve_unmapped=True if you want to keep unmapped
    # flows in the resulting data frame
    mapping = method.get_metadata()['mapping']
    mapped_data = lciafmt.map_flows(data, system=mapping)

    mapped_data = collapse_indicators(mapped_data)

    # write the result to parquet and JSON-LD
    store_method(mapped_data, method)
    for m in mapped_data['Method'].unique():
        save_json(method, mapped_data, m)
示例#10
0
def main():
    modulepath = os.path.dirname(os.path.realpath(__file__)).replace('\\', '/')
    outputpath = modulepath + '/../output/'
    os.makedirs(outputpath, exist_ok=True)

    log.basicConfig(level=log.INFO)
    data = lciafmt.get_method(lciafmt.Method.TRACI)

    # map the flows to the Fed.LCA commons flows
    # set preserve_unmapped=True if you want to keep unmapped
    # flows in the resulting data frame
    mapped_data = lciafmt.map_flows(data, system="TRACI2.1")

    # write the result to JSON-LD and CSV
    mapped_data.to_csv(outputpath + "traci_2.1.csv", index=False)
    json_pack = outputpath + "traci_2.1_json.zip"
    if os.path.exists(json_pack):
        os.remove(json_pack)
    lciafmt.to_jsonld(mapped_data, json_pack)
示例#11
0
def main():

    data = lciafmt.get_method(method)
    
    if mod is not None:
        log.info("getting modified CFs")
        modified_cfs=get_modification(mod,"TRACI2.1")
        data = data.merge(modified_cfs,how='left',on=['Flowable','Context','Indicator'])
        data.loc[data['Updated CF'].notnull(),'Characterization Factor']=data['Updated CF']
        data = data.drop(columns=['Updated CF','Note'])
        data['Method']="TRACI 2.1 ("+mod+" mod)"
    
    # map the flows to the Fed.LCA commons flows
    # set preserve_unmapped=True if you want to keep unmapped
    # flows in the resulting data frame
    mapping = method.get_metadata()['mapping']
    mapped_data = lciafmt.map_flows(data, system=mapping)

    # write the result to parquet and JSON-LD
    store_method(mapped_data, method)
    save_json(method, mapped_data)
示例#12
0
and TRACI2.1 from the lcia_formatter
Requires lciafmt from lcia_formatter (https://github.com/USEPA/lciaformatter)
BEWARE this will replace the existing mapping file if it exists in /flowmapping
"""

import pandas as pd
import fedelemflowlist
from fedelemflowlist.globals import inputpath, flowmappingpath

lcia_name = 'TRACI2.1'

if __name__ == '__main__':
    ## Bring in TRACI flowables and contexts from the lcia_formatter
    import lciafmt

    lcia_lciafmt = lciafmt.get_method('TRACI 2.1')
    """ due to substances listed more than once with different names
    this replaces all instances of the Original Flowable with a New Flowable
    based on a csv input file, otherwise zero values for CFs will override
    when there are duplicate names"""
    flowables_replace = pd.read_csv(inputpath + '/TRACI_2.1_replacement.csv')
    for index, row in flowables_replace.iterrows():
        orig = row['Original Flowable']
        new = row['New Flowable']
        lcia_lciafmt['Flowable'] = lcia_lciafmt['Flowable'].replace(orig, new)
    """ due to substances listed more than once with the same name but different CAS
    this replaces all instances of the Original Flowable with a New Flowable
    based on a csv input file according to the CAS"""
    flowables_split = pd.read_csv(inputpath + '/TRACI_2.1_split.csv')
    for index, row in flowables_split.iterrows():
        CAS = row['CAS']