-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_code.py
More file actions
152 lines (119 loc) · 6.19 KB
/
run_code.py
File metadata and controls
152 lines (119 loc) · 6.19 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import numpy as np
import datetime as dt
from run_lidarcollect import *
from run_hydrocollect import *
from funcs.create_contours import *
from funcs.lidar_check import *
from funcs.calculate_beachvol import *
# from funcs.lidar_fillgaps import *
from run_makeplots import *
import pickle
# DEFINE WHERE FRF DATA FILES ARE LOCATED
# local_base = 'C:/Users/rdchlerh/Desktop/FRF_data/'
local_base = '/volumes/macDrive/FRF_data/'
# DEFINE TIME PERIOD OF INTEREST
time_beg = '2015-01-01T00:00:00' # 'YYYY-MM-DDThh:mm:ss' (string), time of interest BEGIN
time_end = '2025-01-01T00:00:00' # 'YYYY-MM-DDThh:mm:ss (string), time of interest END
tzinfo = dt.timezone(-dt.timedelta(hours=4)) # FRF = UTC-4
# DEFINE CONTOUR ELEVATIONS OF INTEREST
mwl = -0.13
mhw = 3.6
dune_toe = 3.22
cont_elev = np.array([mwl, dune_toe, mhw]) #np.arange(0,2.5,0.5) # <<< MUST BE POSITIVELY INCREASING
# DEFINE NUMBER OF PROFILES TO PLOT
num_profs_plot = 15
# DEFINE SUBDIR WITH LIDAR FILES
lidarfloc = local_base + 'dune_lidar/lidar_transect/'
lidarext = 'nc' # << change not recommended; defines file type to look for
# DEFINE SUBDIR WITH NOAA WATERLEVEL FILES
noaawlfloc = local_base + 'waterlevel/'
noaawlext = 'nc' # << change not recommended; defines file type to look for
# DEFINE SUBDIR WITH LIDAR HYDRO FILES
lidarhydrofloc = local_base + 'waves_lidar/lidar_hydro/'
lidarhydroext = 'nc' # << change not recommended; defines file type to look for
# -------------------- SAVE VARIABLES AS PICKLE --------------------
# convert period of interest to datenum
time_format = '%Y-%m-%dT%H:%M:%S'
epoch_beg = dt.datetime.strptime(time_beg,time_format).timestamp()
epoch_end = dt.datetime.strptime(time_end,time_format).timestamp()
TOI_duration = dt.datetime.fromtimestamp(epoch_end)-dt.datetime.fromtimestamp(epoch_beg)
# Save timing variables
with open('timeinfo.pickle','wb') as file:
pickle.dump([tzinfo,time_format,time_beg,time_end,epoch_beg,epoch_end,TOI_duration], file)
# Save file locations
with open('fileinfo.pickle','wb') as file:
pickle.dump([local_base,lidarfloc,lidarext,noaawlfloc,noaawlext,lidarhydrofloc,lidarhydroext],file)
# -------------------- EVERYTHING BELOW THIS LINE IS OLD/NONESSENTIAL --------------------
# -------------------- BEGIN RUN_CODE.PY --------------------
# run file run_lidarcollect.py
lidarelev,lidartime,lidar_xFRF,lidarelevstd,lidarmissing = run_lidarcollect(lidarfloc, lidarext)
# Remove weird data (first order filtering)
stdthresh = 0.05 # [m], e.g., 0.05 equals 5cm standard deviation in hrly reading
pmissthresh = 0.75 # [0-1]. e.g., 0.75 equals 75% time series missing
tmpii = (lidarelevstd >= stdthresh) + (lidarmissing > pmissthresh)
lidarelev[tmpii] = np.nan
# run file run_hydrocollect.py
wlmax_lidar,wlmin_lidar,wltime_lidar,wlmean_lidar = run_hydrocollect_func(noaawlfloc, noaawlext, lidarhydrofloc, lidarhydroext)
# run file create_contours.py
elev_input = lidarelev
cont_ts, cmean, cstd = create_contours(elev_input,lidartime,lidar_xFRF,cont_elev)
# Run quality check script
# exec(open('funcs/lidar_check.py').read())
daily_zstdev,daily_znum = lidar_check(elev_input,lidartime)
# Run beach volume calculation script -- MUST RUN create_contours.py FIRST!
beachVol, beachVol_xc, dBeachVol_dt,total_beachVol, total_dBeachVol_dt, total_obsBeachWid = calculate_beachvol(elev_input,lidartime,lidar_xFRF,cont_elev,cont_ts)
# make some plots
fig, ax1, ax2 = plot_ContourTimeSeries(cont_elev,cont_ts,lidartime,wlmean_lidar,wltime_lidar,lidar_xFRF)
ax2.grid(which='minor',axis='x')
ax1.grid(which='minor',axis='x')
# fig, ax = plot_ProfilesSubset(elev_input,lidartime,lidar_xFRF,num_profs_plot)
# fig, ax = plot_ProfilesTimestack(elev_input,lidartime,lidar_xFRF)
# fig, ax = plot_QualityDataWithContourPositions(elev_input, lidar_xFRF, cont_elev, cmean, cstd)
# fig, ax = plot_QualityDataTimeSeries(elev_input,lidartime)
# fig, ax1,ax2,ax3 = plot_DailyVariationTimestack(elev_input,lidartime,lidar_xFRF,daily_zstdev,daily_znum)
# fig, ax1, ax2 = plot_BeachVolume(lidartime,cont_elev,beachVol,dBeachVol_dt)
# # Try filling gaps??
# halfspan_time = 6
# halfspan_x = 10
# lidar_filled = lidar_fillgaps(lidarelev,lidartime,lidar_xFRF,halfspan_time,halfspan_x)
#
# # run file run_hydrocollect.py
# wlmax_lidar,wlmin_lidar,wltime_lidar,wlmean_lidar = run_hydrocollect_func(noaawlfloc, noaawlext, lidarhydrofloc, lidarhydroext)
#
# # Run quality check script
# # exec(open('funcs/lidar_check.py').read())
# daily_zstdev,daily_znum = lidar_check(elev_input,lidartime)
#
# # Run beach volume calculation script -- MUST RUN create_contours.py FIRST!
# beachVol, beachVol_xc, dBeachVol_dt,total_beachVol, total_dBeachVol_dt, total_obsBeachWid = calculate_beachvol(elev_input,lidartime,lidar_xFRF,cont_elev,cont_ts)
#
# # make some plots
# fig, ax1, ax2 = plot_ContourTimeSeries(cont_elev,cont_ts,lidartime,wlmean_lidar,wltime_lidar,lidar_xFRF)
# ax2.grid(which='minor',axis='x')
# ax1.grid(which='minor',axis='x')
# # fig, ax = plot_ProfilesSubset(elev_input,lidartime,lidar_xFRF,num_profs_plot)
# # fig, ax = plot_ProfilesTimestack(elev_input,lidartime,lidar_xFRF)
# # fig, ax = plot_QualityDataWithContourPositions(elev_input, lidar_xFRF, cont_elev, cmean, cstd)
# # fig, ax = plot_QualityDataTimeSeries(elev_input,lidartime)
# # fig, ax1,ax2,ax3 = plot_DailyVariationTimestack(elev_input,lidartime,lidar_xFRF,daily_zstdev,daily_znum)
# # fig, ax1, ax2 = plot_BeachVolume(lidartime,cont_elev,beachVol,dBeachVol_dt)
#
#
# # Try filling gaps??
# halfspan_time = 6
# halfspan_x = 10
# lidar_filled = lidar_fillgaps(lidarelev,lidartime,lidar_xFRF,halfspan_time,halfspan_x)
# #
# # # Plot the new lidar, filled in gaps
# fig1, ax1, fig2, ax2 = plot_PrefillPostfillTimestack(lidarelev,lidar_filled,lidartime,lidar_xFRF)
# #
# # # Re-run file create_contours.py
# # # elev_input = lidar_filled
# # cont_ts, cmean, cstd = create_contours(elev_input,lidartime,lidar_xFRF,cont_elev)
# #
# # # Re-run beach volume calculation script
# # beachVol, beachVol_xc, dBeachVol_dt = calculate_beachvol(elev_input,lidartime,lidar_xFRF,cont_elev,cont_ts)
# #
# # # Re-run some plots
# # fig, ax1, ax2 = plot_ContourTimeSeries(cont_elev,cont_ts,lidartime,wlmax_lidar,wlmin_lidar,wltime_lidar)
# # fig, ax1, ax2 = plot_BeachVolume(lidartime,cont_elev,beachVol,dBeachVol_dt)