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'] # Write the output. all_results.to_csv('Q:/IO_output/structural_scenarios_2012.csv') # Remote version all_results.to_csv('C:/Users/qread/Dropbox/projects/foodwaste/Data/structural_scenarios_2012.csv') # Local version
def eeio_lcia_contributions(model_path, demand_values, demand_codes): eeio = useeiopy.assemble(model_path) demand_dict = dict(zip(demand_codes, demand_values)) result = iomb.calculate(eeio, demand_dict) lcia_contr = result.lcia_contributions return lcia_contr
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)
# Create dictionary to map the old and new name key_mapping = dict(zip(key_demand, drc_index_sorted)) # Correct names in original dictionary dict_corrected = dict( (key_mapping[key], value) for (key, value) in demand_dict.items()) return (dict_corrected) # Get names of the sectors sector_names = drc.index.values.tolist() # Get dairy code dairy_code = [x for x in sector_names if re.search('dairies', x)] dairy_result = iomb.calculate(useeio1pt1, {dairy_code[0]: 1}) # Get inputs and outputs of dairy sector dairy_inputs = drc.loc[:, dairy_code[0]] dairy_outputs = drc.loc[dairy_code[0], :] # Milk products that use output from dairies dairyproducts_code = [x for x in sector_names if re.search('^3115', x)] cheese_result = iomb.calculate(useeio1pt1, {dairyproducts_code[0]: 1}) # Inputs and outputs of cheese sector cheese_inputs = drc.loc[:, dairyproducts_code[ 0]] # 33 cents of dairy output is required to produce 1 dollar of cheese. cheese_outputs = drc.loc[dairyproducts_code[ 0], :] # 1/2 cent of cheese output is required to produce 1 dollar of restaurant value