diff --git a/Model/create_table_for_save_as.py b/Model/create_table_for_save_as.py index 5ec91a0..4f8a2b2 100644 --- a/Model/create_table_for_save_as.py +++ b/Model/create_table_for_save_as.py @@ -99,6 +99,7 @@ class CreateTableForSaveAs: ID INTEGER PRIMARY KEY AUTOINCREMENT, acoustic_data INTEGER, temperature FLOAT, + distance_to_free_surface FLOAT, tmin_index FLOAT, tmin_value FLOAT, tmax_index FLOAT, tmax_value FLOAT, rmin_index FLOAT, rmin_value FLOAT, @@ -312,11 +313,9 @@ class CreateTableForSaveAs: VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) """, ( - stg.acoustic_data[i], #stg.date[i], stg.hour[i], - str(stg.date[i].year) + str('-') - + str(stg.date[i].month) + str('-') - + str(stg.date[i].day), - str(stg.hour[i].hour) + str(':') + str(stg.hour[i].minute), + stg.acoustic_data[i], + stg.date[i].isoformat(), + stg.hour[i].isoformat(), stg.freq[i][j], stg.water_attenuation[i][j], stg.kt_read[j], stg.kt_corrected[j], @@ -410,16 +409,17 @@ class CreateTableForSaveAs: cur.execute( """ INSERT into Settings( - acoustic_data, temperature, + acoustic_data, temperature, distance_to_free_surface, tmin_index, tmin_value, tmax_index, tmax_value, rmin_index, rmin_value, rmax_index, rmax_value, freq_bottom_detection_index, freq_bottom_detection_value, SNR_filter_value, Nb_cells_to_average_BS_signal ) - VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) """, ( stg.acoustic_data[i], stg.temperature, + stg.distance_from_ABS_to_free_surface[i], stg.tmin[i][0], stg.tmin[i][1], stg.tmax[i][0], stg.tmax[i][1], stg.rmin[i][0], stg.rmin[i][1], @@ -543,7 +543,8 @@ class CreateTableForSaveAs: np.array(stg.X_exponent).tobytes(), np.array(stg.alpha_s).tobytes(), np.array(stg.zeta).tobytes(), - stg.FCB.tobytes(), stg.depth_real.tobytes(), + np.array(stg.FCB).tobytes(), + np.array(stg.depth_real).tobytes(), np.array(stg.lin_reg).tobytes() ) ) diff --git a/Model/read_table_for_open.py b/Model/read_table_for_open.py index 3516131..1364332 100644 --- a/Model/read_table_for_open.py +++ b/Model/read_table_for_open.py @@ -26,6 +26,8 @@ import sqlite3 import logging import numpy as np +from datetime import date, time + from PyQt5.QtWidgets import QFileDialog, QApplication, QWidget, QTabWidget import settings as stg @@ -33,6 +35,7 @@ from settings import BS_raw_data, acoustic_data from View.acoustic_data_tab import AcousticDataTab +from tools import trace logger = logging.getLogger("acoused") @@ -81,6 +84,7 @@ class ReadTableForOpen: self.read_table_settings() self.read_table_sediment_file() self.read_table_table_sediment_data() + self.read_table_table_calibration() logger.debug(f"Reading '{stg.filename_open}' done") @@ -113,6 +117,7 @@ class ReadTableForOpen: stg.filename_BS_raw_data.append( str(data[1]) + '.aqa' ) + stg.path_BS_raw_data.append("") stg.ABS_name.append(data[2]) stg.path_BS_noise_data.append(data[3]) stg.filename_BS_noise_data.append(data[4]) @@ -134,7 +139,7 @@ class ReadTableForOpen: stg.hour = [0]*len(stg.acoustic_data) for i in range(len(stg.acoustic_data)): - query1 = f''' + query = f''' SELECT acoustic_data, Date, Hour, frequency, sound_attenuation, kt_read, kt_corrected, NbProfiles, @@ -144,38 +149,38 @@ class ReadTableForOpen: FROM Measure WHERE (acoustic_data = {i}) ''' - data1 = self.execute(query1) + data = self.execute(query) - logger.debug(f"data1 for {i}: {data1}") + logger.debug(f"data for {i}: {data}") - stg.date[i] = data1[0][1] - stg.hour[i] = data1[0][2] + stg.date[i] = date.fromisoformat(data[0][1]) + stg.hour[i] = time.fromisoformat(data[0][2]) stg.freq.append( - np.array([x[3] for x in data1]) + np.array([x[3] for x in data]) ) stg.freq_text.append( - [str(x[3]*1e-6) + 'MHz' for x in data1] + [str(x[3]*1e-6) + 'MHz' for x in data] ) stg.water_attenuation.append( - [x[4] for x in data1] + [x[4] for x in data] ) - stg.kt_read = [x[5] for x in data1] - stg.kt_corrected = [x[6] for x in data1] + stg.kt_read = [x[5] for x in data] + stg.kt_corrected = [x[6] for x in data] - stg.nb_profiles.append([x[7] for x in data1]) - stg.nb_profiles_per_sec.append([x[8] for x in data1]) - stg.nb_cells.append([x[9] for x in data1]) - stg.cell_size.append([x[10] for x in data1]) - stg.pulse_length.append([x[11] for x in data1]) + stg.nb_profiles.append([x[7] for x in data]) + stg.nb_profiles_per_sec.append([x[8] for x in data]) + stg.nb_cells.append([x[9] for x in data]) + stg.cell_size.append([x[10] for x in data]) + stg.pulse_length.append([x[11] for x in data]) stg.nb_pings_per_sec.append( - [x[12] for x in data1] + [x[12] for x in data] ) stg.nb_pings_averaged_per_profile.append( - [x[13] for x in data1] + [x[13] for x in data] ) - stg.gain_rx.append([x[14] for x in data1]) - stg.gain_tx.append([x[15] for x in data1]) + stg.gain_rx.append([x[14] for x in data]) + stg.gain_tx.append([x[15] for x in data]) logger.debug("measure:") logger.debug(f"- stg.acoustic_data: {stg.acoustic_data}") @@ -477,7 +482,7 @@ class ReadTableForOpen: for s in range(len(stg.acoustic_data)): query3 = f''' SELECT - acoustic_data, temperature, + acoustic_data, temperature, distance_to_free_surface, tmin_index, tmin_value, tmax_index, tmax_value, rmin_index, rmin_value, rmax_index, rmax_value, freq_bottom_detection_index, freq_bottom_detection_value, @@ -490,13 +495,14 @@ class ReadTableForOpen: x = data[0] stg.temperature = [x[1]][0] - stg.tmin.append((x[2], x[3])) - stg.tmax.append((x[4], x[5])) - stg.rmin.append((x[6], x[7])) - stg.rmax.append((x[8], x[9])) - stg.freq_bottom_detection.append((x[10], x[11])) - stg.SNR_filter_value.append(x[12]) - stg.Nb_cells_to_average_BS_signal.append(x[13]) + stg.distance_from_ABS_to_free_surface.append(x[2]) + stg.tmin.append((x[3], x[4])) + stg.tmax.append((x[5], x[6])) + stg.rmin.append((x[7], x[8])) + stg.rmax.append((x[9], x[10])) + stg.freq_bottom_detection.append((x[11], x[12])) + stg.SNR_filter_value.append(x[13]) + stg.Nb_cells_to_average_BS_signal.append(x[14]) logger.debug(f"stg.temperature: {stg.temperature}") logger.debug(f"stg.tmin: {stg.tmin}") @@ -536,6 +542,7 @@ class ReadTableForOpen: + list(stg.radius_grain_sand) ) + @trace def read_table_table_sediment_data(self): np_f64_parse = lambda d: np.frombuffer(d, dtype=np.float64) @@ -558,32 +565,32 @@ class ReadTableForOpen: stg.frac_vol_sand = [] stg.frac_vol_sand_cumul = [] - for f in range(len(data)): - stg.sample_fine.append((data[f][0], data[f][1])) - stg.distance_from_bank_fine.append(data[f][2]) - stg.depth_fine.append(data[f][3]) - stg.time_fine.append(data[f][4]) - stg.Ctot_fine.append(data[f][5]) - stg.Ctot_fine_per_cent.append(data[f][6]) - stg.D50_fine.append(data[f][7]) + for d in data: + stg.sample_fine.append((d[0], d[1])) + stg.distance_from_bank_fine.append(d[2]) + stg.depth_fine.append(d[3]) + stg.time_fine.append(d[4]) + stg.Ctot_fine.append(d[5]) + stg.Ctot_fine_per_cent.append(d[6]) + stg.D50_fine.append(d[7]) stg.frac_vol_fine.append( - np_f64_parse(data[f][8]) + np_f64_parse(d[8]) ) stg.frac_vol_fine_cumul.append( - np_f64_parse(data[f][9]) + np_f64_parse(d[9]) ) - stg.sample_sand.append((data[f][10], data[f][11])) - stg.distance_from_bank_sand.append(data[f][12]) - stg.depth_sand.append(data[f][13]) - stg.time_sand.append(data[f][14]) - stg.Ctot_sand.append(data[f][15]) - stg.Ctot_sand_per_cent.append(data[f][16]) - stg.D50_sand.append(data[f][17]) + stg.sample_sand.append((d[10], d[11])) + stg.distance_from_bank_sand.append(d[12]) + stg.depth_sand.append(d[13]) + stg.time_sand.append(d[14]) + stg.Ctot_sand.append(d[15]) + stg.Ctot_sand_per_cent.append(d[16]) + stg.D50_sand.append(d[17]) stg.frac_vol_sand.append( - np_f64_parse(data[f][18]) + np_f64_parse(d[18]) ) stg.frac_vol_sand_cumul.append( - np_f64_parse(data[f][19]) + np_f64_parse(d[19]) ) stg.frac_vol_fine = np.array(stg.frac_vol_fine) @@ -592,3 +599,36 @@ class ReadTableForOpen: stg.frac_vol_sand_cumul = np.array(stg.frac_vol_sand_cumul) logger.debug(f"fine: {stg.Ctot_fine}, sand: {stg.sample_sand}") + + @trace + def read_table_table_calibration(self): + np_f64_parse = lambda d: np.frombuffer(d, dtype=np.float64) + + query = f''' + SELECT + path_calibration_file, + filename_calibration_file, + range_lin_interp, + M_profile_fine, + ks, sv, + X_exponent, + alpha_s, zeta, FCB, + depth_real, lin_reg + FROM Calibration + ''' + + data = self.execute(query) + it = iter(data[0]) + + stg.path_calibration_file = next(it) + stg.filename_calibration_file = next(it) + stg.range_lin_interp = np_f64_parse(next(it)) + stg.M_profile_fine = np_f64_parse(next(it)) + stg.ks = np_f64_parse(next(it)) + stg.sv = np_f64_parse(next(it)) + stg.X_exponent = np_f64_parse(next(it)) + stg.alpha_s = np_f64_parse(next(it)) + stg.zeta = np_f64_parse(next(it)) + stg.FCB = np_f64_parse(next(it)) + stg.depth_real = np_f64_parse(next(it)) + stg.lin_reg = np_f64_parse(next(it)) diff --git a/Model/update_table_for_save.py b/Model/update_table_for_save.py index c7f80e6..7382f1b 100644 --- a/Model/update_table_for_save.py +++ b/Model/update_table_for_save.py @@ -147,15 +147,8 @@ class UpdateTableForSave: ) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''', ( stg.acoustic_data[i], - ( - str(stg.date[i].year) + str('-') + - str(stg.date[i].month) + str('-') + - str(stg.date[i].day) - ), - ( - str(stg.hour[i].hour) + str(':') + - str(stg.hour[i].minute) - ), + stg.date[i].isoformat(), + stg.hour[i].isoformat(), stg.freq[i][j], stg.water_attenuation[i][j], stg.kt_read[j], @@ -214,21 +207,29 @@ class UpdateTableForSave: BS_mean) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''', (stg.acoustic_data[i], stg.time[i].tobytes(), stg.depth[i].tobytes(), stg.BS_raw_data[i].tobytes(), - stg.time_reshape[i].tobytes(), stg.depth_reshape[i].tobytes(), stg.BS_raw_data_reshape[i].tobytes(), - stg.time_cross_section[i].tobytes(), stg.depth_cross_section[i].tobytes(), stg.BS_cross_section[i].tobytes(), - stg.BS_stream_bed[i].tobytes(), - stg.depth_bottom[i].tobytes(), stg.val_bottom[i].tobytes(), np.array(stg.ind_bottom[i]).tobytes(), - stg.time_noise[i].tobytes(), stg.depth_noise[i].tobytes(), - stg.BS_noise_raw_data[i].tobytes(), - stg.SNR_raw_data[i].tobytes(), stg.SNR_cross_section[i].tobytes(), - stg.SNR_stream_bed[i].tobytes(), - stg.BS_raw_data_pre_process_SNR[i].tobytes(), - stg.BS_raw_data_pre_process_average[i].tobytes(), - stg.BS_cross_section_pre_process_SNR[i].tobytes(), - stg.BS_cross_section_pre_process_average[i].tobytes(), - stg.BS_stream_bed_pre_process_SNR[i].tobytes(), - stg.BS_stream_bed_pre_process_average[i].tobytes(), - stg.BS_mean[i].tobytes() + stg.time_reshape[i].tobytes(), + stg.depth_reshape[i].tobytes(), + stg.BS_raw_data_reshape[i].tobytes(), + stg.time_cross_section[i].tobytes(), + stg.depth_cross_section[i].tobytes(), + stg.BS_cross_section[i].tobytes(), + np.array(stg.BS_stream_bed[i]).tobytes(), + np.array(stg.depth_bottom[i]).tobytes(), + np.array(stg.val_bottom[i]).tobytes(), + np.array(stg.ind_bottom[i]).tobytes(), + np.array(stg.time_noise[i]).tobytes(), + np.array(stg.depth_noise[i]).tobytes(), + np.array(stg.BS_noise_raw_data[i]).tobytes(), + np.array(stg.SNR_raw_data[i]).tobytes(), + np.array(stg.SNR_cross_section[i]).tobytes(), + np.array(stg.SNR_stream_bed[i]).tobytes(), + np.array(stg.BS_raw_data_pre_process_SNR[i]).tobytes(), + np.array(stg.BS_raw_data_pre_process_average[i]).tobytes(), + np.array(stg.BS_cross_section_pre_process_SNR[i]).tobytes(), + np.array(stg.BS_cross_section_pre_process_average[i]).tobytes(), + np.array(stg.BS_stream_bed_pre_process_SNR[i]).tobytes(), + np.array(stg.BS_stream_bed_pre_process_average[i]).tobytes(), + np.array(stg.BS_mean[i]).tobytes() ) ) @@ -245,29 +246,48 @@ class UpdateTableForSave: cur.execute(''' DROP TABLE Settings''') - cur.execute('''CREATE TABLE Settings(ID INTEGER PRIMARY KEY AUTOINCREMENT, - acoustic_data INTEGER, - temperature FLOAT, - tmin_index FLOAT, tmin_value FLOAT, tmax_index FLOAT, tmax_value FLOAT, - rmin_index FLOAT, rmin_value FLOAT, rmax_index FLOAT, rmax_value FLOAT, - freq_bottom_detection_index FLOAT, freq_bottom_detection_value STRING, - SNR_filter_value FLOAT, Nb_cells_to_average_BS_signal FLOAT - )''' + cur.execute(''' + CREATE TABLE Settings( + ID INTEGER PRIMARY KEY AUTOINCREMENT, + acoustic_data INTEGER, + temperature FLOAT, + distance_to_free_surface FLOAT, + tmin_index FLOAT, tmin_value FLOAT, + tmax_index FLOAT, tmax_value FLOAT, + rmin_index FLOAT, rmin_value FLOAT, + rmax_index FLOAT, rmax_value FLOAT, + freq_bottom_detection_index FLOAT, + freq_bottom_detection_value STRING, + SNR_filter_value FLOAT, + Nb_cells_to_average_BS_signal FLOAT + ) + ''' ) for i in stg.acoustic_data: - cur.execute('''INSERT into Settings(acoustic_data, temperature, - tmin_index, tmin_value, tmax_index, tmax_value, - rmin_index, rmin_value, rmax_index, rmax_value, - freq_bottom_detection_index, freq_bottom_detection_value, - SNR_filter_value, Nb_cells_to_average_BS_signal) - VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''', - (stg.acoustic_data[i], stg.temperature, - stg.tmin[i][0], stg.tmin[i][1], stg.tmax[i][0], stg.tmax[i][1], - stg.rmin[i][0], stg.rmin[i][1], stg.rmax[i][0], stg.rmax[i][1], - stg.freq_bottom_detection[i][0], stg.freq_bottom_detection[i][1], - stg.SNR_filter_value[i], stg.Nb_cells_to_average_BS_signal[i]) + cur.execute(''' + INSERT into Settings( + acoustic_data, temperature, + distance_to_free_surface, + tmin_index, tmin_value, tmax_index, tmax_value, + rmin_index, rmin_value, rmax_index, rmax_value, + freq_bottom_detection_index, freq_bottom_detection_value, + SNR_filter_value, Nb_cells_to_average_BS_signal + ) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + ''', + ( + stg.acoustic_data[i], stg.temperature, + stg.distance_from_ABS_to_free_surface[i], + stg.tmin[i][0], stg.tmin[i][1], + stg.tmax[i][0], stg.tmax[i][1], + stg.rmin[i][0], stg.rmin[i][1], + stg.rmax[i][0], stg.rmax[i][1], + stg.freq_bottom_detection[i][0], + stg.freq_bottom_detection[i][1], + stg.SNR_filter_value[i], + stg.Nb_cells_to_average_BS_signal[i] ) + ) cnx.commit() diff --git a/View/acoustic_data_tab.py b/View/acoustic_data_tab.py index 0620ea6..83a8c7b 100644 --- a/View/acoustic_data_tab.py +++ b/View/acoustic_data_tab.py @@ -59,6 +59,7 @@ from Model.acoustic_data_loader import AcousticDataLoader from Model.acoustic_data_loader_UBSediFlow import AcousticDataLoaderUBSediFlow from Model.calibration_constant_kt import CalibrationConstantKt +from tools import trace locale.setlocale(locale.LC_ALL, '') @@ -733,6 +734,7 @@ class AcousticDataTab(QWidget): # -------------------- Functions for Acoustic dataTab -------------------- + @trace def full_update(self): logger.debug(f"{__name__}: Update") self.blockSignals(True) @@ -842,7 +844,6 @@ class AcousticDataTab(QWidget): self.groupbox_measurement_information_UBSediFlow() def groupbox_measurement_information_no_ABS(self): - self.label_ABS_name.hide() self.combobox_ABS_name.hide() @@ -1190,15 +1191,22 @@ class AcousticDataTab(QWidget): self.lineEdit_distance_from_ABS_to_free_surface.setText("0.00") else: - stg.distance_from_ABS_to_free_surface[self.fileListWidget\ - .currentRow()] = ( + stg.distance_from_ABS_to_free_surface[ + self.fileListWidget.currentRow() + ] = ( float( self.lineEdit_distance_from_ABS_to_free_surface\ .text().replace(",", ".") ) ) + self.lineEdit_distance_from_ABS_to_free_surface.setText( - str("%4s" % stg.distance_from_ABS_to_free_surface[self.fileListWidget.currentRow()])) + str( + "%4s" % stg.distance_from_ABS_to_free_surface[ + self.fileListWidget.currentRow() + ] + ) + ) def refresh_distance_from_ABS_to_free_surface(self): self.pushbutton_distance_from_ABS_to_free_surface.blockSignals(True) @@ -1777,6 +1785,10 @@ class AcousticDataTab(QWidget): .currentIndexChanged\ .connect(self.combobox_frequency_information_update) + self.lineEdit_distance_from_ABS_to_free_surface.setText( + str(stg.distance_from_ABS_to_free_surface[file_id]) + ) + logger.debug(f"Set temperature = {stg.temperature}") self.lineEdit_temperature.setText(str(stg.temperature)) diff --git a/View/acoustic_inversion_tab.py b/View/acoustic_inversion_tab.py index b898c21..b2e0032 100644 --- a/View/acoustic_inversion_tab.py +++ b/View/acoustic_inversion_tab.py @@ -48,6 +48,7 @@ from View.checkable_combobox import CheckableComboBox import settings as stg from Model.acoustic_inversion_method_high_concentration import AcousticInversionMethodHighConcentration +from tools import trace _translate = QCoreApplication.translate @@ -371,6 +372,7 @@ class AcousticInversionTab(QWidget): # ------------------------------------ Functions for Acoustic Inversion Tab ---------------------------------------- # ================================================================================================================== + @trace def full_update(self): logger.debug(f"{__name__}: Update") self.blockSignals(True) diff --git a/View/note_tab.py b/View/note_tab.py index a5bf496..d8b7274 100644 --- a/View/note_tab.py +++ b/View/note_tab.py @@ -10,6 +10,8 @@ from PyQt5.QtCore import Qt import settings as stg +from tools import trace + logger = logging.getLogger("acoused") class NoteTab(QWidget): @@ -136,7 +138,7 @@ class NoteTab(QWidget): ## ---------- Functions ---------- ## ------------------------------- - + @trace def full_update(self): logger.debug(f"{__name__}: Update") self.blockSignals(True) diff --git a/View/sample_data_tab.py b/View/sample_data_tab.py index dd9f673..f9e4b96 100644 --- a/View/sample_data_tab.py +++ b/View/sample_data_tab.py @@ -49,6 +49,8 @@ import Translation.constant_string as cs import settings as stg +from tools import trace + _translate = QCoreApplication.translate logger = logging.getLogger("acoused") @@ -278,6 +280,7 @@ class SampleDataTab(QWidget): self.groupbox_plot_PSD.setTitle(_translate("CONSTANT_STRING", cs.DISTRIBUTION_PLOT)) + @trace def full_update(self): logger.debug(f"{__name__}: Update") self.blockSignals(True) @@ -475,7 +478,8 @@ class SampleDataTab(QWidget): self.item_checkbox_fine.setCheckState(Qt.Checked) self.tableWidget_fine.setItem(i, 1, self.item_checkbox_fine) self.item_checkbox_fine.setText("F" + str(i + 1)) - stg.sample_fine.append(("F" + str(i + 1), i)) + if len(stg.sample_fine) <= i: + stg.sample_fine.append(("F" + str(i + 1), i)) # --- Fill table with data --- for i in range(stg.frac_vol_fine.shape[0]): @@ -570,7 +574,8 @@ class SampleDataTab(QWidget): self.item_checkbox_sand.setCheckState(Qt.Checked) self.tableWidget_sand.setItem(i, 1, self.item_checkbox_sand) self.item_checkbox_sand.setText("S" + str(i + 1)) - stg.sample_sand.append(("S" + str(i + 1), i)) + if len(stg.sample_sand) <= i: + stg.sample_sand.append(("S" + str(i + 1), i)) # --- Fill table with data --- for i in range(stg.frac_vol_sand.shape[0]): diff --git a/View/sediment_calibration_tab.py b/View/sediment_calibration_tab.py index 7d4c8ea..2d7563a 100644 --- a/View/sediment_calibration_tab.py +++ b/View/sediment_calibration_tab.py @@ -48,6 +48,8 @@ import settings as stg from View.checkable_combobox import CheckableComboBox from Model.acoustic_inversion_method_high_concentration import AcousticInversionMethodHighConcentration +from tools import trace + logger = logging.getLogger("acoused") class SedimentCalibrationTab(QWidget): @@ -857,6 +859,7 @@ class SedimentCalibrationTab(QWidget): # ----------------------------------- Functions for Signal processing Tab -------------------------------------- # ============================================================================================================== + @trace def full_update(self): logger.debug(f"{__name__}: Update") self.blockSignals(True) @@ -873,7 +876,7 @@ class SedimentCalibrationTab(QWidget): return self.update_acoustic_data() - # self.compute_depth_2D() + self.compute_depth_2D() def update_acoustic_data(self): self.combobox_acoustic_data_choice.clear() @@ -931,11 +934,13 @@ class SedimentCalibrationTab(QWidget): self.compute_FCB() def plot_acoustic_recording(self): + data_id = self.combobox_acoustic_data_choice.currentIndex() + # --- Record frequencies for calibration --- stg.frequencies_for_calibration.clear() stg.frequencies_for_calibration.append( ( - stg.freq[self.combobox_acoustic_data_choice.currentIndex()][ + stg.freq[data_id][ self.combobox_freq1.currentIndex() ], self.combobox_freq1.currentIndex() @@ -943,7 +948,7 @@ class SedimentCalibrationTab(QWidget): ) stg.frequencies_for_calibration.append( ( - stg.freq[self.combobox_acoustic_data_choice.currentIndex()][ + stg.freq[data_id][ self.combobox_freq2.currentIndex() ], self.combobox_freq2.currentIndex() @@ -952,7 +957,7 @@ class SedimentCalibrationTab(QWidget): stg.frequency_for_inversion = tuple() stg.frequency_for_inversion = ( - stg.freq[self.combobox_acoustic_data_choice.currentIndex()][ + stg.freq[data_id][ self.combobox_freq2.currentIndex() ], self.combobox_freq2.currentIndex() @@ -970,18 +975,18 @@ class SedimentCalibrationTab(QWidget): self.verticalLayout_groupbox_data_plot.addWidget(self.canvas_BS) if stg.BS_stream_bed_pre_process_average[ - self.combobox_acoustic_data_choice.currentIndex() + data_id ].shape != (0,): val_min = np.nanmin( stg.BS_stream_bed_pre_process_average[ - self.combobox_acoustic_data_choice.currentIndex() + data_id ][ self.combobox_freq2.currentIndex(), :, : ] ) val_max = np.nanmax( stg.BS_stream_bed_pre_process_average[ - self.combobox_acoustic_data_choice.currentIndex() + data_id ][ self.combobox_freq2.currentIndex(), :, : ] @@ -989,346 +994,346 @@ class SedimentCalibrationTab(QWidget): if val_min == 0: val_min = 1e-5 - if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + 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[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], - -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + -stg.depth_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], - stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_stream_bed_pre_process_average[data_id][ self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) else: self.axis_BS.pcolormesh( - stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], - -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + -stg.depth[data_id][ self.combobox_freq2.currentIndex(), :], - stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_stream_bed_pre_process_average[data_id][ self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) else: - if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + if stg.depth_cross_section[data_id].shape != (0,): self.axis_BS.pcolormesh( - stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time[data_id][ self.combobox_freq2.currentIndex(), :], - -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + -stg.depth_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], - stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_stream_bed_pre_process_average[data_id][ self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) else: self.axis_BS.pcolormesh( - stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time[data_id][ self.combobox_freq2.currentIndex(), :], - -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + -stg.depth[data_id][ self.combobox_freq2.currentIndex(), :], - stg.BS_stream_bed_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_stream_bed_pre_process_average[data_id][ self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + elif stg.BS_stream_bed_pre_process_SNR[data_id].shape != (0,): val_min = np.nanmin( - stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_stream_bed_pre_process_SNR[data_id][ self.combobox_freq2.currentIndex(), :, :]) val_max = np.nanmax( - stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_stream_bed_pre_process_SNR[data_id][ self.combobox_freq2.currentIndex(), :, :]) if val_min == 0: val_min = 1e-5 - if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + 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[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], - -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + -stg.depth_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], - stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_stream_bed_pre_process_SNR[data_id][ self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) else: self.axis_BS.pcolormesh( - stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], - -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + -stg.depth[data_id][ self.combobox_freq2.currentIndex(), :], - stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_stream_bed_pre_process_SNR[data_id][ self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) else: - if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + if stg.depth_cross_section[data_id].shape != (0,): self.axis_BS.pcolormesh( - stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time[data_id][ self.combobox_freq2.currentIndex(), :], - -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + -stg.depth_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], - stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_stream_bed_pre_process_SNR[data_id][ self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) else: self.axis_BS.pcolormesh( - stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time[data_id][ self.combobox_freq2.currentIndex(), :], - -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + -stg.depth[data_id][ self.combobox_freq2.currentIndex(), :], - stg.BS_stream_bed_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_stream_bed_pre_process_SNR[data_id][ self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + elif stg.BS_stream_bed[data_id].shape != (0,): val_min = np.nanmin( - stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex(), + stg.BS_stream_bed[data_id][self.combobox_freq2.currentIndex(), :, :]) val_max = np.nanmax( - stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex(), + stg.BS_stream_bed[data_id][self.combobox_freq2.currentIndex(), :, :]) if val_min == 0: val_min = 1e-5 - if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + 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[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], - -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + -stg.depth_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], - stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex(), + stg.BS_stream_bed[data_id][self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) else: self.axis_BS.pcolormesh( - stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], - -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + -stg.depth[data_id][ self.combobox_freq2.currentIndex(), :], - stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex(), + stg.BS_stream_bed[data_id][self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) else: - if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + if stg.depth_cross_section[data_id].shape != (0,): self.axis_BS.pcolormesh( - stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time[data_id][ self.combobox_freq2.currentIndex(), :], - -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + -stg.depth_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], - stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex(), + stg.BS_stream_bed[data_id][self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) else: self.axis_BS.pcolormesh( - stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time[data_id][ self.combobox_freq2.currentIndex(), :], - -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + -stg.depth[data_id][ self.combobox_freq2.currentIndex(), :], - stg.BS_stream_bed[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex(), + stg.BS_stream_bed[data_id][self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + elif stg.BS_cross_section_pre_process_average[data_id].shape != (0,): val_min = np.nanmin( - stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_cross_section_pre_process_average[data_id][ self.combobox_freq2.currentIndex(), :, :]) val_max = np.nanmax( - stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_cross_section_pre_process_average[data_id][ self.combobox_freq2.currentIndex(), :, :]) if val_min == 0: val_min = 1e-5 - if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + 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[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], - -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + -stg.depth_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], - stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_cross_section_pre_process_average[data_id][ self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) else: self.axis_BS.pcolormesh( - stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], - -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + -stg.depth[data_id][ self.combobox_freq2.currentIndex(), :], - stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_cross_section_pre_process_average[data_id][ self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) else: - if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + if stg.depth_cross_section[data_id].shape != (0,): self.axis_BS.pcolormesh( - stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time[data_id][ self.combobox_freq2.currentIndex(), :], - -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + -stg.depth_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], - stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_cross_section_pre_process_average[data_id][ self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) else: self.axis_BS.pcolormesh( - stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time[data_id][ self.combobox_freq2.currentIndex(), :], - -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + -stg.depth[data_id][ self.combobox_freq2.currentIndex(), :], - stg.BS_cross_section_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_cross_section_pre_process_average[data_id][ self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + elif stg.BS_cross_section_pre_process_SNR[data_id].shape != (0,): val_min = np.nanmin( - stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_cross_section_pre_process_SNR[data_id][ self.combobox_freq2.currentIndex(), :, :]) val_max = np.nanmax( - stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_cross_section_pre_process_SNR[data_id][ self.combobox_freq2.currentIndex(), :, :]) if val_min == 0: val_min = 1e-5 - if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0): + 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[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], - -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + -stg.depth_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], - stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_cross_section_pre_process_SNR[data_id][ self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) else: self.axis_BS.pcolormesh( - stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], - -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + -stg.depth[data_id][ self.combobox_freq2.currentIndex(), :], - stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_cross_section_pre_process_SNR[data_id][ self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) else: - if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0): + if stg.depth_cross_section[data_id].shape != (0): self.axis_BS.pcolormesh( - stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time[data_id][ self.combobox_freq2.currentIndex(), :], - -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + -stg.depth_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], - stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_cross_section_pre_process_SNR[data_id][ self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) else: self.axis_BS.pcolormesh( - stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time[data_id][ self.combobox_freq2.currentIndex(), :], - -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + -stg.depth[data_id][ self.combobox_freq2.currentIndex(), :], - stg.BS_cross_section_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_cross_section_pre_process_SNR[data_id][ self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + elif stg.BS_cross_section[data_id].shape != (0,): val_min = np.nanmin( - stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_cross_section[data_id][ self.combobox_freq2.currentIndex(), :, :]) val_max = np.nanmax( - stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_cross_section[data_id][ self.combobox_freq2.currentIndex(), :, :]) if val_min == 0: val_min = 1e-5 - if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + 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[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], - -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + -stg.depth_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], - stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_cross_section[data_id][ self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) else: self.axis_BS.pcolormesh( - stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], - -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + -stg.depth[data_id][ self.combobox_freq2.currentIndex(), :], - stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_cross_section[data_id][ self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) else: - if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + if stg.depth_cross_section[data_id].shape != (0,): self.axis_BS.pcolormesh( - stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time[data_id][ self.combobox_freq2.currentIndex(), :], - -stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + -stg.depth_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], - stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_cross_section[data_id][ self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) else: self.axis_BS.pcolormesh( - stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time[data_id][ self.combobox_freq2.currentIndex(), :], - -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + -stg.depth[data_id][ self.combobox_freq2.currentIndex(), :], - stg.BS_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.BS_cross_section[data_id][ self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + elif stg.BS_raw_data_pre_process_average[data_id].shape != (0,): - val_min = np.nanmin(stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][ + val_min = np.nanmin(stg.BS_raw_data_pre_process_average[data_id][ self.combobox_freq2.currentIndex(), :, :]) - val_max = np.nanmax(stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][ + val_max = np.nanmax(stg.BS_raw_data_pre_process_average[data_id][ self.combobox_freq2.currentIndex(), :, :]) if val_min == 0: val_min = 1e-5 self.axis_BS.pcolormesh( - stg.time[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex(), :], - -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex(), :], - stg.BS_raw_data_pre_process_average[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time[data_id][self.combobox_freq2.currentIndex(), :], + -stg.depth[data_id][self.combobox_freq2.currentIndex(), :], + stg.BS_raw_data_pre_process_average[data_id][ self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + elif stg.BS_raw_data_pre_process_SNR[data_id].shape != (0,): - val_min = np.nanmin(stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][ + val_min = np.nanmin(stg.BS_raw_data_pre_process_SNR[data_id][ self.combobox_freq2.currentIndex(), :, :]) - val_max = np.nanmax(stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][ + val_max = np.nanmax(stg.BS_raw_data_pre_process_SNR[data_id][ self.combobox_freq2.currentIndex(), :, :]) if val_min == 0: val_min = 1e-5 self.axis_BS.pcolormesh( - stg.time[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex(), :], - -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex(), :], - stg.BS_raw_data_pre_process_SNR[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time[data_id][self.combobox_freq2.currentIndex(), :], + -stg.depth[data_id][self.combobox_freq2.currentIndex(), :], + stg.BS_raw_data_pre_process_SNR[data_id][ self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) - elif stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + elif stg.BS_raw_data[data_id].shape != (0,): - val_min = np.nanmin(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][ + val_min = np.nanmin(stg.BS_raw_data[data_id][ self.combobox_freq2.currentIndex(), :, :]) - val_max = np.nanmax(stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][ + val_max = np.nanmax(stg.BS_raw_data[data_id][ self.combobox_freq2.currentIndex(), :, :]) if val_min == 0: val_min = 1e-5 self.axis_BS.pcolormesh( - stg.time[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex(), :], - -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][self.combobox_freq2.currentIndex(), :], - stg.BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time[data_id][self.combobox_freq2.currentIndex(), :], + -stg.depth[data_id][self.combobox_freq2.currentIndex(), :], + stg.BS_raw_data[data_id][ self.combobox_freq2.currentIndex(), :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) @@ -1367,16 +1372,16 @@ class SedimentCalibrationTab(QWidget): # --- Plot vertical red line for position of FCB profile --- if stg.sand_sample_target_indice: - if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + if stg.depth_cross_section[data_id].shape != (0,): - if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + if stg.time_cross_section[data_id].shape != (0,): self.red_line_plot_return, = ( self.axis_BS.plot( - stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time_cross_section[data_id][ self.combobox_freq2.currentIndex(), stg.sand_sample_target_indice[0][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()][ + np.ones(stg.depth_cross_section[data_id].shape[1]), + -stg.depth_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], color='red', linestyle="solid", linewidth=2)) @@ -1384,23 +1389,23 @@ class SedimentCalibrationTab(QWidget): self.red_line_plot_return, = ( self.axis_BS.plot( - stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time[data_id][ self.combobox_freq2.currentIndex(), stg.sand_sample_target_indice[0][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()][ + np.ones(stg.depth_cross_section[data_id].shape[1]), + -stg.depth_cross_section[data_id][ self.combobox_freq2.currentIndex(), :], color='red', linestyle="solid", linewidth=2)) else: - if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): + if stg.time_cross_section[data_id].shape != (0,): self.red_line_plot_return, = ( self.axis_BS.plot( - stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time_cross_section[data_id][ self.combobox_freq2.currentIndex(), stg.sand_sample_target_indice[0][1]] * - np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]), - -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + np.ones(stg.depth[data_id].shape[1]), + -stg.depth[data_id][ self.combobox_freq2.currentIndex(), :], color='red', linestyle="solid", linewidth=2)) @@ -1408,10 +1413,10 @@ class SedimentCalibrationTab(QWidget): self.red_line_plot_return, = ( self.axis_BS.plot( - stg.time[self.combobox_acoustic_data_choice.currentIndex()][ + stg.time[data_id][ self.combobox_freq2.currentIndex(), stg.sand_sample_target_indice[0][1]] * - np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape[1]), - -stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ + np.ones(stg.depth[data_id].shape[1]), + -stg.depth[data_id][ self.combobox_freq2.currentIndex(), :], color='red', linestyle="solid", linewidth=2)) @@ -1941,13 +1946,12 @@ class SedimentCalibrationTab(QWidget): def compute_depth_2D(self): if self.combobox_acoustic_data_choice.count() > 0: - for k in range(self.combobox_acoustic_data_choice.count()): + while len(stg.depth_2D) <= k: + stg.depth_2D.append(np.array([])) if stg.depth_cross_section[k].shape != (0,): - if stg.time_cross_section[k].shape != (0,): - stg.depth_2D[k] = ( np.zeros((stg.freq[k].shape[0], stg.depth_cross_section[k].shape[1], @@ -1961,7 +1965,6 @@ class SedimentCalibrationTab(QWidget): axis=1)) elif stg.time[k].shape != (0,): - stg.depth_2D[k] = ( np.zeros((stg.freq[k].shape[0], stg.depth_cross_section[k].shape[1], @@ -1976,9 +1979,7 @@ class SedimentCalibrationTab(QWidget): axis=1)) elif stg.depth[k].shape != (0,): - if stg.time_cross_section[k].shape != (0,): - stg.depth_2D[k] = ( np.zeros((stg.freq[k].shape[0], stg.depth[k].shape[1], @@ -1993,7 +1994,6 @@ class SedimentCalibrationTab(QWidget): axis=1)) elif stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): - stg.depth_2D[k] = ( np.zeros((stg.freq[k].shape[0], stg.depth[k].shape[1], diff --git a/View/signal_processing_tab.py b/View/signal_processing_tab.py index 931fd15..a5cef86 100644 --- a/View/signal_processing_tab.py +++ b/View/signal_processing_tab.py @@ -511,6 +511,7 @@ class SignalProcessingTab(QWidget): self.icon_clear = QIcon(path_icon("clear.png")) self.icon_apply = QIcon(path_icon("circle_green_arrow_right.png")) + @trace def full_update(self): logger.debug(f"{__name__}: Update") self.blockSignals(True) diff --git a/tools.py b/tools.py index fe30842..7fe6e53 100644 --- a/tools.py +++ b/tools.py @@ -35,9 +35,10 @@ def trace(func): f"{head} Return {func.__module__}." + f"{func.__qualname__}: {value}" ) + dt = t1-t logger.debug( f"{head}[TIME] {func.__module__}." + - f"{func.__qualname__}: {t1-t} sec" + f"{func.__qualname__}: {dt:f} sec" ) return value