From 0f3117477a09c17dd61c9e301c5e6a8039e44718 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby Date: Wed, 26 Mar 2025 09:58:06 +0100 Subject: [PATCH] Acoustic data: Add 'distance_from_ABS_to_free_surface' in save DB. --- Model/create_table_for_save_as.py | 6 ++-- Model/read_table_for_open.py | 17 ++++----- Model/update_table_for_save.py | 57 ++++++++++++++++++++----------- View/acoustic_data_tab.py | 18 +++++++--- 4 files changed, 65 insertions(+), 33 deletions(-) diff --git a/Model/create_table_for_save_as.py b/Model/create_table_for_save_as.py index 5ec91a0..ef12041 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, @@ -410,16 +411,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], diff --git a/Model/read_table_for_open.py b/Model/read_table_for_open.py index 3516131..85220d0 100644 --- a/Model/read_table_for_open.py +++ b/Model/read_table_for_open.py @@ -477,7 +477,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 +490,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}") diff --git a/Model/update_table_for_save.py b/Model/update_table_for_save.py index c7f80e6..336473d 100644 --- a/Model/update_table_for_save.py +++ b/Model/update_table_for_save.py @@ -245,29 +245,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 dee1ce5..83a8c7b 100644 --- a/View/acoustic_data_tab.py +++ b/View/acoustic_data_tab.py @@ -844,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() @@ -1192,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) @@ -1779,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))