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


Python HexModelGrid.hexplot方法代码示例

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


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

示例1: main

# 需要导入模块: from landlab import HexModelGrid [as 别名]
# 或者: from landlab.HexModelGrid import hexplot [as 别名]
def main():
    """
    In this simple tutorial example, the main function does all the work: 
    it sets the parameter values, creates and initializes a grid, sets up 
    the state variables, runs the main loop, and cleans up.
    """

    # INITIALIZE
    
    # User-defined parameter values
    numrows = 7         # number of rows in the grid
    basenumcols = 6          # number of columns in the grid
    dx = 10.0             # grid cell spacing
    kd = 0.01             # diffusivity coefficient, in m2/yr
    uplift_rate = 0.001   # baselevel/uplift rate, in m/yr
    num_time_steps = 1000 # number of time steps in run
    
    # Derived parameters
    dt = 0.1*dx**2 / kd    # time-step size set by CFL condition
    
    # Create and initialize a raster model grid
    mg = HexModelGrid(numrows, basenumcols, dx)
    
    # Set up scalar values: elevation and elevation time derivative
    z = mg.add_zeros('node', 'Land_surface__elevation')
    dzdt = mg.add_zeros('node', 'Land_surface__time_derivative_of_elevation')
    
    # Get a list of the core nodes
    core_nodes = mg.core_nodes

    # Display a message
    print( 'Running diffusion_with_model_hex_grid.py' )
    print( 'Time-step size has been set to ' + str( dt ) + ' years.' )
    start_time = time.time()

    
    # RUN
    
    # Main loop
    for i in range(0, num_time_steps):
        
        # Calculate the gradients and sediment fluxes
        g = mg.calculate_gradients_at_active_links(z)
        qs = -kd*g
        
        # Calculate the net deposition/erosion rate at each node
        dqsds = mg.calculate_flux_divergence_at_nodes(qs)
        
        # Calculate the total rate of elevation change
        dzdt = uplift_rate - dqsds
            
        # Update the elevations
        z[core_nodes] = z[core_nodes] + dzdt[core_nodes] * dt
        
   
    # FINALIZE
    
    import numpy

    # Test solution for a 1-cell hex grid
    if mg.number_of_nodes==7:  # single cell with 6 boundaries
        perimeter = dx*6*(numpy.sqrt(3.)/3.)
        flux = kd*(numpy.amax(z)/dx)
        total_outflux = perimeter*flux
        total_influx = mg.cell_areas*uplift_rate  # just one cell ...
        print 'total influx=',total_influx,'total outflux=',total_outflux
    print('Run time = '+str(time.time()-start_time)+' seconds')
    
    # Plot the points, colored by elevation
    mg.hexplot('Land_surface__elevation')
    pylab.figure()
    mg.display_grid(draw_voronoi=True)
开发者ID:Kirubaharan,项目名称:landlab,代码行数:74,代码来源:diffusion_with_model_hex_grid.py

示例2: HexModelGrid

# 需要导入模块: from landlab import HexModelGrid [as 别名]
# 或者: from landlab.HexModelGrid import hexplot [as 别名]
from landlab import HexModelGrid
from numpy import arange
from pylab import figure, show, title

# Case 1: Make and display a hex-shaped grid with horizontal rows of nodes

# Create the grid
hg1 = HexModelGrid(5, 3, 1.0, orientation='horizontal', shape='hex')

# Make some data
d = hg1.add_zeros('node', 'mydata')
d[:] = arange(hg1.number_of_nodes)

# Display the grid
figure(1)
hg1.hexplot(d)
title('hexagon shape, horizontal orientation')
show()


# Case 2: Make and display a hex-shaped grid with vertical columns of nodes

# Create the grid
hg2 = HexModelGrid(3, 5, 1.0, orientation='vertical', shape='hex')

# Make some data
d = hg2.add_zeros('node', 'mydata')
d[:] = arange(hg2.number_of_nodes)

# Display the grid
figure(2)
开发者ID:carldswanson,项目名称:landlab,代码行数:33,代码来源:hex_grid_types.py


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