当前位置: 首页>>代码示例>>Python>>正文


Python WindMover.model_step_is_done方法代码示例

本文整理汇总了Python中gnome.movers.WindMover.model_step_is_done方法的典型用法代码示例。如果您正苦于以下问题:Python WindMover.model_step_is_done方法的具体用法?Python WindMover.model_step_is_done怎么用?Python WindMover.model_step_is_done使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gnome.movers.WindMover的用法示例。


在下文中一共展示了WindMover.model_step_is_done方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_active

# 需要导入模块: from gnome.movers import WindMover [as 别名]
# 或者: from gnome.movers.WindMover import model_step_is_done [as 别名]
def test_active():
    """ test that mover must be both active and on to get movement """

    time_step = 15 * 60  # seconds

    start_pos = (3., 6., 0.)
    rel_time = datetime(2012, 8, 20, 13)  # yyyy/month/day/hr/min/sec

    sc = sample_sc_release(5, start_pos, rel_time)

    # value is given as (r,theta)

    time_val = np.zeros((1, ), dtype=datetime_value_2d)
    time_val['time'] = np.datetime64(rel_time.isoformat())
    time_val['value'] = (2., 25.)

    wm = WindMover(environment.Wind(timeseries=time_val,
                   units='meter per second'), on=False)

    wm.prepare_for_model_run()
    wm.prepare_for_model_step(sc, time_step, rel_time)
    delta = wm.get_move(sc, time_step, rel_time)
    wm.model_step_is_done()
    assert wm.active == False
    assert np.all(delta == 0)  # model_time + time_step = active_start
开发者ID:JamesMakela,项目名称:GNOME2,代码行数:27,代码来源:test_wind_mover.py

示例2: test_windage_index

# 需要导入模块: from gnome.movers import WindMover [as 别名]
# 或者: from gnome.movers.WindMover import model_step_is_done [as 别名]
def test_windage_index():
    """
    A very simple test to make sure windage is set for the correct sc
    if staggered release
    """

    sc = SpillContainer()
    rel_time = datetime(2013, 1, 1, 0, 0)
    timestep = 30
    for i in range(2):
        spill = point_line_release_spill(num_elements=5,
                                start_position=(0., 0., 0.),
                                release_time=rel_time + i * timedelta(hours=1),
                                element_type=floating(windage_range=(i * .01 +
                                                        .01, i * .01 + .01),
                                                      windage_persist=900)
                                )
        sc.spills.add(spill)

    windage = {'windages': array_types.windages,
               'windage_range': array_types.windage_range,
               'windage_persist': array_types.windage_persist}
    sc.prepare_for_model_run(array_types=windage)
    sc.release_elements(timestep, rel_time)
    wm = WindMover(environment.ConstantWind(5, 0))
    wm.prepare_for_model_step(sc, timestep, rel_time)
    wm.model_step_is_done()  # need this to toggle _windage_is_set_flag

    def _check_index(sc):
        '''
        internal function for doing the test after windage is set
        - called twice so made a function
        '''

        # only 1st sc is released

        for sp in sc.spills:
            mask = sc.get_spill_mask(sp)
            if np.any(mask):
                assert np.all(sc['windages'][mask] ==
                              (sp.element_type.initializers["windages"].
                              windage_range[0]))

    # only 1st spill is released
    _check_index(sc)  # 1st ASSERT

    sc.release_elements(timestep, rel_time + timedelta(hours=1))
    wm.prepare_for_model_step(sc, timestep, rel_time)
    _check_index(sc)  # 2nd ASSERT
开发者ID:kthyng,项目名称:GNOME2,代码行数:51,代码来源:test_wind_mover.py

示例3: test_timespan

# 需要导入模块: from gnome.movers import WindMover [as 别名]
# 或者: from gnome.movers.WindMover import model_step_is_done [as 别名]
def test_timespan():
    """
    Ensure the active flag is being set correctly and checked,
    such that if active=False, the delta produced by get_move = 0
    """
    time_step = 15 * 60  # seconds

    start_pos = (3., 6., 0.)
    rel_time = datetime(2012, 8, 20, 13)  # yyyy/month/day/hr/min/sec

    sc = sample_sc_release(5, start_pos, rel_time)

    # value is given as (r,theta)
    model_time = rel_time
    time_val = np.zeros((1, ), dtype=datetime_value_2d)
    time_val['time'] = rel_time
    time_val['value'] = (2., 25.)

    wm = WindMover(Wind(timeseries=time_val,
                        units='meter per second'),
                   active_range=(model_time + timedelta(seconds=time_step),
                                 InfDateTime('inf')))

    wm.prepare_for_model_run()
    wm.prepare_for_model_step(sc, time_step, model_time)

    delta = wm.get_move(sc, time_step, model_time)
    wm.model_step_is_done()

    assert wm.active is False
    assert np.all(delta == 0)  # model_time + time_step = active_start

    wm.active_range = (model_time - timedelta(seconds=time_step / 2),
                       InfDateTime('inf'))
    wm.prepare_for_model_step(sc, time_step, model_time)

    delta = wm.get_move(sc, time_step, model_time)
    wm.model_step_is_done()

    assert wm.active is True
    print '''\ntest_timespan delta \n{0}'''.format(delta)
    assert np.all(delta[:, :2] != 0)  # model_time + time_step > active_start
开发者ID:NOAA-ORR-ERD,项目名称:PyGnome,代码行数:44,代码来源:test_wind_mover.py


注:本文中的gnome.movers.WindMover.model_step_is_done方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。