pyadps 0.1.0__py3-none-any.whl → 0.1.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/Home_Page.py +5 -11
- pyadps/pages/01_Read_File.py +16 -190
- pyadps/pages/02_View_Raw_Data.py +33 -69
- pyadps/pages/03_Download_Raw_File.py +60 -124
- pyadps/pages/04_QC_Test.py +283 -0
- pyadps/pages/05_Profile_Test.py +389 -0
- pyadps/pages/06_Velocity_Test.py +293 -0
- pyadps/pages/07_Write_File.py +367 -0
- pyadps/utils/__init__.py +3 -3
- pyadps/utils/cutbin.py +413 -0
- pyadps/utils/plotgen.py +3 -505
- pyadps/utils/profile_test.py +145 -526
- pyadps/utils/pyreadrdi.py +6 -13
- pyadps/utils/readrdi.py +20 -167
- pyadps/utils/regrid.py +122 -0
- pyadps/utils/script.py +147 -197
- pyadps/utils/signal_quality.py +24 -344
- pyadps/utils/velocity_test.py +16 -99
- pyadps/utils/writenc.py +27 -104
- {pyadps-0.1.0.dist-info → pyadps-0.1.0b0.dist-info}/METADATA +22 -54
- pyadps-0.1.0b0.dist-info/RECORD +29 -0
- {pyadps-0.1.0.dist-info → pyadps-0.1.0b0.dist-info}/WHEEL +1 -1
- pyadps-0.1.0b0.dist-info/entry_points.txt +3 -0
- pyadps/pages/04_Sensor_Health.py +0 -905
- pyadps/pages/05_QC_Test.py +0 -476
- pyadps/pages/06_Profile_Test.py +0 -971
- pyadps/pages/07_Velocity_Test.py +0 -600
- pyadps/pages/08_Write_File.py +0 -574
- pyadps/pages/09_Auto_process.py +0 -62
- pyadps/utils/autoprocess.py +0 -530
- pyadps/utils/metadata/config.ini +0 -99
- pyadps/utils/metadata/demo.000 +0 -0
- pyadps/utils/sensor_health.py +0 -120
- pyadps-0.1.0.dist-info/RECORD +0 -33
- pyadps-0.1.0.dist-info/entry_points.txt +0 -5
- {pyadps-0.1.0.dist-info → pyadps-0.1.0b0.dist-info}/LICENSE +0 -0
pyadps/utils/script.py
CHANGED
@@ -1,205 +1,155 @@
|
|
1
|
-
import
|
1
|
+
import sys
|
2
|
+
|
2
3
|
import matplotlib.pyplot as plt
|
3
4
|
import numpy as np
|
4
5
|
import pyadps.utils.readrdi as rd
|
5
|
-
from pyadps.utils.
|
6
|
+
from pyadps.utils.cutbin import CutBins
|
7
|
+
from pyadps.utils.plotgen import plotmask, plotvar
|
6
8
|
from pyadps.utils.profile_test import side_lobe_beam_angle, trim_ends
|
7
|
-
from pyadps.utils.
|
8
|
-
from pyadps.utils.signal_quality import (
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
pg_check,
|
13
|
-
correlation_check,
|
14
|
-
echo_check,
|
15
|
-
qc_prompt,
|
16
|
-
)
|
17
|
-
from pyadps.utils.velocity_test import (
|
18
|
-
despike,
|
19
|
-
flatline,
|
20
|
-
velocity_modifier,
|
21
|
-
wmm2020api,
|
22
|
-
velocity_cutoff,
|
23
|
-
)
|
24
|
-
|
25
|
-
import pyadps.utils.writenc as wr
|
9
|
+
from pyadps.utils.regrid import regrid2d, regrid3d
|
10
|
+
from pyadps.utils.signal_quality import (default_mask, ev_check, false_target,
|
11
|
+
pg_check, qc_check, qc_prompt)
|
12
|
+
from pyadps.utils.velocity_test import (despike, flatline,
|
13
|
+
magnetic_declination, velocity_cutoff)
|
26
14
|
|
27
15
|
plt.style.use("seaborn-v0_8-darkgrid")
|
28
16
|
|
29
17
|
|
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
|
-
mask =
|
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
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
mask = despike(
|
170
|
-
vel[0, :, :], mask, kernal_size=despike_kernal, cutoff=despike_cutoff
|
171
|
-
)
|
172
|
-
mask = despike(
|
173
|
-
vel[1, :, :], mask, kernal_size=despike_kernal, cutoff=despike_cutoff
|
174
|
-
)
|
175
|
-
|
176
|
-
affirm = input("Remove flatlines? [y/n]: ")
|
177
|
-
if affirm.lower() == "y":
|
178
|
-
flatline_kernal = input("Enter despike kernal size:")
|
179
|
-
flatline_kernal = int(flatline_kernal)
|
180
|
-
flatline_cutoff = input("Enter Flatline deviation: [y/n]")
|
181
|
-
flatlineL_cutoff = int(flatline_cutoff)
|
182
|
-
mask = flatline(
|
183
|
-
vel[0, :, :], mask, kernal_size=flatline_kernal, cutoff=flatline_cutoff
|
184
|
-
)
|
185
|
-
mask = flatline(
|
186
|
-
vel[1, :, :], mask, kernal_size=flatline_kernal, cutoff=flatline_cutoff
|
187
|
-
)
|
188
|
-
mask = flatline(
|
189
|
-
vel[2, :, :], mask, kernal_size=flatline_kernal, cutoff=flatline_cutoff
|
190
|
-
)
|
191
|
-
apply_mask = input("Apply mask? [y/n]: ")
|
192
|
-
if apply_mask.lower() == "y":
|
193
|
-
for i in range(4):
|
194
|
-
vel[i, :, :] = np.where(mask == 0, vel[i, :, :], -32768)
|
195
|
-
|
196
|
-
outfilepath = input("Enter output file name (*nc): ")
|
197
|
-
if os.path.exists(outfilepath):
|
198
|
-
if os.path.isfile(outfilepath):
|
199
|
-
print(f"The file already exists: {outfilepath}")
|
200
|
-
else:
|
201
|
-
wr.finalnc(outfilepath, z, mask, time, vel)
|
202
|
-
|
203
|
-
|
204
|
-
if __name__ == "__main__":
|
205
|
-
main()
|
18
|
+
# Read data
|
19
|
+
filename = "/home/amol/Desktop/BGS11000.000"
|
20
|
+
ds = rd.ReadFile(filename)
|
21
|
+
fl = ds.fixedleader
|
22
|
+
vl = ds.variableleader
|
23
|
+
vel = ds.velocity.data
|
24
|
+
echo = ds.echo.data
|
25
|
+
cor = ds.correlation.data
|
26
|
+
pgood = ds.percentgood.data
|
27
|
+
|
28
|
+
# Data pressure = vl.vleader["Pressure"]
|
29
|
+
beam_angle = int(fl.system_configuration()["Beam Angle"])
|
30
|
+
cell_size = fl.field()["Depth Cell Len"]
|
31
|
+
blank_size = fl.field()["Blank Transmit"]
|
32
|
+
cells = fl.field()["Cells"]
|
33
|
+
|
34
|
+
# sys.exit()
|
35
|
+
|
36
|
+
# Original mask created from velocity
|
37
|
+
mask = default_mask(fl, vel)
|
38
|
+
orig_mask = np.copy(mask)
|
39
|
+
|
40
|
+
# Default threshold
|
41
|
+
ct = fl.field()["Correlation Thresh"]
|
42
|
+
et = 0
|
43
|
+
pgt = fl.field()["Percent Good Min"]
|
44
|
+
evt = fl.field()["Error Velocity Thresh"]
|
45
|
+
ft = fl.field()["False Target Thresh"]
|
46
|
+
|
47
|
+
print(ct, et, pgt, evt, ft)
|
48
|
+
|
49
|
+
# Get the threshold values
|
50
|
+
ct = qc_prompt(fl, "Correlation Thresh")
|
51
|
+
evt = qc_prompt(fl, "Error Velocity Thresh")
|
52
|
+
pgt = qc_prompt(fl, "Percent Good Min")
|
53
|
+
et = qc_prompt(fl, "Echo Intensity Thresh", echo)
|
54
|
+
ft = qc_prompt(fl, "False Target Thresh")
|
55
|
+
|
56
|
+
# Apply threshold
|
57
|
+
values, counts = np.unique(mask, return_counts=True)
|
58
|
+
print(values, counts, np.round(counts * 100 / np.sum(counts)))
|
59
|
+
mask = pg_check(pgood, mask, pgt)
|
60
|
+
mask = qc_check(cor, mask, ct)
|
61
|
+
mask = qc_check(echo, mask, et)
|
62
|
+
mask = ev_check(vel[3, :, :], mask, evt)
|
63
|
+
mask = false_target(echo, mask, ft, threebeam=True)
|
64
|
+
|
65
|
+
|
66
|
+
########## PROFILE TEST #########
|
67
|
+
|
68
|
+
affirm = input("Would you like to trim the ends? [y/n]: ")
|
69
|
+
if affirm.lower() == "y":
|
70
|
+
mask = trim_ends(vl, mask)
|
71
|
+
|
72
|
+
affirm = input("Would you remove the surface backscatter bins? [y/n]: ")
|
73
|
+
if affirm.lower() == "y":
|
74
|
+
mask = side_lobe_beam_angle(fl, vl, mask)
|
75
|
+
|
76
|
+
affirm = input("Would you like to manually select and mask data?")
|
77
|
+
if affirm.lower() == "y":
|
78
|
+
manual = CutBins(echo[0, :, :], mask)
|
79
|
+
plt.show()
|
80
|
+
mask = manual.mask()
|
81
|
+
|
82
|
+
affirm = input("Regrid the data based on pressure sensor? [y/n]:")
|
83
|
+
if affirm.lower() == "y":
|
84
|
+
z, vel = regrid3d(fl, vl, vel, -32768)
|
85
|
+
z, echo_reg = regrid3d(fl, vl, echo, -32768)
|
86
|
+
z, correlation_reg = regrid3d(fl, vl, cor, -32768)
|
87
|
+
z, percentgood_reg = regrid3d(fl, vl, pgood, -32768)
|
88
|
+
z, mask = regrid2d(fl, vl, mask, -32768)
|
89
|
+
|
90
|
+
# affirm = input("Display original and revised mask files? [y/n]:")
|
91
|
+
# if affirm.lower() == "y":
|
92
|
+
# plotmask(orig_mask, mask)
|
93
|
+
|
94
|
+
|
95
|
+
########## VELOCITY TEST ##########
|
96
|
+
affirm = input("Apply correction for magnetic declination? [y/n]:")
|
97
|
+
if affirm.lower() == "y":
|
98
|
+
lat = input("Enter Latitude: ")
|
99
|
+
lat = float(lat)
|
100
|
+
|
101
|
+
lon = input("Enter Longitude: ")
|
102
|
+
lon = float(lon)
|
103
|
+
|
104
|
+
depth = input("Enter Depth (m): ")
|
105
|
+
depth = float(depth)
|
106
|
+
|
107
|
+
year = input("Year: ")
|
108
|
+
year = int(year)
|
109
|
+
|
110
|
+
velocity = magnetic_declination(vel, lat, lon, depth, year)
|
111
|
+
|
112
|
+
affirm = input("Apply velocity thresholds [y/n]: ")
|
113
|
+
if affirm.lower() == "y":
|
114
|
+
maxuvel = input("Enter maximum zonal velocity: ")
|
115
|
+
maxuvel = float(maxuvel)
|
116
|
+
|
117
|
+
maxvvel = input("Enter maximum meridional velocity: ")
|
118
|
+
maxvvel = float(maxvvel)
|
119
|
+
|
120
|
+
maxwvel = input("Enter maximum vertical velocity: ")
|
121
|
+
maxwvel = float(maxwvel)
|
122
|
+
mask = velocity_cutoff(vel[0, :, :], mask, cutoff=maxuvel)
|
123
|
+
mask = velocity_cutoff(vel[1, :, :], mask, cutoff=maxvvel)
|
124
|
+
mask = velocity_cutoff(vel[2, :, :], mask, cutoff=maxwvel)
|
125
|
+
|
126
|
+
affirm = input("Despike the data? [y/n]: ")
|
127
|
+
if affirm.lower() == "y":
|
128
|
+
despike_kernal = input("Enter despike kernal size:")
|
129
|
+
despike_kernal = int(despike_kernal)
|
130
|
+
|
131
|
+
despike_cutoff = input("Enter despike cutoff (mm/s): ")
|
132
|
+
despike_cutoff = float(despike_cutoff)
|
133
|
+
|
134
|
+
mask = despike(
|
135
|
+
vel[0, :, :], mask, kernal_size=despike_kernal, cutoff=despike_cutoff
|
136
|
+
)
|
137
|
+
mask = despike(
|
138
|
+
vel[1, :, :], mask, kernal_size=despike_kernal, cutoff=despike_cutoff
|
139
|
+
)
|
140
|
+
|
141
|
+
affirm = input("Remove flatlines? [y/n]: ")
|
142
|
+
if affirm.lower() == "y":
|
143
|
+
flatline_kernal = input("Enter despike kernal size:")
|
144
|
+
flatline_kernal = int(flatline_kernal)
|
145
|
+
flatline_cutoff = input("Enter Flatline deviation: [y/n]")
|
146
|
+
flatlineL_cutoff = int(flatline_cutoff)
|
147
|
+
mask = flatline(
|
148
|
+
velocity[0, :, :], mask, kernal_size=flatline_kernal, cutoff=flatline_cutoff
|
149
|
+
)
|
150
|
+
mask = flatline(
|
151
|
+
velocity[1, :, :], mask, kernal_size=flatline_kernal, cutoff=flatline_cutoff
|
152
|
+
)
|
153
|
+
mask = flatline(
|
154
|
+
velocity[2, :, :], mask, kernal_size=flatline_kernal, cutoff=flatline_cutoff
|
155
|
+
)
|