本文整理汇总了Python中gnome.model.Model.find_by_attr方法的典型用法代码示例。如果您正苦于以下问题:Python Model.find_by_attr方法的具体用法?Python Model.find_by_attr怎么用?Python Model.find_by_attr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnome.model.Model
的用法示例。
在下文中一共展示了Model.find_by_attr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_model
# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import find_by_attr [as 别名]
#.........这里部分代码省略.........
start_position = (144.664166, 13.441944, 0.0)
end_release_time = start_time + timedelta(hours=6)
spill_amount = 1000.0
spill_units = 'kg'
model.spills += point_line_release_spill(num_elements=1000,
start_position=start_position,
release_time=start_time,
end_release_time=end_release_time,
amount=spill_amount,
units=spill_units,
substance=test_oil)
spill = model.spills[-1]
spill_volume = spill.get_mass() / spill.substance.density_at_temp()
# need a scenario for SimpleMover
# model.movers += SimpleMover(velocity=(1.0, -1.0, 0.0))
print 'adding a RandomMover:'
model.movers += RandomMover(diffusion_coef=100000)
print 'adding a wind mover:'
series = np.zeros((2, ), dtype=datetime_value_2d)
series[0] = (start_time, (5, 180))
series[1] = (start_time + timedelta(hours=18), (5, 180))
w_mover = WindMover(Wind(timeseries=series, units='m/s'))
model.movers += w_mover
model.environment += w_mover.wind
print 'adding a cats shio mover:'
c_mover = CatsMover(testdata['boston_data']['cats_curr2'],
tide=Tide(testdata['boston_data']['cats_shio']))
# c_mover.scale_refpoint should automatically get set from tide object
c_mover.scale = True # default value
c_mover.scale_value = -1
# tide object automatically gets added by model
model.movers += c_mover
print 'adding a cats ossm mover:'
c_mover = CatsMover(testdata['boston_data']['cats_curr2'],
tide=Tide(testdata['boston_data']['cats_ossm']))
c_mover.scale = True # but do need to scale (based on river stage)
c_mover.scale_refpoint = (-70.65, 42.58333, 0.0)
c_mover.scale_value = 1.
print 'adding a cats mover:'
c_mover = CatsMover(testdata['boston_data']['cats_curr3'])
c_mover.scale = True # but do need to scale (based on river stage)
c_mover.scale_refpoint = (-70.78333, 42.39333, 0.0)
# the scale factor is 0 if user inputs no sewage outfall effects
c_mover.scale_value = .04
model.movers += c_mover
# TODO: seg faulting for component mover - comment test for now
# print "adding a component mover:"
# comp_mover = ComponentMover(testdata['boston_data']['component_curr1'],
# testdata['boston_data']['component_curr2'],
# w_mover.wind)
# TODO: callback did not work correctly below - fix!
# comp_mover = ComponentMover(component_file1,
# component_file2,
# Wind(timeseries=series, units='m/s'))
# comp_mover.ref_point = (-70.855, 42.275)
# comp_mover.pat1_angle = 315
# comp_mover.pat1_speed = 19.44
# comp_mover.pat1_speed_units = 1
# comp_mover.pat1ScaleToValue = .138855
# comp_mover.pat2_angle = 225
# comp_mover.pat2_speed = 19.44
# comp_mover.pat2_speed_units = 1
# comp_mover.pat2ScaleToValue = .05121
# model.movers += comp_mover
print 'adding a Weatherer'
model.environment += Water(311.15)
skim_start = start_time + timedelta(hours=3)
model.weatherers += [Evaporation(),
Skimmer(spill_amount * .5,
spill_units,
efficiency=.3,
active_start=skim_start,
active_stop=skim_start + timedelta(hours=2)),
Burn(0.2 * spill_volume, 1.0, skim_start,
efficiency=0.9)]
model.outputters += \
CurrentJsonOutput(model.find_by_attr('_ref_as', 'current_movers',
model.movers, allitems=True))
return model