本文整理汇总了Python中gnome.spill_container.SpillContainer.substancefatedata方法的典型用法代码示例。如果您正苦于以下问题:Python SpillContainer.substancefatedata方法的具体用法?Python SpillContainer.substancefatedata怎么用?Python SpillContainer.substancefatedata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnome.spill_container.SpillContainer
的用法示例。
在下文中一共展示了SpillContainer.substancefatedata方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_split_element
# 需要导入模块: from gnome.spill_container import SpillContainer [as 别名]
# 或者: from gnome.spill_container.SpillContainer import substancefatedata [as 别名]
def test_split_element():
'''
test split_element() method
'''
sc = SpillContainer()
o_sc = SpillContainer()
reltime = datetime(2015, 1, 1, 12, 0, 0)
num_les = 10
sc.spills += point_line_release_spill(num_les, (1, 1, 1),
reltime,
amount=100,
units='kg',
substance=test_oil)
o_sc.spills += copy.deepcopy(sc.spills[0])
sc.prepare_for_model_run({'fate_status'})
sc.release_elements(900, reltime)
o_sc.prepare_for_model_run({'fate_status'})
o_sc.release_elements(900, reltime)
# now do a split at element - fate data is not being initialized; however
# we want to make sure fate_data arrays are sync'd with sc data arrays so
# test for fate=non_weather
num = 2
l_frac = (.65, .35)
subs = sc.get_substances(complete=False)[0]
data = sc.substancefatedata(subs,
{'fate_status'},
fate='non_weather')
assert 'id' in data
ix = data['id'][0]
sc.split_element(ix, num, l_frac)
for name in sc._data_arrays:
split = sc[name]
d_split = data[name]
idx = np.where(sc['id'] == ix)[0][0]
orig = o_sc[name]
assert len(split) == num_les + num - 1
assert len(d_split) == num_les + num - 1
at = sc.array_types[name]
if isinstance(at, array_types.ArrayTypeDivideOnSplit):
assert np.allclose(split[idx:idx + num].sum(0), orig[idx])
assert np.allclose(split[idx], l_frac[0] * orig[idx])
else:
assert np.all(split[idx:idx + num] == orig[idx])
# fatedata copy of sc data is also updated
assert np.allclose(d_split, split)