EventLayers: Add event layers to a landlab grid#

class EventLayers(number_of_stacks, allocated=0)[source]#

Bases: object

Track EventLayers where each event is its own layer.

EventLayers are meant to represent a layered object in which each layer represents a event. Thus they are likely the most appropriate tool to use if the user is interested in chronostratigraphy. If erosion occurs, a new layer with zero thickness is created. Thus, EventLayers may not be the most memory efficent layers datastructure.

EventLayers exists in contrast to the MaterialLayers object which does not make a new layer if only erosion occurs and if the attributes of the new layer are equivalent to the attributes of the material at the surface of the layer stack.

Parameters:

number_of_stacks (int) – Number of layer stacks to track.

Examples

>>> from landlab.layers.eventlayers import EventLayers

Create an empty layer stack with 5 stacks.

>>> layers = EventLayers(5)
>>> layers.number_of_stacks
5
>>> layers.number_of_layers
0

Add a layer with a uniform thickness.

>>> layers.add(1.5)
>>> layers.number_of_layers
1
>>> layers.dz
array([[ 1.5,  1.5,  1.5,  1.5,  1.5]])

Add a second layer with uneven thickness.

>>> layers.add([1.0, 2.0, 0.5, 5.0, 0.0])
>>> layers.dz
array([[ 1.5,  1.5,  1.5,  1.5,  1.5],
       [ 1. ,  2. ,  0.5,  5. ,  0. ]])

Adding a layer with negative thickness will remove existing layers for the top of the stack. Note that this will create a new layer with thickness zero that represents this ‘event’. If instead your application would prefer that no new row is added to the layers datastructure, you may want to consider the MaterialLayers object.

>>> layers.add(-1)
>>> layers.dz
array([[ 1.5,  1.5,  1. ,  1.5,  0.5],
       [ 0. ,  1. ,  0. ,  4. ,  0. ],
       [ 0. ,  0. ,  0. ,  0. ,  0. ]])

Get the index value of the layer within each stack at the topographic surface.

>>> layers.surface_index
array([0, 1, 0, 1, 0])
add(dz, **kwds)[source]#

Add a layer to the stacks.

Parameters:

dz (float or array_like) – Thickness to add to each stack.

Examples

>>> from landlab.layers.eventlayers import EventLayers

Create an empty layer stack with 3 stacks.

>>> layers = EventLayers(3)
>>> layers.number_of_layers
0

To add a layer of uniform thickness to every stack.

>>> layers.add(1.5)
>>> layers.number_of_layers
1
>>> layers.dz
array([[ 1.5,  1.5,  1.5]])

Add a second layer with uneven thickness.

>>> layers.add([1.0, 2.0, 0.5])
>>> layers.dz
array([[ 1.5,  1.5,  1.5],
       [ 1. ,  2. ,  0.5]])

Adding a layer with negative thickness will remove existing layers for the top of the stack.

>>> layers.add(-1)
>>> layers.dz
array([[ 1.5,  1.5,  1. ],
       [ 0. ,  1. ,  0. ],
       [ 0. ,  0. ,  0. ]])

Use keywords to track properties of each layer. For instance, here we create a new stack and add a layer with a particular age. You can access the layer properties as if the object were a dictionary.

>>> layers = EventLayers(3)
>>> layers.add(1.0, age=3.0)
>>> layers.dz
array([[ 1.,  1.,  1.]])
>>> layers["age"]
array([[ 3.,  3.,  3.]])
>>> layers.add(2.0, age=6.0)
>>> layers["age"]
array([[ 3.,  3.,  3.],
       [ 6.,  6.,  6.]])

Attributes for each layer will exist even if the the layer is associated with erosion.

>>> layers.add([-2, -1, 1], age=8.0)
>>> layers.dz
array([[ 1.,  1.,  1.],
       [ 0.,  1.,  2.],
       [ 0.,  0.,  1.]])
>>> layers["age"]
array([[ 3.,  3.,  3.],
       [ 6.,  6.,  6.],
       [ 8.,  8.,  8.]])

To get the values at the surface of the layer stack:

>>> layers.get_surface_values("age")
array([ 3.,  6.,  8.])
property allocated#

Total number of allocated layers.

Examples

>>> from landlab.layers.eventlayers import EventLayers
>>> layers = EventLayers(3)
>>> layers.number_of_layers
0
>>> layers.allocated == 0
True
>>> layers.add(15.0)
>>> layers.number_of_layers
1
>>> layers.allocated == 7
True
>>> for _ in range(layers.allocated):
...     layers.add(0.0)
...
>>> layers.number_of_layers
8
>>> layers.allocated == 15
True

If you know how many layers you will ultimately have, you can allocated enough memory for them when you create your layer stacks.

>>> layers = EventLayers(3, allocated=15)
>>> layers.number_of_layers
0
>>> layers.allocated == 15
True
>>> layers.add(15.0)
>>> layers.number_of_layers
1
>>> layers.allocated == 15
True
>>> for _ in range(layers.allocated):
...     layers.add(0.0)
...
>>> layers.number_of_layers
16
>>> layers.allocated == 24
True
property dz#

Thickness of each layer.

The thickness of each layer at each stack as an array of shape (number_of_layers, number_of_stacks).

Examples

>>> from landlab.layers.eventlayers import EventLayers

Initially there are no layers so there are not thicknesses.

>>> layers = EventLayers(3)
>>> layers.dz.shape == (0, 3)
True

Now add two layers, the first of uniform thickness and the second non-uniform and with some erosion.

>>> layers.add(15.0)
>>> layers.add([1.0, -1.0, 2.0])
>>> layers.dz
array([[ 15.,  14.,  15.],
       [  1.,   0.,   2.]])
get_surface_values(name)[source]#

Values of a field on the surface layer.

property number_of_layers#

Total number of layers.

Examples

>>> from landlab.layers.eventlayers import EventLayers
>>> layers = EventLayers(3)
>>> layers.number_of_layers
0
>>> layers.add(15.0)
>>> layers.add([1.0, -1.0, 2.0])
>>> layers.number_of_layers
2
property number_of_stacks#

Number of stacks.

reduce([start, ]stop[, step])[source]#

Combine layers.

Reduce adjacent layers into a single layer.

Examples

>>> from landlab.layers.eventlayers import EventLayers

Create an empty layer stack with 3 stacks.

>>> layers = EventLayers(3)
>>> layers.number_of_layers
0

To add a layer of uniform thickness to every stack.

>>> layers.add(1.5)
>>> layers.number_of_layers
1
>>> layers.dz
array([[ 1.5,  1.5,  1.5]])

Add a second layer with uneven thickness.

>>> layers.add([1.0, 2.0, 0.5])
>>> layers.dz
array([[ 1.5,  1.5,  1.5],
       [ 1. ,  2. ,  0.5]])

Combine all of the layers into a single layer.

>>> layers.reduce()
>>> layers.dz
array([[ 2.5,  3.5,  2. ]])

Add two additional layers to the top. The bottom-most layer is row 0, and the two new layers are rows 1 and 2.

>>> layers.add([1.0, 2.0, 0.5])
>>> layers.add([1.0, 2.0, 0.5])
>>> layers.dz
array([[ 2.5,  3.5,  2. ],
       [ 1. ,  2. ,  0.5],
       [ 1. ,  2. ,  0.5]])

Combine the two new layers (layers 1 and 2) into a single layer.

>>> layers.reduce(1, 3)
>>> layers.dz
array([[ 2.5,  3.5,  2. ],
       [ 2. ,  4. ,  1. ]])
>>> layers.add([1.0, 2.0, 0.5])
>>> layers.add([1.0, 2.0, 0.5])
>>> layers.dz
array([[ 2.5,  3.5,  2. ],
       [ 2. ,  4. ,  1. ],
       [ 1. ,  2. ,  0.5],
       [ 1. ,  2. ,  0.5]])

Combine the middle two layers.

>>> layers.reduce(1, 3)
>>> layers.dz
array([[ 2.5,  3.5,  2. ],
       [ 3. ,  6. ,  1.5],
       [ 1. ,  2. ,  0.5]])
>>> layers.add([1.0, 1.0, 1.0])
>>> layers.dz
array([[ 2.5,  3.5,  2. ],
       [ 3. ,  6. ,  1.5],
       [ 1. ,  2. ,  0.5],
       [ 1. ,  1. ,  1. ]])

Combine every two layers (layers 0 and 1 and combined, and layers 1 and 2 are combined).

>>> layers.reduce(0, 4, 2)
>>> layers.dz
array([[ 5.5,  9.5,  3.5],
       [ 2. ,  3. ,  1.5]])

When layers are combined, thicknesses are summed but layer attributes can be combined in other ways (e.g. max, or mean)

>>> layers = EventLayers(3)
>>> layers.add([1, 1, 1], age=0.0)
>>> layers.add([1, 2, 5], age=1.0)
>>> layers.add([2, 2, 2], age=2.0)
>>> layers.reduce(age=np.max)
>>> layers["age"]
array([[ 2.,  2.,  2.]])
>>> layers.add([2, 2, 2], age=3.0)
>>> layers.add([2, 2, 2], age=4.0)
>>> layers.reduce(1, 3, age=np.mean)
>>> layers["age"]
array([[ 2. ,  2. ,  2. ],
       [ 3.5,  3.5,  3.5]])
property surface_index#

Index to the top non-empty layer.

Examples

>>> from landlab.layers.eventlayers import EventLayers

Create an empty layer stack with 5 stacks.

>>> layers = EventLayers(3)
>>> layers.surface_index
array([0, 0, 0])

Add a layer with a uniform thickness.

>>> for _ in range(5):
...     layers.add(1.0)
...
>>> layers.surface_index
array([4, 4, 4])

Add a layer with varying thickness. Negative thickness removes thickness from underlying layers, zero thickness adds a layer but doesn’t change the surface index.

>>> layers.add([-1.0, 0.0, 1.0])
>>> layers.surface_index
array([3, 4, 5])
property thickness#

Total thickness of the columns.

The sum of all layer thicknesses for each stack as an array of shape (number_of_stacks, ).

Examples

>>> from landlab.layers.eventlayers import EventLayers

Initially there are no layers so the total thickness is 0.

>>> layers = EventLayers(3)
>>> layers.thickness
array([ 0.,  0.,  0.])

After adding some layers, the stacks have varying thicknesses.

>>> layers.add(15.0)
>>> layers.add([1.0, -1.0, 2.0])
>>> layers.thickness
array([ 16.,  14.,  17.])
property tracking#

Layer properties being tracked.

Examples

>>> from landlab.layers.eventlayers import EventLayers
>>> layers = EventLayers(3)
>>> layers.tracking
[]
>>> layers.add(1.0, age=1.0)
>>> layers.tracking
['age']
property z#

Thickness to top of each layer.

Thickness from the bottom of each stack to the top of each layer as an array of shape (number_of_layers, number_of_stacks).

Examples

>>> from landlab.layers.eventlayers import EventLayers

Initially there are no layers so the elevation to the top is 0.

>>> layers = EventLayers(3)
>>> layers.z.shape == (0, 3)
True

After adding some layers, elevations are to the top of each layer.

>>> layers.add(15.0)
>>> layers.add([1.0, -1.0, 2.0])
>>> layers.dz
array([[ 15.,  14.,  15.],
       [  1.,   0.,   2.]])
>>> layers.z
array([[ 15.,  14.,  15.],
       [ 16.,  14.,  17.]])
class EventLayersMixIn[source]#

Bases: object

MixIn that adds a EventLayers attribute to a ModelGrid.

property at_layer#

EventLayers for each cell.

property event_layers#

EventLayers for each cell.