Acoustic data: Fix temperature value at study open.

dev-brahim
Pierre-Antoine 2025-03-25 16:07:25 +01:00
parent 5631a25b51
commit 6dbd1e3e5c
2 changed files with 33 additions and 18 deletions

View File

@ -498,6 +498,7 @@ class ReadTableForOpen:
stg.SNR_filter_value.append(x[12])
stg.Nb_cells_to_average_BS_signal.append(x[13])
logger.debug(f"stg.temperature: {stg.temperature}")
logger.debug(f"stg.tmin: {stg.tmin}")
logger.debug(f"stg.tmin: {stg.tmax}")
logger.debug(f"stg.SNR_filter_value: {stg.SNR_filter_value}")

View File

@ -737,8 +737,11 @@ class AcousticDataTab(QWidget):
logger.debug(f"{__name__}: Update")
self.blockSignals(True)
self.fileListWidget.blockSignals(True)
self.combobox_ABS_system_choice.blockSignals(True)
self.combobox_ABS_system_choice.setCurrentText(stg.ABS_name[0])
self.ABS_system_choice()
self.fileListWidget.addFilenames(stg.filename_BS_raw_data)
self.fill_measurements_information_groupbox()
@ -751,6 +754,7 @@ class AcousticDataTab(QWidget):
self.compute_rmin_rmax()
self.set_range_for_spinboxes_bathymetry()
self.combobox_ABS_system_choice.blockSignals(False)
self.fileListWidget.blockSignals(False)
self.blockSignals(False)
@ -974,7 +978,7 @@ class AcousticDataTab(QWidget):
self.gridLayout_groupbox_info.addWidget(self.lineEdit_temperature, 3, 1, 1, 1, Qt.AlignLeft)
self.label_temperature_unit.show()
self.gridLayout_groupbox_info.addWidget(self.label_temperature_unit, 3, 2, 1, 1, Qt.AlignLeft)
self.temperature_value()
self.setup_temperature_value()
self.label_speed_of_sound.show()
self.gridLayout_groupbox_info.addWidget(self.label_speed_of_sound, 4, 0, 1, 1, Qt.AlignLeft)
@ -1227,25 +1231,31 @@ class AcousticDataTab(QWidget):
self.update_plot_backscattered_acoustic_signal_recording()
self.update_plot_profile()
def temperature_value(self):
def setup_temperature_value(self):
self.water_velocity()
self.water_attenuation()
def temperature_value(self):
if findall(r",", self.lineEdit_temperature.text()):
stg.temperature = float(self.lineEdit_temperature.text().replace(',', '.'))
self.lineEdit_temperature.setText(self.lineEdit_temperature.text().replace(',', '.'))
else:
stg.temperature = float(self.lineEdit_temperature.text())
self.lineEdit_temperature.setText(self.lineEdit_temperature.text())
self.water_velocity()
self.water_attenuation()
def water_velocity(self):
"""Computing sond speed from Bilaniuk and Wong 1993"""
temp = float(self.lineEdit_temperature.text())
C = (1.40238744 * 1e3 +
5.03836171 * float(self.lineEdit_temperature.text()) -
5.81172916 * 1e-2 * float(self.lineEdit_temperature.text()) ** 2 +
3.34638117 * 1e-4 * float(self.lineEdit_temperature.text()) ** 3 -
1.48259672 * 1e-6 * float(self.lineEdit_temperature.text()) ** 4 +
3.16585020 * 1e-9 * float(self.lineEdit_temperature.text()) ** 5)
5.03836171 * temp -
5.81172916 * 1e-2 * temp ** 2 +
3.34638117 * 1e-4 * temp ** 3 -
1.48259672 * 1e-6 * temp ** 4 +
3.16585020 * 1e-9 * temp ** 5)
stg.water_velocity = C
self.lineEdit_speed_of_sound.setText(str(round(stg.water_velocity, 2)))
@ -1297,26 +1307,29 @@ class AcousticDataTab(QWidget):
# -------- Computing water attenuation coefficient ----------- #
def water_attenuation(self):
"""Computing attenuation from François and Garrison 1982"""
temp = float(self.lineEdit_temperature.text())
file_id = self.fileListWidget.currentRow()
if self.fileListWidget.count() > 0:
stg.water_attenuation[self.fileListWidget.currentRow()].clear()
for f in stg.freq[self.fileListWidget.currentRow()]:
if float(self.lineEdit_temperature.text()) > 20:
stg.water_attenuation[file_id].clear()
for f in stg.freq[file_id]:
if temp > 20:
alpha = ((3.964 * 1e-4 -
1.146 * 1e-5 * float(self.lineEdit_temperature.text()) +
1.45 * 1e-7 * float(self.lineEdit_temperature.text()) ** 2 -
6.5 * 1e-10 * float(self.lineEdit_temperature.text()) ** 3) *
1.146 * 1e-5 * temp +
1.45 * 1e-7 * temp ** 2 -
6.5 * 1e-10 * temp ** 3) *
1e-3 * (np.log(10) / 20) * (f * 1e-3) ** 2)
else:
alpha = ((4.937 * 1e-4 -
2.59 * 1e-5 * float(self.lineEdit_temperature.text()) +
9.11 * 1e-7 * float(self.lineEdit_temperature.text()) ** 2 -
1.5 * 1e-8 * float(self.lineEdit_temperature.text()) ** 3) *
2.59 * 1e-5 * temp +
9.11 * 1e-7 * temp ** 2 -
1.5 * 1e-8 * temp ** 3) *
1e-3 * (np.log(10) / 20) * (f * 1e-3) ** 2)
stg.water_attenuation[self.fileListWidget.currentRow()].append(alpha)
stg.water_attenuation[file_id].append(alpha)
self.lineEdit_sound_attenuation.setText(
str("%.6f" % stg.water_attenuation[self.fileListWidget.currentRow()][
str("%.6f" % stg.water_attenuation[file_id][
self.combobox_frequency_information.currentIndex()]))
def open_dialog_box(self):
@ -1752,6 +1765,7 @@ class AcousticDataTab(QWidget):
.currentIndexChanged\
.connect(self.combobox_frequency_information_update)
logger.debug(f"Set temperature = {stg.temperature}")
self.lineEdit_temperature.setText(str(stg.temperature))
self.label_profiles_value.setText(