Exceptions are added to manage error on algorithm bottom detection
parent
45aa5ae2f5
commit
5b63855bd8
|
|
@ -431,7 +431,7 @@ class AcousticDataTab(QWidget):
|
|||
self.gridlayout_compute_bathymetry.addWidget(self.combobox_freq_choice, 0, 0, 2, 1)
|
||||
|
||||
self.label_from_bathy = QLabel()
|
||||
self.label_from_bathy.setText("From ")
|
||||
self.label_from_bathy.setText("From - ")
|
||||
self.gridlayout_compute_bathymetry.addWidget(self.label_from_bathy, 0, 1, 1, 1)
|
||||
|
||||
self.spinbox_depth_min = QSpinBox()
|
||||
|
|
@ -443,7 +443,7 @@ class AcousticDataTab(QWidget):
|
|||
self.gridlayout_compute_bathymetry.addWidget(self.label_depth_min_unit, 0, 3, 1, 1)
|
||||
|
||||
self.label_to_bathy = QLabel()
|
||||
self.label_to_bathy.setText("to ")
|
||||
self.label_to_bathy.setText("to - ")
|
||||
self.gridlayout_compute_bathymetry.addWidget(self.label_to_bathy, 0, 4, 1, 1)
|
||||
|
||||
self.spinbox_depth_max = QSpinBox()
|
||||
|
|
@ -822,8 +822,14 @@ class AcousticDataTab(QWidget):
|
|||
|
||||
def plot_transect_with_BS_raw_data(self):
|
||||
# --- Condition if table is not filled ---
|
||||
|
||||
if self.tableModel.rowCount(1) == 10:
|
||||
if not self.lineEdit_acoustic_file.text():
|
||||
msgBox = QMessageBox()
|
||||
msgBox.setWindowTitle("Plot transect Error")
|
||||
msgBox.setIcon(QMessageBox.Warning)
|
||||
msgBox.setText("Load data before plot transect 2D field")
|
||||
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||
msgBox.exec()
|
||||
elif self.tableModel.rowCount(1) == 10:
|
||||
msgBox = QMessageBox()
|
||||
msgBox.setWindowTitle("Plot transect Error")
|
||||
msgBox.setIcon(QMessageBox.Warning)
|
||||
|
|
@ -925,7 +931,14 @@ class AcousticDataTab(QWidget):
|
|||
self.fig_BS.canvas.draw_idle()
|
||||
|
||||
def plot_transect_with_SNR_data(self):
|
||||
if self.tableModel.rowCount(1) == 10:
|
||||
if not self.lineEdit_noise_file.text():
|
||||
msgBox = QMessageBox()
|
||||
msgBox.setWindowTitle("Plot transect Error")
|
||||
msgBox.setIcon(QMessageBox.Warning)
|
||||
msgBox.setText("Load data before plot SNR 2D field")
|
||||
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||
msgBox.exec()
|
||||
elif self.tableModel.rowCount(1) == 10:
|
||||
msgBox = QMessageBox()
|
||||
msgBox.setWindowTitle("Plot transect Error")
|
||||
msgBox.setIcon(QMessageBox.Warning)
|
||||
|
|
@ -1076,8 +1089,8 @@ class AcousticDataTab(QWidget):
|
|||
# msgBox.setText("Plot transect before compute bathymety algorithm")
|
||||
# msgBox.setStandardButtons(QMessageBox.Ok)
|
||||
# msgBox.exec()
|
||||
# elif (self.canvas_BS) and (self.canvas_SNR == None):
|
||||
else:
|
||||
elif self.canvas_BS != None:
|
||||
# else:
|
||||
# --- Record frequency choose for bottom detection ---
|
||||
stg.freq_bottom_detection = self.combobox_freq_choice.currentIndex()
|
||||
|
||||
|
|
@ -1095,7 +1108,19 @@ class AcousticDataTab(QWidget):
|
|||
ind_min = np.where(stg.r >= rmin)[0][0]
|
||||
ind_max = np.where(stg.r <= rmax)[0][-1]
|
||||
# Getting the peak
|
||||
try:
|
||||
val_bottom[d] = np.nanmax(stg.BS_raw_data[ind_min:ind_max, self.combobox_freq_choice.currentIndex(), d])
|
||||
except ValueError as e:
|
||||
msgBox = QMessageBox()
|
||||
msgBox.setWindowTitle("Detect bottom Error")
|
||||
msgBox.setIcon(QMessageBox.Warning)
|
||||
msgBox.setText(f"{e} : maximum value of section bottom is not found. \n "
|
||||
f"Please change parameter of algorithm")
|
||||
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||
msgBox_return = msgBox.exec()
|
||||
if msgBox_return == msgBox.Ok:
|
||||
break #msgBox.close()
|
||||
else:
|
||||
# Getting the range cell of the peak
|
||||
ind_bottom = np.where(stg.BS_raw_data[ind_min:ind_max, self.combobox_freq_choice.currentIndex(), d]
|
||||
== val_bottom[d])[0][0]
|
||||
|
|
@ -1110,11 +1135,20 @@ class AcousticDataTab(QWidget):
|
|||
BS_section_bottom = np.zeros((stg.r.shape[0], stg.time.shape[0]))
|
||||
|
||||
for i in range(BS_section_bottom.shape[0]):
|
||||
# print(r_bottom_temp_ind[i])
|
||||
# print(i)
|
||||
try:
|
||||
BS_section_bottom[r_bottom_ind[i]][i] = 1
|
||||
# print(BS_section_bottom[r_bottom_temp_ind[i]][i])
|
||||
except IndexError as e:
|
||||
msgBox = QMessageBox()
|
||||
msgBox.setWindowTitle("Detect bottom Error")
|
||||
msgBox.setIcon(QMessageBox.Warning)
|
||||
msgBox.setText(f"{e} : maximum value of section bottom is not found. \n "
|
||||
f"Please change parameter of algorithm")
|
||||
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||
msgBox_return = msgBox.exec()
|
||||
if msgBox_return == msgBox.Ok:
|
||||
break # msgBox.close()
|
||||
|
||||
if BS_section_bottom.sum() > 2:
|
||||
# --- Record r_bottom for other tabs ---
|
||||
stg.r_bottom = r_bottom[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
|
||||
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]]
|
||||
|
|
@ -1154,7 +1188,7 @@ class AcousticDataTab(QWidget):
|
|||
self.fig_BS.canvas.draw_idle()
|
||||
|
||||
# --- Plot transect SNR with bathymetry ---
|
||||
|
||||
if self.canvas_SNR != None:
|
||||
x, y = np.meshgrid(
|
||||
stg.time[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
|
||||
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]],
|
||||
|
|
|
|||
Loading…
Reference in New Issue