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,9 +357,19 @@ 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)")
|
||||||
|
|
||||||
|
try:
|
||||||
stg.fine_sediment_path = path.dirname(filename_fine_sediment[0])
|
stg.fine_sediment_path = path.dirname(filename_fine_sediment[0])
|
||||||
stg.fine_sediment_filename = path.basename(filename_fine_sediment[0])
|
stg.fine_sediment_filename = path.basename(filename_fine_sediment[0])
|
||||||
self.load_fine_sediment_data()
|
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.setText(stg.fine_sediment_filename)
|
||||||
self.lineEdit_fine_sediment.setToolTip(stg.fine_sediment_path)
|
self.lineEdit_fine_sediment.setToolTip(stg.fine_sediment_path)
|
||||||
|
|
||||||
|
|
@ -368,10 +378,19 @@ class SampleDataTab(QWidget):
|
||||||
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)")
|
||||||
|
|
||||||
|
try:
|
||||||
stg.sand_sediment_path = path.dirname(filename_sand_sediment[0])
|
stg.sand_sediment_path = path.dirname(filename_sand_sediment[0])
|
||||||
stg.sand_sediment_filename = path.basename(filename_sand_sediment[0])
|
stg.sand_sediment_filename = path.basename(filename_sand_sediment[0])
|
||||||
self.load_sand_sediment_data()
|
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.setText(stg.sand_sediment_filename)
|
||||||
self.lineEdit_sand.setToolTip(stg.sand_sediment_path)
|
self.lineEdit_sand.setToolTip(stg.sand_sediment_path)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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")
|
||||||
|
|
@ -671,6 +671,14 @@ class SignalProcessingTab(QWidget):
|
||||||
msgBox.setText("Load data from acoustic data tab before averaging backscatter signal")
|
msgBox.setText("Load data from acoustic data tab before averaging backscatter signal")
|
||||||
msgBox.setStandardButtons(QMessageBox.Ok)
|
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||||
msgBox.exec()
|
msgBox.exec()
|
||||||
|
else:
|
||||||
|
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:
|
else:
|
||||||
filter_convolve = np.ones(self.spinbox_average_horizontal.value())
|
filter_convolve = np.ones(self.spinbox_average_horizontal.value())
|
||||||
|
|
||||||
|
|
@ -790,6 +798,14 @@ class SignalProcessingTab(QWidget):
|
||||||
return R_real
|
return R_real
|
||||||
|
|
||||||
def compute_FCB(self):
|
def compute_FCB(self):
|
||||||
|
if stg.BS_data_section.size == 0:
|
||||||
|
msgBox = QMessageBox()
|
||||||
|
msgBox.setWindowTitle("FCB Error")
|
||||||
|
msgBox.setIcon(QMessageBox.Warning)
|
||||||
|
msgBox.setText("Load Backscatter data from acoustic data tab and compute water attenuation")
|
||||||
|
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||||
|
msgBox.exec()
|
||||||
|
else:
|
||||||
R_real = np.repeat(self.range_cells_function()[:, :, np.newaxis], stg.t.shape[0], axis=2)
|
R_real = np.repeat(self.range_cells_function()[:, :, np.newaxis], stg.t.shape[0], axis=2)
|
||||||
if (stg.BS_data_section_averaged.size == 0) and (stg.BS_data_section_SNR_filter.size == 0):
|
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) +
|
stg.FCB = (np.log(stg.BS_data_section) + np.log(R_real) +
|
||||||
|
|
@ -800,12 +816,21 @@ class SignalProcessingTab(QWidget):
|
||||||
else:
|
else:
|
||||||
stg.FCB = (np.log(stg.BS_data_section_SNR_filter) + np.log(R_real) +
|
stg.FCB = (np.log(stg.BS_data_section_SNR_filter) + np.log(R_real) +
|
||||||
2 * stg.water_attenuation * 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):
|
||||||
|
|
||||||
|
if stg.FCB.size == 0:
|
||||||
|
msgBox = QMessageBox()
|
||||||
|
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()]
|
y0 = stg.FCB[:, self.combobox_frequency_compute_alphaS.currentIndex(), self.slider.value()]
|
||||||
y = y0[np.where(np.isnan(y0) == False)]
|
y = y0[np.where(np.isnan(y0) == False)]
|
||||||
print("y : ", y)
|
|
||||||
|
|
||||||
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)]
|
||||||
|
|
@ -815,19 +840,24 @@ class SignalProcessingTab(QWidget):
|
||||||
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()]
|
|
||||||
# print("y : ", y)
|
|
||||||
|
|
||||||
lin_reg_compute = stats.linregress(x[value1[0][0]:value2[0][0]], y[value1[0][0]:value2[0][0]])
|
lin_reg_compute = stats.linregress(x[value1[0][0]:value2[0][0]], y[value1[0][0]:value2[0][0]])
|
||||||
|
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)
|
stg.lin_reg = (lin_reg_compute.slope, lin_reg_compute.intercept)
|
||||||
print(f"y = {stg.lin_reg[0]}x + {stg.lin_reg[1]}")
|
# print(f"y = {stg.lin_reg[0]}x + {stg.lin_reg[1]}")
|
||||||
|
|
||||||
self.label_alphaS.clear()
|
self.label_alphaS.clear()
|
||||||
self.label_alphaS.setText(f"\u03B1s = {-0.5*stg.lin_reg[0]:.4f} dB/m")
|
self.label_alphaS.setText(f"\u03B1s = {-0.5*stg.lin_reg[0]:.4f} dB/m")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue