Exemplo n.º 1
0
def calculate_EEIO_model(model, year, location, demandtype, perspective,
                         include_data_quality):
    """
    Calculates an EEIO model result
    :param model: A useeopy Model object
    :param year: int, year of demand
    :param location: string, location acronym of demand
    :param demandtype: string, either 'production' or 'consumption'
    :param perspective: string, either 'DIRECT' or 'INDIRECT'
    :return: A useeiopy Result object
    """
    result = {}
    demandfile = model.path + model.name + "_FinalDemand.csv"
    demandcolumnname = str(year) + '_' + location + "_" + demandtype
    demand = dd.demandtodict(demandcolumnname, demandfile)
    if (perspective == 'FINAL'):
        p = calc.FINAL_PERSPECTIVE
        r = calc.calculate(model.model, demand, p)
        result['LCI_f'] = r.lci_contributions.transpose()
        result['LCIA_f'] = r.lcia_contributions.transpose()
    elif (perspective == 'DIRECT'):
        p = calc.DIRECT_PERSPECTIVE
        r = calc.calculate(model.model, demand, p)
        result['LCI_d'] = r.lci_contributions.transpose()
        result['LCIA_d'] = r.lcia_contributions.transpose()
    else:
        log.error('Perspective must be DIRECT or FINAL.')
    new_result = Result(result, model, location, demandtype, perspective, year,
                        include_data_quality)

    return new_result
Exemplo n.º 2
0
def calculate(model, year, location, demandtype, perspective, modelname,
              modelpath):

    demandfile = modelpath + modelname + "_FinalDemand.csv"
    demandcolumnname = str(year) + '_' + location + "_" + demandtype
    demand = dd.demandtodict(demandcolumnname, demandfile)
    if (perspective == 'FINAL'):
        p = calc.FINAL_PERSPECTIVE
    else:
        p = calc.DIRECT_PERSPECTIVE
    result = calc.calculate(model, demand, p)
    lciacontributions = result.lcia_contributions.transpose()
    lciaflowcontributions = result.lcia_flow_contributions.transpose()
    resultsfolder = modelpath + "results/"
    if os.path.exists(resultsfolder) is False:
        os.mkdir(resultsfolder)
    lciacontributions.to_csv(resultsfolder + modelname + "_" + str(year) +
                             "_" + location + "_" + demandtype + "_" +
                             perspective + "_" + "lciacontributions.csv")
    lciaflowcontributions.to_csv(resultsfolder + modelname + "_" + str(year) +
                                 "_" + location + "_" + demandtype + "_" +
                                 perspective + "_" +
                                 "lciaflowcontributions.csv")
Exemplo n.º 3
0
eeio0 = useeiopy.assemble("USEEIO2012_scen0") # Baseline

eeio1 = useeiopy.assemble("USEEIO2012_scen1")

eeio2 = useeiopy.assemble("USEEIO2012_scen2")

eeio3 = useeiopy.assemble("USEEIO2012_scen3")

drc = eeio0.drc_matrix.copy()

demand2012_file = 'C:/Users/qread/Dropbox/projects/foodwaste/Code/USEEIO-master/useeiopy/Model Builds/USEEIO2012/USEEIO2012_FinalDemand.csv'

# Results across all sectors of the economy.

demand_dict2012 = dd.demandtodict('2012_US_Consumption', demand2012_file)
demand_dict2012_corrected = correct_demand_names(demand_dict2012, drc)

result0 = iomb.calculate(eeio0, demand_dict2012_corrected)
result1 = iomb.calculate(eeio1, demand_dict2012_corrected)
result2 = iomb.calculate(eeio2, demand_dict2012_corrected)
result3 = iomb.calculate(eeio3, demand_dict2012_corrected)

result0.lcia_total
result1.lcia_total
result2.lcia_total
result3.lcia_total

all_results = pandas.concat([result0.lcia_total, result1.lcia_total, result2.lcia_total, result3.lcia_total], axis = 1)
all_results.columns = ['result0','result1','result2','result3']
Exemplo n.º 4
0
def get_impacts(scenario_name, scenario_csv):
    demand_dict = dd.demandtodict(scenario_name, scenario_csv)
    demand_dict_corrected = correct_demand_names(demand_dict, drc)
    result = iomb.calculate(useeio1pt1, demand_dict_corrected)
    return (result.lcia_total)