Compare commits
3 Commits
79ee1c3cfa
...
84fe5738a3
| Author | SHA1 | Date |
|---|---|---|
|
|
84fe5738a3 | |
|
|
1fe6b6a1e1 | |
|
|
9857615a12 |
|
|
@ -113,7 +113,6 @@ class ReadTableForOpen:
|
|||
WHERE (acoustic_data = {k})
|
||||
'''
|
||||
data = self.execute(query)[0]
|
||||
print("data acoustic file", data)
|
||||
|
||||
stg.filename_BS_raw_data.append(
|
||||
str(data[1]) + '.aqa'
|
||||
|
|
@ -434,10 +433,18 @@ class ReadTableForOpen:
|
|||
for dest, resh in SNR_vars:
|
||||
SNR = np_f64_parse(next(it))
|
||||
|
||||
if len(SNR) == 0:
|
||||
try:
|
||||
if len(SNR) != 0:
|
||||
dest.append(SNR.reshape(resh[i].shape))
|
||||
else:
|
||||
dest.append(np.array([]))
|
||||
except:
|
||||
logger.warning(
|
||||
"SQL: read_table_BS_raw_data_SNR: "
|
||||
+ "failed to reshape data from "
|
||||
+ f"{SNR.shape} to {resh[i].shape}"
|
||||
)
|
||||
dest.append(np.array([]))
|
||||
else:
|
||||
dest.append(SNR.reshape(resh[i].shape))
|
||||
|
||||
def read_table_BS_raw_data_rest(self, query, i):
|
||||
np_f64_parse = lambda d: np.frombuffer(d, dtype=np.float64)
|
||||
|
|
|
|||
|
|
@ -815,6 +815,7 @@ class AcousticDataTab(QWidget):
|
|||
self.fill_table()
|
||||
self.compute_tmin_tmax()
|
||||
self.compute_rmin_rmax()
|
||||
# self.compute_time_cross_section()
|
||||
self.update_frequency_combobox()
|
||||
# self.fileListWidget.itemSelectionChanged.connect(self.plot_backscattered_acoustic_signal_recording)
|
||||
# self.fileListWidget.itemSelectionChanged.connect(self.plot_profile)
|
||||
|
|
@ -825,8 +826,13 @@ class AcousticDataTab(QWidget):
|
|||
self.fileListWidget.blockSignals(False)
|
||||
|
||||
def print_selected_file(self):
|
||||
print(f"Selected file in list widget : {self.fileListWidget.selectedItems()}")
|
||||
print("self.fileListWidget.selectedItems()[1:] : ", self.fileListWidget.selectedItems()[1:])
|
||||
logger.debug(
|
||||
f"Selected file in list widget : {self.fileListWidget.selectedItems()}"
|
||||
)
|
||||
logger.debug(
|
||||
"self.fileListWidget.selectedItems()[1:] : "
|
||||
+ f"{self.fileListWidget.selectedItems()[1:]}"
|
||||
)
|
||||
if len(self.fileListWidget.selectedItems()) > self.max_selected_file:
|
||||
self.fileListWidget.setSelectionMode(1)
|
||||
|
||||
|
|
@ -1244,6 +1250,7 @@ class AcousticDataTab(QWidget):
|
|||
self.fill_table()
|
||||
|
||||
self.compute_rmin_rmax()
|
||||
self.compute_time_cross_section()
|
||||
self.compute_depth_cross_section()
|
||||
self.set_range_for_spinboxes_bathymetry()
|
||||
|
||||
|
|
@ -1448,13 +1455,6 @@ class AcousticDataTab(QWidget):
|
|||
self.fileListWidget.blockSignals(False)
|
||||
|
||||
def rename_file_in_ListWidget(self, event):
|
||||
if event == QEvent.MouseButtonPress:
|
||||
print("c'est bon")
|
||||
if event.button == Qt.RightButton:
|
||||
print("Right button clicked")
|
||||
elif event.button == Qt.LeftButton:
|
||||
print("Left button clicked")
|
||||
|
||||
if event.type() == QEvent.ContextMenu:
|
||||
menu = QMenu()
|
||||
menu.addAction('Rename')
|
||||
|
|
@ -2143,17 +2143,6 @@ class AcousticDataTab(QWidget):
|
|||
self.tableModel = TableModel(stg.DataFrame_acoustic)
|
||||
self.tableView.setModel(self.tableModel)
|
||||
|
||||
def export_table(self):
|
||||
if self.tableWidget.columnCount() == 10:
|
||||
msgBox = QMessageBox()
|
||||
msgBox.setWindowTitle("Export table Error")
|
||||
msgBox.setIcon(QMessageBox.Warning)
|
||||
msgBox.setText("Fill table before export table")
|
||||
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||
msgBox.exec()
|
||||
else:
|
||||
print("export table")
|
||||
|
||||
def transect_xaxis_choice(self):
|
||||
if self.groupbox_xaxis_time.isChecked() == True:
|
||||
self.groupbox_xaxis_space.setChecked(False)
|
||||
|
|
@ -2267,7 +2256,7 @@ class AcousticDataTab(QWidget):
|
|||
)
|
||||
)
|
||||
)[0][0] + 1,
|
||||
time_max
|
||||
time_max
|
||||
))
|
||||
|
||||
stg.time_cross_section[data_id] = (
|
||||
|
|
|
|||
|
|
@ -301,7 +301,6 @@ class Ui_MainWindow(object):
|
|||
msg_box.exec()
|
||||
|
||||
def about_window(self):
|
||||
print("about")
|
||||
aw = AboutWindow()
|
||||
aw.exec()
|
||||
|
||||
|
|
@ -314,7 +313,6 @@ class Ui_MainWindow(object):
|
|||
)
|
||||
|
||||
def open_doc_file(self, filename):
|
||||
print(self.current_file_path("filename.pdf"))
|
||||
QtGui.QDesktopServices.openUrl(
|
||||
QtCore.QUrl(
|
||||
f"file://{self.current_file_path(filename)}"
|
||||
|
|
@ -335,15 +333,11 @@ class Ui_MainWindow(object):
|
|||
name = QtWidgets.QFileDialog.getExistingDirectory(
|
||||
caption="Select Directory - Acoustic BS raw data Table"
|
||||
)
|
||||
print("name table to save ", name)
|
||||
|
||||
# --- Save the raw acoustic backscatter data from a
|
||||
# --- Dataframe to csv file ---
|
||||
|
||||
t0 = time.time()
|
||||
print("len(stg.BS_raw_data_reshape) ",
|
||||
len(stg.BS_raw_data_reshape))
|
||||
|
||||
if name:
|
||||
for i in range(len(stg.BS_raw_data_reshape)):
|
||||
header_list = []
|
||||
|
|
@ -393,8 +387,7 @@ class Ui_MainWindow(object):
|
|||
)
|
||||
|
||||
t1 = time.time() - t0
|
||||
print("time duration export BS ", t1)
|
||||
print("table of BS value Export finished")
|
||||
logger.debug(f"Time duration export BS {t1}")
|
||||
|
||||
def retranslateUi(self):
|
||||
_translate = QtCore.QCoreApplication.translate
|
||||
|
|
|
|||
|
|
@ -2003,9 +2003,6 @@ class SedimentCalibrationTab(QWidget):
|
|||
bs_data = data
|
||||
break
|
||||
|
||||
print(f"{stg.depth_2D[i].shape}")
|
||||
print(f"{stg.depth_2D[i]}")
|
||||
|
||||
J_cross_section_freq1 = self.inv_hc.j_cross_section(
|
||||
BS = bs_data[i][
|
||||
stg.frequencies_for_calibration[0][1], :, :
|
||||
|
|
|
|||
|
|
@ -548,9 +548,8 @@ class SignalProcessingTab(QWidget):
|
|||
)
|
||||
|
||||
def update_SignalPreprocessingTab(self):
|
||||
|
||||
""" The tab is updated in two cases :
|
||||
- the user remove a file (in the list widget) in the first tab (Acoustic data), so that the combobox
|
||||
- the user remove a file (in the list widget) in the first tab (Acoustic data), so that the combobox
|
||||
of data to be processed is updated,
|
||||
- the user change the limits of one or all the records in the first tab (Acoustic data) """
|
||||
if len(stg.filename_BS_raw_data) == 0:
|
||||
|
|
@ -627,13 +626,68 @@ class SignalProcessingTab(QWidget):
|
|||
|
||||
if stg.noise_method[data_id] == 0:
|
||||
if stg.filename_BS_noise_data[data_id] != "":
|
||||
self.load_noise_data_and_compute_SNR()
|
||||
if len(stg.BS_noise_raw_data) == 0:
|
||||
self.load_noise_data_and_compute_SNR()
|
||||
else:
|
||||
self.compute_noise()
|
||||
elif stg.noise_method[data_id] == 1:
|
||||
self.compute_noise_from_profile_tail_value()
|
||||
|
||||
self.remove_point_with_snr_filter()
|
||||
self.compute_averaged_BS_data()
|
||||
|
||||
def compute_noise(self):
|
||||
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
|
||||
|
||||
if stg.time_cross_section[data_id].shape != (0,):
|
||||
stg.time_noise[data_id] = (
|
||||
stg.time_cross_section[data_id]
|
||||
)
|
||||
else:
|
||||
stg.time_noise[data_id] = (
|
||||
stg.time[data_id]
|
||||
)
|
||||
if stg.depth_cross_section[data_id].shape != (0,):
|
||||
stg.depth_noise[data_id] = (
|
||||
stg.depth_cross_section[data_id]
|
||||
)
|
||||
else:
|
||||
stg.depth_noise[data_id] = (
|
||||
stg.depth[data_id]
|
||||
)
|
||||
|
||||
if self._is_correct_shape(stg.BS_stream_bed):
|
||||
BS_data = stg.BS_stream_bed
|
||||
SNR_data = stg.SNR_stream_bed
|
||||
elif self._is_correct_shape(stg.BS_cross_section):
|
||||
BS_data = stg.BS_cross_section
|
||||
SNR_data = stg.SNR_cross_section
|
||||
else:
|
||||
BS_data = stg.BS_raw_data
|
||||
SNR_data = stg.SNR_raw_data
|
||||
|
||||
noise = np.zeros(BS_data[data_id].shape)
|
||||
for f, _ in enumerate(BS_data[data_id]):
|
||||
noise[f, :, :] = np.mean(
|
||||
stg.BS_noise_raw_data[data_id][f, :, :], axis=(0, 1)
|
||||
)
|
||||
|
||||
stg.BS_noise_averaged_data[data_id] = noise
|
||||
|
||||
SNR_data[data_id] = (
|
||||
np.divide(
|
||||
(
|
||||
BS_data[data_id] - stg.BS_noise_averaged_data[data_id]
|
||||
) ** 2,
|
||||
stg.BS_noise_averaged_data[data_id] ** 2
|
||||
)
|
||||
)
|
||||
|
||||
self.combobox_frequency_profile.clear()
|
||||
self.combobox_frequency_profile.addItems(
|
||||
[f for f in stg.freq_text[data_id]]
|
||||
)
|
||||
|
||||
def replot(self):
|
||||
self.plot_averaged_profile_tail()
|
||||
self.plot_transect_with_SNR_data()
|
||||
|
|
@ -909,7 +963,7 @@ class SignalProcessingTab(QWidget):
|
|||
|
||||
stg.BS_stream_bed_pre_process_SNR[data_id] = np.array([])
|
||||
stg.BS_stream_bed_pre_process_average[data_id] = np.array([])
|
||||
print("stg.noise_method[data_id]", stg.noise_method[data_id])
|
||||
|
||||
if stg.noise_method[data_id] == 0:
|
||||
self.lineEdit_noise_file.clear()
|
||||
|
||||
|
|
@ -1034,50 +1088,42 @@ class SignalProcessingTab(QWidget):
|
|||
|
||||
stg.noise_method[data_id] = 0
|
||||
|
||||
noise_data = AcousticDataLoader(stg.path_BS_noise_data[data_id] +
|
||||
"/" +
|
||||
stg.filename_BS_noise_data[data_id])
|
||||
noise_data = AcousticDataLoader(
|
||||
os.path.join(
|
||||
stg.path_BS_noise_data[data_id],
|
||||
stg.filename_BS_noise_data[data_id]
|
||||
)
|
||||
)
|
||||
stg.BS_noise_raw_data[data_id] = noise_data._BS_raw_data
|
||||
|
||||
stg.time_noise[data_id] = noise_data._time
|
||||
stg.depth_noise[data_id] = noise_data._r
|
||||
|
||||
if stg.BS_stream_bed[data_id].shape != (0,):
|
||||
|
||||
noise = np.zeros(stg.BS_stream_bed[data_id].shape)
|
||||
for f, _ in enumerate(noise_data._freq):
|
||||
noise[f, :, :] = np.mean(
|
||||
stg.BS_noise_raw_data[data_id][f, :, :], axis=(0, 1))
|
||||
stg.BS_noise_averaged_data[data_id] = noise
|
||||
stg.SNR_stream_bed[data_id] = (
|
||||
np.divide((stg.BS_stream_bed[data_id] -
|
||||
stg.BS_noise_averaged_data[data_id]) ** 2,
|
||||
stg.BS_noise_averaged_data[data_id] ** 2))
|
||||
|
||||
BS_data = stg.BS_stream_bed
|
||||
SNR_data = stg.SNR_stream_bed
|
||||
elif stg.BS_cross_section[data_id].shape != (0,):
|
||||
|
||||
noise = np.zeros(stg.BS_cross_section[data_id].shape)
|
||||
for f, _ in enumerate(noise_data._freq):
|
||||
noise[f, :, :] = np.mean(
|
||||
stg.BS_noise_raw_data[data_id][f, :, :], axis=(0, 1))
|
||||
stg.BS_noise_averaged_data[data_id] = noise
|
||||
stg.SNR_cross_section[data_id] = (
|
||||
np.divide((stg.BS_cross_section[data_id] -
|
||||
stg.BS_noise_averaged_data[data_id]) ** 2,
|
||||
stg.BS_noise_averaged_data[data_id] ** 2))
|
||||
# stg.SNR_reshape = np.reshape(stg.SNR_cross_section, (stg.r.shape[1] * stg.t.shape[1], stg.freq.shape[0]), order="F")
|
||||
|
||||
BS_data = stg.BS_cross_section
|
||||
SNR_data = stg.SNR_cross_section
|
||||
else:
|
||||
BS_data = stg.BS_raw_data
|
||||
SNR_data = stg.SNR_raw_data
|
||||
|
||||
noise = np.zeros(stg.BS_raw_data[data_id].shape)
|
||||
for f, _ in enumerate(noise_data._freq):
|
||||
noise[f, :, :] = np.mean(
|
||||
stg.BS_noise_raw_data[data_id][f, :, :], axis=(0, 1))
|
||||
stg.BS_noise_averaged_data[data_id] = noise
|
||||
stg.SNR_raw_data[data_id] = (
|
||||
np.divide((stg.BS_raw_data[data_id] -
|
||||
stg.BS_noise_averaged_data[data_id]) ** 2,
|
||||
stg.BS_noise_averaged_data[data_id] ** 2))
|
||||
noise = np.zeros(BS_data[data_id].shape)
|
||||
for f, _ in enumerate(noise_data._freq):
|
||||
noise[f, :, :] = np.mean(
|
||||
stg.BS_noise_raw_data[data_id][f, :, :], axis=(0, 1)
|
||||
)
|
||||
|
||||
stg.BS_noise_averaged_data[data_id] = noise
|
||||
SNR_data[data_id] = (
|
||||
np.divide(
|
||||
(
|
||||
BS_data[data_id] - stg.BS_noise_averaged_data[data_id]
|
||||
) ** 2,
|
||||
stg.BS_noise_averaged_data[data_id] ** 2
|
||||
)
|
||||
)
|
||||
|
||||
def open_plot_noise_window(self):
|
||||
pnw = PlotNoiseWindow()
|
||||
|
|
@ -1091,6 +1137,11 @@ class SignalProcessingTab(QWidget):
|
|||
float(self.lineEdit_profile_tail_value.text().replace(",", "."))
|
||||
)
|
||||
|
||||
self.compute_noise_from_profile_tail_value_compute()
|
||||
|
||||
def compute_noise_from_profile_tail_value_compute(self):
|
||||
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
|
||||
|
||||
if stg.time_cross_section[data_id].shape != (0,):
|
||||
stg.time_noise[data_id] = (
|
||||
stg.time_cross_section[data_id]
|
||||
|
|
@ -1110,47 +1161,38 @@ class SignalProcessingTab(QWidget):
|
|||
|
||||
# --- Compute noise from value and compute SNR ---
|
||||
if self._is_correct_shape(stg.BS_stream_bed):
|
||||
stg.BS_noise_raw_data[data_id] = np.array([])
|
||||
stg.BS_noise_raw_data[data_id] = (
|
||||
np.full(stg.BS_stream_bed[data_id].shape,
|
||||
float(self.lineEdit_profile_tail_value.text().replace(",", "."))))
|
||||
|
||||
stg.BS_noise_averaged_data[data_id] = (
|
||||
stg.BS_noise_raw_data[data_id][:, :,
|
||||
:stg.BS_stream_bed[data_id].shape[2]])
|
||||
stg.SNR_stream_bed[data_id] = (
|
||||
np.divide((stg.BS_stream_bed[data_id]
|
||||
- stg.BS_noise_raw_data[data_id]) ** 2,
|
||||
stg.BS_noise_raw_data[data_id] ** 2))
|
||||
|
||||
BS_data = stg.BS_stream_bed
|
||||
SNR_data = stg.SNR_stream_bed
|
||||
elif self._is_correct_shape(stg.BS_cross_section):
|
||||
stg.BS_noise_raw_data[data_id] = (
|
||||
np.full(stg.BS_cross_section[data_id].shape,
|
||||
float(self.lineEdit_profile_tail_value.text().replace(",", "."))))
|
||||
|
||||
stg.BS_noise_averaged_data[data_id] = (
|
||||
stg.BS_noise_raw_data[data_id][:, :,
|
||||
:stg.BS_cross_section[data_id].shape[2]])
|
||||
stg.SNR_cross_section[data_id] = (
|
||||
np.divide((stg.BS_cross_section[data_id]
|
||||
- stg.BS_noise_raw_data[data_id]) ** 2,
|
||||
stg.BS_noise_raw_data[data_id] ** 2)) #
|
||||
|
||||
BS_data = stg.BS_cross_section
|
||||
SNR_data = stg.SNR_cross_section
|
||||
else:
|
||||
stg.BS_noise_raw_data[data_id] = (
|
||||
np.full(stg.BS_raw_data[data_id].shape,
|
||||
float(self.lineEdit_profile_tail_value.text().replace(",", "."))))
|
||||
BS_data = stg.BS_raw_data
|
||||
SNR_data = stg.SNR_raw_data
|
||||
|
||||
stg.BS_noise_averaged_data[data_id] = (
|
||||
stg.BS_noise_raw_data[data_id])
|
||||
stg.SNR_raw_data[data_id] = (
|
||||
np.divide((stg.BS_raw_data[data_id]
|
||||
- stg.BS_noise_raw_data[data_id]) ** 2,
|
||||
stg.BS_noise_raw_data[data_id] ** 2))
|
||||
stg.BS_noise_raw_data[data_id] = (
|
||||
np.full(
|
||||
BS_data[data_id].shape,
|
||||
float(self.lineEdit_profile_tail_value.text().replace(",", "."))
|
||||
)
|
||||
)
|
||||
|
||||
stg.BS_noise_averaged_data[data_id] = (
|
||||
stg.BS_noise_raw_data[data_id]
|
||||
)
|
||||
SNR_data[data_id] = (
|
||||
np.divide(
|
||||
(
|
||||
BS_data[data_id] - stg.BS_noise_raw_data[data_id]
|
||||
) ** 2,
|
||||
stg.BS_noise_raw_data[data_id] ** 2
|
||||
)
|
||||
)
|
||||
|
||||
self.combobox_frequency_profile.clear()
|
||||
self.combobox_frequency_profile.addItems(
|
||||
[f for f in stg.freq_text[data_id]])
|
||||
[f for f in stg.freq_text[data_id]]
|
||||
)
|
||||
|
||||
# --- Trigger graphic widgets ---
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue