def treat_economic_flow_info_desag(flow,UP, column_number, UP_list, sign, A, UP_scaling_factor, unit_converter, marker, uncertainty_info, infrastructure_rescale, UP_meta_info,UP_list_desag_1): from treat_pedigree import treat_pedigree UP_name = flow[0] coefficient = float(flow[2].replace(',','.')) if marker == 'Remaining waste' or marker == 'Separated waste': #these flow display less info unit = 'kg' distribution = 'NA' spread1 = 'NA' spread2 = 'NA' spread3 = 'NA' else: #otherwise, the unit, distribution and spreads are in regular places unit = flow[1] distribution = flow[3] spread1 = float(flow[4].replace(',','.')) spread2 = float(flow[5].replace(',','.')) spread3 = float(flow[6].replace(',','.')) try: pedigree = flow[7] except IndexError: pedigree = '' """ #raising a warning if a process calls itself for process in UP_list_desag_1: if UP_list[UP_list_desag_1[process]['UP_number']]==UP_name: line_number=UP_list_desag_1[process]['instance_ID'] """ line_number = UP_list.index(UP_name) if line_number == column_number: print 'alert! UP is calling itself:' print line_number print UP_list[line_number] print '' #adjusting the coefficient for unit consistency. #Two conversions have to be made: one for the process calling, and one for the process being called coefficient = float(coefficient) * unit_converter[unit][1] / UP_scaling_factor * sign if UP_name.find('/I ') != -1: #if the process does NOT NOT contains the infrastructure chain of character, rescale it coefficient = coefficient * infrastructure_rescale A[column_number][line_number] = coefficient uncertainty_info['technology'][column_number][line_number] = {} uncertainty_info['technology'][column_number][line_number]['distribution'] = distribution uncertainty_info['technology'][column_number][line_number]['spread1'] = spread1 uncertainty_info['technology'][column_number][line_number]['spread2'] = spread2 uncertainty_info['technology'][column_number][line_number]['spread3'] = spread3 if pedigree != '': uncertainty_info['technology'][column_number][line_number]['pedigree'] = treat_pedigree(pedigree) return UP_list, A, uncertainty_info
def treat_elementary_flow_info(flow, column_number, EF_list, B, UP_scaling_factor, unit_converter, compartment, uncertainty_info, EF_unit, UP_list): from treat_pedigree import treat_pedigree #for more comment, see treat_economic_flow_info, the structure is the same. EF_name = flow[0] sub_compartment = flow[1] if sub_compartment == '': sub_compartment = '(unspecified)' unit = flow[2] coefficient = float(flow[3].replace(',', '.')) distribution = flow[4] spread1 = float(flow[5].replace(',', '.')) spread2 = float(flow[6].replace(',', '.')) spread3 = float(flow[7].replace(',', '.')) try: pedigree = flow[8] except IndexError: pedigree = '' try: EF_list.index([compartment, EF_name, sub_compartment]) except ValueError: EF_list.append([compartment, EF_name, sub_compartment]) EF_unit[EF_name] = unit_converter[unit][0] line_number = EF_list.index([compartment, EF_name, sub_compartment]) coefficient = float( coefficient) * unit_converter[unit][1] / UP_scaling_factor try: B[column_number][line_number] += coefficient #if there is no error, it means this line already exists. if (spread1 > uncertainty_info['intervention'][column_number] [line_number]['spread1'] or spread2 > uncertainty_info['intervention'][column_number] [line_number]['spread2'] or spread3 > uncertainty_info['intervention'][column_number] [line_number]['spread3']): #if the uncertainty of the new one is bigger, the uncertainty info of the new one is #reatined, just to be on the safe side. uncertainty_info['intervention'][column_number][line_number][ 'distribution'] = distribution uncertainty_info['intervention'][column_number][line_number][ 'spread1'] = spread1 uncertainty_info['intervention'][column_number][line_number][ 'spread2'] = spread2 uncertainty_info['intervention'][column_number][line_number][ 'spread3'] = spread3 if pedigree != '': uncertainty_info['intervention'][column_number][line_number][ 'pedigree'] = treat_pedigree(pedigree) except KeyError: B[column_number][line_number] = coefficient uncertainty_info['intervention'][column_number][line_number] = {} uncertainty_info['intervention'][column_number][line_number][ 'distribution'] = distribution uncertainty_info['intervention'][column_number][line_number][ 'spread1'] = spread1 uncertainty_info['intervention'][column_number][line_number][ 'spread2'] = spread2 uncertainty_info['intervention'][column_number][line_number][ 'spread3'] = spread3 if pedigree != '': uncertainty_info['intervention'][column_number][line_number][ 'pedigree'] = treat_pedigree(pedigree) return EF_list, B, uncertainty_info, EF_unit
def treat_economic_flow_info(flow, column_number, UP_list, sign, A, UP_scaling_factor, unit_converter, marker, uncertainty_info, infrastructure_rescale, UP_meta_info): from treat_pedigree import treat_pedigree UP_name = flow[0] coefficient = float(flow[2].replace(',','.')) if marker == 'Remaining waste' or marker == 'Separated waste': #these flow display less info unit = 'kg' distribution = 'NA' spread1 = 'NA' spread2 = 'NA' spread3 = 'NA' else: #otherwise, the unit, distribution and spreads are in regular places unit = flow[1] distribution = flow[3] spread1 = float(flow[4].replace(',','.')) spread2 = float(flow[5].replace(',','.')) spread3 = float(flow[6].replace(',','.')) try: pedigree = flow[7] except IndexError: pedigree = '' #if the UP is not in the list yet, add it try: UP_list.index(UP_name) except ValueError: UP_list.append(UP_name) #raising a warning if a process calls itself line_number = UP_list.index(UP_name) ''' if line_number == column_number: print 'alert! UP is calling itself:', print UP_list[line_number], print "("+str(line_number)+")" ''' #adjusting the coefficient for unit consistency. #Two conversions have to be made: one for the process calling, and one for the process being called coefficient = float(coefficient) * unit_converter[unit][1] / UP_scaling_factor * sign if distribution=="Normal": spread1=float(spread1) * unit_converter[unit][1] / UP_scaling_factor if UP_name.find('/I ') != -1: #if the process does NOT contains the infrastructure chain of character, rescale it coefficient = coefficient * infrastructure_rescale try: #sometimes, a process is called several times. In this case, the coefficient should be added to the existing one A[column_number][line_number] += coefficient #if there is no error, it means this line already exists. if (spread1 > uncertainty_info['technology'][column_number][line_number]['spread1'] or spread2 > uncertainty_info['technology'][column_number][line_number]['spread2'] or spread3 > uncertainty_info['technology'][column_number][line_number]['spread3']): #if the uncertainty of the new one is bigger, the uncertainty info of the new one is #reatined, just to be on the safe side. uncertainty_info['technology'][column_number][line_number]['distribution'] = distribution uncertainty_info['technology'][column_number][line_number]['spread1'] = spread1 uncertainty_info['technology'][column_number][line_number]['spread2'] = spread2 uncertainty_info['technology'][column_number][line_number]['spread3'] = spread3 if pedigree != '': uncertainty_info['technology'][column_number][line_number]['pedigree'] = treat_pedigree(pedigree) except KeyError: #the process has been called for the first time, so the info has to be created from scratch A[column_number][line_number] = coefficient uncertainty_info['technology'][column_number][line_number] = {} uncertainty_info['technology'][column_number][line_number]['distribution'] = distribution uncertainty_info['technology'][column_number][line_number]['spread1'] = spread1 uncertainty_info['technology'][column_number][line_number]['spread2'] = spread2 uncertainty_info['technology'][column_number][line_number]['spread3'] = spread3 if pedigree != '': uncertainty_info['technology'][column_number][line_number]['pedigree'] = treat_pedigree(pedigree) return UP_list, A, uncertainty_info
def treat_economic_flow_info( flow, column_number, UP_list, sign, A, UP_scaling_factor, unit_converter, marker, uncertainty_info, infrastructure_rescale, UP_meta_info, ): from treat_pedigree import treat_pedigree UP_name = flow[0] coefficient = float(flow[2].replace(",", ".")) if marker == "Remaining waste" or marker == "Separated waste": # these flow display less info unit = "kg" distribution = "NA" spread1 = "NA" spread2 = "NA" spread3 = "NA" else: # otherwise, the unit, distribution and spreads are in regular places unit = flow[1] distribution = flow[3] spread1 = float(flow[4].replace(",", ".")) spread2 = float(flow[5].replace(",", ".")) spread3 = float(flow[6].replace(",", ".")) try: pedigree = flow[7] except IndexError: pedigree = "" # if the UP is not in the list yet, add it try: UP_list.index(UP_name) except ValueError: UP_list.append(UP_name) # raising a warning if a process calls itself line_number = UP_list.index(UP_name) """ if line_number == column_number: print 'alert! UP is calling itself:', print UP_list[line_number], print "("+str(line_number)+")" """ # adjusting the coefficient for unit consistency. # Two conversions have to be made: one for the process calling, and one for the process being called coefficient = float(coefficient) * unit_converter[unit][1] / UP_scaling_factor * sign if distribution == "Normal": spread1 = float(spread1) * unit_converter[unit][1] / UP_scaling_factor if UP_name.find("/I ") != -1: # if the process does NOT contains the infrastructure chain of character, rescale it coefficient = coefficient * infrastructure_rescale try: # sometimes, a process is called several times. In this case, the coefficient should be added to the existing one A[column_number][line_number] += coefficient # if there is no error, it means this line already exists. if ( spread1 > uncertainty_info["technology"][column_number][line_number]["spread1"] or spread2 > uncertainty_info["technology"][column_number][line_number]["spread2"] or spread3 > uncertainty_info["technology"][column_number][line_number]["spread3"] ): # if the uncertainty of the new one is bigger, the uncertainty info of the new one is # reatined, just to be on the safe side. uncertainty_info["technology"][column_number][line_number]["distribution"] = distribution uncertainty_info["technology"][column_number][line_number]["spread1"] = spread1 uncertainty_info["technology"][column_number][line_number]["spread2"] = spread2 uncertainty_info["technology"][column_number][line_number]["spread3"] = spread3 if pedigree != "": uncertainty_info["technology"][column_number][line_number]["pedigree"] = treat_pedigree(pedigree) except KeyError: # the process has been called for the first time, so the info has to be created from scratch A[column_number][line_number] = coefficient uncertainty_info["technology"][column_number][line_number] = {} uncertainty_info["technology"][column_number][line_number]["distribution"] = distribution uncertainty_info["technology"][column_number][line_number]["spread1"] = spread1 uncertainty_info["technology"][column_number][line_number]["spread2"] = spread2 uncertainty_info["technology"][column_number][line_number]["spread3"] = spread3 if pedigree != "": uncertainty_info["technology"][column_number][line_number]["pedigree"] = treat_pedigree(pedigree) return UP_list, A, uncertainty_info
def treat_elementary_flow_info(flow, column_number, EF_list, B, UP_scaling_factor, unit_converter, compartment, uncertainty_info, EF_unit, UP_list): from treat_pedigree import treat_pedigree #for more comment, see treat_economic_flow_info, the structure is the same. EF_name = flow[0] sub_compartment = flow[1] if sub_compartment == '': sub_compartment = '(unspecified)' unit = flow[2] coefficient = float(flow[3].replace(',','.')) distribution = flow[4] spread1 = float(flow[5].replace(',','.')) spread2 = float(flow[6].replace(',','.')) spread3 = float(flow[7].replace(',','.')) try: pedigree = flow[8] except IndexError: pedigree = '' try: EF_list.index([compartment, EF_name, sub_compartment]) except ValueError: EF_list.append([compartment, EF_name, sub_compartment]) EF_unit[EF_name] = unit_converter[unit][0] line_number = EF_list.index([compartment, EF_name, sub_compartment]) coefficient = float(coefficient) * unit_converter[unit][1] / UP_scaling_factor try: B[column_number][line_number] += coefficient #if there is no error, it means this line already exists. if (spread1 > uncertainty_info['intervention'][column_number][line_number]['spread1'] or spread2 > uncertainty_info['intervention'][column_number][line_number]['spread2'] or spread3 > uncertainty_info['intervention'][column_number][line_number]['spread3']): #if the uncertainty of the new one is bigger, the uncertainty info of the new one is #reatined, just to be on the safe side. uncertainty_info['intervention'][column_number][line_number]['distribution'] = distribution uncertainty_info['intervention'][column_number][line_number]['spread1'] = spread1 uncertainty_info['intervention'][column_number][line_number]['spread2'] = spread2 uncertainty_info['intervention'][column_number][line_number]['spread3'] = spread3 if pedigree != '': uncertainty_info['intervention'][column_number][line_number]['pedigree'] = treat_pedigree(pedigree) except KeyError: B[column_number][line_number] = coefficient uncertainty_info['intervention'][column_number][line_number] = {} uncertainty_info['intervention'][column_number][line_number]['distribution'] = distribution uncertainty_info['intervention'][column_number][line_number]['spread1'] = spread1 uncertainty_info['intervention'][column_number][line_number]['spread2'] = spread2 uncertainty_info['intervention'][column_number][line_number]['spread3'] = spread3 if pedigree != '': uncertainty_info['intervention'][column_number][line_number]['pedigree'] = treat_pedigree(pedigree) return EF_list, B, uncertainty_info, EF_unit
def treat_economic_flow_info_desag(flow, UP, column_number, UP_list, sign, A, UP_scaling_factor, unit_converter, marker, uncertainty_info, infrastructure_rescale, UP_meta_info, UP_list_desag_1): from treat_pedigree import treat_pedigree UP_name = flow[0] coefficient = float(flow[2].replace(',', '.')) if marker == 'Remaining waste' or marker == 'Separated waste': #these flow display less info unit = 'kg' distribution = 'NA' spread1 = 'NA' spread2 = 'NA' spread3 = 'NA' else: #otherwise, the unit, distribution and spreads are in regular places unit = flow[1] distribution = flow[3] spread1 = float(flow[4].replace(',', '.')) spread2 = float(flow[5].replace(',', '.')) spread3 = float(flow[6].replace(',', '.')) try: pedigree = flow[7] except IndexError: pedigree = '' """ #raising a warning if a process calls itself for process in UP_list_desag_1: if UP_list[UP_list_desag_1[process]['UP_number']]==UP_name: line_number=UP_list_desag_1[process]['instance_ID'] """ line_number = UP_list.index(UP_name) if line_number == column_number: print 'alert! UP is calling itself:' print line_number print UP_list[line_number] print '' #adjusting the coefficient for unit consistency. #Two conversions have to be made: one for the process calling, and one for the process being called coefficient = float( coefficient) * unit_converter[unit][1] / UP_scaling_factor * sign if UP_name.find( '/I ' ) != -1: #if the process does NOT NOT contains the infrastructure chain of character, rescale it coefficient = coefficient * infrastructure_rescale A[column_number][line_number] = coefficient uncertainty_info['technology'][column_number][line_number] = {} uncertainty_info['technology'][column_number][line_number][ 'distribution'] = distribution uncertainty_info['technology'][column_number][line_number][ 'spread1'] = spread1 uncertainty_info['technology'][column_number][line_number][ 'spread2'] = spread2 uncertainty_info['technology'][column_number][line_number][ 'spread3'] = spread3 if pedigree != '': uncertainty_info['technology'][column_number][line_number][ 'pedigree'] = treat_pedigree(pedigree) return UP_list, A, uncertainty_info