pyadps 0.1.0b0__py3-none-any.whl → 0.1.2__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 +11 -5
- pyadps/pages/01_Read_File.py +194 -18
- pyadps/pages/02_View_Raw_Data.py +69 -33
- pyadps/pages/03_Download_Raw_File.py +214 -66
- pyadps/pages/04_Sensor_Health.py +905 -0
- pyadps/pages/05_QC_Test.py +476 -0
- pyadps/pages/06_Profile_Test.py +971 -0
- pyadps/pages/07_Velocity_Test.py +600 -0
- pyadps/pages/08_Write_File.py +606 -0
- pyadps/pages/09_Auto_process.py +64 -0
- pyadps/utils/__init__.py +3 -3
- pyadps/utils/autoprocess.py +548 -0
- pyadps/utils/metadata/config.ini +99 -0
- pyadps/utils/metadata/demo.000 +0 -0
- pyadps/utils/plotgen.py +505 -3
- pyadps/utils/profile_test.py +752 -145
- pyadps/utils/pyreadrdi.py +27 -17
- pyadps/utils/readrdi.py +167 -20
- pyadps/utils/script.py +197 -147
- pyadps/utils/sensor_health.py +120 -0
- pyadps/utils/signal_quality.py +344 -24
- pyadps/utils/velocity_test.py +103 -20
- pyadps/utils/writenc.py +223 -27
- {pyadps-0.1.0b0.dist-info → pyadps-0.1.2.dist-info}/METADATA +56 -24
- pyadps-0.1.2.dist-info/RECORD +33 -0
- {pyadps-0.1.0b0.dist-info → pyadps-0.1.2.dist-info}/WHEEL +1 -1
- pyadps-0.1.2.dist-info/entry_points.txt +5 -0
- pyadps/pages/04_QC_Test.py +0 -283
- pyadps/pages/05_Profile_Test.py +0 -389
- pyadps/pages/06_Velocity_Test.py +0 -293
- pyadps/pages/07_Write_File.py +0 -367
- pyadps/utils/cutbin.py +0 -413
- pyadps/utils/regrid.py +0 -122
- pyadps-0.1.0b0.dist-info/RECORD +0 -29
- pyadps-0.1.0b0.dist-info/entry_points.txt +0 -3
- {pyadps-0.1.0b0.dist-info → pyadps-0.1.2.dist-info}/LICENSE +0 -0
@@ -18,16 +18,33 @@ if "fname" not in st.session_state:
|
|
18
18
|
st.session_state.fname = "No file selected"
|
19
19
|
|
20
20
|
if "rawfilename" not in st.session_state:
|
21
|
-
st.session_state.rawfilename = "
|
21
|
+
st.session_state.rawfilename = "RAW_DAT.nc"
|
22
|
+
|
23
|
+
if "fleadfilename" not in st.session_state:
|
24
|
+
st.session_state.fleadfilename = "RAW_FIX.nc"
|
22
25
|
|
23
26
|
if "vleadfilename" not in st.session_state:
|
24
|
-
st.session_state.vleadfilename = "
|
27
|
+
st.session_state.vleadfilename = "RAW_VAR.nc"
|
25
28
|
|
26
29
|
if "attributes" not in st.session_state:
|
27
30
|
st.session_state.attributes = {}
|
28
|
-
|
29
|
-
if "
|
30
|
-
st.session_state.
|
31
|
+
|
32
|
+
if "add_attributes_DRW" not in st.session_state:
|
33
|
+
st.session_state.add_attributes_DRW = "No" # Default value
|
34
|
+
|
35
|
+
if "file_prefix" not in st.session_state:
|
36
|
+
raw_basename = os.path.basename(st.session_state.fname)
|
37
|
+
st.session_state.filename = os.path.splitext(raw_basename)[0]
|
38
|
+
st.session_state.file_prefix = st.session_state.filename
|
39
|
+
|
40
|
+
|
41
|
+
if "prefix_saved" not in st.session_state:
|
42
|
+
st.session_state.prefix_saved = False
|
43
|
+
|
44
|
+
if "filename" not in st.session_state:
|
45
|
+
st.session_state.filename = "" # <-- Default file name if not passed
|
46
|
+
|
47
|
+
|
31
48
|
|
32
49
|
################ Functions #######################
|
33
50
|
@st.cache_data()
|
@@ -38,6 +55,7 @@ def file_access(uploaded_file):
|
|
38
55
|
f.write(uploaded_file.getvalue())
|
39
56
|
return path
|
40
57
|
|
58
|
+
|
41
59
|
@st.cache_data
|
42
60
|
def read_file(filepath):
|
43
61
|
ds = rd.ReadFile(st.session_state.fpath)
|
@@ -46,82 +64,200 @@ def read_file(filepath):
|
|
46
64
|
st.session_state.ds = ds
|
47
65
|
|
48
66
|
@st.cache_data
|
49
|
-
def
|
67
|
+
def get_prefixed_filename(base_name):
|
68
|
+
"""Generates the file name with the optional prefix."""
|
69
|
+
if st.session_state.file_prefix:
|
70
|
+
return f"{st.session_state.file_prefix}_{base_name}"
|
71
|
+
return base_name
|
72
|
+
|
73
|
+
|
74
|
+
@st.cache_data
|
75
|
+
def file_write(path, axis_option, add_attributes=True):
|
50
76
|
tempdirname = tempfile.TemporaryDirectory(delete=False)
|
51
|
-
st.session_state.rawfilename = tempdirname.name
|
52
|
-
|
77
|
+
st.session_state.rawfilename = os.path.join(tempdirname.name, get_prefixed_filename("RAW_DAT.nc"))
|
78
|
+
|
79
|
+
if add_attributes:
|
80
|
+
wr.rawnc(
|
81
|
+
path,
|
82
|
+
st.session_state.rawfilename,
|
83
|
+
st.session_state.date1,
|
84
|
+
axis_option,
|
85
|
+
attributes=st.session_state.attributes,
|
86
|
+
)
|
87
|
+
else:
|
88
|
+
wr.rawnc(
|
89
|
+
path, st.session_state.rawfilename, st.session_state.date1, axis_option
|
90
|
+
)
|
91
|
+
|
92
|
+
@st.cache_data
|
93
|
+
def file_write_flead(path, axis_option, add_attributes=True):
|
94
|
+
tempvardirname = tempfile.TemporaryDirectory(delete=False)
|
95
|
+
st.session_state.fleadfilename = os.path.join(tempvardirname.name, get_prefixed_filename("RAW_FIX.nc"))
|
96
|
+
|
53
97
|
if add_attributes:
|
54
|
-
wr.
|
98
|
+
wr.flead_nc(
|
99
|
+
path,
|
100
|
+
st.session_state.fleadfilename,
|
101
|
+
st.session_state.date2,
|
102
|
+
axis_option,
|
103
|
+
attributes=st.session_state.attributes,
|
104
|
+
)
|
55
105
|
else:
|
56
|
-
wr.
|
106
|
+
wr.flead_nc(
|
107
|
+
path, st.session_state.fleadfilename, st.session_state.date2, axis_option
|
108
|
+
)
|
57
109
|
|
58
110
|
@st.cache_data
|
59
|
-
def file_write_vlead(path, add_attributes=True):
|
111
|
+
def file_write_vlead(path, axis_option, add_attributes=True):
|
60
112
|
tempvardirname = tempfile.TemporaryDirectory(delete=False)
|
61
|
-
st.session_state.vleadfilename = tempvardirname.name
|
62
|
-
|
113
|
+
st.session_state.vleadfilename = os.path.join(tempvardirname.name, get_prefixed_filename("RAW_VAR.nc"))
|
114
|
+
|
63
115
|
if add_attributes:
|
64
|
-
wr.vlead_nc(
|
116
|
+
wr.vlead_nc(
|
117
|
+
path,
|
118
|
+
st.session_state.vleadfilename,
|
119
|
+
st.session_state.date3,
|
120
|
+
axis_option,
|
121
|
+
attributes=st.session_state.attributes,
|
122
|
+
)
|
65
123
|
else:
|
66
|
-
wr.vlead_nc(
|
124
|
+
wr.vlead_nc(
|
125
|
+
path, st.session_state.vleadfilename, st.session_state.date3, axis_option
|
126
|
+
)
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
if "axis_option" not in st.session_state:
|
131
|
+
st.session_state.axis_option = "ensemble" # Default value
|
67
132
|
|
68
133
|
# UI for attribute selection
|
69
134
|
st.header("NetCDF File", divider="blue")
|
70
135
|
|
71
136
|
# Option to add attributes
|
72
|
-
|
137
|
+
st.session_state.add_attributes_DRW = st.radio(
|
138
|
+
"Do you want to add attributes to the NetCDF file?", ["No", "Yes"], horizontal=True
|
139
|
+
)
|
73
140
|
|
74
|
-
if
|
141
|
+
if st.session_state.add_attributes_DRW == "Yes":
|
75
142
|
st.write("### Please fill in the attributes:")
|
76
|
-
|
143
|
+
|
77
144
|
# Two-column layout
|
78
145
|
col1, col2 = st.columns(2)
|
79
|
-
|
80
|
-
with col1:
|
81
|
-
st.session_state.attributes['Cruise_No.'] = st.text_input("Cruise No.")
|
82
|
-
st.session_state.attributes['Ship_Name'] = st.text_input("Ship Name")
|
83
|
-
st.session_state.attributes['Project_No.'] = st.text_input("Project No.")
|
84
|
-
st.session_state.attributes['Water_Depth_m'] = st.text_input("Water Depth (m)")
|
85
|
-
st.session_state.attributes['Deployment_Depth_m'] = st.text_input("Deployment Depth (m)")
|
86
|
-
st.session_state.attributes['Deployment_Date'] = st.date_input("Deployment Date")
|
87
|
-
st.session_state.attributes['Recovery_Date'] = st.date_input("Recovery Date")
|
88
146
|
|
147
|
+
with col1:
|
148
|
+
st.session_state.attributes["Cruise_No."] = st.text_input("Cruise No.")
|
149
|
+
st.session_state.attributes["Ship_Name"] = st.text_input("Ship Name")
|
150
|
+
st.session_state.attributes["Project_No."] = st.text_input("Project No.")
|
151
|
+
st.session_state.attributes["Water_Depth_m"] = st.text_input("Water Depth (m)")
|
152
|
+
st.session_state.attributes["Deployment_Depth_m"] = st.text_input(
|
153
|
+
"Deployment Depth (m)"
|
154
|
+
)
|
155
|
+
st.session_state.attributes["Deployment_Date"] = st.date_input(
|
156
|
+
"Deployment Date"
|
157
|
+
)
|
158
|
+
st.session_state.attributes["Recovery_Date"] = st.date_input("Recovery Date")
|
89
159
|
|
90
160
|
with col2:
|
91
|
-
st.session_state.attributes[
|
92
|
-
st.session_state.attributes[
|
93
|
-
st.session_state.attributes[
|
94
|
-
st.session_state.attributes[
|
95
|
-
st.session_state.attributes[
|
96
|
-
|
97
|
-
|
161
|
+
st.session_state.attributes["Latitude"] = st.text_input("Latitude")
|
162
|
+
st.session_state.attributes["Longitude"] = st.text_input("Longitude")
|
163
|
+
st.session_state.attributes["Platform_Type"] = st.text_input("Platform Type")
|
164
|
+
st.session_state.attributes["Participants"] = st.text_area("Participants")
|
165
|
+
st.session_state.attributes["File_created_by"] = st.text_input(
|
166
|
+
"File created by"
|
167
|
+
)
|
168
|
+
st.session_state.attributes["Contact"] = st.text_input("Contact")
|
169
|
+
st.session_state.attributes["Comments"] = st.text_area("Comments")
|
98
170
|
|
99
171
|
st.write("Attributes will be added to the NetCDF file once you submit.")
|
100
|
-
|
172
|
+
|
173
|
+
|
174
|
+
st.info(f"Current file name: **{st.session_state.filename}**")
|
175
|
+
|
176
|
+
# Prefix editing option
|
177
|
+
st.session_state.use_custom_filename = st.radio(
|
178
|
+
"Do you want to edit Output Filename?",
|
179
|
+
["No", "Yes"],
|
180
|
+
horizontal=True,
|
181
|
+
)
|
182
|
+
|
183
|
+
if st.session_state.use_custom_filename == "Yes" and not st.session_state.prefix_saved:
|
184
|
+
st.session_state.file_prefix = st.text_input(
|
185
|
+
"Enter file name (e.g., GD10A000)",
|
186
|
+
value=st.session_state.file_prefix,
|
187
|
+
)
|
188
|
+
|
189
|
+
if st.button("Save Filename"):
|
190
|
+
if st.session_state.file_prefix.strip():
|
191
|
+
st.session_state.prefix_saved = True
|
192
|
+
st.rerun()
|
193
|
+
else:
|
194
|
+
st.warning("Please enter a valid filename before saving.")
|
195
|
+
|
196
|
+
if st.session_state.prefix_saved:
|
197
|
+
st.success(f"Filename saved as: **{st.session_state.file_prefix}**")
|
198
|
+
|
199
|
+
# Dropdown for axis_option
|
200
|
+
st.session_state.axis_option_DRW = st.selectbox(
|
201
|
+
"Select x-axis option:",
|
202
|
+
options=["time", "ensemble"],
|
203
|
+
index=0, # Default to "time"
|
204
|
+
)
|
205
|
+
|
206
|
+
# Ensure it is passed correctly
|
207
|
+
# st.session_state.axis_option = axis_option
|
208
|
+
|
101
209
|
# Buttons to generate files
|
102
|
-
|
103
|
-
|
210
|
+
st.session_state.rawnc_download_DRW = st.button("Generate Raw NetCDF File")
|
211
|
+
st.session_state.fleadnc_download_DRW = st.button(
|
212
|
+
"Generate Raw Fixed Leader NetCDF File"
|
213
|
+
)
|
214
|
+
st.session_state.vleadnc_download_DRW = st.button(
|
215
|
+
"Generate Raw Variable Leader NetCDF File"
|
216
|
+
)
|
104
217
|
|
105
|
-
if
|
106
|
-
file_write(
|
218
|
+
if st.session_state.rawnc_download_DRW:
|
219
|
+
file_write(
|
220
|
+
st.session_state.fpath,
|
221
|
+
st.session_state.axis_option_DRW,
|
222
|
+
st.session_state.add_attributes_DRW == "Yes",
|
223
|
+
)
|
107
224
|
st.write(st.session_state.rawfilename)
|
108
225
|
with open(st.session_state.rawfilename, "rb") as file:
|
109
226
|
st.download_button(
|
110
227
|
label="Download Raw File",
|
111
228
|
data=file,
|
112
|
-
file_name="
|
229
|
+
file_name=get_prefixed_filename("RAW_DAT.nc"),
|
113
230
|
)
|
114
231
|
|
115
|
-
if
|
116
|
-
|
232
|
+
if st.session_state.fleadnc_download_DRW:
|
233
|
+
file_write_flead(
|
234
|
+
st.session_state.fpath,
|
235
|
+
st.session_state.axis_option,
|
236
|
+
st.session_state.add_attributes_DRW == "Yes",
|
237
|
+
)
|
238
|
+
st.write(st.session_state.fleadfilename)
|
239
|
+
with open(st.session_state.fleadfilename, "rb") as file:
|
240
|
+
st.download_button(
|
241
|
+
label="Download Fixed Leader",
|
242
|
+
data=file,
|
243
|
+
file_name=get_prefixed_filename("RAW_FIX.nc"),
|
244
|
+
)
|
245
|
+
|
246
|
+
if st.session_state.vleadnc_download_DRW:
|
247
|
+
file_write_vlead(
|
248
|
+
st.session_state.fpath,
|
249
|
+
st.session_state.axis_option,
|
250
|
+
st.session_state.add_attributes_DRW == "Yes",
|
251
|
+
)
|
117
252
|
st.write(st.session_state.vleadfilename)
|
118
253
|
with open(st.session_state.vleadfilename, "rb") as file:
|
119
254
|
st.download_button(
|
120
255
|
label="Download Variable Leader",
|
121
256
|
data=file,
|
122
|
-
file_name="
|
257
|
+
file_name=get_prefixed_filename("RAW_VAR.nc"),
|
123
258
|
)
|
124
259
|
|
260
|
+
|
125
261
|
def download_csv_with_ensemble(data, filename):
|
126
262
|
# Create ensemble numbers from 1 to the number of rows in the data
|
127
263
|
ensembles = np.arange(1, len(next(iter(data.values()))) + 1)
|
@@ -131,60 +267,62 @@ def download_csv_with_ensemble(data, filename):
|
|
131
267
|
df.insert(0, "RDI_Ensemble", ensembles) # Add ensemble numbers as the first column
|
132
268
|
|
133
269
|
# Export the DataFrame as a CSV
|
134
|
-
csv = df.to_csv(index=False).encode(
|
270
|
+
csv = df.to_csv(index=False).encode("utf-8")
|
135
271
|
return st.download_button(
|
136
272
|
label=f"Download {filename} as CSV",
|
137
273
|
data=csv,
|
138
274
|
file_name=f"{filename}.csv",
|
139
|
-
mime=
|
275
|
+
mime="text/csv",
|
140
276
|
)
|
141
|
-
|
277
|
+
|
278
|
+
|
142
279
|
def download_csv(data, filename):
|
143
280
|
# Convert data to DataFrame if it's not already one
|
144
281
|
if isinstance(data, dict):
|
145
282
|
df = pd.DataFrame.from_dict(data, orient="index").T
|
146
283
|
else:
|
147
284
|
df = pd.DataFrame(data)
|
148
|
-
|
285
|
+
|
149
286
|
# Export the DataFrame as a CSV
|
150
|
-
csv = df.to_csv(index=False).encode(
|
287
|
+
csv = df.to_csv(index=False).encode("utf-8")
|
151
288
|
return st.download_button(
|
152
289
|
label=f"Download {filename} as CSV",
|
153
290
|
data=csv,
|
154
291
|
file_name=f"{filename}.csv",
|
155
|
-
mime=
|
292
|
+
mime="text/csv",
|
156
293
|
)
|
157
|
-
|
158
|
-
|
294
|
+
|
295
|
+
|
159
296
|
def download_csv1(data, filename):
|
160
297
|
# Convert data to DataFrame if it's not already one
|
161
298
|
if isinstance(data, dict):
|
162
299
|
df = pd.DataFrame.from_dict(data, orient="index").T
|
163
300
|
else:
|
164
301
|
df = pd.DataFrame(data)
|
165
|
-
|
302
|
+
|
166
303
|
# Create ensemble and depth arrays
|
167
304
|
ensembles = np.arange(1, df.shape[0] + 1)
|
168
305
|
depths = np.arange(1, df.shape[1] + 1)
|
169
|
-
|
306
|
+
|
170
307
|
# Add ensemble numbers as the first column
|
171
|
-
df.insert(0,
|
172
|
-
|
308
|
+
df.insert(0, "Ensemble", ensembles)
|
309
|
+
|
173
310
|
# Transpose the DataFrame to switch rows and columns
|
174
311
|
df = df.T
|
175
|
-
|
312
|
+
|
176
313
|
# Add depth values as the first row
|
177
|
-
df.insert(0,
|
178
|
-
|
314
|
+
df.insert(0, "Depth", [""] + list(depths))
|
315
|
+
|
179
316
|
# Export the DataFrame as a CSV
|
180
|
-
csv = df.to_csv(index=False, header=False).encode(
|
317
|
+
csv = df.to_csv(index=False, header=False).encode("utf-8")
|
181
318
|
return st.download_button(
|
182
319
|
label=f"Download {filename} as CSV",
|
183
320
|
data=csv,
|
184
321
|
file_name=f"{filename}.csv",
|
185
|
-
mime=
|
322
|
+
mime="text/csv",
|
186
323
|
)
|
187
324
|
|
325
|
+
|
188
326
|
# Load data
|
189
327
|
fdata = st.session_state.flead.fleader
|
190
328
|
vdata = st.session_state.vlead.vleader
|
@@ -202,25 +340,36 @@ X, Y = np.meshgrid(x, y)
|
|
202
340
|
st.header("Download Raw Data CSV File", divider="blue")
|
203
341
|
|
204
342
|
# Selection for the data category
|
205
|
-
|
343
|
+
st.session_state.rawcsv_option_DRW = st.selectbox(
|
206
344
|
"Select data type to download:",
|
207
|
-
[
|
345
|
+
[
|
346
|
+
"Velocity",
|
347
|
+
"Echo Intensity",
|
348
|
+
"Correlation",
|
349
|
+
"Percent Good",
|
350
|
+
"Variable Leader",
|
351
|
+
"Fixed Leader",
|
352
|
+
],
|
208
353
|
)
|
209
354
|
|
210
355
|
# Show corresponding variable options based on selection
|
211
|
-
if
|
356
|
+
if st.session_state.rawcsv_option_DRW == "Fixed Leader":
|
212
357
|
# Combine all variables of Fixed Leader into one DataFrame
|
213
358
|
f_combined_data = {var: fdata[var] for var in fdata.keys()}
|
214
359
|
download_csv_with_ensemble(f_combined_data, "Fixed_Leader_All_Variables")
|
215
360
|
|
216
|
-
elif
|
361
|
+
elif st.session_state.rawcsv_option_DRW == "Variable Leader":
|
217
362
|
# Combine all variables of Variable Leader into one DataFrame
|
218
363
|
v_combined_data = {var: vdata[var] for var in vdata.keys()}
|
219
364
|
download_csv(v_combined_data, "Variable_Leader_All_Variables")
|
220
365
|
|
221
366
|
else:
|
222
|
-
|
367
|
+
st.session_state.rawcsv_beam_DRW = st.radio(
|
368
|
+
"Select beam to download", (1, 2, 3, 4), horizontal=True
|
369
|
+
)
|
223
370
|
|
371
|
+
data_type = st.session_state.rawcsv_option_DRW
|
372
|
+
beam_download = st.session_state.rawcsv_beam_DRW
|
224
373
|
if data_type == "Velocity":
|
225
374
|
download_data = velocity[beam_download - 1, :, :]
|
226
375
|
elif data_type == "Echo Intensity":
|
@@ -231,4 +380,3 @@ else:
|
|
231
380
|
download_data = pgood[beam_download - 1, :, :]
|
232
381
|
|
233
382
|
download_csv1(download_data, f"{data_type}_Beam_{beam_download}")
|
234
|
-
|