diff --git a/View/sediment_calibration_tab.py b/View/sediment_calibration_tab.py index 0fdde5b..153ed07 100644 --- a/View/sediment_calibration_tab.py +++ b/View/sediment_calibration_tab.py @@ -1039,441 +1039,129 @@ class SedimentCalibrationTab(QWidget): self.verticalLayout_groupbox_data_plot.addWidget(self.toolbar_BS) self.verticalLayout_groupbox_data_plot.addWidget(self.canvas_BS) - if stg.BS_stream_bed_pre_process_average[ - data_id - ].shape != (0,): - val_min = np.nanmin( - stg.BS_stream_bed_pre_process_average[data_id][freq2, :, :] - ) - val_max = np.nanmax( - stg.BS_stream_bed_pre_process_average[data_id][freq2, :, :] - ) - if val_min == 0: - val_min = 1e-5 - - if stg.time_cross_section[data_id].shape != (0,): - if stg.depth_cross_section[data_id].shape != (0,): - self.axis_BS.pcolormesh( - stg.time_cross_section[data_id][freq2, :], - -stg.depth_cross_section[data_id][freq2, :], - stg.BS_stream_bed_pre_process_average[data_id][ - freq2, :, :], - cmap='viridis', - norm=LogNorm(vmin=val_min, vmax=val_max) - ) - else: - self.axis_BS.pcolormesh( - stg.time_cross_section[data_id][ - freq2, :], - -stg.depth[data_id][ - freq2, :], - stg.BS_stream_bed_pre_process_average[data_id][ - freq2, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - else: - if stg.depth_cross_section[data_id].shape != (0,): - self.axis_BS.pcolormesh( - stg.time[data_id][ - freq2, :], - -stg.depth_cross_section[data_id][ - freq2, :], - stg.BS_stream_bed_pre_process_average[data_id][ - freq2, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - else: - self.axis_BS.pcolormesh( - stg.time[data_id][ - freq2, :], - -stg.depth[data_id][ - freq2, :], - stg.BS_stream_bed_pre_process_average[data_id][ - freq2, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - - + BS_data = None + time_data = None + depth_data = None + 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,): - - val_min = np.nanmin( - stg.BS_stream_bed_pre_process_SNR[data_id][ - freq2, :, :]) - val_max = np.nanmax( - stg.BS_stream_bed_pre_process_SNR[data_id][ - freq2, :, :]) - if val_min == 0: - val_min = 1e-5 - - if stg.time_cross_section[data_id].shape != (0,): - if stg.depth_cross_section[data_id].shape != (0,): - self.axis_BS.pcolormesh( - stg.time_cross_section[data_id][ - freq2, :], - -stg.depth_cross_section[data_id][ - freq2, :], - stg.BS_stream_bed_pre_process_SNR[data_id][ - freq2, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - else: - self.axis_BS.pcolormesh( - stg.time_cross_section[data_id][ - freq2, :], - -stg.depth[data_id][ - freq2, :], - stg.BS_stream_bed_pre_process_SNR[data_id][ - freq2, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - else: - if stg.depth_cross_section[data_id].shape != (0,): - self.axis_BS.pcolormesh( - stg.time[data_id][ - freq2, :], - -stg.depth_cross_section[data_id][ - freq2, :], - stg.BS_stream_bed_pre_process_SNR[data_id][ - freq2, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - else: - self.axis_BS.pcolormesh( - stg.time[data_id][ - freq2, :], - -stg.depth[data_id][ - freq2, :], - stg.BS_stream_bed_pre_process_SNR[data_id][ - freq2, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - + BS_data = stg.BS_stream_bed_pre_process_SNR elif stg.BS_stream_bed[data_id].shape != (0,): - - val_min = np.nanmin( - stg.BS_stream_bed[data_id][freq2, - :, :]) - val_max = np.nanmax( - stg.BS_stream_bed[data_id][freq2, - :, :]) - if val_min == 0: - val_min = 1e-5 - - if stg.time_cross_section[data_id].shape != (0,): - if stg.depth_cross_section[data_id].shape != (0,): - self.axis_BS.pcolormesh( - stg.time_cross_section[data_id][ - freq2, :], - -stg.depth_cross_section[data_id][ - freq2, :], - stg.BS_stream_bed[data_id][freq2, - :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - else: - self.axis_BS.pcolormesh( - stg.time_cross_section[data_id][ - freq2, :], - -stg.depth[data_id][ - freq2, :], - stg.BS_stream_bed[data_id][freq2, - :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - - else: - if stg.depth_cross_section[data_id].shape != (0,): - self.axis_BS.pcolormesh( - stg.time[data_id][ - freq2, :], - -stg.depth_cross_section[data_id][ - freq2, :], - stg.BS_stream_bed[data_id][freq2, - :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - else: - self.axis_BS.pcolormesh( - stg.time[data_id][ - freq2, :], - -stg.depth[data_id][ - freq2, :], - stg.BS_stream_bed[data_id][freq2, - :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - + BS_data = stg.BS_stream_bed elif stg.BS_cross_section_pre_process_average[data_id].shape != (0,): - - val_min = np.nanmin( - stg.BS_cross_section_pre_process_average[data_id][ - freq2, :, :]) - val_max = np.nanmax( - stg.BS_cross_section_pre_process_average[data_id][ - freq2, :, :]) - if val_min == 0: - val_min = 1e-5 - - if stg.time_cross_section[data_id].shape != (0,): - if stg.depth_cross_section[data_id].shape != (0,): - self.axis_BS.pcolormesh( - stg.time_cross_section[data_id][ - freq2, :], - -stg.depth_cross_section[data_id][ - freq2, :], - stg.BS_cross_section_pre_process_average[data_id][ - freq2, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - else: - self.axis_BS.pcolormesh( - stg.time_cross_section[data_id][ - freq2, :], - -stg.depth[data_id][ - freq2, :], - stg.BS_cross_section_pre_process_average[data_id][ - freq2, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - else: - if stg.depth_cross_section[data_id].shape != (0,): - self.axis_BS.pcolormesh( - stg.time[data_id][ - freq2, :], - -stg.depth_cross_section[data_id][ - freq2, :], - stg.BS_cross_section_pre_process_average[data_id][ - freq2, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - else: - self.axis_BS.pcolormesh( - stg.time[data_id][ - freq2, :], - -stg.depth[data_id][ - freq2, :], - stg.BS_cross_section_pre_process_average[data_id][ - freq2, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - + BS_data = stg.BS_cross_section_pre_process_average elif stg.BS_cross_section_pre_process_SNR[data_id].shape != (0,): - - val_min = np.nanmin( - stg.BS_cross_section_pre_process_SNR[data_id][ - freq2, :, :]) - val_max = np.nanmax( - stg.BS_cross_section_pre_process_SNR[data_id][ - freq2, :, :]) - if val_min == 0: - val_min = 1e-5 - - if stg.time_cross_section[data_id].shape != (0,): - if stg.depth_cross_section[data_id].shape != (0): - self.axis_BS.pcolormesh( - stg.time_cross_section[data_id][ - freq2, :], - -stg.depth_cross_section[data_id][ - freq2, :], - stg.BS_cross_section_pre_process_SNR[data_id][ - freq2, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - else: - self.axis_BS.pcolormesh( - stg.time_cross_section[data_id][ - freq2, :], - -stg.depth[data_id][ - freq2, :], - stg.BS_cross_section_pre_process_SNR[data_id][ - freq2, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - else: - if stg.depth_cross_section[data_id].shape != (0): - self.axis_BS.pcolormesh( - stg.time[data_id][ - freq2, :], - -stg.depth_cross_section[data_id][ - freq2, :], - stg.BS_cross_section_pre_process_SNR[data_id][ - freq2, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - else: - self.axis_BS.pcolormesh( - stg.time[data_id][ - freq2, :], - -stg.depth[data_id][ - freq2, :], - stg.BS_cross_section_pre_process_SNR[data_id][ - freq2, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - - elif stg.BS_cross_section[data_id].shape != (0,): - - val_min = np.nanmin( - stg.BS_cross_section[data_id][ - freq2, :, :]) - val_max = np.nanmax( - stg.BS_cross_section[data_id][ - freq2, :, :]) - if val_min == 0: - val_min = 1e-5 - - if stg.time_cross_section[data_id].shape != (0,): - if stg.depth_cross_section[data_id].shape != (0,): - self.axis_BS.pcolormesh( - stg.time_cross_section[data_id][ - freq2, :], - -stg.depth_cross_section[data_id][ - freq2, :], - stg.BS_cross_section[data_id][ - freq2, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - else: - self.axis_BS.pcolormesh( - stg.time_cross_section[data_id][ - freq2, :], - -stg.depth[data_id][ - freq2, :], - stg.BS_cross_section[data_id][ - freq2, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - else: - if stg.depth_cross_section[data_id].shape != (0,): - self.axis_BS.pcolormesh( - stg.time[data_id][ - freq2, :], - -stg.depth_cross_section[data_id][ - freq2, :], - stg.BS_cross_section[data_id][ - freq2, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - else: - self.axis_BS.pcolormesh( - stg.time[data_id][ - freq2, :], - -stg.depth[data_id][ - freq2, :], - stg.BS_cross_section[data_id][ - freq2, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - - + BS_data = stg.BS_cross_section_pre_process_SNR elif stg.BS_raw_data_pre_process_average[data_id].shape != (0,): - - val_min = np.nanmin(stg.BS_raw_data_pre_process_average[data_id][ - freq2, :, :]) - val_max = np.nanmax(stg.BS_raw_data_pre_process_average[data_id][ - freq2, :, :]) - if val_min == 0: - val_min = 1e-5 - - self.axis_BS.pcolormesh( - stg.time[data_id][freq2, :], - -stg.depth[data_id][freq2, :], - stg.BS_raw_data_pre_process_average[data_id][ - freq2, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - - - + BS_data = stg.BS_raw_data_pre_process_average elif stg.BS_raw_data_pre_process_SNR[data_id].shape != (0,): - - val_min = np.nanmin(stg.BS_raw_data_pre_process_SNR[data_id][ - freq2, :, :]) - val_max = np.nanmax(stg.BS_raw_data_pre_process_SNR[data_id][ - freq2, :, :]) - if val_min == 0: - val_min = 1e-5 - - self.axis_BS.pcolormesh( - stg.time[data_id][freq2, :], - -stg.depth[data_id][freq2, :], - stg.BS_raw_data_pre_process_SNR[data_id][ - freq2, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - + BS_data = stg.BS_raw_data_pre_process_SNR elif stg.BS_raw_data[data_id].shape != (0,): + BS_data = stg.BS_raw_data - val_min = np.nanmin(stg.BS_raw_data[data_id][ - freq2, :, :]) - val_max = np.nanmax(stg.BS_raw_data[data_id][ - freq2, :, :]) - if val_min == 0: - val_min = 1e-5 + if stg.time_cross_section[data_id].shape != (0,): + time_data = stg.time_cross_section + else: + time_data = stg.time - self.axis_BS.pcolormesh( - stg.time[data_id][freq2, :], - -stg.depth[data_id][freq2, :], - stg.BS_raw_data[data_id][ - freq2, :, :], - cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) + if stg.depth_cross_section[data_id].shape != (0,): + depth_data = stg.depth_cross_section + else: + depth_date = stg.depth - # --- Plot samples --- + val_min = np.nanmin( + BS_data[data_id][freq2, :, :] + ) + val_max = np.nanmax( + BS_data[data_id][freq2, :, :] + ) + + if val_min == 0: + val_min = 1e-5 + + self.axis_BS.pcolormesh( + time_data[data_id][freq2, :], + -depth_data[data_id][freq2, :], + BS_data[data_id][freq2, :, :], + norm=LogNorm(vmin=val_min, vmax=val_max), + cmap='viridis' + ) + + self.plot_acoustic_recording_samples() + + def plot_acoustic_recording_samples(self): + data_id = self.combobox_acoustic_data_choice.currentIndex() + freq1 = self.combobox_freq1.currentIndex() + freq2 = self.combobox_freq2.currentIndex() if (stg.fine_sample_profile) or (stg.sand_sample_target): - - self.axis_BS.scatter([stg.time_fine[f[1]] for f in stg.fine_sample_profile], - [stg.depth_fine[f[1]] for f in stg.fine_sample_profile], - marker='o', s=20, facecolor="k", edgecolor="None") - self.axis_BS.scatter([stg.time_sand[s[1]] for s in stg.sand_sample_target], - [stg.depth_sand[s[1]] for s in stg.sand_sample_target], - marker='o', s=50, facecolor="None", edgecolor="k") + self.axis_BS.scatter( + [stg.time_fine[f[1]] for f in stg.fine_sample_profile], + [stg.depth_fine[f[1]] for f in stg.fine_sample_profile], + marker='o', s=20, facecolor="k", edgecolor="None" + ) + self.axis_BS.scatter( + [stg.time_sand[s[1]] for s in stg.sand_sample_target], + [stg.depth_sand[s[1]] for s in stg.sand_sample_target], + marker='o', s=50, facecolor="None", edgecolor="k" + ) for i in stg.fine_sample_profile: - self.axis_BS.text(stg.time_fine[i[1]] + 5, stg.depth_fine[i[1]] - .2, i[0], - fontstyle="normal", fontweight="light", fontsize=8) + self.axis_BS.text( + stg.time_fine[i[1]] + 5, stg.depth_fine[i[1]] - .2, i[0], + fontstyle="normal", fontweight="light", fontsize=8 + ) for j in stg.sand_sample_target: - self.axis_BS.text(stg.time_sand[j[1]] - 12, stg.depth_sand[j[1]] - .2, j[0], - fontstyle="normal", fontweight="light", fontsize=8) + self.axis_BS.text( + stg.time_sand[j[1]] - 12, stg.depth_sand[j[1]] - .2, j[0], + fontstyle="normal", fontweight="light", fontsize=8 + ) elif (stg.sample_fine) or (stg.sample_sand): - - self.axis_BS.scatter(stg.time_fine, stg.depth_fine, marker='o', s=20, facecolor="k", edgecolor="None") - self.axis_BS.scatter(stg.time_sand, stg.depth_sand, marker='o', s=50, facecolor="None", edgecolor="k") + self.axis_BS.scatter( + stg.time_fine, stg.depth_fine, + marker='o', s=20, facecolor="k", edgecolor="None" + ) + self.axis_BS.scatter( + stg.time_sand, stg.depth_sand, + marker='o', s=50, facecolor="None", edgecolor="k" + ) for i in stg.sample_fine: - self.axis_BS.text(stg.time_fine[i[1]] + 5, stg.depth_fine[i[1]] - .2, i[0], - fontstyle="normal", fontweight="light", fontsize=8) + self.axis_BS.text( + stg.time_fine[i[1]] + 5, stg.depth_fine[i[1]] - .2, i[0], + fontstyle="normal", fontweight="light", fontsize=8 + ) for j in stg.sample_sand: - self.axis_BS.text(stg.time_sand[j[1]] - 12, stg.depth_sand[j[1]] - .2, j[0], - fontstyle="normal", fontweight="light", fontsize=8) + self.axis_BS.text( + stg.time_sand[j[1]] - 12, stg.depth_sand[j[1]] - .2, j[0], + fontstyle="normal", fontweight="light", fontsize=8 + ) # --- Plot vertical red line for position of FCB profile --- if stg.sand_sample_target_indice: - if stg.depth_cross_section[data_id].shape != (0,): - - if stg.time_cross_section[data_id].shape != (0,): - - self.red_line_plot_return, = ( - self.axis_BS.plot( - stg.time_cross_section[data_id][ - freq2, stg.sand_sample_target_indice[0][1]] * - np.ones(stg.depth_cross_section[data_id].shape[1]), - -stg.depth_cross_section[data_id][ - freq2, :], - color='red', linestyle="solid", linewidth=2)) - - else: - - self.red_line_plot_return, = ( - self.axis_BS.plot( - stg.time[data_id][ - freq2, stg.sand_sample_target_indice[0][1]] * - np.ones(stg.depth_cross_section[data_id].shape[1]), - -stg.depth_cross_section[data_id][ - freq2, :], - color='red', linestyle="solid", linewidth=2)) - + depth_data = stg.depth_cross_section else: + depth_data = stg.depth - if stg.time_cross_section[data_id].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, = ( - self.axis_BS.plot( - stg.time_cross_section[data_id][ - freq2, stg.sand_sample_target_indice[0][1]] * - np.ones(stg.depth[data_id].shape[1]), - -stg.depth[data_id][freq2, :], - color='red', linestyle="solid", linewidth=2)) - - else: - - self.red_line_plot_return, = ( - self.axis_BS.plot( - stg.time[data_id][ - freq2, stg.sand_sample_target_indice[0][1]] * - np.ones(stg.depth[data_id].shape[1]), - -stg.depth[data_id][freq2, :], - color='red', linestyle="solid", linewidth=2)) + self.red_line_plot_return, = ( + self.axis_BS.plot( + time_data[data_id][ + freq2, stg.sand_sample_target_indice[0][1] + ] * np.ones(depth_data[data_id].shape[1]), + -depth_data[data_id][freq2, :], + color='red', linestyle="solid", linewidth=2 + ) + ) self.axis_BS.set_xlabel("Time (sec)") self.axis_BS.set_ylabel("Depth (m)")