diff --git a/View/sediment_calibration_tab.py b/View/sediment_calibration_tab.py
index bb98b83..18e4da8 100644
--- a/View/sediment_calibration_tab.py
+++ b/View/sediment_calibration_tab.py
@@ -1235,7 +1235,7 @@ class SedimentCalibrationTab(QWidget):
data_id = self.combobox_acoustic_data_choice.currentIndex()
freq1_id = self.combobox_freq1.currentIndex()
- freq2_id = self.combobox_freq1.currentIndex()
+ freq2_id = self.combobox_freq2.currentIndex()
# --- Find index in depth (along acoustic recording) of sand sample target ---
if stg.depth_cross_section[data_id].shape != (0,):
@@ -1273,54 +1273,120 @@ class SedimentCalibrationTab(QWidget):
return (d1, d2)
def summary_samples_choices(self):
-
- self.pushbutton_compute_calibration.setToolTip("Calibration is computed at abscissa " + str(self.combobox_sand_sample_choice.currentText()))
+ self.pushbutton_compute_calibration\
+ .setToolTip(
+ "Calibration is computed at abscissa "
+ + str(self.combobox_sand_sample_choice.currentText())
+ )
for i in reversed(range(self.gridLayout_groupbox_interpolate_info.count())):
- self.gridLayout_groupbox_interpolate_info.itemAt(i).widget().setParent(None)
+ self.gridLayout_groupbox_interpolate_info\
+ .itemAt(i)\
+ .widget()\
+ .setParent(None)
- self.gridLayout_groupbox_interpolate_info.addWidget(self.pushbutton_interpolate_Mfine_profile, 0, 0, 1, 4, Qt.AlignCenter)
+ self.gridLayout_groupbox_interpolate_info\
+ .addWidget(
+ self.pushbutton_interpolate_Mfine_profile,
+ 0, 0, 1, 4,
+ Qt.AlignCenter
+ )
+ self.summary_samples_choices_fine()
+ self.summary_samples_choices_sand()
+
+ def summary_samples_choices_fine(self):
fine_head = ["Sample", "Depth (m)", "time", "Cfine (g/L)"]
- fine_label = [self.label_sample_fine, self.label_depth_fine, self.label_time_fine,
- self.label_concentration_fine]
+ fine_label = [
+ self.label_sample_fine,
+ self.label_depth_fine,
+ self.label_time_fine,
+ self.label_concentration_fine
+ ]
for j in range(len(fine_head)):
- exec("fine_label[" + str(j) + "] = QLabel()")
- eval("fine_label[" + str(j) + "].setText(fine_head[" + str(j) + "])")
- print((f"self.gridLayout_groupbox_interpolate_info.addWidget(fine_label[{j}], 1, {j}, 1, 1, Qt.AlignCenter)"))
- eval(f"self.gridLayout_groupbox_interpolate_info.addWidget(fine_label[{j}], 1, {j}, 1, 1, Qt.AlignCenter)")
+ fine_label[j] = QLabel()
+ fine_label[j].setText(fine_head[j])
+ self.gridLayout_groupbox_interpolate_info\
+ .addWidget(
+ fine_label[j], 1, j, 1, 1, Qt.AlignCenter
+ )
+ self.gridLayout_groupbox_interpolate_info\
+ .addWidget(
+ fine_label[j], 1, j, 1, 1, Qt.AlignCenter
+ )
fine_data = []
for k in range(len(stg.fine_sample_profile)):
- fine_data.append([stg.fine_sample_profile[k][0], str(stg.depth_fine[k]), str(stg.time_fine[k]), str(stg.Ctot_fine[k])])
- print(fine_data)
+ fine_data.append(
+ [
+ stg.fine_sample_profile[k][0],
+ str(stg.depth_fine[k]),
+ str(stg.time_fine[k]),
+ str(stg.Ctot_fine[k])
+ ]
+ )
for p in range(len(fine_data)):
for q in range(len(fine_data[0])):
- print(f"self.gridLayout_groupbox_interpolate_info.addWidget(QLabel(fine_data[{p}][{q}]), {2 + p}, {q}, 1, 1, Qt.AlignCenter)")
- eval(f"self.gridLayout_groupbox_interpolate_info.addWidget(QLabel(fine_data[{p}][{q}]), {2 + p}, {q}, 1, 1, Qt.AlignCenter)")
+ self.gridLayout_groupbox_interpolate_info\
+ .addWidget(
+ QLabel(fine_data[p][q]),
+ 2 + p, q, 1, 1,
+ Qt.AlignCenter
+ )
- self.gridLayout_groupbox_interpolate_info.addWidget(self.double_horizontal_line, 2 + len(fine_data), 0, 1, 4, Qt.AlignCenter)
+ self.gridLayout_groupbox_interpolate_info\
+ .addWidget(
+ self.double_horizontal_line,
+ 2 + len(fine_data), 0, 1, 4,
+ Qt.AlignCenter
+ )
+ def summary_samples_choices_sand(self):
sand_head = ["Sample", "Depth (m)", "time", "Csand (g/L)"]
- sand_label = [self.label_sample_sand, self.label_depth_sand, self.label_time_sand,
- self.label_concentration_sand]
+ sand_label = [
+ self.label_sample_sand,
+ self.label_depth_sand,
+ self.label_time_sand,
+ self.label_concentration_sand
+ ]
+
+ fine_data = []
+ for k in range(len(stg.fine_sample_profile)):
+ fine_data.append(
+ [
+ stg.fine_sample_profile[k][0],
+ str(stg.depth_fine[k]),
+ str(stg.time_fine[k]),
+ str(stg.Ctot_fine[k])
+ ]
+ )
for s in range(len(sand_head)):
- exec("sand_label[" + str(s) + "] = QLabel()")
- eval("sand_label[" + str(s) + "].setText(sand_head[" + str(s) + "])")
- print(f"self.gridLayout_groupbox_interpolate_info.addWidget(sand_label[{s}], {3 + len(fine_data)}, {s}, 1, 1, Qt.AlignCenter)")
- eval(f"self.gridLayout_groupbox_interpolate_info.addWidget(sand_label[{s}], {3 + len(fine_data)}, {s}, 1, 1, Qt.AlignCenter)")
+ sand_label[s] = QLabel()
+ sand_label[s].setText(sand_head[s])
+ self.gridLayout_groupbox_interpolate_info\
+ .addWidget(
+ sand_label[s],
+ 3 + len(fine_data), s, 1, 1,
+ Qt.AlignCenter
+ )
- sand_data = [stg.sand_sample_target[0][0],
- str(stg.depth_sand[stg.sand_sample_target[0][1]]),
- str(stg.time_sand[stg.sand_sample_target[0][1]]),
- str(stg.Ctot_sand[stg.sand_sample_target[0][1]])]
+ sand_data = [
+ stg.sand_sample_target[0][0],
+ str(stg.depth_sand[stg.sand_sample_target[0][1]]),
+ str(stg.time_sand[stg.sand_sample_target[0][1]]),
+ str(stg.Ctot_sand[stg.sand_sample_target[0][1]])
+ ]
for t in range(len(sand_data)):
- self.gridLayout_groupbox_interpolate_info.addWidget(QLabel(sand_data[t]), 4 + len(fine_data), t, 1, 1, Qt.AlignCenter)
-
+ self.gridLayout_groupbox_interpolate_info\
+ .addWidget(
+ QLabel(sand_data[t]),
+ 4 + len(fine_data), t, 1, 1,
+ Qt.AlignCenter
+ )
def plot_profile_of_concentration_fine(self):
@@ -2205,302 +2271,239 @@ class SedimentCalibrationTab(QWidget):
stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape[1], axis=2))
def compute_FCB(self):
+ data_id = self.combobox_acoustic_data_choice.currentIndex()
+ fcb_id = self.combobox_frequency_FCB.currentIndex()
self.combobox_frequency_FCB.clear()
- self.combobox_frequency_FCB.addItems(stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()])
+ self.combobox_frequency_FCB.addItems(stg.freq_text[data_id])
self.range_cells_function()
- if stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
+ BS_data = stg.BS_raw_data
- stg.FCB = \
- (np.log(stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()]) +
- np.log(stg.depth_real) +
- 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_frequency_FCB.currentIndex()] *
- stg.depth_real)
+ if stg.BS_stream_bed_pre_process_average[data_id].shape != (0,):
+ BS_data = stg.BS_stream_bed_pre_process_average
+ elif stg.BS_stream_bed_pre_process_SNR[data_id].shape != (0,):
+ BS_data = stg.BS_stream_bed_pre_process_SNR
+ elif stg.BS_stream_bed[data_id].shape != (0,):
+ BS_data = stg.BS_stream_bed
+ elif stg.BS_cross_section_pre_process_average[data_id].shape != (0,):
+ BS_data = stg.BS_cross_section_pre_process_average
+ elif stg.BS_cross_section_pre_process_SNR[data_id].shape != (0,):
+ BS_data = stg.BS_cross_section_pre_process_SNR
+ elif stg.BS_cross_section[data_id].shape != (0,):
+ BS_data = stg.BS_cross_section
+ elif stg.BS_raw_data_pre_process_average[data_id].shape != (0,):
+ BS_data = stg.BS_raw_data_pre_process_average
+ elif stg.BS_raw_data_pre_process_SNR[data_id].shape != (0,):
+ BS_data = stg.BS_raw_data_pre_process_SNR
- elif stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
-
- stg.FCB = \
- (np.log(stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()]) +
- np.log(stg.depth_real) +
- 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_frequency_FCB.currentIndex()] *
- stg.depth_real)
-
- elif stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
-
- stg.FCB = \
- (np.log(stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()]) +
- np.log(stg.depth_real) +
- 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_frequency_FCB.currentIndex()] *
- stg.depth_real)
-
- elif stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
-
- stg.FCB = \
- (np.log(stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()]) +
- np.log(stg.depth_real) +
- 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_frequency_FCB.currentIndex()] *
- stg.depth_real)
-
- elif stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
-
- stg.FCB = \
- (np.log(stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()]) +
- np.log(stg.depth_real) +
- 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_frequency_FCB.currentIndex()] *
- stg.depth_real)
-
- elif stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
-
- stg.FCB = \
- (np.log(stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()]) +
- np.log(stg.depth_real) +
- 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_frequency_FCB.currentIndex()] *
- stg.depth_real)
-
- elif stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
-
- stg.FCB = \
- (np.log(stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()]) +
- np.log(stg.depth_real) +
- 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_frequency_FCB.currentIndex()] *
- stg.depth_real)
-
- elif stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
-
- stg.FCB = \
- (np.log(stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()]) +
- np.log(stg.depth_real) +
- 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_frequency_FCB.currentIndex()] *
- stg.depth_real)
-
- elif stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
-
- stg.FCB = \
- (np.log(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()]) +
- np.log(stg.depth_real) +
- 2 * stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_frequency_FCB.currentIndex()] *
- stg.depth_real)
+ stg.FCB = (
+ np.log(BS_data[data_id])
+ + np.log(stg.depth_real)
+ + 2 * stg.water_attenuation[data_id][fcb_id]
+ * stg.depth_real
+ )
self.plot_FCB()
def plot_FCB(self):
+ data_id = self.combobox_acoustic_data_choice.currentIndex()
+ fcb_id = self.combobox_frequency_FCB.currentIndex()
- if stg.FCB.shape != (0,):
+ if stg.FCB.shape == (0,):
+ return
- if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
+ if stg.time_cross_section[data_id].shape != (0,):
+ self.slider_FCB.setMaximum(
+ stg.time_cross_section[data_id].shape[1]
+ )
+ else:
+ self.slider_FCB.setMaximum(stg.time[data_id].shape[1])
- self.slider_FCB.setMaximum(stg.time_cross_section[
- self.combobox_acoustic_data_choice.currentIndex()].shape[1])
+ self.slider_FCB.setValue(stg.sand_sample_target_indice[0][1])
- else:
+ self.verticalLayout_groupbox_FCB_plot.removeWidget(self.canvas_FCB)
+ self.verticalLayout_groupbox_FCB_plot.removeWidget(self.toolbar_FCB)
- self.slider_FCB.setMaximum(stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape[1])
+ self.fig_FCB, self.axis_FCB = plt.subplots(
+ nrows=1, ncols=1, layout="constrained"
+ )
- self.slider_FCB.setValue(stg.sand_sample_target_indice[0][1])
+ self.canvas_FCB = FigureCanvas(self.fig_FCB)
+ self.toolbar_FCB = NavigationToolBar(self.canvas_FCB, self)
- self.verticalLayout_groupbox_FCB_plot.removeWidget(self.canvas_FCB)
- self.verticalLayout_groupbox_FCB_plot.removeWidget(self.toolbar_FCB)
+ self.verticalLayout_groupbox_FCB_plot.addWidget(self.toolbar_FCB)
+ self.verticalLayout_groupbox_FCB_plot.addWidget(self.canvas_FCB)
- self.fig_FCB, self.axis_FCB = plt.subplots(nrows=1, ncols=1, layout="constrained")
+ if stg.depth_cross_section[data_id].shape != (0,):
- self.canvas_FCB = FigureCanvas(self.fig_FCB)
- self.toolbar_FCB = NavigationToolBar(self.canvas_FCB, self)
+ self.axis_FCB.plot(
+ stg.depth_cross_section[data_id][fcb_id],
+ stg.FCB[fcb_id, :, self.slider_FCB.value() - 1],
+ linestyle="solid", linewidth=1, color="k"
+ )
+ else:
+ self.axis_FCB.plot(
+ stg.depth[data_id][fcb_id],
+ stg.FCB[fcb_id, :, self.slider_FCB.value() - 1],
+ linestyle="solid", linewidth=1, color="k"
+ )
- self.verticalLayout_groupbox_FCB_plot.addWidget(self.toolbar_FCB)
- self.verticalLayout_groupbox_FCB_plot.addWidget(self.canvas_FCB)
+ self.axis_FCB.text(
+ .95, .05,
+ stg.freq_text[data_id][fcb_id],
+ fontsize=10, fontweight='bold', fontname="DejaVu Sans",
+ fontstyle="normal", c="black", alpha=0.2,
+ horizontalalignment='right', verticalalignment='bottom',
+ transform=self.axis_FCB.transAxes
+ )
- if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
+ self.fig_FCB.supxlabel("Depth (m)")
+ self.fig_FCB.supylabel("FCB")
+ self.fig_FCB.canvas.draw_idle()
- self.axis_FCB.plot(
- stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_frequency_FCB.currentIndex()],
- stg.FCB[self.combobox_frequency_FCB.currentIndex(), :, self.slider_FCB.value() - 1],
- linestyle="solid", linewidth=1, color="k")
- else:
-
- self.axis_FCB.plot(
- stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_frequency_FCB.currentIndex()],
- stg.FCB[self.combobox_frequency_FCB.currentIndex(), :, self.slider_FCB.value() - 1],
- linestyle="solid", linewidth=1, color="k")
-
- self.axis_FCB.text(.95, .05,
- stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_frequency_FCB.currentIndex()],
- fontsize=10, fontweight='bold', fontname="DejaVu Sans",
- fontstyle="normal", c="black", alpha=0.2,
- horizontalalignment='right', verticalalignment='bottom',
- transform=self.axis_FCB.transAxes)
-
- self.fig_FCB.supxlabel("Depth (m)")
- self.fig_FCB.supylabel("FCB")
- self.fig_FCB.canvas.draw_idle()
-
- self.slider_FCB.valueChanged.connect(self.update_plot_FCB)
- self.combobox_frequency_FCB.currentIndexChanged.connect(self.update_plot_FCB)
+ self.slider_FCB.valueChanged.connect(self.update_plot_FCB)
+ self.combobox_frequency_FCB.currentIndexChanged\
+ .connect(self.update_plot_FCB)
def update_plot_FCB(self):
+ data_id = self.combobox_acoustic_data_choice.currentIndex()
+ fcb_id = self.combobox_frequency_FCB.currentIndex()
+
+ freq1_id = self.combobox_freq1.currentIndex()
+ freq2_id = self.combobox_freq2.currentIndex()
if stg.FCB.shape != (0,):
self.axis_FCB.cla()
- if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
-
+ if stg.depth_cross_section[data_id].shape != (0,):
self.axis_FCB.plot(
- stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_frequency_FCB.currentIndex()],
- stg.FCB[self.combobox_frequency_FCB.currentIndex(), :, self.slider_FCB.value() - 1],
- linestyle="solid", linewidth=1, color="k")
-
+ stg.depth_cross_section[data_id][fcb_id],
+ stg.FCB[fcb_id, :, self.slider_FCB.value() - 1],
+ linestyle="solid", linewidth=1, color="k"
+ )
else:
-
self.axis_FCB.plot(
- stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_frequency_FCB.currentIndex()],
- stg.FCB[self.combobox_frequency_FCB.currentIndex(), :, self.slider_FCB.value() - 1],
- linestyle="solid", linewidth=1, color="k")
+ stg.depth[data_id][fcb_id],
+ stg.FCB[fcb_id, :, self.slider_FCB.value() - 1],
+ linestyle="solid", linewidth=1, color="k"
+ )
- self.axis_FCB.text(.95, .05,
- stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_frequency_FCB.currentIndex()],
- fontsize=10, fontweight='bold', fontname="DejaVu Sans",
- fontstyle="normal", c="black", alpha=0.2,
- horizontalalignment='right', verticalalignment='bottom',
- transform=self.axis_FCB.transAxes)
+ self.axis_FCB.text(
+ .95, .05,
+ stg.freq_text[data_id][fcb_id],
+ fontsize=10, fontweight='bold', fontname="DejaVu Sans",
+ fontstyle="normal", c="black", alpha=0.2,
+ horizontalalignment='right', verticalalignment='bottom',
+ transform=self.axis_FCB.transAxes
+ )
self.fig_FCB.canvas.draw_idle()
# --- Update red line on acoustic record plot ---
if stg.sand_sample_target_indice:
-
- if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
-
- if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
-
- self.red_line_plot_return.set_data(
- stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_freq2.currentIndex(), self.slider_FCB.value() -1] *
- np.ones(
- stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[
- 1]),
- -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_freq2.currentIndex(), :])
-
- else:
-
- self.red_line_plot_return.set_data(
- stg.time[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_freq2.currentIndex(), self.slider_FCB.value() -1] *
- np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[
- 1]),
- -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_freq2.currentIndex(), :])
-
+ if stg.depth_cross_section[data_id].shape != (0,):
+ depth_data = stg.depth_cross_section
else:
+ depth_data = stg.depth
- if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
+ if stg.time_cross_section[data_id].shape != (0,):
+ time_data = stg.time_cross_section
+ else:
+ time_data = stg.time
- self.red_line_plot_return.set_data(
- stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_freq2.currentIndex(), self.slider_FCB.value() -1] *
- np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]),
- -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_freq2.currentIndex(), :])
-
- else:
-
- self.red_line_plot_return.set_data(
- stg.time[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_freq2.currentIndex(), self.slider_FCB.value() -1] *
- np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]),
- -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_freq2.currentIndex(), :])
+ self.red_line_plot_return.set_data(
+ time_data[data_id][freq2_id, self.slider_FCB.value() -1]
+ * np.ones(
+ depth_data[data_id].shape[1]
+ ),
+ -stg.depth_data[data_id][freq2_id, :]
+ )
self.fig_BS.canvas.draw_idle()
def fit_FCB_profile_with_linear_regression_and_compute_alphaS(self):
+ data_id = self.combobox_acoustic_data_choice.currentIndex()
+ fcb_id = self.combobox_frequency_FCB.currentIndex()
self.update_plot_FCB()
- if stg.FCB.shape != (0,):
+ if stg.FCB.shape == (0,):
+ return
- # --- Identify FCB profile where value are not NaN ---
- y0 = stg.FCB[self.combobox_frequency_FCB.currentIndex(), :, self.slider_FCB.value() - 1]
- y = y0[np.where(np.isnan(y0) == False)]
+ # --- Identify FCB profile where value are not NaN ---
+ y0 = stg.FCB[fcb_id, :, self.slider_FCB.value() - 1]
+ y = y0[np.where(np.isnan(y0) == False)]
- if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
+ if stg.depth_cross_section[data_id].shape != (0,):
+ depth_data = stg.depth_cross_section
+ else:
+ depth_data = stg.depth
- # --- Select depth corresponding to the FCB profile where value are not NaN ---
- x0 = stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_frequency_FCB.currentIndex(), :]
- x = x0[np.where(np.isnan(y0) == False)]
+ # --- Select depth corresponding to the FCB profile where value are not NaN ---
+ x0 = depth_data[data_id][fcb_id, :]
+ x = x0[np.where(np.isnan(y0) == False)]
- # --- Find the indices of the values between which the linear regression is fitted ---
- value1 = np.where(np.round(np.abs(x - float(self.lineEdit_FCB_from.text().replace(',','.'))), 2) ==
- np.min(np.round(np.abs(x - float(self.lineEdit_FCB_from.text().replace(',','.'))), 2)))[0][0]
- value2 = np.where(np.round(np.abs(x - float(self.lineEdit_FCB_to.text().replace(',', '.'))), 2) ==
- np.min(np.round(np.abs(x - float(self.lineEdit_FCB_to.text().replace(',', '.'))), 2)))[0][0]
+ # --- Find the indices of the values between which the linear regression is fitted ---
+ value1 = np.where(
+ np.round(
+ np.abs(
+ x - float(
+ self.lineEdit_FCB_from\
+ .text().replace(',','.')
+ )
+ ), 2
+ ) == np.min(
+ np.round(
+ np.abs(
+ x - float(
+ self.lineEdit_FCB_from.text().replace(',','.'))
+ ), 2
+ )
+ )
+ )[0][0]
- lin_reg_compute = linregress(x[value1:value2], y[value1:value2])
+ value2 = np.where(
+ np.round(
+ np.abs(
+ x - float(
+ self.lineEdit_FCB_to.text().replace(',', '.')
+ )
+ ), 2
+ ) == np.min(
+ np.round(
+ np.abs(
+ x - float(
+ self.lineEdit_FCB_to.text().replace(',', '.')
+ )
+ ), 2
+ )
+ )
+ )[0][0]
- stg.lin_reg.clear()
- stg.lin_reg = [lin_reg_compute.slope, lin_reg_compute.intercept]
+ lin_reg_compute = linregress(x[value1:value2], y[value1:value2])
- # --- Plot result of linear regression ---
- self.axis_FCB.plot(
- stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_frequency_FCB.currentIndex(), value1:value2],
- stg.lin_reg[0] *
- stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_frequency_FCB.currentIndex(), value1:value2] +
- stg.lin_reg[1],
- linestyle="dashed", linewidth=1, color="b")
+ stg.lin_reg.clear()
+ stg.lin_reg = [lin_reg_compute.slope, lin_reg_compute.intercept]
- else:
+ # --- Plot result of linear regression ---
+ self.axis_FCB.plot(
+ depth_data[data_id][fcb_id, value1:value2],
+ stg.lin_reg[0]
+ * depth_data[data_id][fcb_id, value1:value2]
+ + stg.lin_reg[1],
+ linestyle="dashed", linewidth=1, color="b"
+ )
- # --- Select depth corresponding to the FCB profile where value are not NaN ---
- x0 = stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_frequency_FCB.currentIndex(), :]
- x = x0[np.where(np.isnan(y0) == False)]
+ self.fig_FCB.canvas.draw_idle()
- # --- Find the indices of the values between which the linear regression is fitted ---
- value1 = np.where(np.round(np.abs(x - float(self.lineEdit_FCB_from.text().replace(',','.'))), 2) ==
- np.min(np.round(np.abs(x - float(self.lineEdit_FCB_from.text().replace(',','.'))), 2)))[0][0]
- value2 = np.where(np.round(np.abs(x - float(self.lineEdit_FCB_to.text().replace(',', '.'))), 2) ==
- np.min(np.round(np.abs(x - float(self.lineEdit_FCB_to.text().replace(',', '.'))), 2)))[0][0]
-
- lin_reg_compute = linregress(x[value1:value2], y[value1:value2])
-
- stg.lin_reg.clear()
- stg.lin_reg = [lin_reg_compute.slope, lin_reg_compute.intercept]
-
- # --- Plot result of linear regression ---
- self.axis_FCB.plot(
- stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_frequency_FCB.currentIndex(), value1:value2],
- stg.lin_reg[0] *
- stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
- self.combobox_frequency_FCB.currentIndex(), value1:value2] +
- stg.lin_reg[1],
- linestyle="dashed", linewidth=1, color="b")
-
- self.fig_FCB.canvas.draw_idle()
-
- # --- Display the value of alphaS compute with FCB ---
- self.label_alphaS_FCB.clear()
- self.label_alphaS_FCB.setText(f"αs = {-0.5*stg.lin_reg[0]:.4f} dB/m")
+ # --- Display the value of alphaS compute with FCB ---
+ self.label_alphaS_FCB.clear()
+ self.label_alphaS_FCB.setText(
+ f"αs = {-0.5*stg.lin_reg[0]:.4f} dB/m"
+ )
def slider_profile_number_to_begin_FCB(self):
self.slider_FCB.setValue(int(self.slider_FCB.minimum()))