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