kt corrected values are read from a file in the settings. The file can include differents same ABS (that is to say with different serial number).

dev-brahim
brahim 2024-10-24 16:53:35 +02:00
parent 8af3e16a1c
commit ffcc3e6eff
4 changed files with 103 additions and 87 deletions

View File

@ -38,9 +38,9 @@ class CalibrationConstantKt(QDialog):
self.tab = QTabWidget() self.tab = QTabWidget()
self.verticalLayout_Main.addWidget(self.tab) self.verticalLayout_Main.addWidget(self.tab)
data_ABS = pd.read_excel("../ABS_calibration_constant_kt.xlsx", header=0, sheet_name=None) self.data_ABS = pd.read_excel("ABS_calibration_constant_kt.xlsx", header=0, sheet_name=None)
for t_index, t_value in enumerate(list(data_ABS.keys())): for t_index, t_value in enumerate(list(self.data_ABS.keys())):
print("t = ", t_index, t_value) print("t = ", t_index, t_value)
exec("self.tab_" + str(t_index) + "= QWidget()") exec("self.tab_" + str(t_index) + "= QWidget()")
eval("self.tab.addTab(self.tab_" + str(t_index) + ", '" + str(t_value) + "')") eval("self.tab.addTab(self.tab_" + str(t_index) + ", '" + str(t_value) + "')")
@ -61,24 +61,21 @@ class CalibrationConstantKt(QDialog):
exec("self.label_kt_" + str(t_index) + " = QLabel('kt')") exec("self.label_kt_" + str(t_index) + " = QLabel('kt')")
eval("self.gridLayout_tab_" + str(t_index) + ".addWidget(self.label_kt_" + str(t_index) + ", 0, 1, 1, 1, Qt.AlignCenter)") eval("self.gridLayout_tab_" + str(t_index) + ".addWidget(self.label_kt_" + str(t_index) + ", 0, 1, 1, 1, Qt.AlignCenter)")
print(data_ABS[t_value].shape[0]) for x in range(self.data_ABS[t_value].shape[0]):
print(type(data_ABS[t_value])) exec("self.label_freq_" + str(x) + "_ABS_" + str(t_index) + " = QLabel('" + str(self.data_ABS[t_value].iloc[x][0]) + " MHz')")
for x in range(data_ABS[t_value].shape[0]):
exec("self.label_freq_" + str(x) + "_ABS_" + str(t_index) + " = QLabel('" + str(data_ABS[t_value].iloc[x][0]) + " MHz')")
eval("self.gridLayout_tab_" + str(t_index) + ".addWidget(self.label_freq_" + str(x) + "_ABS_" + str(t_index) + eval("self.gridLayout_tab_" + str(t_index) + ".addWidget(self.label_freq_" + str(x) + "_ABS_" + str(t_index) +
", " + str(x + 1) + ", 0, 1, 1,Qt.AlignCenter)") ", " + str(x + 1) + ", 0, 1, 1,Qt.AlignCenter)")
exec("self.lineEdit_" + str(x) + "_ABS_" + str(t_index) + " = QLineEdit()") exec("self.lineEdit_" + str(x) + "_ABS_" + str(t_index) + " = QLineEdit()")
exec("self.lineEdit_" + str(x) + "_ABS_" + str(t_index) + ".setText('" + str(data_ABS[t_value].iloc[x][1]) + "')") exec("self.lineEdit_" + str(x) + "_ABS_" + str(t_index) + ".setText('" + str(self.data_ABS[t_value].iloc[x][1]) + "')")
exec("self.lineEdit_" + str(x) + "_ABS_" + str(t_index) + ".setMaximumWidth(" + str(100) + ")") exec("self.lineEdit_" + str(x) + "_ABS_" + str(t_index) + ".setMaximumWidth(" + str(100) + ")")
eval("self.gridLayout_tab_" + str(t_index) + ".addWidget(self.lineEdit_" + str(x) + "_ABS_" + str(t_index) + eval("self.gridLayout_tab_" + str(t_index) + ".addWidget(self.lineEdit_" + str(x) + "_ABS_" + str(t_index) +
", " + str(x+1) + ", 1, 1, 1, Qt.AlignCenter)") ", " + str(x+1) + ", 1, 1, 1, Qt.AlignCenter)")
if __name__ == "__main__": # if __name__ == "__main__":
app = QApplication(sys.argv) # app = QApplication(sys.argv)
cal = CalibrationConstantKt() # cal = CalibrationConstantKt()
cal.show() # cal.show()
# sys.exit(app.exec_()) # # sys.exit(app.exec_())
app.exec() # app.exec()

View File

@ -39,6 +39,7 @@ import Translation.constant_string as cs
from Model.TableModel import TableModel from Model.TableModel import TableModel
from Model.acoustic_data_loader import AcousticDataLoader from Model.acoustic_data_loader import AcousticDataLoader
from Model.acoustic_data_loader_UBSediFlow import AcousticDataLoaderUBSediFlow from Model.acoustic_data_loader_UBSediFlow import AcousticDataLoaderUBSediFlow
from Model.calibration_constant_kt import CalibrationConstantKt
import settings as stg import settings as stg
@ -83,6 +84,8 @@ class AcousticDataTab(QWidget):
self.icon_between = QPixmap(self.path_icon + "between.png") self.icon_between = QPixmap(self.path_icon + "between.png")
self.icon_refresh = QIcon(self.path_icon + "update.png") self.icon_refresh = QIcon(self.path_icon + "update.png")
self.calib_kt = CalibrationConstantKt()
### --- General layout of widgets --- ### --- General layout of widgets ---
self.verticalLayoutMain = QVBoxLayout(tab_widget) self.verticalLayoutMain = QVBoxLayout(tab_widget)
@ -144,7 +147,6 @@ class AcousticDataTab(QWidget):
self.groupbox_info = QGroupBox() self.groupbox_info = QGroupBox()
self.scrollbar_measurement_information = QScrollArea() self.scrollbar_measurement_information = QScrollArea()
# self.scrollbar_measurement_information.setWindowTitle("Measurements information")
self.verticalLayout_groupbox_download.addWidget(self.scrollbar_measurement_information, 5) self.verticalLayout_groupbox_download.addWidget(self.scrollbar_measurement_information, 5)
# +++++++++++++++++++++++++++ # +++++++++++++++++++++++++++
@ -216,22 +218,25 @@ class AcousticDataTab(QWidget):
# | Group Box Measurements information | # | Group Box Measurements information |
# ++++++++++++++++++++++++++++++++++++++ # ++++++++++++++++++++++++++++++++++++++
self.gridLayout_groupbox_info = QGridLayout()
self.groupbox_info.setLayout(self.gridLayout_groupbox_info)
self.scrollbar_measurement_information.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) self.scrollbar_measurement_information.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
self.scrollbar_measurement_information.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) self.scrollbar_measurement_information.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
self.scrollbar_measurement_information.setWidgetResizable(True) self.scrollbar_measurement_information.setWidgetResizable(True)
self.gridLayout_groupbox_info = QGridLayout(self.scrollbar_measurement_information)
self.groupbox_info.setLayout(self.gridLayout_groupbox_info)
self.scrollbar_measurement_information.setWidget(self.groupbox_info) self.scrollbar_measurement_information.setWidget(self.groupbox_info)
self.label_ABS_name = QLabel() self.label_ABS_name = QLabel()
self.combobox_ABS_name = QComboBox()
self.combobox_ABS_name.addItems(self.calib_kt.data_ABS.keys())
self.label_date_acoustic_file = QLabel() self.label_date_acoustic_file = QLabel()
self.label_hour_acoustic_file = QLabel() self.label_hour_acoustic_file = QLabel()
self.label_distance_from_ABS_to_free_surface = QLabel() self.label_distance_from_ABS_to_free_surface = QLabel()
self.label_distance_from_ABS_to_free_surface.setText("ABS distance from the free surface") self.label_distance_from_ABS_to_free_surface.setText("Distance from ABS to free surface")
self.lineEdit_distance_from_ABS_to_free_surface = QLineEdit() self.lineEdit_distance_from_ABS_to_free_surface = QLineEdit()
self.lineEdit_distance_from_ABS_to_free_surface.setText("0.00") self.lineEdit_distance_from_ABS_to_free_surface.setText("0.00")
@ -1320,6 +1325,8 @@ class AcousticDataTab(QWidget):
# self.fileListWidget.clicked.connect(self.rename_file_in_ListWidget) # self.fileListWidget.clicked.connect(self.rename_file_in_ListWidget)
self.combobox_ABS_name.currentIndexChanged.connect(self.fill_measurements_information_groupbox)
self.checkbox_kt.stateChanged.connect(self.activate_unactivate_spinbox_kt) self.checkbox_kt.stateChanged.connect(self.activate_unactivate_spinbox_kt)
# self.radiobutton_value.toggled.connect(self.onClicked_radiobutton_gps) # self.radiobutton_value.toggled.connect(self.onClicked_radiobutton_gps)
@ -1536,6 +1543,8 @@ class AcousticDataTab(QWidget):
self.label_ABS_name.hide() self.label_ABS_name.hide()
self.combobox_ABS_name.hide()
self.label_date_acoustic_file.hide() self.label_date_acoustic_file.hide()
self.label_hour_acoustic_file.hide() self.label_hour_acoustic_file.hide()
@ -1590,6 +1599,8 @@ class AcousticDataTab(QWidget):
# --- Hide UBSediFlow information and remove widget from grid layout --- # --- Hide UBSediFlow information and remove widget from grid layout ---
self.label_ABS_name.hide() self.label_ABS_name.hide()
self.combobox_ABS_name.hide()
self.label_date_acoustic_file.hide() self.label_date_acoustic_file.hide()
self.label_hour_acoustic_file.hide() self.label_hour_acoustic_file.hide()
@ -1651,7 +1662,10 @@ class AcousticDataTab(QWidget):
self.label_ABS_name.show() self.label_ABS_name.show()
self.label_ABS_name.setText("Acoustic Backscatter System: AQUAscat") self.label_ABS_name.setText("Acoustic Backscatter System: AQUAscat")
self.gridLayout_groupbox_info.addWidget(self.label_ABS_name, 0, 0, 1, 2) self.gridLayout_groupbox_info.addWidget(self.label_ABS_name, 0, 0, 1, 2, Qt.AlignCenter)
self.combobox_ABS_name.show()
self.gridLayout_groupbox_info.addWidget(self.combobox_ABS_name, 0, 2, 1, 2, Qt.AlignCenter)
self.label_date_acoustic_file.show() self.label_date_acoustic_file.show()
self.gridLayout_groupbox_info.addWidget(self.label_date_acoustic_file, 1, 0, 1, 1) self.gridLayout_groupbox_info.addWidget(self.label_date_acoustic_file, 1, 0, 1, 1)
@ -1742,6 +1756,8 @@ class AcousticDataTab(QWidget):
# --- Hide Aquascat information --- # --- Hide Aquascat information ---
self.label_ABS_name.hide() self.label_ABS_name.hide()
self.combobox_ABS_name.hide()
self.label_date_acoustic_file.hide() self.label_date_acoustic_file.hide()
self.label_hour_acoustic_file.hide() self.label_hour_acoustic_file.hide()
@ -1802,7 +1818,10 @@ class AcousticDataTab(QWidget):
# --- Show UBSediFlow information --- # --- Show UBSediFlow information ---
self.label_ABS_name.show() self.label_ABS_name.show()
self.label_ABS_name.setText("Acoustic Backscatter System: UBSediFlow") self.label_ABS_name.setText("Acoustic Backscatter System: UBSediFlow")
self.gridLayout_groupbox_info.addWidget(self.label_ABS_name, 0, 0, 1, 2) self.gridLayout_groupbox_info.addWidget(self.label_ABS_name, 0, 0, 1, 2, Qt.AlignCenter)
self.combobox_ABS_name.show()
self.gridLayout_groupbox_info.addWidget(self.combobox_ABS_name, 0, 2, 1, 2, Qt.AlignCenter)
self.label_date_acoustic_file.show() self.label_date_acoustic_file.show()
self.gridLayout_groupbox_info.addWidget(self.label_date_acoustic_file, 1, 0, 1, 1) self.gridLayout_groupbox_info.addWidget(self.label_date_acoustic_file, 1, 0, 1, 1)
@ -2629,61 +2648,55 @@ class AcousticDataTab(QWidget):
self.label_profiles_value.setText(str(stg.nb_profiles[self.fileListWidget.currentRow()] self.label_profiles_value.setText(str(stg.nb_profiles[self.fileListWidget.currentRow()]
[self.combobox_frequency_information.currentIndex()])) [self.combobox_frequency_information.currentIndex()]))
self.gridLayout_groupbox_info.addWidget(self.label_profiles_value, 7, 1, 1, 1) self.gridLayout_groupbox_info.addWidget(self.label_profiles_value, 8, 1, 1, 1)
self.label_profiles_per_sec_value.setText(str(stg.nb_profiles_per_sec[self.fileListWidget.currentRow()] self.label_profiles_per_sec_value.setText(str(stg.nb_profiles_per_sec[self.fileListWidget.currentRow()]
[self.combobox_frequency_information.currentIndex()]) + " Hz") [self.combobox_frequency_information.currentIndex()]) + " Hz")
self.gridLayout_groupbox_info.addWidget(self.label_profiles_per_sec_value, 8, 1, 1, 1) self.gridLayout_groupbox_info.addWidget(self.label_profiles_per_sec_value, 9, 1, 1, 1)
self.label_cells_value.setText(str(stg.nb_cells[self.fileListWidget.currentRow()] self.label_cells_value.setText(str(stg.nb_cells[self.fileListWidget.currentRow()]
[self.combobox_frequency_information.currentIndex()])) [self.combobox_frequency_information.currentIndex()]))
self.gridLayout_groupbox_info.addWidget(self.label_cells_value, 9, 1, 1, 1) self.gridLayout_groupbox_info.addWidget(self.label_cells_value, 10, 1, 1, 1)
self.label_cell_size_value.setText(str(100*round(stg.cell_size[self.fileListWidget.currentRow()] self.label_cell_size_value.setText(str(100*round(stg.cell_size[self.fileListWidget.currentRow()]
[self.combobox_frequency_information.currentIndex()], 3)) + " cm") [self.combobox_frequency_information.currentIndex()], 3)) + " cm")
self.gridLayout_groupbox_info.addWidget(self.label_cell_size_value, 10, 1, 1, 1) self.gridLayout_groupbox_info.addWidget(self.label_cell_size_value, 11, 1, 1, 1)
self.label_pulse_length_value.setText(str(round(stg.pulse_length[self.fileListWidget.currentRow()] self.label_pulse_length_value.setText(str(round(stg.pulse_length[self.fileListWidget.currentRow()]
[self.combobox_frequency_information.currentIndex()], 6)) + " sec") [self.combobox_frequency_information.currentIndex()], 6)) + " sec")
self.gridLayout_groupbox_info.addWidget(self.label_pulse_length_value, 11, 1, 1, 1) self.gridLayout_groupbox_info.addWidget(self.label_pulse_length_value, 12, 1, 1, 1)
self.label_pings_per_sec_value.setText(str(stg.nb_pings_per_sec[self.fileListWidget.currentRow()] self.label_pings_per_sec_value.setText(str(stg.nb_pings_per_sec[self.fileListWidget.currentRow()]
[self.combobox_frequency_information.currentIndex()]) + " Hz") [self.combobox_frequency_information.currentIndex()]) + " Hz")
self.gridLayout_groupbox_info.addWidget(self.label_pings_per_sec_value, 12, 1, 1, 1) self.gridLayout_groupbox_info.addWidget(self.label_pings_per_sec_value, 13, 1, 1, 1)
self.label_pings_per_profile_value.setText(str(stg.nb_pings_averaged_per_profile[self.fileListWidget.currentRow()] self.label_pings_per_profile_value.setText(str(stg.nb_pings_averaged_per_profile[self.fileListWidget.currentRow()]
[self.combobox_frequency_information.currentIndex()])) [self.combobox_frequency_information.currentIndex()]))
self.gridLayout_groupbox_info.addWidget(self.label_pings_per_profile_value, 13, 1, 1, 1) self.gridLayout_groupbox_info.addWidget(self.label_pings_per_profile_value, 14, 1, 1, 1)
if self.combobox_ABS_system_choice.currentText() == "Aquascat 1000R": stg.kt_corrected.clear()
# stg.kt_corrected = stg.kt_read for f in range(stg.freq[self.fileListWidget.currentRow()].shape[0]):
stg.kt_corrected = {"0.3 MHz" : 0.78905595, stg.kt_corrected.append(
"0.5 MHz" : 0.36257121, self.calib_kt.data_ABS[self.combobox_ABS_name.currentText()].iloc[
"1.0 MHz" : 0.64446145, np.where(
"2.5 MHz" : 0.31522785, np.abs(np.array([stg.freq[self.fileListWidget.currentRow()][f] - l for l in
"4.0 MHz" : 0.30339201, self.calib_kt.data_ABS[self.combobox_ABS_name.currentText()][
"5.0 MHz" : 0.27143525} self.calib_kt.data_ABS[
elif self.combobox_ABS_system_choice.currentText() == "UB-SediFlow": self.combobox_ABS_name.currentText()].columns[0]].values]))
# stg.kt_corrected = stg.kt_read ==
stg.kt_corrected = [0.79352001, 0.36462244, 0.64810746, 0.27297088] np.min(np.abs(np.array([stg.freq[self.fileListWidget.currentRow()][f] - l for l in
# if self.checkbox_kt.isChecked(): self.calib_kt.data_ABS[self.combobox_ABS_name.currentText()][
# self.spinbox_kt.setValue( self.calib_kt.data_ABS[
# stg.kt_corrected[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()]) self.combobox_ABS_name.currentText()].columns[
# else: 0]].values])
))
)[0][0]
][1])
print(stg.ABS_name)
print(stg.kt_corrected)
print(self.combobox_frequency_information.currentText())
print(stg.kt_corrected[self.combobox_frequency_information.currentText()])
# self.spinbox_kt.setValue( print("stg.kt_corrected ", stg.kt_corrected)
# stg.kt_corrected[self.combobox_frequency_information.currentText()])
# self.spinbox_kt.setSuffix(f" V.m^{1.5}")
# self.spinbox_kt.setEnabled(True)
# # self.checkbox_kt.stateChanged.connect(self.activate_unactivate_spinbox_kt)
# self.spinbox_kt.valueChanged.connect(self.kt_value)
self.lineEdit_kt.setText(str("%.4f" % stg.kt_corrected[self.combobox_frequency_information.currentText()])) self.lineEdit_kt.setText(str("%.4f" % stg.kt_corrected[self.combobox_frequency_information.currentIndex()]))
self.lineEdit_kt.setEnabled(True) self.lineEdit_kt.setEnabled(True)
self.lineEdit_kt.returnPressed.connect(self.kt_value) self.lineEdit_kt.returnPressed.connect(self.kt_value)
@ -2806,42 +2819,42 @@ class AcousticDataTab(QWidget):
self.gridLayout_groupbox_info.removeWidget(self.label_profiles_value) self.gridLayout_groupbox_info.removeWidget(self.label_profiles_value)
self.label_profiles_value.setText(str(stg.nb_profiles[self.fileListWidget.currentRow()] self.label_profiles_value.setText(str(stg.nb_profiles[self.fileListWidget.currentRow()]
[self.combobox_frequency_information.currentIndex()])) [self.combobox_frequency_information.currentIndex()]))
self.gridLayout_groupbox_info.addWidget(self.label_profiles_value, 7, 1, 1, 1) self.gridLayout_groupbox_info.addWidget(self.label_profiles_value, 8, 1, 1, 1)
self.label_profiles_per_sec_value.clear() self.label_profiles_per_sec_value.clear()
self.label_profiles_per_sec_value.setText( self.label_profiles_per_sec_value.setText(
str(stg.nb_profiles_per_sec[self.fileListWidget.currentRow()] str(stg.nb_profiles_per_sec[self.fileListWidget.currentRow()]
[self.combobox_frequency_information.currentIndex()]) + " Hz") [self.combobox_frequency_information.currentIndex()]) + " Hz")
self.gridLayout_groupbox_info.addWidget(self.label_profiles_per_sec_value, 8, 1, 1, 1) self.gridLayout_groupbox_info.addWidget(self.label_profiles_per_sec_value, 9, 1, 1, 1)
self.label_cells_value.clear() self.label_cells_value.clear()
self.label_cells_value.setText(str(stg.nb_cells[self.fileListWidget.currentRow()] self.label_cells_value.setText(str(stg.nb_cells[self.fileListWidget.currentRow()]
[self.combobox_frequency_information.currentIndex()])) [self.combobox_frequency_information.currentIndex()]))
self.gridLayout_groupbox_info.addWidget(self.label_cells_value, 9, 1, 1, 1) self.gridLayout_groupbox_info.addWidget(self.label_cells_value, 10, 1, 1, 1)
self.label_cell_size_value.clear() self.label_cell_size_value.clear()
self.gridLayout_groupbox_info.removeWidget(self.label_cell_size_value) self.gridLayout_groupbox_info.removeWidget(self.label_cell_size_value)
self.label_cell_size_value.setText( self.label_cell_size_value.setText(
str(100 * round(stg.cell_size[self.fileListWidget.currentRow()] str(100 * round(stg.cell_size[self.fileListWidget.currentRow()]
[self.combobox_frequency_information.currentIndex()], 3)) + " cm") [self.combobox_frequency_information.currentIndex()], 3)) + " cm")
self.gridLayout_groupbox_info.addWidget(self.label_cell_size_value, 10, 1, 1, 1) self.gridLayout_groupbox_info.addWidget(self.label_cell_size_value, 11, 1, 1, 1)
self.label_pulse_length_value.clear() self.label_pulse_length_value.clear()
self.label_pulse_length_value.setText( self.label_pulse_length_value.setText(
str(round(stg.pulse_length[self.fileListWidget.currentRow()] str(round(stg.pulse_length[self.fileListWidget.currentRow()]
[self.combobox_frequency_information.currentIndex()], 6)) + " sec") [self.combobox_frequency_information.currentIndex()], 6)) + " sec")
self.gridLayout_groupbox_info.addWidget(self.label_pulse_length_value, 11, 1, 1, 1) self.gridLayout_groupbox_info.addWidget(self.label_pulse_length_value, 12, 1, 1, 1)
self.label_pings_per_sec_value.clear() self.label_pings_per_sec_value.clear()
self.label_pings_per_sec_value.setText(str(stg.nb_pings_per_sec[self.fileListWidget.currentRow()] self.label_pings_per_sec_value.setText(str(stg.nb_pings_per_sec[self.fileListWidget.currentRow()]
[self.combobox_frequency_information.currentIndex()]) + " Hz") [self.combobox_frequency_information.currentIndex()]) + " Hz")
self.gridLayout_groupbox_info.addWidget(self.label_pings_per_sec_value, 12, 1, 1, 1) self.gridLayout_groupbox_info.addWidget(self.label_pings_per_sec_value, 13, 1, 1, 1)
self.label_pings_per_profile_value.clear() self.label_pings_per_profile_value.clear()
self.label_pings_per_profile_value.setText( self.label_pings_per_profile_value.setText(
str(stg.nb_pings_averaged_per_profile[self.fileListWidget.currentRow()] str(stg.nb_pings_averaged_per_profile[self.fileListWidget.currentRow()]
[self.combobox_frequency_information.currentIndex()])) [self.combobox_frequency_information.currentIndex()]))
self.gridLayout_groupbox_info.addWidget(self.label_pings_per_profile_value, 13, 1, 1, 1) self.gridLayout_groupbox_info.addWidget(self.label_pings_per_profile_value, 14, 1, 1, 1)
print("stg.kt_corrected ", stg.kt_corrected) print("stg.kt_corrected ", stg.kt_corrected)
print("self.combobox_frequency_information.currentText()", print("self.combobox_frequency_information.currentText()",
@ -2851,7 +2864,7 @@ class AcousticDataTab(QWidget):
if self.checkbox_kt.isChecked(): if self.checkbox_kt.isChecked():
if self.combobox_frequency_information.count() > 0: if self.combobox_frequency_information.count() > 0:
# self.spinbox_kt.setValue(stg.kt_corrected[self.combobox_frequency_information.currentText()]) # self.spinbox_kt.setValue(stg.kt_corrected[self.combobox_frequency_information.currentText()])
self.lineEdit_kt.setText(str("%.4f" % stg.kt_corrected[self.combobox_frequency_information.currentText()])) self.lineEdit_kt.setText(str("%.4f" % stg.kt_corrected[self.combobox_frequency_information.currentIndex()]))
else: else:
# print("combobox information update : checkbox unchecked") # print("combobox information update : checkbox unchecked")
# self.spinbox_kt.setValue(stg.kt_read[self.combobox_frequency_information.currentIndex()]) # self.spinbox_kt.setValue(stg.kt_read[self.combobox_frequency_information.currentIndex()])
@ -2876,7 +2889,7 @@ class AcousticDataTab(QWidget):
self.lineEdit_kt.setEnabled(True) self.lineEdit_kt.setEnabled(True)
if stg.kt_corrected: if stg.kt_corrected:
# self.spinbox_kt.setValue(stg.kt_corrected[self.combobox_frequency_information.currentText()]) # self.spinbox_kt.setValue(stg.kt_corrected[self.combobox_frequency_information.currentText()])
self.lineEdit_kt.setText(str("%.4f" % stg.kt_corrected[self.combobox_frequency_information.currentText()])) self.lineEdit_kt.setText(str("%.4f" % stg.kt_corrected[self.combobox_frequency_information.currentIndex()]))
else: else:
# self.spinbox_kt.setDisabled(True) # self.spinbox_kt.setDisabled(True)
self.lineEdit_kt.setDisabled(True) self.lineEdit_kt.setDisabled(True)
@ -2909,11 +2922,11 @@ class AcousticDataTab(QWidget):
if self.checkbox_kt.isChecked(): if self.checkbox_kt.isChecked():
if findall(r",", self.lineEdit_kt.text()): if findall(r",", self.lineEdit_kt.text()):
stg.kt_corrected[self.combobox_frequency_information.currentText()] = ( stg.kt_corrected[self.combobox_frequency_information.currentIndex()] = (
float(self.lineEdit_kt.text().replace(',', '.'))) float(self.lineEdit_kt.text().replace(',', '.')))
self.lineEdit_kt.setText("%.4f" % float(self.lineEdit_kt.text().replace(',', '.'))) self.lineEdit_kt.setText("%.4f" % float(self.lineEdit_kt.text().replace(',', '.')))
else: else:
stg.kt_corrected[self.combobox_frequency_information.currentText()] = ( stg.kt_corrected[self.combobox_frequency_information.currentIndex()] = (
float(self.lineEdit_kt.text())) float(self.lineEdit_kt.text()))
self.lineEdit_kt.setText("%.4f" % float(self.lineEdit_kt.text())) self.lineEdit_kt.setText("%.4f" % float(self.lineEdit_kt.text()))
@ -2923,7 +2936,6 @@ class AcousticDataTab(QWidget):
# self.lineEdit_kt.setText(str("%.4f" % stg.kt_corrected[ # self.lineEdit_kt.setText(str("%.4f" % stg.kt_corrected[
# self.combobox_frequency_information.currentText()])) # self.combobox_frequency_information.currentText()]))
# print(f"1 stg.kt_read : {stg.kt_read}") # print(f"1 stg.kt_read : {stg.kt_read}")
print(f"1 stg.kt_corrected {stg.kt_corrected}") print(f"1 stg.kt_corrected {stg.kt_corrected}")
@ -3246,7 +3258,7 @@ class AcousticDataTab(QWidget):
stg.tmin[self.fileListWidget.currentRow()][0]:stg.tmax[self.fileListWidget.currentRow()][0]]) stg.tmin[self.fileListWidget.currentRow()][0]:stg.tmax[self.fileListWidget.currentRow()][0]])
print(f"BS_cross_section shape : {stg.BS_cross_section[self.fileListWidget.currentRow()].shape}") print(f"BS_cross_section shape : {stg.BS_cross_section[self.fileListWidget.currentRow()].shape}")
print(f"BS_cross_section : {stg.BS_cross_section}") # print(f"BS_cross_section : {stg.BS_cross_section}")
def update_frequency_combobox(self): def update_frequency_combobox(self):
if self.fileListWidget.currentRow() != -1: if self.fileListWidget.currentRow() != -1:

View File

@ -13,20 +13,16 @@ from PyQt5 import QtCore, QtGui, QtWidgets
from Model.create_table_for_save_as import CreateTableForSaveAs from Model.create_table_for_save_as import CreateTableForSaveAs
from Model.update_table_for_save import UpdateTableForSave from Model.update_table_for_save import UpdateTableForSave
from Model.read_table_for_open import ReadTableForOpen from Model.read_table_for_open import ReadTableForOpen
from Model.calibration_constant_kt import CalibrationConstantKt
from View.about_window import AboutWindow from View.about_window import AboutWindow
import settings as stg import settings as stg
import numpy as np import numpy as np
import pandas as pd
import sys
from os import chdir
from subprocess import check_call, run from subprocess import check_call, run
import time import time
# from View.acoustic_data_tab import AcousticDataTab # from View.acoustic_data_tab import AcousticDataTab
from functools import partial
class Ui_MainWindow(object): class Ui_MainWindow(object):
def setupUi(self, MainWindow): def setupUi(self, MainWindow):
@ -135,6 +131,8 @@ class Ui_MainWindow(object):
icon7.addPixmap(QtGui.QPixmap("icons/fr.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) icon7.addPixmap(QtGui.QPixmap("icons/fr.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.actionFrench.setIcon(icon7) self.actionFrench.setIcon(icon7)
self.actionFrench.setObjectName("actionFrench") self.actionFrench.setObjectName("actionFrench")
self.action_ABSCalibrationConstant = QtWidgets.QAction(MainWindow)
self.action_ABSCalibrationConstant.setText("ABS constant calibration kt")
self.actionTable_of_Backscatter_values = QtWidgets.QAction(MainWindow) self.actionTable_of_Backscatter_values = QtWidgets.QAction(MainWindow)
self.actionTable_of_Backscatter_values.setObjectName("actionTable_of_Backscatter_values") self.actionTable_of_Backscatter_values.setObjectName("actionTable_of_Backscatter_values")
self.actionSave_As = QtWidgets.QAction(MainWindow) self.actionSave_As = QtWidgets.QAction(MainWindow)
@ -148,6 +146,7 @@ class Ui_MainWindow(object):
self.menuLanguage.addAction(self.actionEnglish) self.menuLanguage.addAction(self.actionEnglish)
self.menuLanguage.addAction(self.actionFrench) self.menuLanguage.addAction(self.actionFrench)
self.menuSettings.addAction(self.menuLanguage.menuAction()) self.menuSettings.addAction(self.menuLanguage.menuAction())
self.menuSettings.addAction(self.action_ABSCalibrationConstant)
self.menuExport.addAction(self.actionTable_of_Backscatter_values) self.menuExport.addAction(self.actionTable_of_Backscatter_values)
self.menuFile.addAction(self.actionOpen) self.menuFile.addAction(self.actionOpen)
self.menuFile.addAction(self.actionSave) self.menuFile.addAction(self.actionSave)
@ -177,6 +176,9 @@ class Ui_MainWindow(object):
self.tabWidget.setCurrentIndex(0) self.tabWidget.setCurrentIndex(0)
QtCore.QMetaObject.connectSlotsByName(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow)
# --- Create Context Menu ---
self.createContextMenu()
# --- Connect Action Save As --- # --- Connect Action Save As ---
self.actionSave_As.triggered.connect(self.save_as) self.actionSave_As.triggered.connect(self.save_as)
@ -187,6 +189,9 @@ class Ui_MainWindow(object):
self.actionOpen.triggered.connect(self.open) self.actionOpen.triggered.connect(self.open)
self.actionOpen.triggered.connect(lambda: print('tott')) self.actionOpen.triggered.connect(lambda: print('tott'))
# --- Connect Action ABS calibration constant kt ---
self.action_ABSCalibrationConstant.triggered.connect(self.load_calibration_constant_values)
# --- Connect Action export acoustic backscatter values --- # --- Connect Action export acoustic backscatter values ---
self.actionTable_of_Backscatter_values.triggered.connect( self.actionTable_of_Backscatter_values.triggered.connect(
self.export_table_of_acoustic_BS_values_to_excel_or_libreOfficeCalc_file) self.export_table_of_acoustic_BS_values_to_excel_or_libreOfficeCalc_file)
@ -200,8 +205,18 @@ class Ui_MainWindow(object):
# --- Connect Action User Manual --- # --- Connect Action User Manual ---
self.actionUserManual.triggered.connect(self.user_manual) self.actionUserManual.triggered.connect(self.user_manual)
# --- Create Context Menu ---
self.createContextMenu() def createContextMenu(self):
# Setting contextMenuPolicy
self.centralwidget.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu)
# Populating the widget with actions
self.centralwidget.addAction(self.actionSave_As)
self.centralwidget.addAction(self.actionSave)
self.centralwidget.addAction(self.actionOpen)
self.centralwidget.addAction(self.actionTable_of_Backscatter_values)
self.centralwidget.addAction(self.actionEnglish)
self.centralwidget.addAction(self.actionFrench)
self.centralwidget.addAction(self.actionDB_Browser_for_SQLite)
def save_as(self): def save_as(self):
CreateTableForSaveAs() CreateTableForSaveAs()
@ -216,17 +231,9 @@ class Ui_MainWindow(object):
# #
# acoustic_data_tab.fileListWidget.addItems(stg.acoustic_data) # acoustic_data_tab.fileListWidget.addItems(stg.acoustic_data)
def createContextMenu(self): def load_calibration_constant_values(self):
# Setting contextMenuPolicy cc_kt = CalibrationConstantKt()
self.centralwidget.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) cc_kt.exec()
# Populating the widget with actions
self.centralwidget.addAction(self.actionSave_As)
self.centralwidget.addAction(self.actionSave)
self.centralwidget.addAction(self.actionOpen)
self.centralwidget.addAction(self.actionTable_of_Backscatter_values)
self.centralwidget.addAction(self.actionEnglish)
self.centralwidget.addAction(self.actionFrench)
self.centralwidget.addAction(self.actionDB_Browser_for_SQLite)
def db_browser_for_sqlite(self): def db_browser_for_sqlite(self):
check_call("/usr/bin/sqlitebrowser") check_call("/usr/bin/sqlitebrowser")

View File

@ -41,7 +41,7 @@ freq_text = [] # Frequency of measurements : list of string
kt_read = [] # Constant of calibration kt of the ABS read from acoustic file # List of list kt_read = [] # Constant of calibration kt of the ABS read from acoustic file # List of list
# for each frequency # for each frequency
kt_corrected = {} # Constant of calibration kt of the ABS corrected # Dictionary kt_corrected = [] # Constant of calibration kt of the ABS corrected # list of float
# Sometimes, the read values of kt are wrong. Then, we define # Sometimes, the read values of kt are wrong. Then, we define
# default values for all frequency of the ABS. # default values for all frequency of the ABS.