pyadps 0.2.1b0__py3-none-any.whl → 0.3.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.
@@ -1,12 +1,15 @@
1
1
  import os
2
2
  import tempfile
3
3
 
4
+ import numpy as np
4
5
  import pandas as pd
5
6
  import streamlit as st
6
7
  import utils.readrdi as rd
7
- import utils.writenc as wr
8
- from streamlit.runtime.state import session_state
9
8
  from utils.signal_quality import default_mask
9
+ from utils.readrdi import ReadFile
10
+
11
+ # To make the page wider if the user presses the reload button.
12
+ st.set_page_config(layout="wide")
10
13
 
11
14
  """
12
15
  Streamlit page to load ADCP binary file and display File Header
@@ -110,7 +113,7 @@ if uploaded_file is not None:
110
113
  correlation = ds.correlation.data
111
114
  echo = ds.echo.data
112
115
  pgood = ds.percentgood.data
113
- beamdir = ds.fixedleader.system_configuration()['Beam Direction']
116
+ beamdir = ds.fixedleader.system_configuration()["Beam Direction"]
114
117
 
115
118
  st.session_state.fname = uploaded_file.name
116
119
  st.session_state.head = ds.fileheader
@@ -121,6 +124,14 @@ if uploaded_file is not None:
121
124
  st.session_state.correlation = ds.correlation.data
122
125
  st.session_state.pgood = ds.percentgood.data
123
126
  st.session_state.beam_direction = beamdir
127
+ st.session_state.sound_speed = ds.variableleader.speed_of_sound.data
128
+ st.session_state.depth = ds.variableleader.depth_of_transducer.data
129
+ st.session_state.temperature = (
130
+ ds.variableleader.temperature.data * ds.variableleader.temperature.scale
131
+ )
132
+ st.session_state.salinity = (
133
+ ds.variableleader.salinity.data * ds.variableleader.salinity.scale
134
+ )
124
135
 
125
136
  # st.session_state.flead = flead
126
137
  # st.session_state.vlead = vlead
@@ -134,6 +145,9 @@ if uploaded_file is not None:
134
145
  elif "flead" in st.session_state:
135
146
  st.write("You selected `%s`" % st.session_state.fname)
136
147
  else:
148
+ # reset the cache and resources if the user press reload button.
149
+ st.cache_data.clear()
150
+ st.cache_resource.clear()
137
151
  st.stop()
138
152
 
139
153
  ########## TIME AXIS ##############
@@ -168,10 +182,63 @@ date_df = pd.DataFrame(
168
182
  st.session_state.date = pd.to_datetime(date_df)
169
183
  st.session_state.date1 = pd.to_datetime(date_df)
170
184
  st.session_state.date2 = pd.to_datetime(date_df)
185
+ st.session_state.ensemble_axis = np.arange(0, st.session_state.head.ensembles, 1)
171
186
 
172
187
 
173
-
174
- ######### MASK DATA ##############
188
+ # ---------- Initialize all options -------------
189
+ # ------------------
190
+ # Global Tests
191
+ # ------------------
192
+ # Checks if the following tests are carried out
193
+ st.session_state.isSensorTest = False
194
+ st.session_state.isQCTest = False
195
+ st.session_state.isProfileTest = False
196
+ st.session_state.isGrid = False
197
+ st.session_state.isGridSave = False
198
+ st.session_state.isVelocityTest = False
199
+
200
+ # Check if visiting the page first time
201
+ st.session_state.isFirstSensorVisit = True
202
+ st.session_state.isFirstQCVisit = True
203
+ st.session_state.isFirstProfileVisit = True
204
+ st.session_state.isFirstVelocityVisit = True
205
+ # ------------------
206
+ # Local Tests:
207
+ # ------------------
208
+ st.session_state.isRollCheck = False
209
+ st.session_state.isPitchCheck = False
210
+
211
+ st.session_state.isQCCheck = False
212
+ st.session_state.isBeamModified = False
213
+
214
+ st.session_state.isTrimEndsCheck = False
215
+ st.session_state.isCutBinSideLobeCheck = False
216
+ st.session_state.isCutBinManualCheck = False
217
+ st.session_state.isRegridCheck = False
218
+
219
+ st.session_state.isMagnetCheck = False
220
+ st.session_state.isDespikeCheck = False
221
+ st.session_state.isFlatlineCheck = False
222
+ st.session_state.isCutoffCheck = False
223
+
224
+
225
+ # ------------------
226
+ # Data Modifications
227
+ # ------------------
228
+ # SENSOR TEST
229
+ # Velocity Modified Based on Sound
230
+ st.session_state.isVelocityModifiedSound = False
231
+ # Transducer depth modified based on Pressure sensor
232
+ st.session_state.isDepthModified = False
233
+ st.session_state.isTemperatureModified = False
234
+ st.session_state.isSalinityModified = False
235
+ # QC TEST
236
+ st.session_state.isBeamModified = False
237
+ # VELOCITY TEST
238
+ # Velocity Modified based on magnetic declination
239
+ st.session_state.isVelocityModifiedMagnet = False
240
+
241
+ # MASK DATA
175
242
  # The velocity data has missing values due to the cutoff
176
243
  # criteria used before deployment. The `default_mask` uses
177
244
  # the velocity to create a mask. This mask file is stored
@@ -180,16 +247,17 @@ st.session_state.date2 = pd.to_datetime(date_df)
180
247
  # WARNING: Never Change `st.session_state.orig_mask` in the code!
181
248
  #
182
249
  if "orig_mask" not in st.session_state:
183
- st.session_state.orig_mask = default_mask(
184
- st.session_state.flead, st.session_state.velocity
185
- )
250
+ ds = st.session_state.ds
251
+ st.session_state.orig_mask = default_mask(ds)
186
252
 
187
- # Checks if the following quality checks are carried out
188
- st.session_state.isQCMask = False
189
- st.session_state.isProfileMask = False
190
- st.session_state.isGrid = False
191
- st.session_state.isGridSave = False
192
- st.session_state.isVelocityMask = False
253
+ # ----------------------
254
+ # Page returning options
255
+ # ----------------------
256
+ # This checks if we have returned back to the page after saving the data
257
+ st.session_state.isSensorPageReturn = False
258
+ st.session_state.isQCPageReturn = False
259
+ st.session_state.isProfilePageReturn = False
260
+ st.session_state.isVelocityPageReturn = False
193
261
 
194
262
  ########## FILE HEADER ###############
195
263
  st.header("File Header", divider="blue")
@@ -266,10 +334,18 @@ if flead_check_button:
266
334
 
267
335
  flead_button = st.button("Fixed Leader")
268
336
  if flead_button:
337
+ # Pandas array should have all elements with same data type.
338
+ # Except Sl. no., which is np.uint64, rest are np.int64.
339
+ # Convert all datatype to uint64
340
+ fl_dict = st.session_state.flead.field().items()
341
+ new_dict = {}
342
+ for key, value in fl_dict:
343
+ new_dict[key] = value.astype(np.uint64)
344
+
269
345
  df = pd.DataFrame(
270
346
  {
271
- "Fields": st.session_state.flead.field().keys(),
272
- "Values": st.session_state.flead.field().values(),
347
+ "Fields": new_dict.keys(),
348
+ "Values": new_dict.values(),
273
349
  }
274
350
  )
275
351
  st.dataframe(df, use_container_width=True)
@@ -287,4 +363,3 @@ with right:
287
363
  df = df.astype("str")
288
364
  st.write((df.style.map(color_bool2)))
289
365
  # st.dataframe(df)
290
-
@@ -84,45 +84,81 @@ The ordinate (y-axis) for the heatmap is `bins` as the depth correction is not a
84
84
  xbutton = st.radio("Select an x-axis to plot", ["time", "ensemble"], horizontal=True)
85
85
 
86
86
 
87
+ tab1, tab2, tab3, tab4 = st.tabs(["Primary Data", "Variable Leader", "Fixed Leader", "Advanced"])
88
+
89
+ with tab3:
87
90
  # Fixed Leader Plots
88
- st.header("Fixed Leader", divider="blue")
89
- fbutton = st.radio("Select a dynamic variable to plot:", fdata.keys(), horizontal=True)
90
- lineplot(fdata[fbutton], fbutton, xaxis=str(xbutton))
91
+ st.header("Fixed Leader", divider="blue")
92
+ fbutton = st.radio("Select a dynamic variable to plot:", fdata.keys(), horizontal=True)
93
+ lineplot(fdata[fbutton], fbutton, xaxis=str(xbutton))
91
94
 
95
+ with tab2:
92
96
  # Variable Leader Plots
93
- st.header("Variable Leader", divider="blue")
94
- vbutton = st.radio("Select a dynamic variable to plot:", vdata.keys(), horizontal=True)
95
- lineplot(vdata[vbutton], vbutton, xaxis=str(xbutton))
96
-
97
- basic_options = [
98
- "Pressure",
99
- "Temperature",
100
- "Salinity",
101
- "Depth of Transducer",
102
- "Heading",
103
- "Pitch",
104
- "Roll",
105
- ]
106
-
97
+ st.header("Variable Leader", divider="blue")
98
+ vbutton = st.radio("Select a dynamic variable to plot:", vdata.keys(), horizontal=True)
99
+ lineplot(vdata[vbutton], vbutton, xaxis=str(xbutton))
107
100
 
108
- st.header("Velocity, Echo Intensity, Correlation & Percent Good", divider="blue")
101
+ with tab1:
102
+ st.header("Velocity, Echo Intensity, Correlation & Percent Good", divider="blue")
109
103
 
110
104
 
111
- def call_plot(varname, beam, xaxis="time"):
112
- if varname == "Velocity":
113
- fillplot_plotly(velocity[beam - 1, :, :], title=varname, xaxis=xaxis)
114
- elif varname == "Echo":
115
- fillplot_plotly(echo[beam - 1, :, :], title=varname, xaxis=xaxis)
116
- elif varname == "Correlation":
117
- fillplot_plotly(correlation[beam - 1, :, :], title=varname, xaxis=xaxis)
118
- elif varname == "Percent Good":
119
- fillplot_plotly(pgood[beam - 1, :, :], title=varname, xaxis=xaxis)
105
+ def call_plot(varname, beam, xaxis="time"):
106
+ if varname == "Velocity":
107
+ fillplot_plotly(velocity[beam - 1, :, :], title=varname, xaxis=xaxis)
108
+ elif varname == "Echo":
109
+ fillplot_plotly(echo[beam - 1, :, :], title=varname, xaxis=xaxis)
110
+ elif varname == "Correlation":
111
+ fillplot_plotly(correlation[beam - 1, :, :], title=varname, xaxis=xaxis)
112
+ elif varname == "Percent Good":
113
+ fillplot_plotly(pgood[beam - 1, :, :], title=varname, xaxis=xaxis)
120
114
 
121
115
 
122
- var_option = st.selectbox(
123
- "Select a data type", ("Velocity", "Echo", "Correlation", "Percent Good")
124
- )
125
- beam = st.radio("Select beam", (1, 2, 3, 4), horizontal=True)
126
- call_plot(var_option, beam, xaxis=str(xbutton))
127
-
116
+ var_option = st.selectbox(
117
+ "Select a data type", ("Velocity", "Echo", "Correlation", "Percent Good")
118
+ )
119
+ beam = st.radio("Select beam", (1, 2, 3, 4), horizontal=True)
120
+ call_plot(var_option, beam, xaxis=str(xbutton))
121
+
122
+
123
+ with tab4:
124
+ st.header("Advanced Data", divider="blue")
125
+ adv_option = st.selectbox(
126
+ "Select a data type", ("Bit Result",
127
+ "ADC Channel",
128
+ "Error Status Word 1",
129
+ "Error Status Word 2",
130
+ "Error Status Word 3",
131
+ "Error Status Word 4"))
132
+ if adv_option == "Bit Result":
133
+ bitdata = st.session_state.vlead.bitresult()
134
+ st.subheader("BIT Result", divider="orange")
135
+ st.write("""
136
+ This field contains the results of Workhorse ADCPs builtin test functions.
137
+ A zero indicates a successful BIT result.
138
+ """)
139
+ bitbutton = st.radio("Select a dynamic variable to plot:", bitdata.keys(), horizontal=True)
140
+ lineplot(bitdata[bitbutton], bitbutton, xaxis=str(xbutton))
141
+
142
+ elif adv_option == "ADC Channel":
143
+ adcdata = st.session_state.vlead.adc_channel()
144
+ st.subheader("ADC Channel", divider="orange")
145
+ adcbutton = st.radio("Select a dynamic variable to plot:", adcdata.keys(), horizontal=True)
146
+ lineplot(adcdata[adcbutton], adcbutton, xaxis=str(xbutton))
147
+ elif adv_option == "Error Status Word 1":
148
+ errordata1 = st.session_state.vlead.error_status_word(esw=1)
149
+ st.subheader("Error Status Word", divider="orange")
150
+ errorbutton = st.radio("Select a dynamic variable to plot:", errordata1.keys(), horizontal=True)
151
+ lineplot(errordata1[errorbutton], errorbutton, xaxis=str(xbutton))
152
+ elif adv_option == "Error Status Word 2":
153
+ errordata2 = st.session_state.vlead.error_status_word(esw=2)
154
+ errorbutton = st.radio("Select a dynamic variable to plot:", errordata2.keys(), horizontal=True)
155
+ lineplot(errordata2[errorbutton], errorbutton, xaxis=str(xbutton))
156
+ elif adv_option == "Error Status Word 3":
157
+ errordata3 = st.session_state.vlead.error_status_word(esw=3)
158
+ errorbutton = st.radio("Select a dynamic variable to plot:", errordata3.keys(), horizontal=True)
159
+ lineplot(errordata3[errorbutton], errorbutton, xaxis=str(xbutton))
160
+ elif adv_option == "Error Status Word 4":
161
+ errordata4 = st.session_state.vlead.error_status_word(esw=4)
162
+ errorbutton = st.radio("Select a dynamic variable to plot:", errordata4.keys(), horizontal=True)
163
+ lineplot(errordata4[errorbutton], errorbutton, xaxis=str(xbutton))
128
164