예제 #1
0
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():

    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)
예제 #7
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)
예제 #8
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)
예제 #9
0
def main():

    data = lciafmt.get_method(method, endpoint=True, summary=apply_summary)

    # 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)

    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)