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


Python Model.map方法代码示例

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


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

示例1: test_simple_run_with_map

# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import map [as 别名]
def test_simple_run_with_map():
    '''
    pretty much all this tests is that the model will run
    '''

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

    model = Model()

    model.map = gnome.map.MapFromBNA(testmap, refloat_halflife=6)  # hours
    a_mover = SimpleMover(velocity=(1., 2., 0.))

    model.movers += a_mover
    assert len(model.movers) == 1

    spill = point_line_release_spill(num_elements=10,
                                     start_position=(0., 0., 0.),
                                     release_time=start_time)

    model.spills += spill
    assert len(model.spills) == 1
    model.start_time = spill.release.release_time

    # test iterator
    for step in model:
        print 'just ran time step: %s' % step
        assert step['step_num'] == model.current_time_step

    # reset and run again
    model.reset()

    # test iterator is repeatable
    for step in model:
        print 'just ran time step: %s' % step
        assert step['step_num'] == model.current_time_step
开发者ID:JamesMakela-NOAA,项目名称:PyGnome,代码行数:37,代码来源:test_model.py

示例2: make_model

# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import map [as 别名]
def make_model(images_dir=os.path.join(base_dir, 'images')):
    print 'initializing the model'

    start_time = datetime(2015, 9, 24, 3, 0)

    # 1 day of data in file
    # 1/2 hr in seconds
    model = Model(start_time=start_time,
                  duration=timedelta(hours = 48),
                  time_step=3600)

    mapfile = get_datafile(os.path.join(base_dir, 'Perfland.bna'))

    print 'adding the map'
    model.map = MapFromBNA(mapfile, refloat_halflife=1, raster_size=1024*1024)  # seconds

    # draw_ontop can be 'uncertain' or 'forecast'
    # 'forecast' LEs are in black, and 'uncertain' are in red
    # default is 'forecast' LEs draw on top
    renderer = Renderer(mapfile, images_dir, image_size=(800, 600),
                        output_timestep=timedelta(hours=1),
                        timestamp_attrib={'size': 'medium', 'color':'uncert_LE'})
    renderer.set_timestamp_attrib(format='%a %c')
    renderer.graticule.set_DMS(True)
#     renderer.viewport = ((-124.25, 47.5), (-122.0, 48.70))


    print 'adding outputters'
    model.outputters += renderer

    print 'adding a spill'
    # for now subsurface spill stays on initial layer
    # - will need diffusion and rise velocity
    # - wind doesn't act
    # - start_position = (-76.126872, 37.680952, 5.0),
    spill1 = point_line_release_spill(num_elements=5000,
                                     start_position=(0.0,
                                                     0.0,
                                                     0.0),
                                     release_time=start_time)

    model.spills += spill1

    print 'adding a RandomMover:'
    model.movers += RandomMover(diffusion_coef=50000)

    print 'adding a wind mover:'

    model.movers += constant_wind_mover(13, 270, units='m/s')

    print 'adding a current mover:'
#     curr_file = get_datafile(os.path.join(base_dir, 'COOPSu_CREOFS24.nc'))
#
#     # uncertain_time_delay in hours
#     c_mover = GridCurrentMover(curr_file)
#     c_mover.uncertain_cross = 0  # default is .25
#
#     model.movers += c_mover

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

示例3: make_model

# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import map [as 别名]
def make_model(images_dir=os.path.join(base_dir, 'images')):
    print 'initializing the model'

    start_time = datetime(2013, 1, 1, 1)  # data starts at 1:00 instead of 0:00
    model = Model(start_time=start_time, duration=timedelta(days=1),
                  time_step=900, uncertain=False)

    try:
        mapfile = get_datafile(os.path.join(base_dir, './pearl_harbor.bna'))
    except HTTPError:
        print ('Could not download Pearl Harbor data from server - '
               'returning empty model')
        return model

    print 'adding the map'
    model.map = MapFromBNA(mapfile, refloat_halflife=1)  # hours

    #
    # Add the outputters -- render to images, and save out as netCDF
    #

    print 'adding renderer and netcdf output'
    model.outputters += Renderer(mapfile, images_dir, size=(800, 600))

    netcdf_output_file = os.path.join(base_dir, 'pearl_harbor_output.nc')
    scripting.remove_netcdf(netcdf_output_file)
    model.outputters += NetCDFOutput(netcdf_output_file, which_data='all')

    # #
    # # Set up the movers:
    # #
    print 'adding a random mover:'
    model.movers += RandomMover(diffusion_coef=10000)

    print 'adding a wind mover:'
    series = np.zeros((3, ), dtype=datetime_value_2d)
    series[0] = (start_time, (4, 180))
    series[1] = (start_time + timedelta(hours=12), (2, 270))
    series[2] = (start_time + timedelta(hours=24), (4, 180))

    w_mover = WindMover(Wind(timeseries=series, units='knots'))
    model.movers += w_mover
    model.environment += w_mover.wind

    print 'adding a current mover:'
    # this is CH3D currents
    curr_file = os.path.join(base_dir, r"./ch3d2013.nc")
    topology_file = os.path.join(base_dir, r"./PearlHarborTop.dat")
    model.movers += GridCurrentMover(curr_file, topology_file)

    # #
    # # Add a spill (sources of elements)
    # #
    print 'adding spill'
    model.spills += point_line_release_spill(num_elements=1000,
                                             start_position=(-157.97064,
                                                             21.331524, 0.0),
                                             release_time=start_time)
    return model
开发者ID:JamesMakela-NOAA,项目名称:PyGnome,代码行数:61,代码来源:script_pearl_harbor.py

示例4: make_model

# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import map [as 别名]
def make_model(images_dir=os.path.join(base_dir, "images")):
    print "initializing the model"

    # set up the modeling environment
    start_time = datetime(2004, 12, 31, 13, 0)
    model = Model(start_time=start_time, duration=timedelta(days=3), time_step=30 * 60, uncertain=False)

    print "adding the map"
    model.map = GnomeMap()  # this is a "water world -- no land anywhere"

    # renderere is only top-down view on 2d -- but it's something
    renderer = Renderer(output_dir=images_dir, size=(1024, 768), output_timestep=timedelta(hours=1))
    renderer.viewport = ((-0.15, -0.35), (0.15, 0.35))

    print "adding outputters"
    model.outputters += renderer

    # Also going to write the results out to a netcdf file
    netcdf_file = os.path.join(base_dir, "script_plume.nc")
    scripting.remove_netcdf(netcdf_file)

    model.outputters += NetCDFOutput(
        netcdf_file,
        which_data="most",
        # output most of the data associated with the elements
        output_timestep=timedelta(hours=2),
    )

    print "adding Horizontal and Vertical diffusion"

    # Horizontal Diffusion
    # model.movers += RandomMover(diffusion_coef=5)
    # vertical diffusion (different above and below the mixed layer)
    model.movers += RandomVerticalMover(
        vertical_diffusion_coef_above_ml=5, vertical_diffusion_coef_below_ml=0.11, mixed_layer_depth=10
    )

    print "adding Rise Velocity"
    # droplets rise as a function of their density and radius
    model.movers += RiseVelocityMover()

    print "adding a circular current and eastward current"
    # This is .3 m/s south
    model.movers += PyGridCurrentMover(current=vg, default_num_method="Trapezoid", extrapolate=True)
    model.movers += SimpleMover(velocity=(0.0, -0.1, 0.0))

    # Now to add in the TAMOC "spill"
    print "Adding TAMOC spill"

    model.spills += tamoc_spill.TamocSpill(
        release_time=start_time,
        start_position=(0, 0, 1000),
        num_elements=1000,
        end_release_time=start_time + timedelta(days=1),
        name="TAMOC plume",
        TAMOC_interval=None,  # how often to re-run TAMOC
    )

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

示例5: make_model

# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import map [as 别名]
def make_model(images_dir=os.path.join(base_dir, 'images')):
    print 'initializing the model'

    start_time = datetime(2015, 9, 24, 1, 1)

    # 1 day of data in file
    # 1/2 hr in seconds
    model = Model(start_time=start_time,
                  duration=timedelta(hours = 48),
                  time_step=900)

    mapfile = get_datafile(os.path.join(base_dir, 'columbia_river.bna'))

    print 'adding the map'
    model.map = MapFromBNA(mapfile, refloat_halflife=0.0)  # seconds

    # draw_ontop can be 'uncertain' or 'forecast'
    # 'forecast' LEs are in black, and 'uncertain' are in red
    # default is 'forecast' LEs draw on top
    renderer = Renderer(mapfile, images_dir, image_size=(600, 1200))
    renderer.graticule.set_DMS(True)
#     renderer.viewport = ((-123.35, 45.6), (-122.68, 46.13))
#     renderer.viewport = ((-122.9, 45.6), (-122.6, 46.0))
    

    print 'adding outputters'
    model.outputters += renderer

    print 'adding a spill'
    # for now subsurface spill stays on initial layer
    # - will need diffusion and rise velocity
    # - wind doesn't act
    # - start_position = (-76.126872, 37.680952, 5.0),
    spill1 = point_line_release_spill(num_elements=5000,
                                     start_position=(-122.625,
                                                     45.609,
                                                     0.0),
                                     release_time=start_time)

    model.spills += spill1

    print 'adding a RandomMover:'
    model.movers += RandomMover(diffusion_coef=5000)

    print 'adding a wind mover:'
   
#     model.movers += constant_wind_mover(8, 90, units='m/s')

    print 'adding a current mover:'
    curr_file = get_datafile(os.path.join(base_dir, 'COOPSu_CREOFS24.nc'))
   
    # uncertain_time_delay in hours
    c_mover = GridCurrentMover(curr_file)
    c_mover.uncertain_cross = 0  # default is .25
   
    model.movers += c_mover

    return model
开发者ID:liuy0813,项目名称:PyGnome,代码行数:60,代码来源:script_columbia_river.py

示例6: make_models

# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import map [as 别名]
def make_models():
    print 'initializing the model'

    # start_time = datetime(2015, 12, 18, 06, 01)

    # 1 day of data in file
    # 1/2 hr in seconds
    models = []
    start_time = datetime(2012, 10, 27, 0, 30)
    duration_hrs=23
    time_step=450
    num_steps = duration_hrs * 3600 / time_step
    names = [
             'Euler',
             'Trapezoid',
             'RK4',
             ]

    mapfile = get_datafile(os.path.join(base_dir, 'long_beach.bna'))
    print 'gen map'
    map = MapFromBNA(mapfile, refloat_halflife=0.0)  # seconds
    fn = ('00_dir_roms_display.ncml.nc4')
    curr = GridCurrent.from_netCDF(filename=fn)
    models = []
    for method in names:

        mod = Model(start_time=start_time,
                    duration=timedelta(hours=duration_hrs),
                    time_step=time_step)

        mod.map = map
        spill = point_line_release_spill(num_elements=1000,
                                         start_position=(-74.1,
                                                      39.7525,
                                                      0.0),
                                         release_time=start_time)
        mod.spills += spill
        mod.movers += RandomMover(diffusion_coef=100)
        mod.movers += PyGridCurrentMover(current=curr, default_num_method=method)

        images_dir = method + '-' + str(time_step / 60) + 'min-' + str(num_steps) + 'steps'
        renderer = Renderer(mapfile, images_dir, image_size=(1024, 768))
        renderer.delay = 25
#         renderer.add_grid(curr.grid)
        mod.outputters += renderer


        netCDF_fn = os.path.join(base_dir, images_dir + '.nc')
        mod.outputters += NetCDFOutput(netCDF_fn, which_data='all')
        models.append(mod)

    print 'returning models'
    return models
开发者ID:,项目名称:,代码行数:55,代码来源:

示例7: make_model

# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import map [as 别名]
def make_model(images_dir=os.path.join(base_dir, 'images')):
    print 'initializing the model'
    start_time = datetime(2006, 3, 31, 20, 0)
    model = Model(start_time=start_time,
                  duration=timedelta(days=3), time_step=30 * 60,
                  uncertain=True)

    print 'adding the map'
    mapfile = get_datafile(os.path.join(base_dir, './coastSF.bna'))
    model.map = MapFromBNA(mapfile, refloat_halflife=1)  # seconds

    renderer = Renderer(mapfile, images_dir, size=(800, 600),
                        draw_ontop='forecast')
    renderer.viewport = ((-124.5, 37.), (-120.5, 39))

    print 'adding outputters'
    model.outputters += renderer

    netcdf_file = os.path.join(base_dir, 'script_sf_bay.nc')
    scripting.remove_netcdf(netcdf_file)
    model.outputters += NetCDFOutput(netcdf_file, which_data='all')

    print 'adding a spill'
    spill = point_line_release_spill(num_elements=1000,
                                     start_position=(-123.57152, 37.369436,
                                                     0.0),
                                     release_time=start_time,
                                     element_type=floating(windage_range=(0.01,
                                                                          0.04)
                                                           )
                                     )
    model.spills += spill

    # print 'adding a RandomMover:'
    # r_mover = gnome.movers.RandomMover(diffusion_coef=50000)
    # model.movers += r_mover

    print 'adding a grid wind mover:'
    wind_file = get_datafile(os.path.join(base_dir, r"./WindSpeedDirSubset.nc")
                             )
    topology_file = get_datafile(os.path.join(base_dir,
                                              r"./WindSpeedDirSubsetTop.dat"))
    w_mover = GridWindMover(wind_file, topology_file)

    #w_mover.uncertain_time_delay = 6
    #w_mover.uncertain_duration = 6
    w_mover.uncertain_speed_scale = 1
    w_mover.uncertain_angle_scale = 0.2  # default is .4
    w_mover.wind_scale = 2

    model.movers += w_mover

    return model
开发者ID:axiom-data-science,项目名称:PyGnome,代码行数:55,代码来源:script_sf_wind.py

示例8: make_model

# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import map [as 别名]
def make_model(base_dir='.'):
    #,images_dir=os.path.join(base_dir, 'images',gdat_dir='/data/dylan/ArcticTAP/data_gnome/ROMS_h2ouv/')):
    print 'initializing the model'
    print base_dir
    start_time = datetime(1985, 1, 1, 13, 31)
    # start with generic times...this will be changed when model is run
    model = Model(start_time=start_time,
                  duration=timedelta(hours=96),
                  time_step=120*60)
    mapfile = get_datafile(os.path.join(base_dir, 'arctic_coast3.bna'))
    print mapfile
    print 'adding the map'
    model.map = MapFromBNA(mapfile, refloat_halflife=0.0)  # seconds

    return model
开发者ID:dylanrighi,项目名称:pygnomeTAP,代码行数:17,代码来源:RunPyGnome.py

示例9: test_simple_run_rewind

# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import map [as 别名]
def test_simple_run_rewind():
    '''
    Pretty much all this tests is that the model will run
    and the seed is set during first run, then set correctly
    after it is rewound and run again
    '''

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

    model = Model()

    model.map = gnome.map.GnomeMap()
    a_mover = SimpleMover(velocity=(1., 2., 0.))

    model.movers += a_mover
    assert len(model.movers) == 1

    spill = point_line_release_spill(num_elements=10,
                                     start_position=(0., 0., 0.),
                                     release_time=start_time)

    model.spills += spill
    assert len(model.spills) == 1

    # model.add_spill(spill)

    model.start_time = spill.release.release_time

    # test iterator
    for step in model:
        print 'just ran time step: %s' % model.current_time_step
        assert step['step_num'] == model.current_time_step

    pos = np.copy(model.spills.LE('positions'))

    # rewind and run again:
    print 'rewinding'
    model.rewind()

    # test iterator is repeatable
    for step in model:
        print 'just ran time step: %s' % model.current_time_step
        assert step['step_num'] == model.current_time_step

    assert np.all(model.spills.LE('positions') == pos)
开发者ID:sandhujasmine,项目名称:PyGnome,代码行数:47,代码来源:test_model.py

示例10: test_simple_run_with_map

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

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

    model = Model()

    model.map = gnome.map.MapFromBNA(testmap, refloat_halflife=6)  # hours
    a_mover = SimpleMover(velocity=(1., 2., 0.))

    model.movers += a_mover
    assert len(model.movers) == 1

    spill = PointLineSource(num_elements=10,
            start_position=(0., 0., 0.), release_time=start_time)

    model.spills += spill

    # model.add_spill(spill)

    assert len(model.spills) == 1
    model.start_time = spill.release_time

    # test iterator:

    for step in model:
        print 'just ran time step: %s' % step

    # reset and run again:

    model.reset()

    # test iterator:

    for step in model:
        print 'just ran time step: %s' % step

    assert True
开发者ID:JamesMakela,项目名称:GNOME2,代码行数:42,代码来源:test_model.py

示例11: setup_model

# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import map [as 别名]
def setup_model():
    print 'initializing the model'
    # start with default time,duration...this will be changed when model is run
    model = Model() #change to use all defaults and set time_step also in Setup_TAP!!
    mapfile = os.path.join(setup.MapFileDir, setup.MapFileName)
    print 'adding the map: ', mapfile
    model.map = MapFromBNA(mapfile, refloat_halflife=0.0)  # seconds
    
    print 'adding a GridCurrentMover:'
    c_mover = GridCurrentMover(filename=setup.curr_fn,topology_file=setup.curr_topo)
    model.movers += c_mover

    # print 'adding a GridWindMover:'
    # w_mover = GridWindMover(wind_file=setup.w_filelist,topology_file=setup.w_Topology)
    # w_mover = GridWindMover(wind_file=setup.w_filelist)
    # model.movers += w_mover

    if setup.diff_coef is not None:
        print 'adding a RandomMover:'
        random_mover = RandomMover(diffusion_coef=setup.diff_coef) #in cm/s 
        model.movers += random_mover

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

示例12: make_model

# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import map [as 别名]
def make_model(images_dir=os.path.join(base_dir, 'images')):
    print 'initializing the model'

    start_time = datetime(2013, 5, 18, 0)

    model = Model(start_time=start_time, duration=timedelta(days=8),
                  time_step=4 * 3600, uncertain=False)

    mapfile = get_datafile(os.path.join(base_dir, 'mariana_island.bna'))

    print 'adding the map'
    model.map = MapFromBNA(mapfile, refloat_halflife=6)  # hours

    #
    # Add the outputters -- render to images, and save out as netCDF
    #

    print 'adding renderer'
    rend =  Renderer(mapfile,
                                 images_dir,
                                 size=(800, 600),
                                 draw_map_bounds=True
                                 )
    rend.draw_raster_map()
    model.outputters += rend
#                                 draw_back_to_fore=True)

    # print "adding netcdf output"
    # netcdf_output_file = os.path.join(base_dir,'mariana_output.nc')
    # scripting.remove_netcdf(netcdf_output_file)
    # model.outputters += NetCDFOutput(netcdf_output_file, which_data='all')

    #
    # Set up the movers:
    #
    rend.zoom(0.5)
    rend.zoom(2)

    print 'adding a RandomMover:'
    model.movers += RandomMover(diffusion_coef=10000)

    print 'adding a simple wind mover:'
    model.movers += constant_wind_mover(7, 90, units='m/s')

    print 'adding a current mover:'

#     # # this is HYCOM currents
#     curr_file = get_datafile(os.path.join(base_dir, 'HYCOM.nc'))
#     model.movers += GridCurrentMover(curr_file,
#                                      num_method=numerical_methods.euler);

    # #
    # # Add some spills (sources of elements)
    # #

    print 'adding four spill'
    model.spills += point_line_release_spill(num_elements=NUM_ELEMENTS // 4,
                                             start_position=(146, 15.25,
                                                             0.0),
                                             release_time=start_time)
    model.spills += point_line_release_spill(num_elements=NUM_ELEMENTS // 4,
                                             start_position=(146, 15.125,
                                                             0.0),
                                             release_time=start_time)
    model.spills += point_line_release_spill(num_elements=NUM_ELEMENTS // 4,
                                             start_position=(146, 15.0,
                                                             0.0),
                                             release_time=start_time)
    model.spills += point_line_release_spill(num_elements=NUM_ELEMENTS // 4,
                                             start_position=(146, 14.875,
                                                             0.0),
                                             release_time=start_time)

    return model
开发者ID:liuy0813,项目名称:PyGnome,代码行数:76,代码来源:script_server_render.py

示例13: make_model

# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import map [as 别名]
def make_model(images_dir=os.path.join(base_dir, 'images')):
    print 'initializing the model'

    start_time = datetime(1985, 1, 1, 13, 31)

    # 1 day of data in file
    # 1/2 hr in seconds
    model = Model(start_time=start_time,
                  duration=timedelta(days=4),
                  time_step=7200)

#     mapfile = get_datafile(os.path.join(base_dir, 'ak_arctic.bna'))
    mapfile = get_datafile('arctic_coast3.bna')

    print 'adding the map'
    model.map = MapFromBNA(mapfile, refloat_halflife=0.0)  # seconds

    print 'adding a spill'
    # for now subsurface spill stays on initial layer
    # - will need diffusion and rise velocity
    # - wind doesn't act
    # - start_position = (-76.126872, 37.680952, 5.0),
#     spill1 = point_line_release_spill(num_elements=10000,
#                                       start_position=(-163.75,
#                                                       69.75,
#                                                       0.0),
#                                       release_time=start_time)
#
    spill1 = point_line_release_spill(num_elements=50000,
                                      start_position=(196.25,
                                                      69.75,
                                                      0.0),
                                      release_time=start_time)

    model.spills += spill1
#     model.spills += spill2

    print 'adding a wind mover:'

#     model.movers += constant_wind_mover(0.5, 0, units='m/s')

    print 'adding a current mover:'

    fn = ['arctic_avg2_0001_gnome.nc',
          'arctic_avg2_0002_gnome.nc']

#     fn = ['C:\\Users\\jay.hennen\\Documents\\Code\\pygnome\\py_gnome\\scripts\\script_TAP\\arctic_avg2_0001_gnome.nc',
#           'C:\\Users\\jay.hennen\\Documents\\Code\\pygnome\\py_gnome\\scripts\\script_TAP\\arctic_avg2_0002_gnome.nc']

    gt = {'node_lon': 'lon',
          'node_lat': 'lat'}
#     fn='arctic_avg2_0001_gnome.nc'

    wind_method = 'Euler'
    method = 'RK2'
    print 'adding outputters'

    # draw_ontop can be 'uncertain' or 'forecast'
    # 'forecast' LEs are in black, and 'uncertain' are in red
    # default is 'forecast' LEs draw on top
    renderer = Renderer(mapfile, images_dir, image_size=(1024, 768))
    model.outputters += renderer
    netcdf_file = os.path.join(base_dir, str(model.time_step / 60) + method + '.nc')
    scripting.remove_netcdf(netcdf_file)

    print 'adding movers'
    model.outputters += NetCDFOutput(netcdf_file, which_data='all')


    print 'loading entire current data'
    ice_aware_curr = IceAwareCurrent.from_netCDF(filename=fn,
                                                 grid_topology=gt)

#     env1 = get_env_from_netCDF(filename)
#     mov = PyCurrentMover.from_netCDF(filename)

    ice_aware_curr.ice_velocity.variables[0].dimension_ordering = ['time', 'x', 'y']
    ice_aware_wind = IceAwareWind.from_netCDF(filename=fn,
                                              ice_velocity=ice_aware_curr.ice_velocity,
                                              ice_concentration=ice_aware_curr.ice_concentration,
                                              grid=ice_aware_curr.grid)

    curr = GridCurrent.from_netCDF(filename=fn)
#     GridCurrent.is_gridded()

#     import pprint as pp
#     from gnome.utilities.orderedcollection import OrderedCollection
#     model.environment = OrderedCollection(dtype=Environment)
#     model.environment.add(ice_aware_curr)
#     from gnome.environment import WindTS

    print 'loading entire wind data'

#     i_c_mover = PyCurrentMover(current=ice_aware_curr)
#     i_c_mover = PyCurrentMover(current=ice_aware_curr, default_num_method='Euler')
    i_c_mover = PyCurrentMover(current=ice_aware_curr, default_num_method=method, extrapolate=True)
    i_w_mover = PyWindMover(wind=ice_aware_wind, default_num_method=wind_method)

#     ice_aware_curr.grid.node_lon = ice_aware_curr.grid.node_lon[:]-360
#     ice_aware_curr.grid.build_celltree()
#.........这里部分代码省略.........
开发者ID:NOAA-ORR-ERD,项目名称:PyGnome,代码行数:103,代码来源:script_new_TAP.py

示例14: test_all_movers

# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import map [as 别名]
def test_all_movers(start_time, release_delay, duration):
    '''
    Tests that all the movers at least can be run

    Add new ones as they come along!
    '''

    model = Model()
    model.time_step = timedelta(hours=1)
    model.duration = timedelta(seconds=model.time_step * duration)
    model.start_time = start_time
    start_loc = (1., 2., 0.)  # random non-zero starting points

    # a spill - release after 5 timesteps

    release_time = (start_time +
                    timedelta(seconds=model.time_step * release_delay))
    model.spills += point_line_release_spill(num_elements=10,
                                             start_position=start_loc,
                                             release_time=release_time)

    # the land-water map
    model.map = gnome.map.GnomeMap()  # the simplest of maps

    # simple mover
    model.movers += SimpleMover(velocity=(1., -1., 0.))
    assert len(model.movers) == 1

    # random mover
    model.movers += RandomMover(diffusion_coef=100000)
    assert len(model.movers) == 2

    # wind mover
    series = np.array((start_time, (10, 45)),
                      dtype=datetime_value_2d).reshape((1, ))
    model.movers += WindMover(Wind(timeseries=series,
                              units='meter per second'))
    assert len(model.movers) == 3

    # CATS mover
    model.movers += CatsMover(testdata['CatsMover']['curr'])
    assert len(model.movers) == 4

    # run the model all the way...
    num_steps_output = 0
    for step in model:
        num_steps_output += 1
        print 'running step:', step

    # test release happens correctly for all cases
    if release_delay < duration:
        # at least one get_move has been called after release
        assert np.all(model.spills.LE('positions')[:, :2] != start_loc[:2])
    elif release_delay == duration:
        # particles are released after last step so no motion,
        # only initial _state
        assert np.all(model.spills.LE('positions') == start_loc)
    else:
        # release_delay > duration so nothing released though model ran
        assert len(model.spills.LE('positions')) == 0

    # 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,代码行数:66,代码来源:test_model.py

示例15: make_model

# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import map [as 别名]
def make_model(images_dir=os.path.join(base_dir, 'images')):
    print 'initializing the model'

    # set up the modeling environment
    start_time = datetime(2016, 9, 18, 1, 0)
    model = Model(start_time=start_time,
                  duration=timedelta(days=3),
                  time_step=30 * 60,
                  uncertain=False)

    print 'adding the map'
    model.map = GnomeMap()  # this is a "water world -- no land anywhere"

    # renderere is only top-down view on 2d -- but it's something
    renderer = Renderer(output_dir=images_dir,
                        size=(1024, 768),
                        output_timestep=timedelta(hours=1),
                        )
    renderer.viewport = ((-87.095, 27.595), (-87.905, 28.405))

    print 'adding outputters'
    model.outputters += renderer

    # Also going to write the results out to a netcdf file
    netcdf_file = os.path.join(base_dir, 'gulf_tamoc.nc')
    scripting.remove_netcdf(netcdf_file)

    model.outputters += NetCDFOutput(netcdf_file,
                                     which_data='most',
                                     # output most of the data associated with the elements
                                     output_timestep=timedelta(hours=2))

    print "adding Horizontal and Vertical diffusion"

    # Horizontal Diffusion
    model.movers += RandomMover(diffusion_coef=100000)
    # vertical diffusion (different above and below the mixed layer)
    model.movers += RandomVerticalMover(vertical_diffusion_coef_above_ml=50,
                                        vertical_diffusion_coef_below_ml=10,
                                        horizontal_diffusion_coef_above_ml=100000,
                                        horizontal_diffusion_coef_below_ml=100,
                                        mixed_layer_depth=10)

    print 'adding Rise Velocity'
    # droplets rise as a function of their density and radius
    model.movers += TamocRiseVelocityMover()

    print 'adding the 3D current mover'
    gc = GridCurrent.from_netCDF('HYCOM_3d.nc')

    model.movers += GridCurrentMover('HYCOM_3d.nc')
#    model.movers += SimpleMover(velocity=(0., 0, 0.))
#    model.movers += constant_wind_mover(5, 315, units='knots')

    # Wind from a buoy
    w = Wind(filename='KIKT.osm')
    model.movers += WindMover(w)


    # Now to add in the TAMOC "spill"
    print "Adding TAMOC spill"

    model.spills += tamoc_spill.TamocSpill(release_time=start_time,
                                        start_position=(-87.5, 28.0, 2000),
                                        num_elements=30000,
                                        end_release_time=start_time + timedelta(days=2),
                                        name='TAMOC plume',
                                        TAMOC_interval=None,  # how often to re-run TAMOC
                                        )

    model.spills[0].data_sources['currents'] = gc

    return model
开发者ID:,项目名称:,代码行数:75,代码来源:


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