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


Python Model.uncertain方法代码示例

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


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

示例1: make_model

# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import uncertain [as 别名]
def make_model():

    start_time = datetime(2015, 5, 14, 0)
    model = Model(time_step=3600*24,  # one day
                  start_time=start_time,
                  duration=timedelta(days=3),)
    model.cache_enabled = False
    model.uncertain = False

    # N = 10  # a line of ten points
    # line_pos = np.zeros((N, 3), dtype=np.float64)
    # line_pos[:, 0] = np.linspace(rel_start_pos[0], rel_end_pos[0], N)
    # line_pos[:, 1] = np.linspace(rel_start_pos[1], rel_end_pos[1], N)

    # start_pos = (-164.01696, 72.921024, 0)
    # model.spills += point_line_release_spill(1,
    #                                          start_position=start_pos,
    #                                          release_time=model.start_time,
    #                                          end_position=start_pos)

    # release = SpatialRelease(start_position=line_pos,
    #                          release_time=model.start_time)
    # model.spills += Spill(release)

    c_ice_mover = IceMover(curr_file, topology_file)
    model.movers += c_ice_mover

    model.outputters += IceImageOutput(c_ice_mover,
                                       viewport=((-175.0, 65.0),
                                                 (-145.0, 75.05))
                                       )

    return model
开发者ID:NOAA-ORR-ERD,项目名称:PyGnome,代码行数:35,代码来源:test_ice_image_outputter.py

示例2: test_ice_image_mid_run

# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import uncertain [as 别名]
def test_ice_image_mid_run():
    """
        Test image outputter with a model
        NOTE: could it be tested with just a mover, and not a full model?
          -- that gets tricky with the cache and timesteps...
    """
    start_time = datetime(2015, 5, 14, 0)
    model = Model(time_step=3600 * 24, start_time=start_time, duration=timedelta(days=3))  # one day
    model.cache_enabled = False
    model.uncertain = False

    c_ice_mover = IceMover(curr_file, topology_file)
    model.movers += c_ice_mover

    # run the model a couple steps
    step = model.step()
    step = model.step()

    # now add the outputter
    model.outputters += IceImageOutput(c_ice_mover, viewport=((-175.0, 65.0), (-145.0, 75.05)))

    # and run some more:
    step = model.step()
    step = model.step()

    # and check the output
    ice_output = step["IceImageOutput"]

    for key in ("time_stamp", "thickness_image", "concentration_image", "bounding_box", "projection"):
        assert key in ice_output

        print "thickness img size:", len(ice_output["thickness_image"])
        print "concentration img size:", len(ice_output["concentration_image"])
开发者ID:NOAA-ORR-ERD,项目名称:PyGnome,代码行数:35,代码来源:test_ice_image_outputter.py

示例3: test_simple_run_with_image_output_uncertainty

# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import uncertain [as 别名]
def test_simple_run_with_image_output_uncertainty(tmpdir):
    '''
    Pretty much all this tests is that the model will run and output images
    '''
    images_dir = tmpdir.mkdir('Test_images2').strpath

    if os.path.isdir(images_dir):
        shutil.rmtree(images_dir)
    os.mkdir(images_dir)

    start_time = datetime(2012, 9, 15, 12, 0)

    # the land-water map
    gmap = gnome.map.MapFromBNA(testdata['MapFromBNA']['testmap'],
                                refloat_halflife=6)  # hours
    renderer = gnome.outputters.Renderer(testdata['MapFromBNA']['testmap'],
                                         images_dir, size=(400, 300))

    model = Model(start_time=start_time,
                  time_step=timedelta(minutes=15), duration=timedelta(hours=1),
                  map=gmap,
                  uncertain=True, cache_enabled=False,
                  )

    model.outputters += renderer
    a_mover = SimpleMover(velocity=(1., -1., 0.))
    model.movers += a_mover

    N = 10  # a line of ten points
    start_points = np.zeros((N, 3), dtype=np.float64)
    start_points[:, 0] = np.linspace(-127.1, -126.5, N)
    start_points[:, 1] = np.linspace(47.93, 48.1, N)
    # print start_points

    release = SpatialRelease(start_position=start_points,
                             release_time=start_time)

    model.spills += Spill(release)

    # model.add_spill(spill)

    model.start_time = release.release_time

    # image_info = model.next_image()

    model.uncertain = True
    num_steps_output = 0
    while True:
        try:
            image_info = model.step()
            num_steps_output += 1
            print image_info
        except StopIteration:
            print 'Done with the model run'
            break

    # there is the zeroth step, too.
    calculated_steps = (model.duration.total_seconds() / model.time_step) + 1
    assert num_steps_output == calculated_steps
开发者ID:sandhujasmine,项目名称:PyGnome,代码行数:61,代码来源:test_model.py

示例4: sample_model_fixture_base

# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import uncertain [as 别名]
def sample_model_fixture_base():
    """
    sample model with no outputter and no spills. Use this as a template for
    fixtures to add spills
    Uses:
        sample_data/MapBounds_Island.bna
        Contains: gnome.movers.SimpleMover(velocity=(1.0, -1.0, 0.0))
        duration is 1 hour with 15min intervals so 5 timesteps total,
        including initial condition,
        model is uncertain and cache is not enabled
        No spills or outputters defined

    To use:
        add a spill and run

    :returns: It returns a dict -
        {'model':model,
         'release_start_pos':start_points,
         'release_end_pos':end_points}
        The release_start_pos and release_end_pos can be used by test to define
        the spill's 'start_position' and 'end_position'
    """

    release_time = datetime(2012, 9, 15, 12, 0)

    # the image output map

    mapfile = os.path.join(os.path.dirname(__file__),
                           'sample_data',
                           'MapBounds_Island.bna')

    # the land-water map

    map_ = MapFromBNA(mapfile, refloat_halflife=06)  # seconds

    model = Model(time_step=timedelta(minutes=15),
                  start_time=release_time,
                  duration=timedelta(hours=1),
                  map=map_,
                  uncertain=True,
                  cache_enabled=False,
                  )

    model.movers += SimpleMover(velocity=(1., -1., 0.0))

    model.uncertain = True

    start_points = np.zeros((3, ), dtype=np.float64)
    end_points = np.zeros((3, ), dtype=np.float64)

    start_points[:] = (-127.1, 47.93, 0)
    end_points[:] = (-126.5, 48.1, 0)

    return {'model': model,
            'release_start_pos': start_points,
            'release_end_pos': end_points,
            }
开发者ID:NOAA-ORR-ERD,项目名称:PyGnome,代码行数:59,代码来源:conftest.py

示例5: test_ice_image_mid_run

# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import uncertain [as 别名]
def test_ice_image_mid_run():
    '''
    Test image outputter with a model 
    NOTE: could it be tested with just a mover, and not a full model?
      -- that gets tricky with the cache and timesteps...
    '''
    start_time = datetime(2015, 5, 14, 0)
    model = Model(time_step=3600*24, # one day
                  start_time=start_time,
                  duration=timedelta(days=3),)
    model.cache_enabled = False
    model.uncertain = False
    c_ice_mover = IceMover(curr_file, topology_file)
    model.movers += c_ice_mover

    ## run the model a couple steps
    step = model.step()
    step = model.step()

    ## now add the outputter
    iio = IceImageOutput(c_ice_mover)
    model.outputters += iio

    ## and run some more:

    step = model.step()
    step = model.step()
    ## and check the output
    ice_output = step['IceImageOutput']
    # print ice_output['time_stamp']
    # print ice_output['concentration_image'][:50] # could be really big!
    # print ice_output['bounding_box']
    # print ice_output['projection']
    for key in ('time_stamp',
                'thickness_image',
                'concentration_image',
                'bounding_box',
                'projection'):
        assert key in ice_output
开发者ID:liuy0813,项目名称:PyGnome,代码行数:41,代码来源:test_ice_image_outputter.py

示例6: test_simple_run_with_image_output_uncertainty

# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import uncertain [as 别名]
def test_simple_run_with_image_output_uncertainty():
    """
    pretty much all this tests is that the model will run and output images
    """

    # create a place for test images (cleaning out any old ones)

    images_dir = os.path.join(basedir, 'Test_images2')
    if os.path.isdir(images_dir):
        shutil.rmtree(images_dir)
    os.mkdir(images_dir)

    start_time = datetime(2012, 9, 15, 12, 0)

    # the land-water map

    gmap = gnome.map.MapFromBNA(testmap, refloat_halflife=6)  # hours
    renderer = gnome.renderer.Renderer(testmap, images_dir, size=(400,
            300))

    model = Model(
        time_step=timedelta(minutes=15),
        start_time=start_time,
        duration=timedelta(hours=1),
        map=gmap,
        uncertain=True,
        cache_enabled=False,
        )

    model.outputters += renderer
    a_mover = SimpleMover(velocity=(1., -1., 0.))
    model.movers += a_mover

    N = 10  # a line of ten points
    start_points = np.zeros((N, 3), dtype=np.float64)
    start_points[:, 0] = np.linspace(-127.1, -126.5, N)
    start_points[:, 1] = np.linspace(47.93, 48.1, N)

    # print start_points

    spill = SpatialRelease(start_positions=start_points,
                           release_time=start_time)

    model.spills += spill

    # model.add_spill(spill)

    model.start_time = spill.release_time

    # image_info = model.next_image()

    model.uncertain = True

    num_steps_output = 0
    while True:
        try:
            image_info = model.step()
            num_steps_output += 1
            print image_info
        except StopIteration:
            print 'Done with the model run'
            break

    # there is the zeroth step, too.

    assert num_steps_output == model.duration.total_seconds() \
        / model.time_step + 1
开发者ID:JamesMakela,项目名称:GNOME2,代码行数:69,代码来源:test_model.py


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