-
Notifications
You must be signed in to change notification settings - Fork 1
/
CalibrateNewChannel.py
95 lines (77 loc) · 2.74 KB
/
CalibrateNewChannel.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
85
86
87
88
89
90
91
92
93
94
95
"""
This script uses the HKplus functions to generate a channel centerline,
run it for a certain number of years,
then save the resulting centerline for later use.
@JA 2021
"""
import math
import matplotlib.pyplot as plt
import HKplus as hkp
import numpy as np
import pandas as pd
# Set Variables for centerline and curvature calculation
D = 3.4 # constant width-average channel depth (m)
W = 100 # constant channel width (m)
deltas = W // 2
# spacing of nodes along centerline
nit = 10000 # number of iterations/how many timesteps to migrate the centerline
Cf = 0.005 # dimensionless Chezy friction factor
kl = 35 / (365 * 24 * 60 * 60.0) # migration rate constant (m/s)
dt = 0.25 * 365 * 24 * 60 * 60.0 # time step (s)
pad = 100 # number of nodes for periodic boundary
saved_ts = 5000 # timesteps between saving centerlines
crdist = 4 * W # how close banks get before cutoff in m
Length = (50 * W) * 10
# Set Variables fror Cutoff nonlocal efects
tau = 8 # e-folding timescale for nonlocal effects in years
decay_rate = dt / (tau * (365 * 24 * 60 * 60.0))
# this is the half-life on nonlocal effects, in units of seconds
bump_scale = 3 # this is the magntiude of nonlocal effects in relative difference
# Set Result Directory
result_dir = (
"data/InitialChannel/" ##change this to wherever you want to save your results
)
# Choose name for centerline
name = "66"
# Initiate Channel Object
ch = hkp.generate_initial_channel(W, D, deltas, pad, Length)
# Initiate Channel Belt for migrating channel object
chb = hkp.ChannelBelt(
channels=[ch],
cutoffs=[],
cl_times=[0.0],
cutoff_times=[],
cutoff_dists=[],
decay_rate=decay_rate,
bump_scale=bump_scale,
cut_thresh=1000,
sinuosity=[1],
)
# Plot initial centerline
# chb.plot_channels()
# plt.title(str(int(nit*dt/(365*24*60*60.0)))+ " years at "+ str(kl*(365*24*60*60.0))+ "m/yr")
# plt.show()
# Migrate Centerline for nit
chb.migrate_years(nit, saved_ts, deltas, pad, crdist, Cf, kl, dt)
# Plot Resulting Centerline
chb.plot_channels()
plt.title(
str(int(nit * dt / (365 * 24 * 60 * 60.0)))
+ " years at "
+ str(kl * (365 * 24 * 60 * 60.0))
+ "m/yr"
)
plt.show()
# Save Sinuosity time series
times = chb.cl_times
sins = chb.sinuosity
# uncomment to save sinuosity series
# sinseries = pd.DataFrame({'time':times, 'sinuosity': sins});
# sinseries.to_csv(result_dir+"InitialCL_"+name+"sinseries"+".csv", header = True, index = False)
hkp.plot_sinuosity(times, sins)
plt.show()
# Save Resulting Centerline
xes = chb.channels[-1].x
yes = chb.channels[-1].y
cl = pd.DataFrame({"x": xes, "y": yes})
cl.to_csv(result_dir + "InitialCL_" + name + ".csv", header=False, index=False)