pyadps 0.1.1__py3-none-any.whl → 0.2.1b0__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.
Files changed (48) hide show
  1. pyadps/Home_Page.py +5 -11
  2. pyadps/pages/01_Read_File.py +19 -188
  3. pyadps/pages/02_View_Raw_Data.py +33 -69
  4. pyadps/pages/03_Download_Raw_File.py +61 -149
  5. pyadps/pages/04_QC_Test.py +334 -0
  6. pyadps/pages/05_Profile_Test.py +575 -0
  7. pyadps/pages/06_Velocity_Test.py +341 -0
  8. pyadps/pages/07_Write_File.py +452 -0
  9. pyadps/utils/__init__.py +3 -3
  10. pyadps/utils/autoprocess.py +78 -344
  11. pyadps/utils/cutbin.py +413 -0
  12. pyadps/utils/metadata/config.ini +4 -22
  13. pyadps/utils/plotgen.py +3 -505
  14. pyadps/utils/profile_test.py +125 -494
  15. pyadps/utils/pyreadrdi.py +17 -27
  16. pyadps/utils/readrdi.py +18 -164
  17. pyadps/utils/{__pycache__/regrid.cpython-312.pyc → regrid.py} +0 -0
  18. pyadps/utils/script.py +147 -197
  19. pyadps/utils/signal_quality.py +24 -344
  20. pyadps/utils/velocity_test.py +31 -79
  21. pyadps/utils/writenc.py +21 -155
  22. {pyadps-0.1.1.dist-info → pyadps-0.2.1b0.dist-info}/METADATA +5 -5
  23. pyadps-0.2.1b0.dist-info/RECORD +31 -0
  24. {pyadps-0.1.1.dist-info → pyadps-0.2.1b0.dist-info}/WHEEL +1 -1
  25. {pyadps-0.1.1.dist-info → pyadps-0.2.1b0.dist-info}/entry_points.txt +0 -1
  26. pyadps/pages/04_Sensor_Health.py +0 -905
  27. pyadps/pages/05_QC_Test.py +0 -476
  28. pyadps/pages/06_Profile_Test.py +0 -971
  29. pyadps/pages/07_Velocity_Test.py +0 -600
  30. pyadps/pages/08_Write_File.py +0 -587
  31. pyadps/pages/09_Auto_process.py +0 -64
  32. pyadps/pages/__pycache__/__init__.cpython-312.pyc +0 -0
  33. pyadps/utils/__pycache__/__init__.cpython-312.pyc +0 -0
  34. pyadps/utils/__pycache__/autoprocess.cpython-312.pyc +0 -0
  35. pyadps/utils/__pycache__/cutbin.cpython-312.pyc +0 -0
  36. pyadps/utils/__pycache__/plotgen.cpython-312.pyc +0 -0
  37. pyadps/utils/__pycache__/profile_test.cpython-312.pyc +0 -0
  38. pyadps/utils/__pycache__/pyreadrdi.cpython-312.pyc +0 -0
  39. pyadps/utils/__pycache__/readrdi.cpython-312.pyc +0 -0
  40. pyadps/utils/__pycache__/script.cpython-312.pyc +0 -0
  41. pyadps/utils/__pycache__/sensor_health.cpython-312.pyc +0 -0
  42. pyadps/utils/__pycache__/signal_quality.cpython-312.pyc +0 -0
  43. pyadps/utils/__pycache__/velocity_test.cpython-312.pyc +0 -0
  44. pyadps/utils/__pycache__/writenc.cpython-312.pyc +0 -0
  45. pyadps/utils/metadata/demo.000 +0 -0
  46. pyadps/utils/sensor_health.py +0 -120
  47. pyadps-0.1.1.dist-info/RECORD +0 -47
  48. {pyadps-0.1.1.dist-info → pyadps-0.2.1b0.dist-info}/LICENSE +0 -0
@@ -1,587 +0,0 @@
1
- import configparser
2
- import tempfile
3
-
4
- import numpy as np
5
- import pandas as pd
6
- import plotly.graph_objects as go
7
- import streamlit as st
8
- import utils.writenc as wr
9
- from plotly_resampler import FigureResampler
10
-
11
- if "flead" not in st.session_state:
12
- st.write(":red[Please Select Data!]")
13
- st.stop()
14
-
15
- if "fname" not in st.session_state:
16
- st.session_state.fname = "No file selected"
17
-
18
- if "rawfilename" not in st.session_state:
19
- st.session_state.rawfilename = "rawfile.nc"
20
-
21
- if "vleadfilename" not in st.session_state:
22
- st.session_state.vleadfilename = "vlead.nc"
23
-
24
-
25
- # Check if attributes exist in session state
26
- if "attributes" not in st.session_state:
27
- st.session_state.attributes = {}
28
- st.session_state.isAttributes = False
29
-
30
- if st.session_state.isVelocityTest:
31
- st.session_state.final_mask = st.session_state.velocity_mask
32
-
33
- if st.session_state.isVelocityModifiedMagnet:
34
- st.session_state.final_velocity = st.session_state.velocity_magnet
35
- if st.session_state.isRegridCheck_PT:
36
- st.session_state.final_velocity = st.session_state.velocity_regrid
37
- elif st.session_state.isVelocityModifiedSound_ST:
38
- st.session_state.final_velocity = st.session_state.velocity_sensor
39
- else:
40
- st.session_state.final_velocity = st.session_state.velocity
41
-
42
- if st.session_state.isRegridCheck_PT:
43
- st.session_state.final_echo = st.session_state.echo_regrid
44
- st.session_state.final_correlation = st.session_state.correlation_regrid
45
- st.session_state.final_pgood = st.session_state.pgood_regrid
46
- else:
47
- st.session_state.final_echo = st.session_state.echo
48
- st.session_state.final_correlation = st.session_state.correlation
49
- st.session_state.final_pgood = st.session_state.pgood
50
- else:
51
- if st.session_state.isRegridCheck_PT:
52
- st.session_state.final_mask = st.session_state.profile_mask_regrid
53
- st.session_state.final_velocity = st.session_state.velocity_regrid
54
- st.session_state.final_echo = st.session_state.echo_regrid
55
- st.session_state.final_correlation = st.session_state.correlation_regrid
56
- st.session_state.final_pgood = st.session_state.pgood_regrid
57
- else:
58
- if st.session_state.isProfileTest:
59
- st.session_state.final_mask = st.session_state.profile_mask
60
- elif st.session_state.isQCTest:
61
- st.session_state.final_mask = st.session_state.qc_mask
62
- elif st.session_state.isSensorTest:
63
- st.session_state.final_mask = st.session_state.sensor_mask
64
- else:
65
- st.session_state.final_mask = st.session_state.orig_mask
66
- st.session_state.final_velocity = st.session_state.velocity
67
- st.session_state.final_echo = st.session_state.echo
68
- st.session_state.final_correlation = st.session_state.correlation
69
- st.session_state.final_pgood = st.session_state.pgood
70
-
71
-
72
- if "depth_axis" not in st.session_state:
73
- st.session_state.isRegridCheck_PT = False
74
-
75
-
76
- @st.cache_data
77
- def file_write(filename="processed_file.nc"):
78
- tempdirname = tempfile.TemporaryDirectory(delete=False)
79
- outfilepath = tempdirname.name + "/" + filename
80
- return outfilepath
81
-
82
-
83
- # If the data is not regrided based on pressure sensor. Use the mean depth
84
- if not st.session_state.isRegridCheck_PT:
85
- st.write(":red[WARNING!]")
86
- st.write(
87
- "Data not regrided. Using the mean transducer depth to calculate the depth axis."
88
- )
89
- # mean_depth = np.mean(st.session_state.vlead.vleader["Depth of Transducer"]) / 10
90
- mean_depth = np.mean(st.session_state.depth) / 10
91
- mean_depth = np.trunc(mean_depth)
92
- st.write(f"Mean depth of the transducer is `{mean_depth}`")
93
- cells = st.session_state.flead.field()["Cells"]
94
- cell_size = st.session_state.flead.field()["Depth Cell Len"] / 100
95
- bin1dist = st.session_state.flead.field()["Bin 1 Dist"] / 100
96
- if st.session_state.beam_direction_QCT.lower() == "up":
97
- sgn = -1
98
- else:
99
- sgn = 1
100
- first_depth = mean_depth + sgn * bin1dist
101
- last_depth = first_depth + sgn * cells * cell_size
102
- z = np.arange(first_depth, last_depth, sgn * cell_size)
103
- st.session_state.final_depth_axis = z
104
- else:
105
- st.session_state.final_depth_axis = st.session_state.depth_axis
106
-
107
-
108
- # Functions for plotting
109
- @st.cache_data
110
- def fillplot_plotly(
111
- x, y, data, maskdata, colorscale="balance", title="Data", mask=False
112
- ):
113
- fig = FigureResampler(go.Figure())
114
- if mask:
115
- data1 = np.where(maskdata == 1, np.nan, data)
116
- else:
117
- data1 = np.where(data == -32768, np.nan, data)
118
-
119
- fig.add_trace(
120
- go.Heatmap(
121
- z=data1[:, 0:-1],
122
- x=x,
123
- y=y,
124
- colorscale=colorscale,
125
- hoverongaps=False,
126
- )
127
- )
128
- fig.update_layout(
129
- xaxis=dict(showline=True, mirror=True),
130
- yaxis=dict(showline=True, mirror=True),
131
- title_text=title,
132
- )
133
- fig.update_yaxes(autorange="reversed")
134
- st.plotly_chart(fig)
135
-
136
-
137
- def call_plot(varname, beam, mask=False):
138
- if varname == "Velocity":
139
- fillplot_plotly(
140
- st.session_state.date,
141
- st.session_state.final_depth_axis,
142
- st.session_state.final_velocity[beam - 1, :, :],
143
- st.session_state.final_mask,
144
- title=varname,
145
- mask=mask,
146
- )
147
- elif varname == "Echo":
148
- fillplot_plotly(
149
- st.session_state.date,
150
- st.session_state.final_depth_axis,
151
- st.session_state.final_echo[beam - 1, :, :],
152
- st.session_state.final_mask,
153
- title=varname,
154
- mask=mask,
155
- )
156
- elif varname == "Correlation":
157
- fillplot_plotly(
158
- st.session_state.date,
159
- st.session_state.final_depth_axis,
160
- st.session_state.final_correlation[beam - 1, :, :],
161
- st.session_state.final_mask,
162
- title=varname,
163
- mask=mask,
164
- )
165
- elif varname == "Percent Good":
166
- fillplot_plotly(
167
- st.session_state.date,
168
- st.session_state.final_depth_axis,
169
- st.session_state.final_pgood[beam - 1, :, :],
170
- st.session_state.final_mask,
171
- title=varname,
172
- mask=mask,
173
- )
174
-
175
-
176
- # Option to View Processed Data
177
- st.header("View Processed Data", divider="blue")
178
- var_option = st.selectbox(
179
- "Select a data type", ("Velocity", "Echo", "Correlation", "Percent Good")
180
- )
181
- beam = st.radio("Select beam", (1, 2, 3, 4), horizontal=True)
182
-
183
- mask_radio = st.radio("Apply Mask", ("Yes", "No"), horizontal=True)
184
- plot_button = st.button("Plot Processed Data")
185
- if plot_button:
186
- if mask_radio == "Yes":
187
- call_plot(var_option, beam, mask=True)
188
- elif mask_radio == "No":
189
- call_plot(var_option, beam, mask=False)
190
-
191
-
192
- # Option to Write Processed Data
193
- st.header("Write Data", divider="blue")
194
-
195
- st.session_state.mask_data_WF = st.radio(
196
- "Do you want to mask the final data?", ("Yes", "No")
197
- )
198
-
199
- if st.session_state.mask_data_WF == "Yes":
200
- mask = st.session_state.final_mask
201
- st.session_state.write_velocity = np.copy(st.session_state.final_velocity).astype(np.int16)
202
- st.session_state.write_velocity[:, mask == 1] = -32768
203
-
204
- else:
205
- st.session_state.write_velocity = np.copy(st.session_state.final_velocity)
206
-
207
- st.session_state.file_type_WF = st.radio(
208
- "Select output file format:", ("NetCDF", "CSV")
209
- )
210
-
211
- if st.session_state.file_type_WF == "NetCDF":
212
- add_attr_button = st.checkbox("Add attributes to NetCDF file")
213
-
214
- if add_attr_button:
215
- st.session_state.isAttributes = True
216
- st.write("### Modify Attributes")
217
-
218
- # Create two-column layout for attributes
219
- col1, col2 = st.columns(2)
220
-
221
- with col1:
222
- # Display attributes in the first column
223
- for key in [
224
- "Cruise_No.",
225
- "Ship_Name",
226
- "Project_No.",
227
- "Water_Depth_m",
228
- "Deployment_Depth_m",
229
- "Deployment_Date",
230
- "Recovery_Date",
231
- ]:
232
- if key in st.session_state.attributes:
233
- st.session_state.attributes[key] = st.text_input(
234
- key, value=st.session_state.attributes[key]
235
- )
236
- else:
237
- st.session_state.attributes[key] = st.text_input(key)
238
-
239
- with col2:
240
- # Display attributes in the second column
241
- for key in [
242
- "Latitude",
243
- "Longitude",
244
- "Platform_Type",
245
- "Participants",
246
- "File_created_by",
247
- "Contact",
248
- "Comments",
249
- ]:
250
- if key in st.session_state.attributes:
251
- st.session_state.attributes[key] = st.text_input(
252
- key, value=st.session_state.attributes[key]
253
- )
254
- else:
255
- st.session_state.attributes[key] = st.text_input(key)
256
-
257
- download_button = st.button("Generate Processed files")
258
-
259
- if download_button:
260
- st.session_state.processed_filename = file_write()
261
- st.write(":grey[Processed file created. Click the download button.]")
262
- # st.write(st.session_state.processed_filename)
263
- depth_axis = np.trunc(st.session_state.final_depth_axis)
264
- final_mask = st.session_state.final_mask
265
- st.session_state.write_echo = np.copy(st.session_state.final_echo)
266
- st.session_state.write_correlation = np.copy(st.session_state.final_correlation)
267
- st.session_state.write_pgood = np.copy(st.session_state.final_pgood)
268
-
269
- if st.session_state.file_type_WF == "NetCDF":
270
- if add_attr_button and st.session_state.attributes:
271
- # Generate file with attributes
272
- wr.finalnc(
273
- st.session_state.processed_filename,
274
- depth_axis,
275
- final_mask,
276
- st.session_state.write_echo,
277
- st.session_state.write_correlation,
278
- st.session_state.write_pgood,
279
- st.session_state.date,
280
- st.session_state.write_velocity,
281
- attributes=st.session_state.attributes, # Pass edited attributes
282
- )
283
- else:
284
- # Generate file without attributes
285
- wr.finalnc(
286
- st.session_state.processed_filename,
287
- depth_axis,
288
- final_mask,
289
- st.session_state.write_echo,
290
- st.session_state.write_correlation,
291
- st.session_state.write_pgood,
292
- st.session_state.date,
293
- st.session_state.write_velocity,
294
- )
295
-
296
- with open(st.session_state.processed_filename, "rb") as file:
297
- st.download_button(
298
- label="Download NetCDF File",
299
- data=file,
300
- file_name="processed_file.nc",
301
- )
302
-
303
- if st.session_state.file_type_WF == "CSV":
304
- udf = pd.DataFrame(
305
- st.session_state.write_velocity[0, :, :].T,
306
- index=st.session_state.date,
307
- columns=-1 * depth_axis,
308
- )
309
- vdf = pd.DataFrame(
310
- st.session_state.write_velocity[1, :, :].T,
311
- index=st.session_state.date,
312
- columns=-1 * depth_axis,
313
- )
314
- wdf = pd.DataFrame(
315
- st.session_state.write_velocity[2, :, :].T,
316
- index=st.session_state.date,
317
- columns=-1 * depth_axis,
318
- )
319
- ucsv = udf.to_csv().encode("utf-8")
320
- vcsv = vdf.to_csv().encode("utf-8")
321
- wcsv = wdf.to_csv().encode("utf-8")
322
- csv_mask = pd.DataFrame(st.session_state.final_mask.T).to_csv().encode("utf-8")
323
- st.download_button(
324
- label="Download Zonal Velocity File (CSV)",
325
- data=ucsv,
326
- file_name="zonal_velocity.csv",
327
- mime="text/csf",
328
- )
329
- st.download_button(
330
- label="Download Meridional Velocity File (CSV)",
331
- data=vcsv,
332
- file_name="meridional_velocity.csv",
333
- mime="text/csf",
334
- )
335
- st.download_button(
336
- label="Download Vertical Velocity File (CSV)",
337
- data=vcsv,
338
- file_name="vertical_velocity.csv",
339
- mime="text/csf",
340
- )
341
-
342
- st.download_button(
343
- label="Download Final Mask (CSV)",
344
- data=csv_mask,
345
- file_name="final_mask.csv",
346
- mime="text/csv",
347
- )
348
-
349
-
350
- # Option to Download Config file
351
- # ------------------------------
352
-
353
- # Header for the Config.ini File Generator
354
- st.header("Config.ini File Generator", divider="blue")
355
-
356
- # Radio button to decide whether to generate the config.ini file
357
- generate_config_radio = st.radio(
358
- "Do you want to generate a config.ini file?", ("No", "Yes")
359
- )
360
-
361
-
362
- if generate_config_radio == "Yes":
363
- # Create a config parser object
364
- config = configparser.ConfigParser()
365
-
366
- # Main section
367
- config["FileSettings"] = {}
368
- config["DownloadOptions"] = {}
369
- config["SensorTest"] = {"sensor_test": "False"}
370
- config["QCTest"] = {"qc_test": "False"}
371
- config["ProfileTest"] = {"profile_test": "False"}
372
- config["VelocityTest"] = {"velocity_test": "False"}
373
- config["Attributes"] = {}
374
-
375
- # ------------------
376
- # File Settings
377
- # ------------------
378
- config["FileSettings"]["input_file_path"] = ""
379
- config["FileSettings"]["input_file_name"] = st.session_state.fname
380
- config["FileSettings"]["output_file_path"] = ""
381
- config["FileSettings"]["output_file_name_raw_netcdf"] = ""
382
- config["FileSettings"]["output_file_name_flead_netcdf"] = ""
383
- config["FileSettings"]["output_file_name_vlead_netcdf"] = ""
384
- config["FileSettings"]["output_file_name_raw_csv"] = ""
385
- config["FileSettings"]["output_file_name_processed_netcdf"] = ""
386
- config["FileSettings"]["output_file_name_processed_csv"] = ""
387
-
388
- if st.session_state.file_type_WF.lower() == "netcdf":
389
- st.session_state.isProcessedNetcdfDownload_WF = True
390
- else:
391
- st.session_state.isProcessedNetcdfDownload_WF = False
392
- st.session_state.isProcessedCSVDownload_WF = True
393
- # ------------------
394
- # Download options
395
- # ------------------
396
- config["DownloadOptions"]["download_raw_netcdf"] = str(
397
- st.session_state.rawnc_download_DRW
398
- )
399
- config["DownloadOptions"]["download_flead_netcdf"] = str(
400
- st.session_state.fleadnc_download_DRW
401
- )
402
- config["DownloadOptions"]["download_vlead_netcdf"] = str(
403
- st.session_state.vleadnc_download_DRW
404
- )
405
- config["DownloadOptions"]["download_processed_netcdf"] = str(
406
- st.session_state.isProcessedNetcdfDownload_WF
407
- )
408
- config["DownloadOptions"]["download_raw_csv"] = str(
409
- st.session_state.rawcsv_download_DRW
410
- )
411
- config["DownloadOptions"]["download_processed_csv"] = str(
412
- st.session_state.isProcessedCSVDownload_WF
413
- )
414
- config["DownloadOptions"]["add_attributes_raw"] = str(
415
- st.session_state.add_attributes_DRW
416
- )
417
- config["DownloadOptions"]["add_attributes_processed"] = str(
418
- st.session_state.isAttributes
419
- )
420
- config["DownloadOptions"]["axis_option"] = str(st.session_state.axis_option_DRW)
421
- config["DownloadOptions"]["apply_mask"] = "True"
422
- config["DownloadOptions"]["download_mask"] = "True"
423
-
424
- # ------------------
425
- # PAGE: Sensor Test
426
- # ------------------
427
- config["SensorTest"]["sensor_test"] = str(st.session_state.isSensorTest)
428
- # Tab 1: Depth Sensor
429
- config["SensorTest"]["is_depth_modified"] = str(st.session_state.isDepthModified_ST)
430
- config["SensorTest"]["depth_input_option"] = str(st.session_state.depthoption_ST)
431
- config["SensorTest"]["is_fixed_depth"] = str(st.session_state.isFixedDepth_ST)
432
- config["SensorTest"]["fixed_depth"] = str(st.session_state.fixeddepth_ST)
433
- config["SensorTest"]["is_upload_depth"] = str(st.session_state.isUploadDepth_ST)
434
- config["SensorTest"]["depth_file_path"] = ""
435
-
436
- # Tab 2: Salinity sensor
437
- config["SensorTest"]["is_salinity_modified"] = str(
438
- st.session_state.isSalinityModified_ST
439
- )
440
- config["SensorTest"]["salinity_input_option"] = str(
441
- st.session_state.salinityoption_ST
442
- )
443
- config["SensorTest"]["is_fixed_salinity"] = str(st.session_state.isFixedSalinity_ST)
444
- config["SensorTest"]["fixed_salinity"] = str(st.session_state.fixedsalinity_ST)
445
- config["SensorTest"]["is_upload_salinity"] = str(
446
- st.session_state.isUploadSalinity_ST
447
- )
448
- config["SensorTest"]["salinity_file_path"] = ""
449
-
450
- # Tab 3: Temperature sensor
451
- config["SensorTest"]["is_temperature_modified"] = str(
452
- st.session_state.isTemperatureModified_ST
453
- )
454
- config["SensorTest"]["temperature_input_option"] = str(
455
- st.session_state.temperatureoption_ST
456
- )
457
- config["SensorTest"]["is_fixed_temperature"] = str(
458
- st.session_state.isFixedTemperature_ST
459
- )
460
- config["SensorTest"]["fixed_temperature"] = str(
461
- st.session_state.fixedtemperature_ST
462
- )
463
- config["SensorTest"]["is_upload_temperature"] = str(
464
- st.session_state.isUploadTemperature_ST
465
- )
466
- config["SensorTest"]["temperature_file_path"] = ""
467
-
468
- # Tab 7:
469
-
470
- config["SensorTest"]["roll_check"] = str(st.session_state.isRollCheck_ST)
471
- config["SensorTest"]["roll_cutoff"] = str(st.session_state.roll_cutoff_ST)
472
- config["SensorTest"]["pitch_check"] = str(st.session_state.isPitchCheck_ST)
473
- config["SensorTest"]["pitch_cutoff"] = str(st.session_state.pitch_cutoff_ST)
474
-
475
- config["SensorTest"]["velocity_modified"] = str(
476
- st.session_state.isVelocityModifiedSound_ST
477
- )
478
-
479
- # ------------------
480
- # PAGE: QC Test
481
- # ------------------
482
- # Tab 2
483
- config["QCTest"]["qc_test"] = str(st.session_state.isQCTest)
484
- config["QCTest"]["qc_check"] = str(st.session_state.isQCCheck_QCT)
485
- config["QCTest"]["correlation"] = str(st.session_state.ct_QCT)
486
- config["QCTest"]["echo_intensity"] = str(st.session_state.et_QCT)
487
- config["QCTest"]["error_velocity"] = str(st.session_state.evt_QCT)
488
- config["QCTest"]["false_target"] = str(st.session_state.ft_QCT)
489
- config["QCTest"]["three_beam"] = str(st.session_state.is3beam_QCT)
490
- config["QCTest"]["percent_good"] = str(st.session_state.pgt_QCT)
491
-
492
- # Tab 4
493
- config["QCTest"]["beam_modified"] = str(st.session_state.isBeamModified_QCT)
494
- config["QCTest"]["orientation"] = str(st.session_state.beam_direction_QCT)
495
-
496
- # ------------------
497
- # PAGE: Profile Test
498
- # ------------------
499
- # Tab 1
500
- config["ProfileTest"]["profile_test"] = str(st.session_state.isProfileTest)
501
- config["ProfileTest"]["trim_ends_check"] = str(st.session_state.isTrimEndsCheck_PT)
502
- config["ProfileTest"]["trim_start_ensemble"] = str(st.session_state.start_ens_PT)
503
- config["ProfileTest"]["trim_end_ensemble"] = str(st.session_state.end_ens_PT)
504
-
505
- # Tab 2
506
- config["ProfileTest"]["cutbins_sidelobe_check"] = str(
507
- st.session_state.isCutBinSideLobeCheck_PT
508
- )
509
- config["ProfileTest"]["extra_cells"] = str(st.session_state.extra_cells_PT)
510
- config["ProfileTest"]["water_depth"] = str(st.session_state.water_depth_PT)
511
-
512
- # Tab 3
513
- # config["ProfileTest"]["manual_cutbins"] = str(
514
- # st.session_state.isCutBinManualCheck_PT
515
- # )
516
-
517
- # Tab 4
518
- config["ProfileTest"]["regrid"] = str(st.session_state.isRegridCheck_PT)
519
- config["ProfileTest"]["end_cell_option"] = str(st.session_state.end_cell_option_PT)
520
- config["ProfileTest"]["interpolate"] = str(st.session_state.interpolate_PT)
521
- config["ProfileTest"]["boundary"] = str(st.session_state.manualdepth_PT)
522
-
523
- # ------------------
524
- # PAGE: Velocity Test
525
- # ------------------
526
-
527
- config["VelocityTest"]["velocity_test"] = str(st.session_state.isVelocityTest)
528
-
529
- # Tab 1
530
- config["VelocityTest"]["magnetic_declination"] = str(
531
- st.session_state.isMagnetCheck_VT
532
- )
533
- config["VelocityTest"]["magnet_method"] = str(st.session_state.magnet_method_VT)
534
- config["VelocityTest"]["magnet_latitude"] = str(st.session_state.magnet_lat_VT)
535
- config["VelocityTest"]["magnet_longitude"] = str(st.session_state.magnet_lon_VT)
536
- config["VelocityTest"]["magnet_depth"] = str(st.session_state.magnet_depth_VT)
537
- config["VelocityTest"]["magnet_year"] = str(st.session_state.magnet_year_VT)
538
- config["VelocityTest"]["magnet_user_input"] = str(
539
- st.session_state.magnet_user_input_VT
540
- )
541
-
542
- # Tab 2
543
- config["VelocityTest"]["cutoff"] = str(st.session_state.isCutoffCheck_VT)
544
- config["VelocityTest"]["max_zonal_velocity"] = str(st.session_state.maxuvel_VT)
545
- config["VelocityTest"]["max_meridional_velocity"] = str(st.session_state.maxvvel_VT)
546
- config["VelocityTest"]["max_vertical_velocity"] = str(st.session_state.maxwvel_VT)
547
-
548
- # Tab 3
549
- config["VelocityTest"]["despike"] = str(st.session_state.isDespikeCheck_VT)
550
- config["VelocityTest"]["despike_kernel_size"] = str(
551
- st.session_state.despike_kernel_VT
552
- )
553
- config["VelocityTest"]["despike_cutoff"] = str(st.session_state.despike_cutoff_VT)
554
-
555
- # Tab 4
556
- config["VelocityTest"]["flatline"] = str(st.session_state.isFlatlineCheck_VT)
557
- config["VelocityTest"]["flatline_kernel_size"] = str(
558
- st.session_state.flatline_kernel_VT
559
- )
560
- config["VelocityTest"]["flatline_cutoff"] = str(st.session_state.flatline_cutoff_VT)
561
-
562
- # Optional section (attributes)
563
-
564
- for key, value in st.session_state.attributes.items():
565
- config["Attributes"][key] = str(value) # Ensure all values are strings
566
-
567
- # Write config.ini to a temporary file
568
- # config_filepath = "config.ini"
569
- # with open(config_filepath, "w") as configfile:
570
- # config.write(configfile)
571
- # Create a temporary file for the config.ini
572
- with tempfile.NamedTemporaryFile("w+", delete=False, suffix=".ini") as temp_config:
573
- config.write(temp_config)
574
- temp_config_path = temp_config.name
575
- # Allow the user to download the generated config.ini file
576
- with open(temp_config_path, "rb") as file:
577
- st.download_button(
578
- label="Download config.ini File",
579
- data=file,
580
- file_name="config.ini",
581
- )
582
-
583
- display_config_radio = st.radio(
584
- "Do you want to display config.ini file?", ("No", "Yes")
585
- )
586
- if display_config_radio == "Yes":
587
- st.write({section: dict(config[section]) for section in config.sections()})
@@ -1,64 +0,0 @@
1
- import os
2
- import tempfile
3
-
4
- import configparser
5
- import json
6
- import streamlit as st
7
- from utils.autoprocess import autoprocess
8
-
9
- # To make the page wider if the user presses the reload button.
10
- st.set_page_config(layout="wide")
11
-
12
- @st.cache_data
13
- def file_access(uploaded_file):
14
- """
15
- Function creates temporary directory to store the uploaded file.
16
- The path of the file is returned
17
-
18
- Args:
19
- uploaded_file (string): Name of the uploaded file
20
-
21
- Returns:
22
- path (string): Path of the uploaded file
23
- """
24
- temp_dir = tempfile.mkdtemp()
25
- path = os.path.join(temp_dir, uploaded_file.name)
26
- with open(path, "wb") as f:
27
- f.write(uploaded_file.getvalue())
28
- return path
29
-
30
-
31
- def display_config_as_json(config_file):
32
- config = configparser.ConfigParser()
33
- config.read_string(config_file.getvalue().decode("utf-8"))
34
- st.json({section: dict(config[section]) for section in config.sections()})
35
-
36
-
37
- def main():
38
- st.title("ADCP Data Auto Processing Tool")
39
- st.write("Upload a binary input file and config.ini file for processing.")
40
-
41
- # File Upload Section
42
- uploaded_binary_file = st.file_uploader(
43
- "Upload ADCP Binary File", type=["000", "bin"]
44
- )
45
- uploaded_config_file = st.file_uploader(
46
- "Upload Config File (config.ini)", type=["ini"]
47
- )
48
-
49
- if uploaded_binary_file and uploaded_config_file:
50
- st.success("Files uploaded successfully!")
51
-
52
- # Display config.ini file content as JSON
53
- display_config_as_json(uploaded_config_file)
54
-
55
- fpath = file_access(uploaded_binary_file)
56
- # Process files
57
- with st.spinner("Processing files. Please wait..."):
58
- autoprocess(uploaded_config_file, binary_file_path=fpath)
59
- st.success("Processing completed successfully!")
60
- st.write("Processed file written.")
61
-
62
-
63
- if __name__ == "__main__":
64
- main()
Binary file