diff --git a/View/acoustic_inversion_tab.py b/View/acoustic_inversion_tab.py index 075008e..d5b47c1 100644 --- a/View/acoustic_inversion_tab.py +++ b/View/acoustic_inversion_tab.py @@ -450,17 +450,20 @@ class AcousticInversionTab(QWidget): logger.debug(f"{__name__}: Update") self.blockSignals(True) + self.update_acoustic_data_choice() + # TODO: Update all widgets self.blockSignals(False) def update_acoustic_data_choice(self): - self.combobox_acoustic_data_choice.clear() for i in range(len(stg.filename_BS_raw_data)): self.combobox_acoustic_data_choice.addItem(stg.data_preprocessed[i]) - self.combobox_acoustic_data_choice.currentIndexChanged.connect(self.combobox_acoustic_data_choice_currentIndexChanged) + self.combobox_acoustic_data_choice\ + .currentIndexChanged\ + .connect(self.combobox_acoustic_data_choice_currentIndexChanged) def combobox_acoustic_data_choice_currentIndexChanged(self): self.fill_combobox_fine_sample() @@ -475,27 +478,28 @@ class AcousticInversionTab(QWidget): def function_run_inversion(self): if (stg.alpha_s[0] < 0) or (stg.alpha_s[1] < 0): - msgBox = QMessageBox() msgBox.setWindowTitle("Alpha computation error") msgBox.setIconPixmap( - QPixmap(self.path_icon + "no_approved.png").scaledToHeight(32, Qt.SmoothTransformation)) + QPixmap( + self.path_icon + "no_approved.png" + ).scaledToHeight(32, Qt.SmoothTransformation) + ) msgBox.setText("Sediment sound attenuation is negative !") msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec() - elif isinf(stg.alpha_s[0]) or isinf(stg.alpha_s[1]): - msgBox = QMessageBox() msgBox.setWindowTitle("Alpha computation error") msgBox.setIconPixmap( - QPixmap(self.path_icon + "no_approved.png").scaledToHeight(32, Qt.SmoothTransformation)) + QPixmap( + self.path_icon + "no_approved.png" + ).scaledToHeight(32, Qt.SmoothTransformation) + ) msgBox.setText("Sediment sound attenuation is infinite !") msgBox.setStandardButtons(QMessageBox.Ok) msgBox.exec() - else: - self.compute_VBI() self.compute_SSC_fine() self.compute_SSC_sand() @@ -530,343 +534,335 @@ class AcousticInversionTab(QWidget): ) def compute_SSC_fine(self): - stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()] = np.array([]) stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()] = self.inv_hc.SSC_fine( zeta=stg.zeta[1], - r2D=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]], - VBI=stg.VBI_cross_section[self.combobox_acoustic_data_choice.currentIndex()], + r2D=stg.depth_2D[ + self.combobox_acoustic_data_choice.currentIndex() + ][ + stg.frequency_for_inversion[1] + ], + VBI=stg.VBI_cross_section[ + self.combobox_acoustic_data_choice.currentIndex() + ], freq=stg.frequencies_for_calibration[1][0], X=stg.X_exponent[0], - j_cross_section=stg.J_cross_section[self.combobox_acoustic_data_choice.currentIndex()][1], - alpha_w=np.full(shape=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]].shape, - fill_value=stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]]) + j_cross_section=stg.J_cross_section[ + self.combobox_acoustic_data_choice.currentIndex() + ][1], + alpha_w=np.full( + shape=stg.depth_2D[ + self.combobox_acoustic_data_choice.currentIndex() + ][ + stg.frequency_for_inversion[1] + ].shape, + fill_value=stg.water_attenuation[ + self.combobox_acoustic_data_choice.currentIndex() + ][ + stg.frequency_for_inversion[1] + ] + ) ) def compute_SSC_sand(self): + data_id = self.combobox_acoustic_data_choice.currentIndex() - stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()] = np.array([]) + stg.SSC_sand[data_id] = np.array([]) - stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()] = self.inv_hc.SSC_sand( - VBI=stg.VBI_cross_section[self.combobox_acoustic_data_choice.currentIndex()], + stg.SSC_sand[data_id] = self.inv_hc.SSC_sand( + VBI=stg.VBI_cross_section[data_id], freq=stg.frequencies_for_calibration[1][0], X=stg.X_exponent, - ks=stg.ks[1]) + ks=stg.ks[1] + ) def plot_SSC_fine(self): + data_id = self.combobox_acoustic_data_choice.currentIndex() - if self.combobox_acoustic_data_choice.count() > 0: + if self.combobox_acoustic_data_choice.count() <= 0: + return - if stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape == (0,): + if stg.SSC_fine[data_id].shape == (0,): + self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.toolbar_SSC_fine) + self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.canvas_SSC_fine) - self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.toolbar_SSC_fine) - self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.canvas_SSC_fine) + self.canvas_SSC_fine = FigureCanvas() + self.toolbar_SSC_fine = NavigationToolBar(self.canvas_SSC_fine, self) - self.canvas_SSC_fine = FigureCanvas() - self.toolbar_SSC_fine = NavigationToolBar(self.canvas_SSC_fine, self) + self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.toolbar_SSC_fine) + self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.canvas_SSC_fine) - self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.toolbar_SSC_fine) - self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.canvas_SSC_fine) + elif stg.SSC_fine[data_id].shape != (0,): + self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.toolbar_SSC_fine) + self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.canvas_SSC_fine) - elif stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + self.figure_SSC_fine, self.axis_SSC_fine = plt.subplots( + nrows=1, ncols=1, layout="constrained" + ) + self.canvas_SSC_fine = FigureCanvas(self.figure_SSC_fine) + self.toolbar_SSC_fine = NavigationToolBar(self.canvas_SSC_fine, self) - self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.toolbar_SSC_fine) - self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.canvas_SSC_fine) + self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.toolbar_SSC_fine) + self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.canvas_SSC_fine) - self.figure_SSC_fine, self.axis_SSC_fine = plt.subplots(nrows=1, ncols=1, layout="constrained") - self.canvas_SSC_fine = FigureCanvas(self.figure_SSC_fine) - self.toolbar_SSC_fine = NavigationToolBar(self.canvas_SSC_fine, self) + val_min = np.nanmin(stg.SSC_fine[data_id]) + val_max = np.nanmax(stg.SSC_fine[data_id]) - self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.toolbar_SSC_fine) - self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.canvas_SSC_fine) + if stg.time_cross_section[data_id].shape != (0,): + time_data = stg.time_cross_section + depth_data = stg.depth_cross_section + else: + time_data = stg.time + depth_data = stg.depth - val_min = np.nanmin(stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()]) - val_max = np.nanmax(stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()]) + pcm_SSC_fine = self.axis_SSC_fine.pcolormesh( + time_data[data_id][stg.frequency_for_inversion[1]], + -depth_data[data_id][stg.frequency_for_inversion[1]], + stg.SSC_fine[data_id], + cmap='rainbow', norm=LogNorm(vmin=1e0, vmax=15), + shading='gouraud' + ) - if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + if stg.depth_bottom[data_id].shape != (0,): + self.axis_SSC_fine.plot( + time_data[data_id][stg.frequency_for_inversion[1]], + -stg.depth_bottom[data_id], + color='black', linewidth=1, linestyle="solid" + ) - pcm_SSC_fine = self.axis_SSC_fine.pcolormesh( - stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]], - -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]], - stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()], - cmap='rainbow', norm=LogNorm(vmin=1e0, vmax=15), shading='gouraud') + self.pcm_SSC_fine_vertical_line, = self.axis_SSC_fine.plot( + time_data[data_id][stg.frequency_for_inversion[1], + self.slider_fine.value() - 1] + * np.ones( + depth_data[data_id][ + stg.frequency_for_inversion[1] + ].shape + ), + -depth_data[data_id][stg.frequency_for_inversion[1]], + linestyle="solid", color='r', linewidth=2 + ) - if stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - self.axis_SSC_fine.plot(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]], - -stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()], - color='black', linewidth=1, linestyle="solid") + # --- Plot samples of fine sediments --- + time_fine_temp = deepcopy(stg.time_fine) + depth_fine_temp = deepcopy(stg.depth_fine) + for s in stg.fine_sample_profile: + time_fine_temp.remove(stg.time_fine[s[1]]) + depth_fine_temp.remove(stg.depth_fine[s[1]]) - self.pcm_SSC_fine_vertical_line, = self.axis_SSC_fine.plot( - stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1], - self.slider_fine.value() - 1] * - np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]].shape), - -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]], - linestyle="solid", color='r', linewidth=2) + self.pcm_SSC_fine_meas_vs_inv, = self.axis_SSC_fine.plot( + time_fine_temp, depth_fine_temp, + ls=" ", marker="o", ms=5, mec="k", mfc="k" + ) - else: + time_fine_temp = deepcopy(stg.time_fine) + depth_fine_temp = deepcopy(stg.depth_fine) + sample_fine_temp = deepcopy(stg.sample_fine) + for s in stg.fine_sample_profile: + sample_fine_temp.remove(s) + time_fine_temp.remove(stg.time_fine[s[1]]) + depth_fine_temp.remove(stg.depth_fine[s[1]]) + for i in range(len(sample_fine_temp)): + self.pcm_SSC_fine_meas_vs_inv_text = self.axis_SSC_fine.text( + time_fine_temp[i], + depth_fine_temp[i], sample_fine_temp[i][0] + ) - pcm_SSC_fine = self.axis_SSC_fine.pcolormesh( - stg.time[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]], - -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]], - stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()], - cmap='rainbow', norm=LogNorm(vmin=1e0, vmax=15), shading='gouraud') + time_fine_temp, depth_fine_temp = stg.time_fine, stg.depth_fine + self.pcm_SSC_fine_meas_vs_inv_sample_calibration, = self.axis_SSC_fine.plot( + [time_fine_temp[s[1]] for s in stg.fine_sample_profile], + [depth_fine_temp[s[1]] for s in stg.fine_sample_profile], + ls=" ", marker="*", ms=12, mec="r", mfc="r" + ) - self.pcm_SSC_fine_vertical_line, = self.axis_SSC_fine.plot( - stg.time[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1], - self.slider_fine.value() - 1] * - np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[ - 1]].shape), - -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]], - linestyle="solid", color='r', linewidth=2) + time_fine_temp, depth_fine_temp = stg.time_fine, stg.depth_fine + for i, j in stg.fine_sample_profile: + self.pcm_SSC_fine_meas_vs_inv_sample_calibration_text = self.axis_SSC_fine.text( + time_fine_temp[j]+5, depth_fine_temp[j]+0.05, i, + color='r', fontweight='bold' + ) - if stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - self.axis_SSC_fine.plot(stg.time[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]], - -stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()], - color='black', linewidth=1, linestyle="solid") + cbar_SSC_fine = self.figure_SSC_fine.colorbar( + pcm_SSC_fine, ax=self.axis_SSC_fine, shrink=1, + location='right' + ) + cbar_SSC_fine.set_label(label='Fine SSC (g/L', rotation=270, labelpad=15) - # --- Plot samples of fine sediments --- - time_fine_temp = deepcopy(stg.time_fine) - depth_fine_temp = deepcopy(stg.depth_fine) - for s in stg.fine_sample_profile: - time_fine_temp.remove(stg.time_fine[s[1]]) - depth_fine_temp.remove(stg.depth_fine[s[1]]) - self.pcm_SSC_fine_meas_vs_inv, = self.axis_SSC_fine.plot( - time_fine_temp, depth_fine_temp, ls=" ", marker="o", ms=5, mec="k", mfc="k") - - time_fine_temp = deepcopy(stg.time_fine) - depth_fine_temp = deepcopy(stg.depth_fine) - sample_fine_temp = deepcopy(stg.sample_fine) - for s in stg.fine_sample_profile: - sample_fine_temp.remove(s) - time_fine_temp.remove(stg.time_fine[s[1]]) - depth_fine_temp.remove(stg.depth_fine[s[1]]) - for i in range(len(sample_fine_temp)): - self.pcm_SSC_fine_meas_vs_inv_text = self.axis_SSC_fine.text( - time_fine_temp[i], - depth_fine_temp[i], sample_fine_temp[i][0]) - - time_fine_temp, depth_fine_temp = stg.time_fine, stg.depth_fine - self.pcm_SSC_fine_meas_vs_inv_sample_calibration, = self.axis_SSC_fine.plot( - [time_fine_temp[s[1]] for s in stg.fine_sample_profile], - [depth_fine_temp[s[1]] for s in stg.fine_sample_profile], - ls=" ", marker="*", ms=12, mec="r", mfc="r") - - time_fine_temp, depth_fine_temp = stg.time_fine, stg.depth_fine - for i, j in stg.fine_sample_profile: - self.pcm_SSC_fine_meas_vs_inv_sample_calibration_text = self.axis_SSC_fine.text( - time_fine_temp[j]+5, depth_fine_temp[j]+0.05, i, color='r', fontweight='bold') - - cbar_SSC_fine = self.figure_SSC_fine.colorbar(pcm_SSC_fine, ax=self.axis_SSC_fine, shrink=1, - location='right') - cbar_SSC_fine.set_label(label='Fine SSC (g/L', rotation=270, labelpad=15) - - self.figure_SSC_fine.supxlabel("Time (sec)", fontsize=10) - self.figure_SSC_fine.supylabel("Depth (m)", fontsize=10) - self.figure_SSC_fine.canvas.draw_idle() + self.figure_SSC_fine.supxlabel("Time (sec)", fontsize=10) + self.figure_SSC_fine.supylabel("Depth (m)", fontsize=10) + self.figure_SSC_fine.canvas.draw_idle() def plot_SSC_fine_vertical_profile(self): + if self.combobox_acoustic_data_choice.count() <= 0: + return - if self.combobox_acoustic_data_choice.count() > 0: + data_id = self.combobox_acoustic_data_choice.currentIndex() - if stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape == (0,): + if stg.SSC_fine[data_id].shape == (0,): + self.verticalLayout_groupbox_plot_vertical_profile_fine\ + .removeWidget(self.toolbar_profile_fine) + self.verticalLayout_groupbox_plot_vertical_profile_fine\ + .removeWidget(self.canvas_profile_fine) - self.verticalLayout_groupbox_plot_vertical_profile_fine.removeWidget(self.toolbar_profile_fine) - self.verticalLayout_groupbox_plot_vertical_profile_fine.removeWidget(self.canvas_profile_fine) + self.canvas_profile_fine = FigureCanvas() + self.toolbar_profile_fine = NavigationToolBar(self.canvas_profile_fine, self) - self.canvas_profile_fine = FigureCanvas() - self.toolbar_profile_fine = NavigationToolBar(self.canvas_profile_fine, self) + self.verticalLayout_groupbox_plot_vertical_profile_fine\ + .addWidget(self.toolbar_profile_fine) + self.verticalLayout_groupbox_plot_vertical_profile_fine\ + .addWidget(self.canvas_profile_fine) - self.verticalLayout_groupbox_plot_vertical_profile_fine.addWidget(self.toolbar_profile_fine) - self.verticalLayout_groupbox_plot_vertical_profile_fine.addWidget(self.canvas_profile_fine) + if stg.SSC_fine[data_id].shape != (0,): + self.slider_fine.setMaximum( + stg.SSC_fine[data_id].shape[1] + ) - if stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + self.verticalLayout_groupbox_plot_vertical_profile_fine\ + .removeWidget(self.toolbar_profile_fine) + self.verticalLayout_groupbox_plot_vertical_profile_fine\ + .removeWidget(self.canvas_profile_fine) - self.slider_fine.setMaximum(stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape[1]) + fig, ax = plt.subplots(nrows=1, ncols=1, layout="constrained") + self.figure_vertical_profile_SSC_fine = fig + self.axis_vertical_profile_SSC_fine = ax - self.verticalLayout_groupbox_plot_vertical_profile_fine.removeWidget(self.toolbar_profile_fine) - self.verticalLayout_groupbox_plot_vertical_profile_fine.removeWidget(self.canvas_profile_fine) + self.canvas_profile_fine = FigureCanvas(self.figure_vertical_profile_SSC_fine) + self.toolbar_profile_fine = NavigationToolBar(self.canvas_profile_fine, self) - self.figure_vertical_profile_SSC_fine, self.axis_vertical_profile_SSC_fine = plt.subplots( - nrows=1, ncols=1, layout="constrained") + self.verticalLayout_groupbox_plot_vertical_profile_fine\ + .addWidget(self.toolbar_profile_fine) + self.verticalLayout_groupbox_plot_vertical_profile_fine\ + .addWidget(self.canvas_profile_fine) - self.canvas_profile_fine = FigureCanvas(self.figure_vertical_profile_SSC_fine) - self.toolbar_profile_fine = NavigationToolBar(self.canvas_profile_fine, self) + if stg.depth_cross_section[data_id].shape != (0,): + time_data = stg.time_cross_section + depth_data = stg.depth_cross_section + else: + time_data = stg.time + depth_data = stg.depth - self.verticalLayout_groupbox_plot_vertical_profile_fine.addWidget(self.toolbar_profile_fine) - self.verticalLayout_groupbox_plot_vertical_profile_fine.addWidget(self.canvas_profile_fine) + self.plot_fine , = self.axis_vertical_profile_SSC_fine.plot( + stg.SSC_fine[data_id][:, self.slider_fine.value() -1], + -depth_data[data_id][stg.frequency_for_inversion[1]], + linestyle="solid", linewidth=1, color="k" + ) - if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + self.pcm_SSC_fine_vertical_line.set_data( + time_data[data_id][ + stg.frequency_for_inversion[1], + self.slider_fine.value() - 1 + ] + * np.ones( + depth_data[data_id][ + stg.frequency_for_inversion[1] + ].shape + ), + -depth_data[data_id][ + stg.frequency_for_inversion[1] + ] + ) + self.figure_SSC_fine.canvas.draw_idle() - self.plot_fine , = self.axis_vertical_profile_SSC_fine.plot( - stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][:, self.slider_fine.value() -1], - -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]], - linestyle="solid", linewidth=1, color="k") + self.axis_vertical_profile_SSC_fine.set_ylim( + [ + -np.nanmax( + depth_data[data_id][stg.frequency_for_inversion[1]] + ), + -np.nanmin( + depth_data[data_id][stg.frequency_for_inversion[1]] + ) + ] + ) - self.pcm_SSC_fine_vertical_line.set_data( - stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1], - self.slider_fine.value() - 1] * - np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]].shape), - -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]]) - self.figure_SSC_fine.canvas.draw_idle() - - self.axis_vertical_profile_SSC_fine.set_ylim( - [-np.nanmax(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]]), - -np.nanmin(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]])]) - - else: - - self.plot_fine , = self.axis_vertical_profile_SSC_fine.plot( - stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][:, self.slider_fine.value() -1], - -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]], - linestyle="solid", linewidth=1, color="k") - - self.pcm_SSC_fine_vertical_line.set_data( - stg.time[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1], self.slider_fine.value() - 1] * - np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]].shape), - -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]]) - self.figure_SSC_fine.canvas.draw_idle() - - self.axis_vertical_profile_SSC_fine.set_ylim( - [-np.nanmax(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]]), - -np.nanmin(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]])]) - - self.axis_vertical_profile_SSC_fine.set_xlim(0, 10) - self.axis_vertical_profile_SSC_fine.set_xlabel("Inverted Fine SSC (g/L)") - self.axis_vertical_profile_SSC_fine.set_ylabel("Depth (m)") - self.figure_vertical_profile_SSC_fine.canvas.draw_idle() + self.axis_vertical_profile_SSC_fine.set_xlim(0, 10) + self.axis_vertical_profile_SSC_fine.set_xlabel("Inverted Fine SSC (g/L)") + self.axis_vertical_profile_SSC_fine.set_ylabel("Depth (m)") + self.figure_vertical_profile_SSC_fine.canvas.draw_idle() def update_plot_SSC_fine_vertical_profile(self): + if len(stg.filename_BS_noise_data) == 0: + return - if stg.filename_BS_noise_data != []: + data_id = self.combobox_acoustic_data_choice.currentIndex() - if stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + if stg.SSC_fine[data_id].shape == (0,): + return - self.axis_vertical_profile_SSC_fine.cla() + self.axis_vertical_profile_SSC_fine.cla() - if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + if stg.depth_cross_section[data_id].shape != (0,): + time_data = stg.time_cross_section + depth_data = stg.depth_cross_section + else: + time_data = stg.time + depth_data = stg.depth - self.axis_vertical_profile_SSC_fine.plot( - stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][:, - self.slider_fine.value() - 1], - -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]], - linestyle="solid", linewidth=1, color="k") + self.axis_vertical_profile_SSC_fine.plot( + stg.SSC_fine[data_id][:, self.slider_fine.value() - 1], + -depth_data[data_id][stg.frequency_for_inversion[1]], + linestyle="solid", linewidth=1, color="k" + ) - self.pcm_SSC_fine_vertical_line.set_data( - stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1], - self.slider_fine.value() - 1] * - np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]].shape), - -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]]) - self.figure_SSC_fine.canvas.draw_idle() + self.pcm_SSC_fine_vertical_line.set_data( + time_data[data_id][stg.frequency_for_inversion[1], + self.slider_fine.value() - 1] + * np.ones(depth_data[data_id][ + stg.frequency_for_inversion[1] + ].shape), + -depth_data[data_id][stg.frequency_for_inversion[1]] + ) + self.figure_SSC_fine.canvas.draw_idle() - self.axis_vertical_profile_SSC_fine.set_ylim( - [-np.nanmax(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]]), - -np.nanmin(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]])]) + self.axis_vertical_profile_SSC_fine.set_ylim( + [ + -np.nanmax( + depth_data[data_id][stg.frequency_for_inversion[1]] + ), + -np.nanmin( + depth_data[data_id][stg.frequency_for_inversion[1]] + ) + ] + ) - else: - - self.axis_vertical_profile_SSC_fine.plot( - stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][:, - self.slider_fine.value() - 1], - -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]], - linestyle="solid", linewidth=1, color="k") - - self.pcm_SSC_fine_vertical_line.set_data( - stg.time[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1], self.slider_fine.value() - 1] * - np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]].shape), - -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]]) - self.figure_SSC_fine.canvas.draw_idle() - - self.axis_vertical_profile_SSC_fine.set_ylim( - [-np.nanmax(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]]), - -np.nanmin(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]])]) - - if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - - for f in stg.fine_sample_profile: - - time_fine_calibration = ( - np.where(np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]] - stg.time_fine[f[1]]) == - np.nanmin(np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]] - stg.time_fine[f[1]])))[0][0] + for f in stg.fine_sample_profile: + time_fine_calibration = ( + np.where( + np.abs( + time_data[data_id][stg.frequency_for_inversion[1]] + - stg.time_fine[f[1]] + ) == np.nanmin( + np.abs( + time_data[data_id][ + stg.frequency_for_inversion[1] + ] + - stg.time_fine[f[1]] ) + ) + )[0][0] + ) - if (stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1], int(self.slider_fine.value())] == - stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1], int(time_fine_calibration)]): + if (time_data[data_id][ + stg.frequency_for_inversion[1], + int(self.slider_fine.value()) + ] == time_data[data_id][ + stg.frequency_for_inversion[1], + int(time_fine_calibration) + ]): + self.axis_vertical_profile_SSC_fine.scatter( + stg.Ctot_fine[f[1]], stg.depth_fine[f[1]], + marker='*', s=48, c='r', edgecolors='r' + ) + self.axis_vertical_profile_SSC_fine.text( + stg.Ctot_fine[f[1]], + stg.depth_fine[f[1]], f[0] + ) - self.axis_vertical_profile_SSC_fine.scatter( - stg.Ctot_fine[f[1]], stg.depth_fine[f[1]], - marker='*', s=48, c='r', edgecolors='r') - self.axis_vertical_profile_SSC_fine.text(stg.Ctot_fine[f[1]], stg.depth_fine[f[1]], f[0]) - - else: - - for f in stg.fine_sample_profile: - - time_fine_calibration = ( - np.where(np.abs(stg.time[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]] - stg.time_fine[f[1]]) == - np.nanmin(np.abs( - stg.time[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1]] - stg.time_fine[f[1]])))[0][0] - ) - - if (stg.time[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1], int(self.slider_fine.value())] == - stg.time[self.combobox_acoustic_data_choice.currentIndex()][ - stg.frequency_for_inversion[1], int(time_fine_calibration)]): - - self.axis_vertical_profile_SSC_fine.scatter( - stg.Ctot_fine[f[1]], stg.depth_fine[f[1]], - marker='*', s=48, c='r', edgecolors='r') - self.axis_vertical_profile_SSC_fine.text(stg.Ctot_fine[f[1]], stg.depth_fine[f[1]], f[0]) - - self.axis_vertical_profile_SSC_fine.set_xlim(0, 10) - self.axis_vertical_profile_SSC_fine.set_xlabel("Inverted Fine SSC (g/L)") - self.axis_vertical_profile_SSC_fine.set_ylabel("Depth (m)") - self.figure_vertical_profile_SSC_fine.canvas.draw_idle() + self.axis_vertical_profile_SSC_fine.set_xlim(0, 10) + self.axis_vertical_profile_SSC_fine\ + .set_xlabel("Inverted Fine SSC (g/L)") + self.axis_vertical_profile_SSC_fine\ + .set_ylabel("Depth (m)") + self.figure_vertical_profile_SSC_fine.canvas.draw_idle() def slider_profile_number_to_begin_fine(self): self.slider_fine.setValue(int(self.slider_fine.minimum()))