-
Notifications
You must be signed in to change notification settings - Fork 1
/
CalibrateRealChannel.py
62 lines (52 loc) · 2.53 KB
/
CalibrateRealChannel.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
"""
This script uses the HKplus functions to load an existing centerline output from Mtlab toolbox RivMap (or any other 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 = 10; #approximate for HK model
#constant width (m)
deltas = 50; #spacing of nodes along centerline (m)
nit = 200 # number of iterations
Cf = 0.022 # dimensionless Chezy friction factor
kl = 5/(365*24*60*60.0) # migration rate constant (m/s)
dt = .5*365*24*60*60.0 # time step (s)
pad= 100 # dont change
saved_ts = 20 # which time steps centerline will be saved at
#Set Variables fro nonlocal efects
#Set Variables fror Cutoff nonlocal efects
decay_rate = dt/(5*(365*24*60*60.0)); #this is the half-life on nonlocal effects, in units of seconds
bump_scale = 2 #this is the magntiude of nonlocal effects in relative difference between
cut_thresh = 5 #how many cutoffs to simulate, arbitrary if running for time
#Set Result Directory
result_dir = "sample_data/InitialChannel/" ##change this to wherever you want to save your results
#Load Existing Centerline
filepath_points ="sample_data/RealCenterlines/firstcl_reachC_1984.csv"
filepath_widths = "sample_data/RealCenterlines/width_reachC_1984.csv"
ch= hkp.generate_channel_from_file(list([filepath_points, filepath_widths]))
W = ch.W
crdist = W # how close banks get before cutoff in m
#Initialize Channel Belt for Migration
chb = hkp.ChannelBelt(channels=[ch],cutoffs=[],cl_times=[0.0],cutoff_times=[], cutoff_dists = [], decay_rate = decay_rate, bump_scale = bump_scale, cut_thresh = cut_thresh)
#Plot initial channel
chb.plot_channels()
plt.title("Initial Centerline")
plt.show()
#Migrate
chb.migrate_cuts(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.tight_layout()
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("sample_data/InitialChannel/InitialCL_2mpyr_small.csv", header = False, index = False)
chb.cutoff_distributions(int(chb.cutoff_times[-1]), result_dir, 'Real')
plt.show()