-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSimulateCutoffDistribution.py
86 lines (69 loc) · 2.46 KB
/
SimulateCutoffDistribution.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
"""
This script uses the HKplus functions to load an existing centerline, run it for a certain number of years, then save the resulting cutoff distribution and bend-by-bend migration rate measurements.
"""
import math
import matplotlib.pyplot as plt
import HKplus as hkp
import numpy as np
import pandas as pd
import os
# 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 n2des along 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 = 100 # timeteps between saving centerlines
crdist = 4 * W # how close banks get before cutoff in m
cut_thresh = 500 # how many cutoffs to simulate, arbitrary if running for time
# 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 mode for titles
mode = "66"
# Set Result Directory
result_dir = "results/experiments/" + str(mode) + "/"
# Load existing Centerline
filepath = "data/InitialChannel/InitialCL_" + str(mode) + ".csv"
ch = hkp.load_initial_channel(filepath, W, D, deltas)
# Initalize Channel Belt for migration
chb = hkp.ChannelBelt(
channels=[ch],
cutoffs=[],
cl_times=[0],
cutoff_times=[],
cutoff_dists=[],
decay_rate=decay_rate,
bump_scale=bump_scale,
cut_thresh=cut_thresh,
sinuosity=[],
)
# Plot initial centerline
chb.plot_channels()
plt.show()
# Migrate
chb.migrate_cuts(saved_ts, deltas, pad, crdist, Cf, kl, dt)
# Plot resulting Centerline
chb.plot_channels()
plt.show()
# Save Sinuosity time series
times = chb.cl_times
sins = chb.sinuosity
# Save Cutoff Distributions for Clustering Tests #
chb.cutoff_distributions(int(chb.cutoff_times[-1]), result_dir, mode)
plt.title(str(len(chb.cutoff_times)) + " cutoffs")
plt.savefig(
result_dir + mode + "_" + str(len(chb.cutoff_times)) + "_timevsspace.png",
bbox_inches="tight",
)
plt.close()
# 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 + "InitialChannel_result.csv", header=False, index=False)