How to use the landlab.ca.celllab_cts.CAPlotter function in landlab

To help you get started, we’ve selected a few landlab examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github landlab / landlab / tests / ca / cts_model.py View on Github external
def initialize_plotting(self, **kwds):
        """Create and configure CAPlotter object."""
        self.ca_plotter = CAPlotter(self.ca, **kwds)
        self.ca_plotter.update_plot()
        axis("off")
github landlab / landlab / landlab / ca / examples / grains.py View on Github external
# Transition data here represent the disease status of a population.
    ns_dict = { 0 : 'fluid', 1 : 'grain' }
    xn_list = setup_transition_list()

    # Create data and initialize values. We start with the 3 middle columns full
    # of grains, and the others empty.
    node_state_grid = hmg.add_zeros('node', 'node_state_grid')
    middle = 0.25*(nc-1)*sqrt(3)
    is_middle_cols = logical_and(hmg.node_xmiddle-1.)
    node_state_grid[where(is_middle_cols)[0]] = 1

    # Create the CA model
    ca = OrientedHexCTS(hmg, ns_dict, xn_list, node_state_grid)

    # Create a CAPlotter object for handling screen display
    ca_plotter = CAPlotter(ca)

    # Plot the initial grid
    ca_plotter.update_plot()

    # RUN
    current_time = 0.0
    while current_time < run_duration:

        # Once in a while, print out simulation and real time to let the user
        # know that the sim is running ok
        current_real_time = time.time()
        if current_real_time >= next_report:
            print('Current sim time',current_time,'(',100*current_time/run_duration,'%)')
            next_report = current_real_time + report_interval

        # Run the model forward in time until the next output step
github landlab / landlab / landlab / ca / examples / diffusion_in_gravity.py View on Github external
node_state_grid[middle_rows] = 1

    # Create the CA model
    ca = OrientedRasterCTS(mg, ns_dict, xn_list, node_state_grid)

    # Debug output if needed
    if _DEBUG:
        n = ca.grid.number_of_nodes
        for r in range(ca.grid.number_of_node_rows):
            for c in range(ca.grid.number_of_node_columns):
                n -= 1
                print('{0:.0f}'.format(ca.node_state[n]), end=' ')
            print()

    # Create a CAPlotter object for handling screen display
    ca_plotter = CAPlotter(ca)

    # Plot the initial grid
    ca_plotter.update_plot()

    # RUN
    current_time = 0.0
    while current_time < run_duration:

        # Once in a while, print out simulation and real time to let the user
        # know that the sim is running ok
        current_real_time = time.time()
        if current_real_time >= next_report:
            print('Current sim time',current_time,'(',100*current_time/run_duration,'%)')
            next_report = current_real_time + report_interval

        # Run the model forward in time until the next output step
github landlab / landlab / examples / ca / cts_lattice_grain.py View on Github external
# Create data and initialize values.
    node_state_grid = hmg.add_zeros("node", "node_state_grid")

    # Make the grid boundary all wall particles
    node_state_grid[hmg.boundary_nodes] = 8

    # Seed the grid interior with randomly oriented particles
    for i in hmg.core_nodes:
        if random.random() < p_init:
            node_state_grid[i] = random.randint(1, 7)

    # Create the CA model
    ca = OrientedHexCTS(hmg, ns_dict, xn_list, node_state_grid)

    # Create a CAPlotter object for handling screen display
    ca_plotter = CAPlotter(ca)

    # Plot the initial grid
    ca_plotter.update_plot()

    # RUN
    current_time = 0.0
    while current_time < run_duration:

        # Once in a while, print out simulation and real time to let the user
        # know that the sim is running ok
        current_real_time = time.time()
        if current_real_time >= next_report:
            print(
                "Current sim time",
                current_time,
                "(",
github landlab / landlab / examples / ca / cts_lattice_grain_silo.py View on Github external
rock = (0.0, 0.0, 0.0)  # '#5F594D'
    sed = (0.6, 0.6, 0.6)  # '#A4874B'
    # sky = '#CBD5E1'
    # sky = '#85A5CC'
    sky = (1.0, 1.0, 1.0)  # '#D0E4F2'
    mob = (0.3, 0.3, 0.3)  # '#D98859'
    # mob = '#DB764F'
    # mob = '#FFFF00'
    # sed = '#CAAE98'
    # clist = [(0.5, 0.9, 0.9),mob, mob, mob, mob, mob, mob,'#CD6839',(0.3,0.3,0.3)]
    clist = [sky, mob, mob, mob, mob, mob, mob, sed, rock]
    my_cmap = matplotlib.colors.ListedColormap(clist)

    # Create a CAPlotter object for handling screen display
    ca_plotter = CAPlotter(ca, cmap=my_cmap)
    k = 0

    # Plot the initial grid
    ca_plotter.update_plot()

    # RUN

    # Run with closed silo
    current_time = 0.0
    while current_time < run_duration:

        # Once in a while, print out simulation and real time to let the user
        # know that the sim is running ok
        current_real_time = time.time()
        if current_real_time >= next_report:
            print(
github landlab / landlab / landlab / ca / examples / isotropic_turbulent_suspension / isotropic_turbulent_suspension.py View on Github external
bottom_rows = where(mg.node_y<0.1*nr)[0]
    node_state_grid[bottom_rows] = 1
    
    # For visual display purposes, set all boundary nodes to fluid
    node_state_grid[mg.closed_boundary_nodes] = 0
    
    # Create the CA model
    ca = RasterCTS(mg, ns_dict, xn_list, node_state_grid)
    
    grain = '#5F594D'
    fluid = '#D0E4F2'
    clist = [fluid,grain]
    my_cmap = matplotlib.colors.ListedColormap(clist)

    # Create a CAPlotter object for handling screen display
    ca_plotter = CAPlotter(ca, cmap=my_cmap)
    
    # Plot the initial grid
    ca_plotter.update_plot()

    # RUN
    current_time = 0.0
    while current_time < run_duration:
        
        # Once in a while, print out simulation and real time to let the user
        # know that the sim is running ok
        current_real_time = time.time()
        if current_real_time >= next_report:
            print 'Current sim time',current_time,'(',100*current_time/run_duration,'%)'
            next_report = current_real_time + report_interval
        
        # Run the model forward in time until the next output step
github landlab / landlab / examples / ca / cts_lattice_gas_with_gravity.py View on Github external
# Create data and initialize values.
    node_state_grid = hmg.add_zeros("node", "node_state_grid")

    # Make the grid boundary all wall particles
    node_state_grid[hmg.boundary_nodes] = 8

    # Seed the grid interior with randomly oriented particles
    for i in hmg.core_nodes:
        if random.random() < p_init:
            node_state_grid[i] = random.randint(1, 7)

    # Create the CA model
    ca = OrientedHexCTS(hmg, ns_dict, xn_list, node_state_grid)

    # Create a CAPlotter object for handling screen display
    ca_plotter = CAPlotter(ca)

    # Plot the initial grid
    ca_plotter.update_plot()

    # RUN
    current_time = 0.0
    while current_time < run_duration:

        # Once in a while, print out simulation and real time to let the user
        # know that the sim is running ok
        current_real_time = time.time()
        if current_real_time >= next_report:
            print(
                "Current sim time",
                current_time,
                "(",
github landlab / landlab / examples / ca / cts_lattice_grain_silo.py View on Github external
xmid = nc * 0.866 * 0.5
    for i in range(hmg.number_of_nodes):
        if (
            node_state_grid[i] == 8
            and hmg.node_x[i] > (xmid - silo_opening_half_width)
            and hmg.node_x[i] < (xmid + silo_opening_half_width)
            and hmg.node_y[i] > 0
            and hmg.node_y[i] < 38.0
        ):
            node_state_grid[i] = 0

    # Create the CA model
    ca = OrientedHexCTS(hmg, ns_dict, xn_list, node_state_grid)

    # Create a CAPlotter object for handling screen display
    ca_plotter = CAPlotter(ca)

    # Plot the initial grid
    ca_plotter.update_plot()

    # Re-run with open silo
    savefig("silo" + str(k) + ".png")
    k += 1
    current_time = 0.0
    while current_time < 5 * run_duration:

        # Once in a while, print out simulation and real time to let the user
        # know that the sim is running ok
        current_real_time = time.time()
        if current_real_time >= next_report:
            print(
                "Current sim time",
github landlab / landlab / landlab / ca / examples / rock_weathering.py View on Github external
# 64-bit integer type)
    node_state_grid = mg.add_zeros('node', 'node_state_map', dtype=np.uint8)
    
    node_state_grid[:] = make_frac_grid(frac_spacing, model_grid=mg)    
    
    # Create the CA model
    ca = RasterCTS(mg, ns_dict, xn_list, node_state_grid)

    # Set up the color map
    rock_color = (0.8, 0.8, 0.8)
    sap_color = (0.4, 0.2, 0)
    clist = [rock_color, sap_color]
    my_cmap = matplotlib.colors.ListedColormap(clist)
    
    # Create a CAPlotter object for handling screen display
    ca_plotter = CAPlotter(ca, cmap=my_cmap)
    
    # Plot the initial grid
    ca_plotter.update_plot()
    
    # Output the initial grid to file
    write_netcdf((outfilename+str(time_slice)+'.nc'), mg, 
                 #format='NETCDF3_64BIT',
                 names='node_state_map')

    # RUN
    current_time = 0.0
    while current_time < run_duration:
        
        # Once in a while, print out simulation and real time to let the user
        # know that the sim is running ok
        current_real_time = time.time()