pyadps 0.2.1b0__py3-none-any.whl → 0.3.0b0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyadps/pages/01_Read_File.py +92 -17
- pyadps/pages/02_View_Raw_Data.py +69 -33
- pyadps/pages/04_Sensor_Health.py +892 -0
- pyadps/pages/05_QC_Test.py +478 -0
- pyadps/pages/06_Profile_Test.py +959 -0
- pyadps/pages/07_Velocity_Test.py +599 -0
- pyadps/pages/{07_Write_File.py → 08_Write_File.py} +127 -52
- pyadps/pages/09_Auto_process.py +62 -0
- pyadps/utils/__init__.py +2 -3
- pyadps/utils/autoprocess.py +129 -46
- pyadps/utils/metadata/config.ini +22 -4
- pyadps/utils/metadata/demo.000 +0 -0
- pyadps/utils/plotgen.py +499 -0
- pyadps/utils/profile_test.py +491 -126
- pyadps/utils/pyreadrdi.py +13 -6
- pyadps/utils/readrdi.py +78 -6
- pyadps/utils/script.py +21 -23
- pyadps/utils/sensor_health.py +120 -0
- pyadps/utils/signal_quality.py +343 -23
- pyadps/utils/velocity_test.py +75 -27
- pyadps/utils/writenc.py +8 -1
- {pyadps-0.2.1b0.dist-info → pyadps-0.3.0b0.dist-info}/METADATA +3 -3
- pyadps-0.3.0b0.dist-info/RECORD +33 -0
- {pyadps-0.2.1b0.dist-info → pyadps-0.3.0b0.dist-info}/WHEEL +1 -1
- pyadps/pages/04_QC_Test.py +0 -334
- pyadps/pages/05_Profile_Test.py +0 -575
- pyadps/pages/06_Velocity_Test.py +0 -341
- pyadps/utils/cutbin.py +0 -413
- pyadps/utils/regrid.py +0 -279
- pyadps-0.2.1b0.dist-info/RECORD +0 -31
- {pyadps-0.2.1b0.dist-info → pyadps-0.3.0b0.dist-info}/LICENSE +0 -0
- {pyadps-0.2.1b0.dist-info → pyadps-0.3.0b0.dist-info}/entry_points.txt +0 -0
pyadps/pages/06_Velocity_Test.py
DELETED
@@ -1,341 +0,0 @@
|
|
1
|
-
import numpy as np
|
2
|
-
import pandas as pd
|
3
|
-
import plotly.express as px
|
4
|
-
import plotly.graph_objects as go
|
5
|
-
import streamlit as st
|
6
|
-
from plotly.subplots import make_subplots
|
7
|
-
from plotly_resampler import FigureResampler
|
8
|
-
from streamlit.runtime.state import session_state
|
9
|
-
from utils.profile_test import side_lobe_beam_angle
|
10
|
-
from utils.signal_quality import default_mask
|
11
|
-
from utils.velocity_test import (despike, flatline, magnetic_declination,
|
12
|
-
velocity_cutoff, wmm2020api, velocity_modifier)
|
13
|
-
|
14
|
-
if "flead" not in st.session_state:
|
15
|
-
st.write(":red[Please Select Data!]")
|
16
|
-
st.stop()
|
17
|
-
|
18
|
-
flobj = st.session_state.flead
|
19
|
-
vlobj = st.session_state.vlead
|
20
|
-
fdata = flobj.fleader
|
21
|
-
vdata = vlobj.vleader
|
22
|
-
|
23
|
-
|
24
|
-
####### Initialize Mask File ##############
|
25
|
-
# Is this the best way?
|
26
|
-
if st.session_state.isProfileMask or st.session_state.isQCMask:
|
27
|
-
st.write(":grey[Working on a saved mask file ...]")
|
28
|
-
if st.session_state.isVelocityMask:
|
29
|
-
st.write(
|
30
|
-
":orange[Warning: Velocity test already completed. Reset to change settings.]"
|
31
|
-
)
|
32
|
-
reset_selectbox = st.selectbox(
|
33
|
-
"Choose reset option",
|
34
|
-
("Profile Test", "QC Test", "Default"),
|
35
|
-
index=None,
|
36
|
-
placeholder="Reset mask to ...",
|
37
|
-
)
|
38
|
-
if reset_selectbox == "Default":
|
39
|
-
st.write("Default mask file selected")
|
40
|
-
st.session_state.maskd = st.session_state.orig_mask
|
41
|
-
st.session_state.dummyvelocity = st.session_state.velocity
|
42
|
-
elif reset_selectbox == "QC Test":
|
43
|
-
st.write("QC Test mask file selected")
|
44
|
-
st.session_state.maskd = st.session_state.qc_mask
|
45
|
-
st.session_state.dummyvelocity = st.session_state.velocity
|
46
|
-
elif reset_selectbox == "Profile Test":
|
47
|
-
st.session_state.maskd = st.session_state.profile_mask
|
48
|
-
if st.session_state.isGridSave:
|
49
|
-
st.session_state.dummyvelocity = st.session_state.velocity_regrid
|
50
|
-
else:
|
51
|
-
st.session_state.dummyvelocity = st.session_state.velocity
|
52
|
-
else:
|
53
|
-
st.session_state.maskd = st.session_state.velocity_mask
|
54
|
-
st.session_state.dummyvelocity = st.session_state.velocity
|
55
|
-
else:
|
56
|
-
if st.session_state.isProfileMask:
|
57
|
-
st.session_state.maskd = st.session_state.profile_mask
|
58
|
-
elif st.session_state.isQCMask:
|
59
|
-
st.session_state.maskd = st.session_state.qc_mask
|
60
|
-
else:
|
61
|
-
st.session_state.maskd = st.session_state.orig_mask
|
62
|
-
else:
|
63
|
-
st.write(":grey[Creating a new mask file ...]")
|
64
|
-
|
65
|
-
|
66
|
-
if "isCutoff" not in st.session_state:
|
67
|
-
st.session_state.isMagnet = False
|
68
|
-
st.session_state.isCutoff = False
|
69
|
-
st.session_state.isDespike = False
|
70
|
-
st.session_state.isFlatline = False
|
71
|
-
|
72
|
-
if "maskd" not in st.session_state:
|
73
|
-
if st.session_state.isProfileMask:
|
74
|
-
st.session_state.maskd = np.copy(st.session_state.profile_mask)
|
75
|
-
elif st.session_state.isQCMask:
|
76
|
-
st.session_state.maskd = np.copy(st.session_state.qc_mask)
|
77
|
-
else:
|
78
|
-
st.session_state.maskd = np.copy(st.session_state.orig_mask)
|
79
|
-
|
80
|
-
# If data are not regrided use the default one
|
81
|
-
if st.session_state.isGridSave:
|
82
|
-
st.session_state.dummyvelocity = np.copy(st.session_state.velocity_regrid)
|
83
|
-
else:
|
84
|
-
st.session_state.dummyvelocity = np.copy(st.session_state.velocity)
|
85
|
-
|
86
|
-
velocity = st.session_state.dummyvelocity
|
87
|
-
|
88
|
-
ensembles = st.session_state.head.ensembles
|
89
|
-
cells = flobj.field()["Cells"]
|
90
|
-
x = np.arange(0, ensembles, 1)
|
91
|
-
y = np.arange(0, cells, 1)
|
92
|
-
|
93
|
-
|
94
|
-
########### Introduction ##########
|
95
|
-
st.header("Velocity Test", divider="orange")
|
96
|
-
|
97
|
-
st.write(
|
98
|
-
"""
|
99
|
-
The processing in this page apply only to the velocity data.
|
100
|
-
"""
|
101
|
-
)
|
102
|
-
|
103
|
-
############ Magnetic Declination ##############
|
104
|
-
st.header("Magnetic Declination", divider="blue")
|
105
|
-
st.write(
|
106
|
-
"""
|
107
|
-
* The magnetic declination is obtained from World Magnetic Model 2020 (WMM2020).
|
108
|
-
The python wrapper module `wmm2020` is available from this [Link](https://github.com/space-physics/wmm2020).
|
109
|
-
|
110
|
-
* The API method utilizes the online magnetic declination service provided by the National Geophysical Data Center (NGDC)
|
111
|
-
of the National Oceanic and Atmospheric Administration (NOAA) to calculate the magnetic declination. The service is available at this [link](https://www.ngdc.noaa.gov/geomag/calculators/magcalc.shtml#declination).
|
112
|
-
Internet connection is necessary for this method to work.
|
113
|
-
|
114
|
-
* In the manual method, the user can directly enter the magnetic declination.
|
115
|
-
|
116
|
-
If the magnetic declination is reset, re-run the remaining tests again.
|
117
|
-
"""
|
118
|
-
)
|
119
|
-
|
120
|
-
# Selecting the method to calculate magnetic declination.
|
121
|
-
method = st.radio("Select a method", ("WMM2020", "API", "Manual"), horizontal=True)
|
122
|
-
# method = method - 1
|
123
|
-
st.session_state.method = method
|
124
|
-
|
125
|
-
if "isMagnetButton" not in st.session_state:
|
126
|
-
st.session_state.isMagnetButton = False
|
127
|
-
|
128
|
-
|
129
|
-
def toggle_btns():
|
130
|
-
st.session_state.isMagnetButton = not st.session_state.isMagnetButton
|
131
|
-
|
132
|
-
|
133
|
-
with st.form(key="magnet_form"):
|
134
|
-
if st.session_state.method == "WMM2020":
|
135
|
-
st.session_state.isMagnet = False
|
136
|
-
lat = st.number_input("Latitude", -90.0, 90.0, 0.0, step=1.0)
|
137
|
-
lon = st.number_input("Longitude", 0.0, 360.0, 0.1, step=1.0, format="%.4f")
|
138
|
-
depth = st.number_input("Depth", 0, 1000, 0, step=1)
|
139
|
-
year = st.number_input("Year", 1950, 2100, 2024, 1)
|
140
|
-
elif st.session_state.method == "API":
|
141
|
-
st.session_state.isMagnet = False
|
142
|
-
lat = st.number_input("Latitude", -90.0, 90.0, 0.0, step=1.0)
|
143
|
-
lon = st.number_input("Longitude", 0.0, 360.0, 0.1, step=1.0, format="%.4f")
|
144
|
-
year = st.number_input("Year", 1950, 2100, 2024, 1)
|
145
|
-
else:
|
146
|
-
st.session_state.isMagnet = False
|
147
|
-
mag = [[st.number_input("Declination", -180.0, 180.0, 0.0, 0.1)]]
|
148
|
-
|
149
|
-
if st.session_state.method == "Manual":
|
150
|
-
button_name = "Accept"
|
151
|
-
else:
|
152
|
-
button_name = "Compute"
|
153
|
-
|
154
|
-
|
155
|
-
if st.form_submit_button(
|
156
|
-
button_name, on_click=toggle_btns, disabled=st.session_state.isMagnetButton
|
157
|
-
):
|
158
|
-
if st.session_state.method == "WMM2020":
|
159
|
-
try:
|
160
|
-
mag = magnetic_declination(lat, lon, depth, year)
|
161
|
-
st.session_state.dummyvelocity = velocity_modifier(velocity, mag)
|
162
|
-
st.session_state.lat = lat
|
163
|
-
st.session_state.lon = lon
|
164
|
-
st.session_state.magnetic_dec_depth = depth
|
165
|
-
st.session_state.year = year
|
166
|
-
st.session_state.angle = np.trunc(mag[0][0])
|
167
|
-
st.session_state.isMagnet = True
|
168
|
-
except:
|
169
|
-
st.write(":red[Process failed! please use other methods: API or Manual]")
|
170
|
-
|
171
|
-
elif st.session_state.method == "API":
|
172
|
-
try:
|
173
|
-
mag = wmm2020api(lat, lon, year)
|
174
|
-
st.session_state.dummyvelocity = velocity_modifier(velocity, mag)
|
175
|
-
st.session_state.lat = lat
|
176
|
-
st.session_state.lon = lon
|
177
|
-
st.session_state.year = year
|
178
|
-
st.session_state.angle = np.trunc(mag[0][0])
|
179
|
-
st.session_state.isMagnet = True
|
180
|
-
except:
|
181
|
-
st.write(":red[Connection error! please check the internet or use other methods: WMM2020 or Manual]")
|
182
|
-
|
183
|
-
else:
|
184
|
-
st.session_state.dummyvelocity = velocity_modifier(velocity, mag)
|
185
|
-
st.session_state.angle = np.trunc(mag[0][0])
|
186
|
-
st.session_state.isMagnet = True
|
187
|
-
|
188
|
-
|
189
|
-
if st.session_state.isMagnet:
|
190
|
-
st.write(f"Magnetic declination: {st.session_state.angle}\u00b0")
|
191
|
-
st.write(":green[Magnetic declination correction applied to velocities]")
|
192
|
-
|
193
|
-
if st.button(
|
194
|
-
"Reset Magnetic Declination",
|
195
|
-
on_click=toggle_btns,
|
196
|
-
disabled=not st.session_state.isMagnetButton,
|
197
|
-
):
|
198
|
-
st.session_state.dummyvelocity = np.copy(velocity)
|
199
|
-
st.session_state.isMagnet = False
|
200
|
-
|
201
|
-
############# Velocity Cutoffs #################
|
202
|
-
st.header("Velocity Cutoffs", divider="blue")
|
203
|
-
st.write(
|
204
|
-
"""
|
205
|
-
Drop velocities whose magnitude is larger than the threshold.
|
206
|
-
"""
|
207
|
-
)
|
208
|
-
with st.form(key="cutbin_form"):
|
209
|
-
maxuvel = st.number_input("Maximum Zonal Velocity Cutoff (cm/s)", 0, 2000, 250, 1)
|
210
|
-
maxvvel = st.number_input(
|
211
|
-
"Maximum Meridional Velocity Cutoff (cm/s)", 0, 2000, 250, 1
|
212
|
-
)
|
213
|
-
maxwvel = st.number_input("Maximum Vertical Velocity Cutoff (cm/s)", 0, 2000, 15, 1)
|
214
|
-
submit_cutoff = st.form_submit_button(label="Submit")
|
215
|
-
|
216
|
-
if submit_cutoff:
|
217
|
-
|
218
|
-
st.session_state.maxuvel = maxuvel
|
219
|
-
st.session_state.maxvvel = maxvvel
|
220
|
-
st.session_state.maxwvel = maxwvel
|
221
|
-
|
222
|
-
st.session_state.maskd = velocity_cutoff(
|
223
|
-
velocity[0, :, :], st.session_state.maskd, cutoff=maxuvel
|
224
|
-
)
|
225
|
-
st.session_state.maskd = velocity_cutoff(
|
226
|
-
velocity[1, :, :], st.session_state.maskd, cutoff=maxvvel
|
227
|
-
)
|
228
|
-
st.session_state.maskd = velocity_cutoff(
|
229
|
-
velocity[2, :, :], st.session_state.maskd, cutoff=maxwvel
|
230
|
-
)
|
231
|
-
st.session_state.isCutoff = True
|
232
|
-
|
233
|
-
|
234
|
-
if st.session_state.isCutoff:
|
235
|
-
st.write(":green[Cutoff Applied]")
|
236
|
-
a = {
|
237
|
-
"Max. Zonal Velocity": maxuvel,
|
238
|
-
"Max. Meridional Velocity": maxvvel,
|
239
|
-
"Max. Vertical Velocity": maxwvel,
|
240
|
-
}
|
241
|
-
st.write(a)
|
242
|
-
|
243
|
-
|
244
|
-
############## DESPIKE DATA #################
|
245
|
-
st.header("Despike Data", divider="blue")
|
246
|
-
despike_kernal = st.number_input(
|
247
|
-
"Enter Despike Kernal Size for Median Filter", 0, 1000, 5, 1
|
248
|
-
)
|
249
|
-
despike_cutoff = st.number_input("Enter Despike Cutoff (mm/s)", 0, 1000, 150, 1)
|
250
|
-
despike_button = st.button("Despike")
|
251
|
-
if despike_button:
|
252
|
-
|
253
|
-
st.session_state.despike_kernal = despike_kernal
|
254
|
-
st.session_state.despike_cutoff = despike_cutoff
|
255
|
-
|
256
|
-
st.session_state.maskd = despike(
|
257
|
-
velocity[0, :, :],
|
258
|
-
st.session_state.maskd,
|
259
|
-
kernal_size=despike_kernal,
|
260
|
-
cutoff=despike_cutoff,
|
261
|
-
)
|
262
|
-
st.session_state.maskd = despike(
|
263
|
-
velocity[1, :, :],
|
264
|
-
st.session_state.maskd,
|
265
|
-
kernal_size=despike_kernal,
|
266
|
-
cutoff=despike_cutoff,
|
267
|
-
)
|
268
|
-
st.session_state.isDespike = True
|
269
|
-
|
270
|
-
if st.session_state.isDespike:
|
271
|
-
st.write(":green[Data Despiked]")
|
272
|
-
b = {
|
273
|
-
"Kernal Size": despike_kernal,
|
274
|
-
"Despike Cutoff": despike_cutoff,
|
275
|
-
}
|
276
|
-
st.write(b)
|
277
|
-
|
278
|
-
st.header("Remove Flatline", divider="blue")
|
279
|
-
flatline_kernal = st.number_input("Enter Flatline Kernal Size", 0, 100, 13, 1)
|
280
|
-
flatline_cutoff = st.number_input("Enter Flatline deviation", 0, 100, 1, 1)
|
281
|
-
|
282
|
-
flatline_button = st.button("Remove Flatline")
|
283
|
-
|
284
|
-
if flatline_button:
|
285
|
-
st.session_state.flatline_kernal = flatline_kernal
|
286
|
-
st.session_state.flatline_cutoff = flatline_cutoff
|
287
|
-
|
288
|
-
st.session_state.maskd = flatline(
|
289
|
-
velocity[0, :, :],
|
290
|
-
st.session_state.maskd,
|
291
|
-
kernal_size=flatline_kernal,
|
292
|
-
cutoff=flatline_cutoff,
|
293
|
-
)
|
294
|
-
st.session_state.maskd = flatline(
|
295
|
-
velocity[1, :, :],
|
296
|
-
st.session_state.maskd,
|
297
|
-
kernal_size=flatline_kernal,
|
298
|
-
cutoff=flatline_cutoff,
|
299
|
-
)
|
300
|
-
st.session_state.maskd = flatline(
|
301
|
-
velocity[2, :, :],
|
302
|
-
st.session_state.maskd,
|
303
|
-
kernal_size=flatline_kernal,
|
304
|
-
cutoff=flatline_cutoff,
|
305
|
-
)
|
306
|
-
st.session_state.isFlatline = True
|
307
|
-
|
308
|
-
if st.session_state.isFlatline:
|
309
|
-
st.write(":green[Flatline Removed]")
|
310
|
-
b = {
|
311
|
-
"Kernal Size": flatline_kernal,
|
312
|
-
"Flatline Cutoff": flatline_cutoff,
|
313
|
-
}
|
314
|
-
st.write(b)
|
315
|
-
|
316
|
-
|
317
|
-
##################### SAVE DATA ###################
|
318
|
-
st.header("Save & Reset Data", divider="blue")
|
319
|
-
|
320
|
-
|
321
|
-
def reset_data():
|
322
|
-
st.session_state.dummyvelocity = np.copy(st.session_state.velocity_regrid)
|
323
|
-
st.session_state.isMagnet = False
|
324
|
-
st.session_state.isCutoff = False
|
325
|
-
st.session_state.isDespike = False
|
326
|
-
st.session_state.isFlatline = False
|
327
|
-
|
328
|
-
|
329
|
-
col1, col2 = st.columns([1, 1])
|
330
|
-
with col1:
|
331
|
-
save_button = st.button(label="Save Data")
|
332
|
-
if save_button:
|
333
|
-
st.session_state.veltest_velocity = np.copy(st.session_state.dummyvelocity)
|
334
|
-
st.session_state.velocity_mask = np.copy(st.session_state.maskd)
|
335
|
-
st.session_state.isVelocityMask = True
|
336
|
-
st.write(":green[Mask data saved]")
|
337
|
-
else:
|
338
|
-
st.write(":red[Data not saved]")
|
339
|
-
|
340
|
-
with col2:
|
341
|
-
st.button(label="Reset Data", on_click=reset_data)
|