Skip to content

Commit

Permalink
Merge pull request #25 from amoodie/refactor
Browse files Browse the repository at this point in the history
Refactor
  • Loading branch information
amoodie committed Sep 17, 2018
2 parents 1b1cf1f + 224fdec commit 511b7f7
Show file tree
Hide file tree
Showing 13 changed files with 883 additions and 731 deletions.
20 changes: 14 additions & 6 deletions README.md
@@ -1,8 +1,7 @@
# rivers2stratigraphy


Explore how a river becomes stratigraphy.

Explore how a river becomes stratigraphy

<img src="https://github.com/amoodie/rivers2stratigraphy/blob/master/private/rivers2stratigraphy_demo.gif" alt="demo_gif">

Expand All @@ -13,6 +12,13 @@ This repository is also linked into the [SedEdu suite of education modules](http



## About the model
Stratigraphic model based on LAB models, i.e., geometric channel body is deposited in "matrix" of floodplain mud.
The channel is always fixed to the basin surface and subsidence is only control on vertical stratigraphy.
Horizontal stratigraphy is set by 1) lateral migration (drawn from a pdf) and dampened for realism, and 2) avulsion that is set to a fixed value.



## Installation and running the module

Visit the section of the text below for more information on installing and executing the `rivers2stratigraphy` program on your computer.
Expand Down Expand Up @@ -73,16 +79,17 @@ Finally, run the module from the Python shell with:
import rivers2stratigraphy
```

You will be asked if you wish to launch the module now, type `Y` and hit enter.
Instructions will indicate to use the following command to then run the module:
```
rivers2stratigraphy.run()
```


Alternatively, run the module with provided script:
Alternatively, run the module with provided script (this is the hook used for launching from SedEdu):
```
python3 <path-to-installation>/run_rivers2stratigraphy.py
```

Note that this may throw an error on closing the window, but this is not a problem to functionality.


Please [open an issue](https://github.com/amoodie/rivers2stratigraphy/issues) if you encounter any additional error messages!
Please include 1) operating system, 2) installation method, and 3) copy-paste the error.
Expand All @@ -96,6 +103,7 @@ If you are interested in contributing to code please see below for instructions.

If you are interested in contributing to the the accompanying activites (which would be greatly appreciated!) please see [Writing Activites for SedEdu](https://github.com/amoodie/sededu/blob/develop/docs/writing_activities.md)


#### Download the source code

You can download this entire repository as a `.zip` by clicking the "Clone or download button on this page", or by [clicking here](https://github.com/amoodie/rivers2stratigraphy/archive/master.zip) to get a `.zip` folder. Unzip the folder in your preferred location.
Expand Down
2 changes: 1 addition & 1 deletion about.json
@@ -1,7 +1,7 @@
{
"title": "Rivers to Stratigraphy",
"author": "Andrew J. Moodie",
"version": "0.2.0",
"version": "0.2.6",
"shortdesc": "Explore how a migrating river becomes stratigraphy",
"difficulty": 7,
"license": "MIT",
Expand Down
9 changes: 7 additions & 2 deletions rivers2stratigraphy/__init__.py
@@ -1,3 +1,8 @@
from . import launcher
print('\n\n SedEdu -- rivers2stratigraphy module')

launcher.import_runner()
print('\n\nTo run the activity use command:\n')
print('rivers2stratigraphy.run()\n')

def run():
from . import gui
gui.Runner()
2 changes: 1 addition & 1 deletion rivers2stratigraphy/_version.py
@@ -1 +1 @@
__version__ = "0.2.5"
__version__ = "0.2.6"
1 change: 0 additions & 1 deletion rivers2stratigraphy/channel.py
@@ -1,7 +1,6 @@

import numpy as np
from matplotlib.patches import Polygon, Rectangle
from matplotlib.collections import PatchCollection, LineCollection
import shapely.geometry as sg
import shapely.ops as so

Expand Down
137 changes: 137 additions & 0 deletions rivers2stratigraphy/gui.py
@@ -0,0 +1,137 @@
"""
rivers2stratigraphy GUI -- build river stratigraphy interactively
Stratigraphic model based on LAB models, i.e., geometric channel body is
deposited in "matrix" of floodplain mud. The channel is always fixed to the
basin surface and subsidence is only control on vertical stratigraphy.
Horizontal stratigraphy is set by 1) lateral migration (drawn from a pdf)
and dampened for realism, and 2) avulsion that is set to a fixed value.
written by Andrew J. Moodie
amoodie@rice.edu
Feb 2018
"""


import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

from .strat import Strat
from .slider_manager import SliderManager
from .channel import ActiveChannel, State, ChannelBody
from . import geom, sedtrans, utils


class GUI(object):

"""
main GUI object that selects parameters for initialization and
handles creation of all the needed parts of the model. This class is
initialized below by class Runner if this file is run as __main__
"""

def __init__(self):
# initial conditions

config = utils.Config()

# model run params
config.dt = 100 # timestep in yrs
self._paused = False

# setup params
config.Cf = 0.004 # friction coeff
config.D50 = 300*1e-6
config.Beta = 1.5 # exponent to avulsion function
config.Df = 0.6 # dampening factor to lateral migration rate change
config.dxdtstd = 1 # stdev of lateral migration dist, [m/yr]?

# constants
config.conR = 1.65
config.cong = 9.81
config.conrhof = 1000
config.connu = 1.004e-6
config.Rep = geom.Repfun(config.D50, config.conR, config.cong, config.connu) # particle Reynolds num

# water discharge slider params
config.Qw = config.Qwinit = 1000
config.Qwmin = 200
config.Qwmax = 4000
config.Qwstep = 100

# subsidence slider params
config.sig = config.siginit = 2
config.sigmin = 0
config.sigmax = 5
config.sigstep = 0.2

# avulsion timescale slider params
config.Ta = config.Tainit = 500
config.Tamin = config.dt
config.Tamax = 1500
config.Tastep = 10

# yView slider params
config.yView = config.yViewinit = 100
config.yViewmin = 25
config.yViewmax = 250
config.yViewstep = 25

# basin width slider params
config.Bb = config.Bbinit = 4000 # width of belt (m)
config.Bbmin = 1
config.Bbmax = 10
config.Bbstep = 0.5

# additional initializations
config.Bast = 0 # Basin top level

# setup the figure
plt.rcParams['toolbar'] = 'None'
plt.rcParams['figure.figsize'] = 8, 6
self.fig, self.strat_ax = plt.subplots()
self.fig.canvas.set_window_title('SedEdu -- rivers2stratigraphy')
plt.subplots_adjust(left=0.085, bottom=0.1, top=0.95, right=0.5)
self.strat_ax.set_xlabel("channel belt (km)")
self.strat_ax.set_ylabel("stratigraphy (m)")
plt.ylim(-config.yView, 0.1*config.yView)
plt.xlim(-config.Bb/2, config.Bb/2)
self.strat_ax.xaxis.set_major_formatter( plt.FuncFormatter(
lambda v, x: str(v / 1000).format('%0.0f')) )

# add sliders
self.config = config
self.sm = SliderManager(self)


def pause_anim(self, event):
"""
pause animation by altering hidden var
"""
if self._paused:
self._paused = False
else:
self._paused = True



class Runner(object):
def __init__(self):
gui = GUI()

# time looping
gui.strat = Strat(gui)

anim = animation.FuncAnimation(gui.fig, gui.strat,
interval=100, blit=False,
save_count=None)

plt.show()



if __name__ == '__main__':
runner = Runner()


48 changes: 0 additions & 48 deletions rivers2stratigraphy/launcher.py

This file was deleted.

0 comments on commit 511b7f7

Please sign in to comment.