-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_stimpy.py
84 lines (76 loc) · 3.27 KB
/
example_stimpy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Example script for using the stimpy module to run 1D STIM profiles
The stimpy module contains a variety of classes that are used within a single
stimpy run. The classes are:
- Stream - class containing basic stream geometry and methods for updating stream profiles
- GenerateRunoff - class containing runoff and discharge details along profile and methods for
calculating and updating details of the runoff as topography evolves
- StimEroder - class containing methods for updating topography through a finite difference solution
of the stochastic threshold incision equations
- StimCounter - class containing information on timesteps and methods for incrementing timesteps
- Stim1D - model class that incorporates all other classes and methods for plotting results of model
"""
import stimpy as st
# Primary location to store outputs
master_location='/Users/person/model_outputs/'
# Folder to store individual timesteps
output_dir=master_location+'stim_test'
## Generate stream instance
# Inputs are:
# length of stream in meters (25000)
# number of bins for calculating runoff and variability (25)
# various optional inputs (see 'stream.py'), e.g., dx
sObj=st.Stream(25000,25,dx=100)
## Generate runoff instance
# Inputs are:
# stream instance (sObj)
# the type of rule for relating topography to runoff and variability ('emp')
# if rule is 'emp' or 'emp_rain', must specify a valid location for which relationships have been generated
# (location='Greater Caucasus')
# control on whether events are linked or unlinked, (random_state='unlinked')
rObj=st.GenerateRunoff(sObj,'emp',random_state='unlinked',location='Greater Caucasus')
## Generate eroder instance
# Inputs are:
# stream instance (sObj)
# uplift rate in m/yr (1e-3)
eObj=st.StimEroder(sObj,1e-3)
# Uplift can also spatially vary, but must be same dimensions as x
# u=np.linspace(1e-3,2e-3,len(sObj.x))
# eObj=st.StimEroder(sObj,u)
## Generate counter instance
# Inputs are:
# timestep in days (1) - using a value other than 1 will produce unexpected results
# length of run in years (500000)
# frequency of outputs being saved in years (5000)
# length of precomputed runoff in years (100) - shorter values will increase computation time
cObj=st.StimCounter(1,500000,5000,100)
## Generate model instance
# Inputs are:
# location to store outputs (output_dir)
mObj=st.Stim1D(output_dir)
# Various methods within model instance
# Run model
mObj.run_new_model(cObj,sObj,eObj,rObj)
# Restart model
# Inputs are:
# Time to restart the model (500000)
# New time to run model to (1000000)
mObj.restart_model(500000,1000000)
# Restart model with different save location and updated timestep (e.g., to run a portion of the
# model at a finer resolution)
# Inputs are:
# Time to restart model (300000)
# New time to run model to (310000)
# Updated save frequency (200)
# New location to save ouptuts to (master_location+'stim_subsample_test')
mObj.restart_model(300000,310000,200,master_location+'stim_subsample_test')
# Plot profile results
# Inputs are:
# title for grapth ('STIM Model - Restart')
# plot every 'n' timesteps (n_step=10)
mObj.plot_profile_results('STIM Model - Restart',n_step=10)
# Run a monte carlo model on the last time step
mc_dict=rObj.monte_carlo_runoff(sObj,100,100)
rObj.plot_monte_carlo(sObj,mc_dict)