导入数据库时 如何处理同一活动的多个输入?

问题描述 投票:1回答:1

例如,在同一工业生产过程中,同一“自来水市场”的多个输入被用于不同目的。导入数据库后,是否在一个“自来水市场,RoW”活动下自动汇总这些输入的金额?]

谢谢!

[已编辑]我添加了一个代码示例,以更好地说明问题:

##the goal is to use a dict to categorize the inputs of the activity "market for tap water, RoW" by industrial classifications. 
##For example, there could be 200+ upstream activities under the classification "3510b: Electric power generation, photovoltaic" 
##using this particular tap water activity. Then the results will be "d['3510b...']=[1E-5, 2E-7,...].

#get tap water of interest
tap_water=db.search('tap water',filter={"location":"row"})[0]
#create a dict to store classifications 
facet_store=defaultdict(list)

#find the upstream activities
for exc in tap_water.upstream():
    temp_classification=exc.output["classifications"]
    flat_classification_list=[el for tuuple in temp_classification for el in tuuple]
    temp_locator=flat_classification_list.index("ISIC rev.4 ecoinvent") #keyword for location
    key_classification=flat_classification_list[temp_locator+1] #actual classification is always immediately after this keyword
    facet_store[key_classification].append(exc["amount"]) #append the input amount of tap water to each upstream activity to the list

问题是,如果上游活动不止一次使用“自来水市场RoW”。这是否意味着该上游活动将在for循环中多次显示为“ exc”?

brightway
1个回答
0
投票

不,这样的总结需要工作,而懒惰是程序员的美德。为了处理多个不确定性分布,或者只是为了使数据集更清晰,必须将此类交换分开进行(例如,对于任何有损失的活动,如果同一生产流有一个生产交换和一个消耗交换,我们拥有相同的事物)。

© www.soinside.com 2019 - 2024. All rights reserved.