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.gridlayout_compute_bathymetry.addWidget(self.combobox_freq_choice, 0, 0, 2, 1)
|
||||||
|
|
||||||
self.label_from_bathy = QLabel()
|
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.gridlayout_compute_bathymetry.addWidget(self.label_from_bathy, 0, 1, 1, 1)
|
||||||
|
|
||||||
self.spinbox_depth_min = QSpinBox()
|
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.gridlayout_compute_bathymetry.addWidget(self.label_depth_min_unit, 0, 3, 1, 1)
|
||||||
|
|
||||||
self.label_to_bathy = QLabel()
|
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.gridlayout_compute_bathymetry.addWidget(self.label_to_bathy, 0, 4, 1, 1)
|
||||||
|
|
||||||
self.spinbox_depth_max = QSpinBox()
|
self.spinbox_depth_max = QSpinBox()
|
||||||
|
|
@ -822,8 +822,14 @@ class AcousticDataTab(QWidget):
|
||||||
|
|
||||||
def plot_transect_with_BS_raw_data(self):
|
def plot_transect_with_BS_raw_data(self):
|
||||||
# --- Condition if table is not filled ---
|
# --- Condition if table is not filled ---
|
||||||
|
if not self.lineEdit_acoustic_file.text():
|
||||||
if self.tableModel.rowCount(1) == 10:
|
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 = QMessageBox()
|
||||||
msgBox.setWindowTitle("Plot transect Error")
|
msgBox.setWindowTitle("Plot transect Error")
|
||||||
msgBox.setIcon(QMessageBox.Warning)
|
msgBox.setIcon(QMessageBox.Warning)
|
||||||
|
|
@ -925,7 +931,14 @@ class AcousticDataTab(QWidget):
|
||||||
self.fig_BS.canvas.draw_idle()
|
self.fig_BS.canvas.draw_idle()
|
||||||
|
|
||||||
def plot_transect_with_SNR_data(self):
|
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 = QMessageBox()
|
||||||
msgBox.setWindowTitle("Plot transect Error")
|
msgBox.setWindowTitle("Plot transect Error")
|
||||||
msgBox.setIcon(QMessageBox.Warning)
|
msgBox.setIcon(QMessageBox.Warning)
|
||||||
|
|
@ -1076,8 +1089,8 @@ class AcousticDataTab(QWidget):
|
||||||
# msgBox.setText("Plot transect before compute bathymety algorithm")
|
# msgBox.setText("Plot transect before compute bathymety algorithm")
|
||||||
# msgBox.setStandardButtons(QMessageBox.Ok)
|
# msgBox.setStandardButtons(QMessageBox.Ok)
|
||||||
# msgBox.exec()
|
# msgBox.exec()
|
||||||
# elif (self.canvas_BS) and (self.canvas_SNR == None):
|
elif self.canvas_BS != None:
|
||||||
else:
|
# else:
|
||||||
# --- Record frequency choose for bottom detection ---
|
# --- Record frequency choose for bottom detection ---
|
||||||
stg.freq_bottom_detection = self.combobox_freq_choice.currentIndex()
|
stg.freq_bottom_detection = self.combobox_freq_choice.currentIndex()
|
||||||
|
|
||||||
|
|
@ -1095,114 +1108,135 @@ class AcousticDataTab(QWidget):
|
||||||
ind_min = np.where(stg.r >= rmin)[0][0]
|
ind_min = np.where(stg.r >= rmin)[0][0]
|
||||||
ind_max = np.where(stg.r <= rmax)[0][-1]
|
ind_max = np.where(stg.r <= rmax)[0][-1]
|
||||||
# Getting the peak
|
# Getting the peak
|
||||||
val_bottom[d] = np.nanmax(stg.BS_raw_data[ind_min:ind_max, self.combobox_freq_choice.currentIndex(), d])
|
try:
|
||||||
# Getting the range cell of the peak
|
val_bottom[d] = np.nanmax(stg.BS_raw_data[ind_min:ind_max, self.combobox_freq_choice.currentIndex(), d])
|
||||||
ind_bottom = np.where(stg.BS_raw_data[ind_min:ind_max, self.combobox_freq_choice.currentIndex(), d]
|
except ValueError as e:
|
||||||
== val_bottom[d])[0][0]
|
msgBox = QMessageBox()
|
||||||
np.append(stg.ind_bottom, ind_bottom)
|
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]
|
||||||
|
np.append(stg.ind_bottom, ind_bottom)
|
||||||
|
|
||||||
r_bottom[d] = stg.r[ind_bottom + ind_min]
|
r_bottom[d] = stg.r[ind_bottom + ind_min]
|
||||||
r_bottom_ind.append(ind_bottom + ind_min)
|
r_bottom_ind.append(ind_bottom + ind_min)
|
||||||
# Updating the range where we will look for the peak (in the next cell)
|
# Updating the range where we will look for the peak (in the next cell)
|
||||||
rmin = r_bottom[d] - locale.atof(self.doublespinbox_next_cell.text())
|
rmin = r_bottom[d] - locale.atof(self.doublespinbox_next_cell.text())
|
||||||
rmax = r_bottom[d] + locale.atof(self.doublespinbox_next_cell.text())
|
rmax = r_bottom[d] + locale.atof(self.doublespinbox_next_cell.text())
|
||||||
|
|
||||||
BS_section_bottom = np.zeros((stg.r.shape[0], stg.time.shape[0]))
|
BS_section_bottom = np.zeros((stg.r.shape[0], stg.time.shape[0]))
|
||||||
|
|
||||||
for i in range(BS_section_bottom.shape[0]):
|
for i in range(BS_section_bottom.shape[0]):
|
||||||
# print(r_bottom_temp_ind[i])
|
try:
|
||||||
# print(i)
|
BS_section_bottom[r_bottom_ind[i]][i] = 1
|
||||||
BS_section_bottom[r_bottom_ind[i]][i] = 1
|
except IndexError as e:
|
||||||
# print(BS_section_bottom[r_bottom_temp_ind[i]][i])
|
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()
|
||||||
|
|
||||||
# --- Record r_bottom for other tabs ---
|
if BS_section_bottom.sum() > 2:
|
||||||
stg.r_bottom = r_bottom[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
|
# --- Record r_bottom for other tabs ---
|
||||||
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]]
|
stg.r_bottom = r_bottom[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
|
||||||
stg.val_bottom = val_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]]
|
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]]
|
||||||
|
stg.val_bottom = val_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]]
|
||||||
|
|
||||||
# --- Plot transect BS with bathymetry ---
|
# --- Plot transect BS with bathymetry ---
|
||||||
for f in range(stg.freq.shape[0]):
|
for f in range(stg.freq.shape[0]):
|
||||||
self.axis_BS[f].cla()
|
self.axis_BS[f].cla()
|
||||||
|
|
||||||
val_min = np.min(stg.BS_raw_data[:, f, :])
|
val_min = np.min(stg.BS_raw_data[:, f, :])
|
||||||
val_max = np.max(stg.BS_raw_data[:, f, :])
|
val_max = np.max(stg.BS_raw_data[:, f, :])
|
||||||
if val_min == 0:
|
if val_min == 0:
|
||||||
val_min = 1e-5
|
val_min = 1e-5
|
||||||
|
|
||||||
pcm = self.axis_BS[f].pcolormesh(
|
pcm = self.axis_BS[f].pcolormesh(
|
||||||
stg.time[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
|
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]],
|
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]],
|
||||||
-stg.r,
|
-stg.r,
|
||||||
(stg.BS_raw_data[:, f,
|
(stg.BS_raw_data[:, f,
|
||||||
np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
|
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]]),
|
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]]),
|
||||||
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
|
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
|
||||||
|
|
||||||
self.axis_BS[f].plot(
|
self.axis_BS[f].plot(
|
||||||
stg.time[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
|
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]],
|
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]],
|
||||||
- r_bottom[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
|
- 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]],
|
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]],
|
||||||
color='black', linewidth=1, linestyle="solid")
|
color='black', linewidth=1, linestyle="solid")
|
||||||
|
|
||||||
self.axis_BS[f].text(1, .70, stg.freq_text[f],
|
self.axis_BS[f].text(1, .70, stg.freq_text[f],
|
||||||
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
|
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
|
||||||
horizontalalignment='right', verticalalignment='bottom',
|
horizontalalignment='right', verticalalignment='bottom',
|
||||||
transform=self.axis_BS[f].transAxes)
|
transform=self.axis_BS[f].transAxes)
|
||||||
|
|
||||||
self.fig_BS.canvas.draw_idle()
|
self.fig_BS.canvas.draw_idle()
|
||||||
|
|
||||||
# --- Plot transect SNR with bathymetry ---
|
# --- 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]],
|
||||||
|
stg.r)
|
||||||
|
|
||||||
x, y = np.meshgrid(
|
for f in range(stg.freq.shape[0]):
|
||||||
stg.time[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
|
self.axis_SNR[f].cla()
|
||||||
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]],
|
|
||||||
stg.r)
|
|
||||||
|
|
||||||
for f in range(stg.freq.shape[0]):
|
val_min = np.min(stg.snr[:, f, :])
|
||||||
self.axis_SNR[f].cla()
|
val_max = np.max(stg.snr[:, f, :])
|
||||||
|
if val_min == 0:
|
||||||
|
val_min = 1e-5
|
||||||
|
if val_max > 1000:
|
||||||
|
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
|
||||||
|
else:
|
||||||
|
levels = np.array([00.1, 1, 2, 10, 100, val_max])
|
||||||
|
bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2]
|
||||||
|
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
|
||||||
|
|
||||||
val_min = np.min(stg.snr[:, f, :])
|
cf = self.axis_SNR[f].contourf(x, -y,
|
||||||
val_max = np.max(stg.snr[:, f, :])
|
stg.snr[:, f,
|
||||||
if val_min == 0:
|
np.where(np.round(stg.time,
|
||||||
val_min = 1e-5
|
2) == self.spinbox_tmin.value())[0][0]:
|
||||||
if val_max > 1000:
|
np.where(np.round(stg.time,
|
||||||
levels = np.array([00.1, 1, 2, 10, 100, 1000, 1e6])
|
2) == self.spinbox_tmax.value())[0][0]],
|
||||||
else:
|
levels, cmap='gist_rainbow', norm=norm) # , shading='gouraud')
|
||||||
levels = np.array([00.1, 1, 2, 10, 100, val_max])
|
|
||||||
bounds = [00.1, 1, 2, 10, 100, 1000, val_max, val_max * 1.2]
|
|
||||||
norm = BoundaryNorm(boundaries=bounds, ncolors=300)
|
|
||||||
|
|
||||||
cf = self.axis_SNR[f].contourf(x, -y,
|
self.axis_SNR[f].text(1, .70, stg.freq_text[f],
|
||||||
stg.snr[:, f,
|
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
|
||||||
np.where(np.round(stg.time,
|
horizontalalignment='right', verticalalignment='bottom',
|
||||||
2) == self.spinbox_tmin.value())[0][0]:
|
transform=self.axis_SNR[f].transAxes)
|
||||||
np.where(np.round(stg.time,
|
|
||||||
2) == self.spinbox_tmax.value())[0][0]],
|
|
||||||
levels, cmap='gist_rainbow', norm=norm) # , shading='gouraud')
|
|
||||||
|
|
||||||
self.axis_SNR[f].text(1, .70, stg.freq_text[f],
|
self.axis_SNR[f].plot(
|
||||||
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
|
stg.time[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
|
||||||
horizontalalignment='right', verticalalignment='bottom',
|
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]],
|
||||||
transform=self.axis_SNR[f].transAxes)
|
- 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]],
|
||||||
|
# + np.min(r_bottom[np.where(np.round(noise_data._time, 2) == self.spinbox_tmin.value())[0][0]:
|
||||||
|
# np.where(np.round(noise_data._time, 2) == self.spinbox_tmax.value())[0][0]]),
|
||||||
|
# np.max(self._model.r_bottom_cross_section) - self._model.r_bottom_cross_section + np.min(self._model.r_bottom_cross_section),
|
||||||
|
color='black', linewidth=1, linestyle="solid")
|
||||||
|
|
||||||
self.axis_SNR[f].plot(
|
self.axis_SNR[f].text(1, .70, stg.freq_text[f],
|
||||||
stg.time[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
|
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
|
||||||
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]],
|
horizontalalignment='right', verticalalignment='bottom',
|
||||||
- r_bottom[np.where(np.round(stg.time, 2) == self.spinbox_tmin.value())[0][0]:
|
transform=self.axis_BS[f].transAxes)
|
||||||
np.where(np.round(stg.time, 2) == self.spinbox_tmax.value())[0][0]],
|
|
||||||
# + np.min(r_bottom[np.where(np.round(noise_data._time, 2) == self.spinbox_tmin.value())[0][0]:
|
|
||||||
# np.where(np.round(noise_data._time, 2) == self.spinbox_tmax.value())[0][0]]),
|
|
||||||
# np.max(self._model.r_bottom_cross_section) - self._model.r_bottom_cross_section + np.min(self._model.r_bottom_cross_section),
|
|
||||||
color='black', linewidth=1, linestyle="solid")
|
|
||||||
|
|
||||||
self.axis_SNR[f].text(1, .70, stg.freq_text[f],
|
self.fig_SNR.canvas.draw_idle()
|
||||||
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
|
|
||||||
horizontalalignment='right', verticalalignment='bottom',
|
|
||||||
transform=self.axis_BS[f].transAxes)
|
|
||||||
|
|
||||||
self.fig_SNR.canvas.draw_idle()
|
|
||||||
|
|
||||||
# else:
|
# else:
|
||||||
#
|
#
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue