landlab

landlab.plot package

Submodules

landlab.plot.imshow module

Methods to plot data defined on Landlab grids.

Plotting functions

imshow_grid(grid, values, \*\*kwds) Prepare a map view of data over all nodes or cells in the grid.
imshow_grid_at_cell(grid, values, \*\*kwds) Map view of grid data over all grid cells.
imshow_grid_at_node(grid, values, \*\*kwds) Prepare a map view of data over all nodes in the grid.
imshow_cell_grid(*args, **kwargs)[source]

Note

This method is deprecated as of Landlab version 0.5.

Use imshow_grid_at_cell() instead.

imshow_grid(grid, values, **kwds)[source]

Prepare a map view of data over all nodes or cells in the grid.

Data is plotted as colored cells. If at=’node’, the surrounding cell is shaded with the value at the node at its center. If at=’cell’, the cell is shaded with its own value. Outer edges of perimeter cells are extrapolated. Closed elements are colored uniformly (default black, overridden with kwd ‘color_for_closed’); other open boundary nodes get their actual values.

values can be a field name, a regular array, or a masked array. If a masked array is provided, masked entries will be treated as if they were Landlab CLOSED_BOUNDARYs. Used together with the color_at_closed=None keyword (i.e., “transparent”), this can allow for construction of overlay layers in a figure (e.g., only defining values in a river network, and overlaying it on another landscape).

Use matplotlib functions like xlim, ylim to modify your plot after calling imshow_grid(), as desired.

This function happily works with both regular and irregular grids.

Construction

imshow_grid(grid, values, plot_name=None, var_name=None,
            var_units=None, grid_units=None,
            symmetric_cbar=False, cmap='pink',
            limits=(values.min(), values.max()),
            vmin=values.min(), vmax=values.max(),
            allow_colorbar=True, colorbar_label=None,
            norm=[linear], shrink=1.,
            color_for_closed='black',
            color_for_background=None,
            show_elements=False)
Parameters:

grid : ModelGrid

Grid containing the field to plot, or describing the geometry of the provided array.

values : array_like, masked_array, or str

Node or cell values, or a field name as a string from which to draw the data.

at : str, {‘node’, ‘cell’}

Tells plotter where values are defined.

plot_name : str, optional

String to put as the plot title.

var_name : str, optional

Variable name, to use as a colorbar label.

var_units : str, optional

Units for the variable being plotted, for the colorbar.

grid_units : tuple of str, optional

Units for y, and x dimensions. If None, component will look to the gri property axis_units for this information. If no units are specified there, no entry is made.

symmetric_cbar : bool

Make the colormap symetric about 0.

cmap : str

Name of a colormap

limits : tuple of float

Minimum and maximum of the colorbar.

vmin, vmax: floats

Alternatives to limits.

allow_colorbar : bool

If True, include the colorbar.

colorbar_label : str or None

The string with which to label the colorbar.

norm : matplotlib.colors.Normalize

The normalizing object which scales data, typically into the interval [0, 1]. Ignore in most cases.

shrink : float

Fraction by which to shrink the colorbar.

color_for_closed : str or None

Color to use for closed elements (default ‘black’). If None, closed (or masked) elements will be transparent.

color_for_background : color str or other color declaration, or None

Color to use for closed elements (default None). If None, the background will be transparent, and appear white.

show_elements : bool

If True, and grid is a Voronoi, the faces will be plotted in black along with just the colour of the cell, defining the cell outlines (defaults False).

output : None, string, or bool

If None (or False), the image is sent to the imaging buffer to await an explicit call to show() or savefig() from outside this function. If a string, the string should be the path to a save location, and the filename (with file extension). The function will then call plt.savefig([string]) itself. If True, the function will call plt.show() itself once plotting is complete.

imshow_grid_at_cell(grid, values, **kwds)[source]

Map view of grid data over all grid cells.

Prepares a map view of data over all cells in the grid. Method can take any of the same **kwds as imshow_grid_at_node().

Construction

imshow_grid_at_cell(grid, values, plot_name=None, var_name=None,
                    var_units=None, grid_units=None,
                    symmetric_cbar=False, cmap='pink',
                    limits=(values.min(), values.max()),
                    vmin=values.min(), vmax=values.max(),
                    allow_colorbar=True, colorbar_label=None,
                    norm=[linear], shrink=1.,
                    color_for_closed='black',
                    color_for_background=None,
                    show_elements=False, output=None)
Parameters:

grid : ModelGrid

Grid containing the field to plot, or describing the geometry of the provided array.

values : array_like, masked_array, or str

Values at the cells on the grid. Alternatively, can be a field name (string) from which to draw the data from the grid.

plot_name : str, optional

String to put as the plot title.

var_name : str, optional

Variable name, to use as a colorbar label.

var_units : str, optional

Units for the variable being plotted, for the colorbar.

grid_units : tuple of str, optional

Units for y, and x dimensions. If None, component will look to the gri property axis_units for this information. If no units are specified there, no entry is made.

symmetric_cbar : bool

Make the colormap symetric about 0.

cmap : str

Name of a colormap

limits : tuple of float

Minimum and maximum of the colorbar.

vmin, vmax: floats

Alternatives to limits.

allow_colorbar : bool

If True, include the colorbar.

colorbar_label : str or None

The string with which to label the colorbar.

norm : matplotlib.colors.Normalize

The normalizing object which scales data, typically into the interval [0, 1]. Ignore in most cases.

shrink : float

Fraction by which to shrink the colorbar.

color_for_closed : str or None

Color to use for closed elements (default ‘black’). If None, closed (or masked) elements will be transparent.

color_for_background : color str or other color declaration, or None

Color to use for closed elements (default None). If None, the background will be transparent, and appear white.

show_elements : bool

If True, and grid is a Voronoi, the faces will be plotted in black along with just the colour of the cell, defining the cell outlines (defaults False).

output : None, string, or bool

If None (or False), the image is sent to the imaging buffer to await an explicit call to show() or savefig() from outside this function. If a string, the string should be the path to a save location, and the filename (with file extension). The function will then call plt.savefig([string]) itself. If True, the function will call plt.show() itself once plotting is complete.

Raises:

ValueError

If input grid is not uniform rectilinear.

imshow_grid_at_node(grid, values, **kwds)[source]

Prepare a map view of data over all nodes in the grid.

Data is plotted as cells shaded with the value at the node at its center. Outer edges of perimeter cells are extrapolated. Closed elements are colored uniformly (default black, overridden with kwd ‘color_for_closed’); other open boundary nodes get their actual values.

values can be a field name, a regular array, or a masked array. If a masked array is provided, masked entries will be treated as if they were Landlab CLOSED_BOUNDARYs. Used together with the color_at_closed=None keyword (i.e., “transparent”), this can allow for construction of overlay layers in a figure (e.g., only defining values in a river network, and overlaying it on another landscape).

Use matplotlib functions like xlim, ylim to modify your plot after calling imshow_grid(), as desired.

This function happily works with both regular and irregular grids.

Construction

imshow_grid_at_node(grid, values, plot_name=None, var_name=None,
                    var_units=None, grid_units=None,
                    symmetric_cbar=False, cmap='pink',
                    limits=(values.min(), values.max()),
                    vmin=values.min(), vmax=values.max(),
                    allow_colorbar=True,
                    norm=[linear], shrink=1.,
                    color_for_closed='black',
                    color_for_background=None,
                    show_elements=False, output=None)
Parameters:

grid : ModelGrid

Grid containing the field to plot, or describing the geometry of the provided array.

values : array_like, masked_array, or str

Node values, or a field name as a string from which to draw the data.

plot_name : str, optional

String to put as the plot title.

var_name : str, optional

Variable name, to use as a colorbar label.

var_units : str, optional

Units for the variable being plotted, for the colorbar.

grid_units : tuple of str, optional

Units for y, and x dimensions. If None, component will look to the gri property axis_units for this information. If no units are specified there, no entry is made.

symmetric_cbar : bool

Make the colormap symetric about 0.

cmap : str

Name of a colormap

limits : tuple of float

Minimum and maximum of the colorbar.

vmin, vmax: floats

Alternatives to limits.

allow_colorbar : bool

If True, include the colorbar.

colorbar_label : str or None

The string with which to label the colorbar.

norm : matplotlib.colors.Normalize

The normalizing object which scales data, typically into the interval [0, 1]. Ignore in most cases.

shrink : float

Fraction by which to shrink the colorbar.

color_for_closed : str or None

Color to use for closed nodes (default ‘black’). If None, closed (or masked) nodes will be transparent.

color_for_background : color str or other color declaration, or None

Color to use for closed elements (default None). If None, the background will be transparent, and appear white.

show_elements : bool

If True, and grid is a Voronoi, the faces will be plotted in black along with just the colour of the cell, defining the cell outlines (defaults False).

output : None, string, or bool

If None (or False), the image is sent to the imaging buffer to await an explicit call to show() or savefig() from outside this function. If a string, the string should be the path to a save location, and the filename (with file extension). The function will then call plt.savefig([string]) itself. If True, the function will call plt.show() itself once plotting is complete.

imshow_node_grid(*args, **kwargs)[source]

Note

This method is deprecated as of Landlab version 0.5.

Use imshow_grid_at_node() instead.

landlab.plot.channel_profile module

Extract and plot channel long profiles.

Plotting functions to extract and plot channel long profiles. Call all three functions in sequence from the main code.

The functions will return the long profile nodes, return distances upstream of those nodes, and plot the long profiles, respectively. The former two are, by necessity, ragged lists of arrays - the number of channels, then the nodes in that channel.

This module selects channels by taking the largest possible drainages crossing the grid boundaries. You can specify how many different channels it handles using the number_of_channels parameter in the channel_nodes function (default is 1). This may lead to strange outputs if the drainage structure of the output changes mid-run (e.g., channel piracy). This may be modified in the future.

analyze_channel_network_and_plot(grid, elevations='topographic__elevation', drainage_area='drainage_area', flow_receiver='flow__receiver_node', links_to_flow_receiver='flow__link_to_receiver_node', number_of_channels=1, starting_nodes=None, threshold=None)[source]

This function wraps the other three present here, and allows a single-line call to plot long profiles. As typical elsewhere, the inputs can be field names or arrays.

Note the key new parameter starting_nodes. This (optionally) can be a Python list of node IDs marking the start of each profile. If it is not provided, the profiles with the largest terminal drainage area will be used instead.

Returns a tuple, containing:
  • the list of arrays profile_IDs.
  • the list of arrays dists_upstr, the distances from the final, lowest
    node in the network.

Both lists are number_of_channels long. -

channel_nodes(grid, steepest_nodes, drainage_area, flow_receiver, number_of_channels=1, threshold=None)[source]
get_distances_upstream(grid, len_node_arrays, profile_IDs, links_to_flow_receiver)[source]
plot_profiles(distances_upstream, profile_IDs, elevations)[source]

landlab.plot.colors module

colors.py

Created on Mon Jan 18 13:28:17 2016

@author: gtucker

colormap(name)[source]

Return named Landlab colormap as a matplotlib colormap.

Parameters:

name : str

Name of colormap

Currently available maps are:

‘water’: black to light blue ‘earth’: dark olive to light sand color

earth_colormap()[source]

Return matplotlib colormap with ‘earth’ theme.

water_colormap()[source]

Return matplotlib colormap with ‘water’ theme.

Module contents