Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
e20fe9d
Updates to 'making-components' tutorial
Sep 27, 2017
6150b1d
got rid of old syntax
nicgaspar Sep 27, 2017
c338225
Merge pull request #11 from landlab/margauxmouchene/update-making-com…
margauxmouchene Oct 2, 2017
e4f3202
Tutorial for the transport-length hillslope diffusion component
Nov 13, 2017
ef00dec
Merge pull request #12 from landlab/margauxmouchene/Transport_length_…
margauxmouchene Nov 16, 2017
f75fa42
Change title and minor typo
Nov 16, 2017
5e957e6
Merge pull request #13 from landlab/margauxmouchene/Transport_length_…
margauxmouchene Nov 16, 2017
fcecd4a
Example on use of Axes3D for Landlab
margauxmouchene Feb 19, 2018
39e4efd
Add warning: developer install is needed to run this tuto as componen…
margauxmouchene Feb 27, 2018
ceab2f8
Revert "Add warning: developer install is needed to run this tuto as …
margauxmouchene Feb 27, 2018
f42c82a
Add warning, correct minor typo
margauxmouchene Feb 27, 2018
f181f4e
Merge pull request #14 from landlab/TLHDiff_tuto_warning
margauxmouchene Feb 28, 2018
9af823d
animation tutorial initial commit
nathanlyons Mar 4, 2018
2a5fbbf
animation tutorial movies
nathanlyons Mar 4, 2018
1aa862c
commented: IPython.display only in ipython session
nathanlyons Mar 4, 2018
d9f2c48
deleted first_phase.mp4, it doesn't run on github
nathanlyons Mar 4, 2018
b7d5885
deleted second_phase.gif, it doesn't run on github
nathanlyons Mar 4, 2018
958abce
cleared animation output, github doesn't display
nathanlyons Mar 4, 2018
24dc41e
Wrap text in README.md.
mcflugen Mar 5, 2018
7fa03ec
Add info about release and next branches.
mcflugen Mar 5, 2018
a827a10
updates to the network model grid tutorial
kbarnhart Mar 8, 2018
7f05392
additional text and code in the networkmodelgrid example
kbarnhart Mar 8, 2018
b89ee6a
udates to the nmg tutorial
kbarnhart Mar 8, 2018
b5fbc21
updates to the nmg notebook during the call
kbarnhart Mar 14, 2018
c47685f
initial commit of normal fault tutorial
kbarnhart Mar 14, 2018
b2bb038
more updates while developing
kbarnhart Mar 14, 2018
017f90d
updates to component tutorial
kbarnhart Mar 14, 2018
31a4214
renaming file
kbarnhart Mar 15, 2018
4ff5d6a
draft of normal fault tutorial ready for review
kbarnhart Mar 15, 2018
1868b19
update of the NMG tutorial
kbarnhart Mar 16, 2018
c3e54be
making some text changes based on review
kbarnhart Mar 20, 2018
9c3ecb7
updates to notebook, fixing ""s and adding a soil production example
kbarnhart Mar 20, 2018
c462b52
updates to component tutorial
kbarnhart Mar 20, 2018
7c9106e
Merge pull request #16 from landlab/barnhark/normal_fault_tutorial
kbarnhart Mar 20, 2018
1e1bea7
Merge pull request #15 from landlab/barnhark/fix_component_tutorial
kbarnhart Apr 4, 2018
0803b1f
Merge branch 'release' into barnhark/nmg_tutorials
kbarnhart Apr 4, 2018
ffed068
updates to nmg tutorial
kbarnhart May 1, 2018
d49c13c
adding example data to NMG files
kbarnhart May 20, 2018
a6af58d
adding a tutorial that shows how to do imports
kbarnhart May 20, 2018
6990db1
verified that this works before hackathon
kbarnhart May 20, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 139 additions & 0 deletions 3D_plot/Axes3D_for_LL.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
"""
Plot a surface + points (clasts) on it

Use matplotlib Axes3D.plot_surface and Axes3D.scatter3D

Axes3D.plot_surface(X, Y, Z, *args, **kwargs)
X, Y and Z are 2D arrays of similar shape.
In our case, the plot is clearer if we don't plot boundary nodes
(but that could bean option). So the shape is that of the LL grid
core nodes.

X = dx * [[1, 2, 3, ..., nb_of_columns-1]
[1, 2, 3, ..., nb_of_columns-1]
...
[1, 2, 3, ..., nb_of_columns-1]]

Y = dy * [[1, 1, 1, ..., 1]
[2, 2, 2, ..., 2]
...
[nb_of_rows-1, ..., nb_of_rows-1]]

Z = [[z_core_node1, z_core_node2, ...]
[..., ... ]
...
[..., ]

The rstride and cstride kwargs set the stride used to sample the input data
to generate the graph. If 1k by 1k arrays are passed in, the default values
for the strides will result in a 100x100 grid being plotted. Defaults to 10.

The kwargs alpha sets the transparency factor (0 to 1).

The LL nodes are at the crossing of the white lines that form the surface
(the surface is made of LL patches, not cells).


Axes3D.scatter(xs, ys, zs=0, zdir='z', s=20, c=None,
depthshade=True, *args, **kwargs)
xs, ys, zs are 1D arrays defining the position of the points.
s = size (in points, so relation to the space scales of the plot itself is
not straightforward...)
c = color
depthshade = Whether or not to shade the scatter markers to give the
appearance of depth. Default is True.
"""

from landlab import RasterModelGrid
import numpy as np

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D


### Create Raster Model Grid
rows = 20
columns = 25
dx = 1
dy = 2

mg = RasterModelGrid((rows, columns), spacing=(dy, dx))

# Add elevation field
z = mg.node_y*0.1
_ = mg.add_field('node', 'topographic__elevation', z)

# Shape of core nodes:
# to be modified for more complex grids (use a mask?)
number_of_core_node_rows = mg.number_of_node_rows - 2
number_of_core_node_columns = mg.number_of_node_columns - 2

#####################################################################

### Data for 3D plot of topographic surface
xplot = mg.node_x[mg.core_nodes].reshape((
number_of_core_node_rows, number_of_core_node_columns))
yplot = mg.node_y[mg.core_nodes].reshape((
number_of_core_node_rows, number_of_core_node_columns))

# Elevation of core nodes, reshaped for 3D plot:
zplot = mg.at_node['topographic__elevation'][mg.core_nodes].reshape(
(number_of_core_node_rows, number_of_core_node_columns))

#####################################################################

### 3D plot of elevation surface:
# Figure and type of projection:
fig = plt.figure(1)
ax = plt.axes(projection='3d')

# Plot surface:
ax.plot_surface(xplot, yplot, zplot, cmap='binary', rstride=1, cstride=1,
alpha=0.5)

# Set initial view of the graph (elevation and azimuth):
ax.view_init(elev=None, azim=-130)

ax.set_xlabel('X axis')
ax.set_ylabel('Y axis')
ax.set_zlabel('Z axis')

#####################################################################

### Data for 3D plot of topographic surface
# The Clast Set class (from Clast Tracker) provides
# clast node ID, x and y coordinates, clast elevation, etc.
# but for this example, we define them here:

clast__node = np.array([382, 386, 386, 390, 392, 392, 392, 392])
clast__number = clast__node.size

clast__x = mg.node_x[clast__node]
clast__y= mg.node_y[clast__node]

clast__elevation = np.array([3, 3, 3, 3, 3, 3, 3, 3])
clast__size = np.array([0.5, 0.5, 0.5, 1, 1, 1, 1, 1])

# For display purpose, clasts sizes are increased:
# Marker size is in "points"...
sizes = clast__size * 100

# Count the number of clast on each node (WILL PUT THIS IN THE CLAST TRACKER)
clast__number_at_node = np.zeros(mg.number_of_nodes)
for i in range(0, mg.number_of_nodes):
clast__number_at_node[i] = list(clast__node).count(mg.nodes.reshape(
clast__number_at_node.shape)[i])

# Assign colors to clast markers as a function of clast density on the node:
clast__color = np.zeros(clast__number)
for j in range(0, clast__number):
clast__color[j] = clast__number_at_node[clast__node[j]]

#####################################################################

### 3D plot of points (scatter):

plot = ax.scatter(clast__x, clast__y, clast__elevation, marker='H',
s=sizes, c=clast__color, label=clast__color, cmap='cool')
cbar = plt.colorbar(plot, ticks=[1, 2, 3, 4], shrink=0.7)
cbar.set_label('# of clasts')
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,12 @@ conventions that we would like you to follow.
be rendered.
* Your tutorial must be able to run without error for the **most
recent landlab release**.
* If your tutorial runs with the most recent **release** of landlab,
a pull request should be sent to the *release* branch.
* If you tutorial does not work with the most recent release but does
work with a development version of landlab that's yet to be release,
submit a pull request to the *next* branch.


Thanks! :heart: :heart: :heart:

Expand Down
43 changes: 30 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,33 @@ Status](https://travis-ci.org/landlab/tutorials.svg?branch=master)](https://trav

[![Landlab header](./landlab_header.png)](http://landlab.github.io)

Most of these Landlab tutorials can either be read as text files or run as interactive IPython notebooks (recommended!).

To run the IPython notebook tutorials locally, you can copy this [landlab/tutorials](https://github.com/landlab/tutorials) repo to your local working environment (use the ``download ZIP`` button or fork/clone, whichever is most familiar to you).

Alternatively, you can also access each notebook online from [https://nbviewer.jupyter.org/github/landlab/tutorials](https://nbviewer.jupyter.org/github/landlab/tutorials) and download an individual notebook (navigate to the specific IPython notebook you want, open it, and click the download button that appears in the upper right).

After downloading/cloning, navigate into your new directory (or to the directory containing your new download) from the command line in your terminal.

Use the command ``$ jupyter notebook`` to launch Jupyter, the IPython notebook viewer (it will open locally in your browser). Then navigate to the ``.ipynb`` tutorial you want to run and click to open it.

To run the code in the notebook, place your cursor in a code cell, hold down ``shift``, and press ``enter``. The order in which you run the cells matters. You can even experiment with typing your own code into the cell and running that.

Here is a short IPython notebook tutorial along with a screencast (the tutorial uses an example with statistics, but you can substitute Landlab!): http://www.randalolson.com/2012/05/12/a-short-demo-on-how-to-use-ipython-notebook-as-a-research-notebook/
Most of these Landlab tutorials can either be read as text files or run
as interactive IPython notebooks (recommended!).

To run the IPython notebook tutorials locally, you can copy this
[landlab/tutorials](https://github.com/landlab/tutorials) repo to your
local working environment (use the ``download ZIP`` button or fork/clone,
whichever is most familiar to you).

Alternatively, you can also access each notebook online from
[https://nbviewer.jupyter.org/github/landlab/tutorials](https://nbviewer.jupyter.org/github/landlab/tutorials)
and download an individual notebook (navigate to the specific IPython
notebook you want, open it, and click the download button that appears
in the upper right).

After downloading/cloning, navigate into your new directory (or to
the directory containing your new download) from the command line
in your terminal.

Use the command ``$ jupyter notebook`` to launch Jupyter, the IPython
notebook viewer (it will open locally in your browser). Then navigate
to the ``.ipynb`` tutorial you want to run and click to open it.

To run the code in the notebook, place your cursor in a code cell,
hold down ``shift``, and press ``enter``. The order in which you
run the cells matters. You can even experiment with typing your own code
into the cell and running that.

Here is a short IPython notebook tutorial along with a screencast
(the tutorial uses an example with statistics, but you can
substitute Landlab!): http://www.randalolson.com/2012/05/12/a-short-demo-on-how-to-use-ipython-notebook-as-a-research-notebook/
Loading