Exceptions for download file are added. Exceptions for FCB are added. Exception for computing averaged backscatter signal is added (enter an odd number)
parent
e8438ec46b
commit
cd33f9d85c
|
|
@ -357,23 +357,42 @@ class SampleDataTab(QWidget):
|
||||||
filename_fine_sediment = QFileDialog.getOpenFileName(self, "Open file",
|
filename_fine_sediment = QFileDialog.getOpenFileName(self, "Open file",
|
||||||
"/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data/Granulo_data",
|
"/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data/Granulo_data",
|
||||||
"Fine sediment file (*.xls, *.ods)")
|
"Fine sediment file (*.xls, *.ods)")
|
||||||
stg.fine_sediment_path = path.dirname(filename_fine_sediment[0])
|
|
||||||
stg.fine_sediment_filename = path.basename(filename_fine_sediment[0])
|
try:
|
||||||
self.load_fine_sediment_data()
|
stg.fine_sediment_path = path.dirname(filename_fine_sediment[0])
|
||||||
self.lineEdit_fine_sediment.setText(stg.fine_sediment_filename)
|
stg.fine_sediment_filename = path.basename(filename_fine_sediment[0])
|
||||||
self.lineEdit_fine_sediment.setToolTip(stg.fine_sediment_path)
|
self.load_fine_sediment_data()
|
||||||
|
except IsADirectoryError:
|
||||||
|
msgBox = QMessageBox()
|
||||||
|
msgBox.setWindowTitle("Download Error")
|
||||||
|
msgBox.setIcon(QMessageBox.Warning)
|
||||||
|
msgBox.setText("Please select a file")
|
||||||
|
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||||
|
msgBox.exec()
|
||||||
|
else:
|
||||||
|
self.lineEdit_fine_sediment.setText(stg.fine_sediment_filename)
|
||||||
|
self.lineEdit_fine_sediment.setToolTip(stg.fine_sediment_path)
|
||||||
|
|
||||||
# --- Function to select directory and file name of sand sediments sample data ---
|
# --- Function to select directory and file name of sand sediments sample data ---
|
||||||
def open_dialog_box_sand_sediment(self):
|
def open_dialog_box_sand_sediment(self):
|
||||||
filename_sand_sediment = QFileDialog.getOpenFileName(self, "Open file",
|
filename_sand_sediment = QFileDialog.getOpenFileName(self, "Open file",
|
||||||
"/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data/Granulo_data",
|
"/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data/Granulo_data",
|
||||||
"Sand sediment file (*.xls, *.ods)")
|
"Sand sediment file (*.xls, *.ods)")
|
||||||
stg.sand_sediment_path = path.dirname(filename_sand_sediment[0])
|
|
||||||
stg.sand_sediment_filename = path.basename(filename_sand_sediment[0])
|
|
||||||
self.load_sand_sediment_data()
|
|
||||||
|
|
||||||
self.lineEdit_sand.setText(stg.sand_sediment_filename)
|
try:
|
||||||
self.lineEdit_sand.setToolTip(stg.sand_sediment_path)
|
stg.sand_sediment_path = path.dirname(filename_sand_sediment[0])
|
||||||
|
stg.sand_sediment_filename = path.basename(filename_sand_sediment[0])
|
||||||
|
self.load_sand_sediment_data()
|
||||||
|
except IsADirectoryError:
|
||||||
|
msgBox = QMessageBox()
|
||||||
|
msgBox.setWindowTitle("Download Error")
|
||||||
|
msgBox.setIcon(QMessageBox.Warning)
|
||||||
|
msgBox.setText("Please select a file")
|
||||||
|
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||||
|
msgBox.exec()
|
||||||
|
else:
|
||||||
|
self.lineEdit_sand.setText(stg.sand_sediment_filename)
|
||||||
|
self.lineEdit_sand.setToolTip(stg.sand_sediment_path)
|
||||||
|
|
||||||
def load_fine_sediment_data(self):
|
def load_fine_sediment_data(self):
|
||||||
fine_granulo_data = GranuloLoader(stg.fine_sediment_path + "/" + stg.fine_sediment_filename)
|
fine_granulo_data = GranuloLoader(stg.fine_sediment_path + "/" + stg.fine_sediment_filename)
|
||||||
|
|
|
||||||
|
|
@ -331,7 +331,7 @@ class SignalProcessingTab(QWidget):
|
||||||
self.gridLayout_groupbox_fit_regression.addWidget(self.pushbutton_plot_FCB, 2, 0, 1, 1)
|
self.gridLayout_groupbox_fit_regression.addWidget(self.pushbutton_plot_FCB, 2, 0, 1, 1)
|
||||||
|
|
||||||
self.pushbutton_plot_FCB.clicked.connect(self.compute_FCB)
|
self.pushbutton_plot_FCB.clicked.connect(self.compute_FCB)
|
||||||
self.pushbutton_plot_FCB.clicked.connect(self.plot_FCB)
|
# self.pushbutton_plot_FCB.clicked.connect(self.plot_FCB)
|
||||||
|
|
||||||
self.pushbutton_fit_linear_regression = QPushButton()
|
self.pushbutton_fit_linear_regression = QPushButton()
|
||||||
self.pushbutton_fit_linear_regression.setText("Fit && Compute \u03B1s")
|
self.pushbutton_fit_linear_regression.setText("Fit && Compute \u03B1s")
|
||||||
|
|
@ -672,24 +672,32 @@ class SignalProcessingTab(QWidget):
|
||||||
msgBox.setStandardButtons(QMessageBox.Ok)
|
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||||
msgBox.exec()
|
msgBox.exec()
|
||||||
else:
|
else:
|
||||||
filter_convolve = np.ones(self.spinbox_average_horizontal.value())
|
if self.spinbox_average_horizontal.value() % 2 == 0:
|
||||||
|
msgBox = QMessageBox()
|
||||||
|
msgBox.setWindowTitle("Average Backscatter signal Error")
|
||||||
|
msgBox.setIcon(QMessageBox.Warning)
|
||||||
|
msgBox.setText("Please enter an odd number")
|
||||||
|
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||||
|
msgBox.exec()
|
||||||
|
else:
|
||||||
|
filter_convolve = np.ones(self.spinbox_average_horizontal.value())
|
||||||
|
|
||||||
stg.BS_data_section_averaged = np.zeros((stg.r.shape[0], stg.freq.shape[0], stg.t.shape[0]))
|
stg.BS_data_section_averaged = np.zeros((stg.r.shape[0], stg.freq.shape[0], stg.t.shape[0]))
|
||||||
for f in range(stg.freq.shape[0]):
|
for f in range(stg.freq.shape[0]):
|
||||||
for i in range(stg.r.shape[0]):
|
for i in range(stg.r.shape[0]):
|
||||||
stg.BS_data_section_averaged[i, f, :] \
|
stg.BS_data_section_averaged[i, f, :] \
|
||||||
= convolve1d(stg.BS_data_section[i, f, :], weights=filter_convolve) / filter_convolve.shape[0]
|
= convolve1d(stg.BS_data_section[i, f, :], weights=filter_convolve) / filter_convolve.shape[0]
|
||||||
|
|
||||||
self.label_cells_horizontal.clear()
|
self.label_cells_horizontal.clear()
|
||||||
self.label_cells_horizontal.setText(
|
self.label_cells_horizontal.setText(
|
||||||
"cells = +/- " + str((self.spinbox_average_horizontal.value() // 2)*(1/stg.nb_profiles_per_sec)) + " sec")
|
"cells = +/- " + str((self.spinbox_average_horizontal.value() // 2)*(1/stg.nb_profiles_per_sec)) + " sec")
|
||||||
|
|
||||||
# self.label_cells_vertical.clear()
|
# self.label_cells_vertical.clear()
|
||||||
# self.label_cells_vertical.setText(
|
# self.label_cells_vertical.setText(
|
||||||
# "cells = +/- " + str((self.spinbox_average_vertical.value() // 2) * (1 / stg.nb_profiles_per_sec)) + " sec")
|
# "cells = +/- " + str((self.spinbox_average_vertical.value() // 2) * (1 / stg.nb_profiles_per_sec)) + " sec")
|
||||||
|
|
||||||
self.plot_averaged_profile()
|
self.plot_averaged_profile()
|
||||||
self.update_plot_profile_position_on_transect()
|
self.update_plot_profile_position_on_transect()
|
||||||
|
|
||||||
# ---------------------------------------- Connect Groupbox filter with SNR ----------------------------------------
|
# ---------------------------------------- Connect Groupbox filter with SNR ----------------------------------------
|
||||||
|
|
||||||
|
|
@ -790,68 +798,90 @@ class SignalProcessingTab(QWidget):
|
||||||
return R_real
|
return R_real
|
||||||
|
|
||||||
def compute_FCB(self):
|
def compute_FCB(self):
|
||||||
R_real = np.repeat(self.range_cells_function()[:, :, np.newaxis], stg.t.shape[0], axis=2)
|
if stg.BS_data_section.size == 0:
|
||||||
if (stg.BS_data_section_averaged.size == 0) and (stg.BS_data_section_SNR_filter.size == 0):
|
msgBox = QMessageBox()
|
||||||
stg.FCB = (np.log(stg.BS_data_section) + np.log(R_real) +
|
msgBox.setWindowTitle("FCB Error")
|
||||||
2 * stg.water_attenuation * R_real)
|
msgBox.setIcon(QMessageBox.Warning)
|
||||||
elif stg.BS_data_section_SNR_filter.size == 0:
|
msgBox.setText("Load Backscatter data from acoustic data tab and compute water attenuation")
|
||||||
stg.FCB = (np.log(stg.BS_data_section_averaged) + np.log(R_real) +
|
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||||
2 * stg.water_attenuation * R_real)
|
msgBox.exec()
|
||||||
else:
|
else:
|
||||||
stg.FCB = (np.log(stg.BS_data_section_SNR_filter) + np.log(R_real) +
|
R_real = np.repeat(self.range_cells_function()[:, :, np.newaxis], stg.t.shape[0], axis=2)
|
||||||
2 * stg.water_attenuation * R_real)
|
if (stg.BS_data_section_averaged.size == 0) and (stg.BS_data_section_SNR_filter.size == 0):
|
||||||
|
stg.FCB = (np.log(stg.BS_data_section) + np.log(R_real) +
|
||||||
|
2 * stg.water_attenuation * R_real)
|
||||||
|
elif stg.BS_data_section_SNR_filter.size == 0:
|
||||||
|
stg.FCB = (np.log(stg.BS_data_section_averaged) + np.log(R_real) +
|
||||||
|
2 * stg.water_attenuation * R_real)
|
||||||
|
else:
|
||||||
|
stg.FCB = (np.log(stg.BS_data_section_SNR_filter) + np.log(R_real) +
|
||||||
|
2 * stg.water_attenuation * R_real)
|
||||||
|
self.plot_FCB()
|
||||||
|
|
||||||
def fit_FCB_profile_with_linear_regression_and_compute_alphaS(self):
|
def fit_FCB_profile_with_linear_regression_and_compute_alphaS(self):
|
||||||
|
|
||||||
y0 = stg.FCB[:, self.combobox_frequency_compute_alphaS.currentIndex(), self.slider.value()]
|
if stg.FCB.size == 0:
|
||||||
y = y0[np.where(np.isnan(y0) == False)]
|
msgBox = QMessageBox()
|
||||||
print("y : ", y)
|
msgBox.setWindowTitle("Linear regression error")
|
||||||
|
msgBox.setIcon(QMessageBox.Warning)
|
||||||
|
msgBox.setText("Please compute FCB before")
|
||||||
|
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||||
|
msgBox.exec()
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
y0 = stg.FCB[:, self.combobox_frequency_compute_alphaS.currentIndex(), self.slider.value()]
|
||||||
|
y = y0[np.where(np.isnan(y0) == False)]
|
||||||
|
|
||||||
x0 = stg.r.reshape(-1)
|
x0 = stg.r.reshape(-1)
|
||||||
x = x0[np.where(np.isnan(y0) == False)]
|
x = x0[np.where(np.isnan(y0) == False)]
|
||||||
|
|
||||||
value1 = np.where(np.round(np.abs(x - self.spinbox_alphaS_computation_from.value()), 2)
|
value1 = np.where(np.round(np.abs(x - self.spinbox_alphaS_computation_from.value()), 2)
|
||||||
== np.min(np.round(np.abs(x - self.spinbox_alphaS_computation_from.value()), 2)))
|
== np.min(np.round(np.abs(x - self.spinbox_alphaS_computation_from.value()), 2)))
|
||||||
value2 = np.where(np.round(np.abs(x - self.spinbox_alphaS_computation_to.value()), 2)
|
value2 = np.where(np.round(np.abs(x - self.spinbox_alphaS_computation_to.value()), 2)
|
||||||
== np.min(np.round(np.abs(x - self.spinbox_alphaS_computation_to.value()), 2)))
|
== np.min(np.round(np.abs(x - self.spinbox_alphaS_computation_to.value()), 2)))
|
||||||
|
|
||||||
print(np.round(np.abs(x - self.spinbox_alphaS_computation_from.value()), 2))
|
# print(np.round(np.abs(x - self.spinbox_alphaS_computation_from.value()), 2))
|
||||||
print("value1 ", value1[0][0])
|
# # print("value1 ", value1[0][0])
|
||||||
print(np.round(np.abs(x - self.spinbox_alphaS_computation_to.value()), 2))
|
# print(np.round(np.abs(x - self.spinbox_alphaS_computation_to.value()), 2))
|
||||||
print("value2 ", value2[0][0])
|
# print("value2 ", value2[0][0])
|
||||||
|
|
||||||
print("y limited ", y[value1[0][0]:value2[0][0]])
|
# print("y limited ", y[value1[0][0]:value2[0][0]])
|
||||||
|
|
||||||
# y = stg.FCB[value1:value2, self.combobox_frequency_compute_alphaS.currentIndex(), self.slider.value()]
|
lin_reg_compute = stats.linregress(x[value1[0][0]:value2[0][0]], y[value1[0][0]:value2[0][0]])
|
||||||
# print("y : ", y)
|
except ValueError:
|
||||||
|
msgBox = QMessageBox()
|
||||||
|
msgBox.setWindowTitle("Linear regression error")
|
||||||
|
msgBox.setIcon(QMessageBox.Warning)
|
||||||
|
msgBox.setText("Please check boundaries to fit a linear line")
|
||||||
|
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||||
|
msgBox.exec()
|
||||||
|
else:
|
||||||
|
stg.lin_reg = (lin_reg_compute.slope, lin_reg_compute.intercept)
|
||||||
|
# print(f"y = {stg.lin_reg[0]}x + {stg.lin_reg[1]}")
|
||||||
|
|
||||||
lin_reg_compute = stats.linregress(x[value1[0][0]:value2[0][0]], y[value1[0][0]:value2[0][0]])
|
self.label_alphaS.clear()
|
||||||
stg.lin_reg = (lin_reg_compute.slope, lin_reg_compute.intercept)
|
self.label_alphaS.setText(f"\u03B1s = {-0.5*stg.lin_reg[0]:.4f} dB/m")
|
||||||
print(f"y = {stg.lin_reg[0]}x + {stg.lin_reg[1]}")
|
|
||||||
|
|
||||||
self.label_alphaS.clear()
|
# for i, value_freq in enumerate(stg.freq):
|
||||||
self.label_alphaS.setText(f"\u03B1s = {-0.5*stg.lin_reg[0]:.4f} dB/m")
|
# for k, value_t in enumerate(stg.t):
|
||||||
|
# # print(f"indice i: {i}, indice k: {k}")
|
||||||
|
# # print(f"values of FCB: {stg.FCB[:, i, k]}")
|
||||||
|
# y = stg.FCB[:, i, k]
|
||||||
|
# # print("y : ", y)
|
||||||
|
# # print(f"values of FCB where FCB is not Nan {y[np.where(np.isnan(y) == False)]}")
|
||||||
|
# # print(f"values of r where FCB is not Nan {x[np.where(np.isnan(y) == False)]}")
|
||||||
|
# lin_reg_compute = stats.linregress(x[np.where(np.isnan(y) == False)], y[np.where(np.isnan(y) == False)])
|
||||||
|
# lin_reg_tuple = (lin_reg_compute.slope, lin_reg_compute.intercept)
|
||||||
|
# stg.lin_reg.append(lin_reg_tuple)
|
||||||
|
|
||||||
# for i, value_freq in enumerate(stg.freq):
|
# print(f"y = {lin_reg.slope}x + {lin_reg.intercept}")
|
||||||
# for k, value_t in enumerate(stg.t):
|
|
||||||
# # print(f"indice i: {i}, indice k: {k}")
|
|
||||||
# # print(f"values of FCB: {stg.FCB[:, i, k]}")
|
|
||||||
# y = stg.FCB[:, i, k]
|
|
||||||
# # print("y : ", y)
|
|
||||||
# # print(f"values of FCB where FCB is not Nan {y[np.where(np.isnan(y) == False)]}")
|
|
||||||
# # print(f"values of r where FCB is not Nan {x[np.where(np.isnan(y) == False)]}")
|
|
||||||
# lin_reg_compute = stats.linregress(x[np.where(np.isnan(y) == False)], y[np.where(np.isnan(y) == False)])
|
|
||||||
# lin_reg_tuple = (lin_reg_compute.slope, lin_reg_compute.intercept)
|
|
||||||
# stg.lin_reg.append(lin_reg_tuple)
|
|
||||||
|
|
||||||
# print(f"y = {lin_reg.slope}x + {lin_reg.intercept}")
|
# plt.figure()
|
||||||
|
# plt.plot(stg.r, stg.FCB[:, 0, 825], 'k-', stg.r, lin_reg.slope*stg.r + lin_reg.intercept, "b--")
|
||||||
|
# plt.show()
|
||||||
|
|
||||||
# plt.figure()
|
# print("lin_reg length ", len(stg.lin_reg))
|
||||||
# plt.plot(stg.r, stg.FCB[:, 0, 825], 'k-', stg.r, lin_reg.slope*stg.r + lin_reg.intercept, "b--")
|
# print("lin_reg ", stg.lin_reg)
|
||||||
# plt.show()
|
|
||||||
|
|
||||||
# print("lin_reg length ", len(stg.lin_reg))
|
|
||||||
# print("lin_reg ", stg.lin_reg)
|
|
||||||
|
|
||||||
# ---------------------------------------- PLOT PROFILE POSITION ON TRANSECT ---------------------------------------
|
# ---------------------------------------- PLOT PROFILE POSITION ON TRANSECT ---------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue