Compare commits

..

No commits in common. "79ee1c3cfa39c6c41bc46dc99afef88a6ba276a8" and "cb46917101b6c2c79df9b45646e1ced34249b589" have entirely different histories.

4 changed files with 188 additions and 325 deletions

View File

@ -100,10 +100,10 @@ class CreateTableForSaveAs:
acoustic_data INTEGER, acoustic_data INTEGER,
temperature FLOAT, temperature FLOAT,
distance_to_free_surface FLOAT, distance_to_free_surface FLOAT,
tmin_index INTEGER, tmin_value FLOAT, tmin_index FLOAT, tmin_value FLOAT,
tmax_index INTEGER, tmax_value FLOAT, tmax_index FLOAT, tmax_value FLOAT,
rmin_index INTEGER, rmin_value FLOAT, rmin_index FLOAT, rmin_value FLOAT,
rmax_index INTEGER, rmax_value FLOAT, rmax_index FLOAT, rmax_value FLOAT,
freq_bottom_detection_index FLOAT, freq_bottom_detection_index FLOAT,
freq_bottom_detection_value STRING, freq_bottom_detection_value STRING,
depth_bottom_detection_min FLOAT, depth_bottom_detection_min FLOAT,
@ -449,10 +449,10 @@ class CreateTableForSaveAs:
( (
stg.acoustic_data[i], stg.temperature, stg.acoustic_data[i], stg.temperature,
stg.distance_from_ABS_to_free_surface[i], stg.distance_from_ABS_to_free_surface[i],
int(stg.tmin[i][0]), stg.tmin[i][1], stg.tmin[i][0], stg.tmin[i][1],
int(stg.tmax[i][0]), stg.tmax[i][1], stg.tmax[i][0], stg.tmax[i][1],
int(stg.rmin[i][0]), stg.rmin[i][1], stg.rmin[i][0], stg.rmin[i][1],
int(stg.rmax[i][0]), stg.rmax[i][1], stg.rmax[i][0], stg.rmax[i][1],
stg.freq_bottom_detection[i][0], stg.freq_bottom_detection[i][0],
stg.freq_bottom_detection[i][1], stg.freq_bottom_detection[i][1],
stg.depth_bottom_detection_min, stg.depth_bottom_detection_min,

View File

@ -524,7 +524,7 @@ class ReadTableForOpen:
logger.debug(f"stg.temperature: {stg.temperature}") logger.debug(f"stg.temperature: {stg.temperature}")
logger.debug(f"stg.tmin: {stg.tmin}") logger.debug(f"stg.tmin: {stg.tmin}")
logger.debug(f"stg.tmax: {stg.tmax}") logger.debug(f"stg.tmin: {stg.tmax}")
logger.debug(f"stg.SNR_filter_value: {stg.SNR_filter_value}") logger.debug(f"stg.SNR_filter_value: {stg.SNR_filter_value}")
def read_table_sediment_file(self): def read_table_sediment_file(self):

View File

@ -1396,6 +1396,7 @@ class AcousticDataTab(QWidget):
self.open_acoustic_data() self.open_acoustic_data()
@trace
def open_acoustic_data(self): def open_acoustic_data(self):
# --- Fill lineEdit with path and file names + load acoustic data --- # --- Fill lineEdit with path and file names + load acoustic data ---
# --- fill date, hour and measurements information + fill frequency combobox for bottom detection --- # --- fill date, hour and measurements information + fill frequency combobox for bottom detection ---
@ -2167,344 +2168,209 @@ class AcousticDataTab(QWidget):
if self.fileListWidget.currentRow() == -1: if self.fileListWidget.currentRow() == -1:
return return
data_id = self.fileListWidget.currentRow() file_id = self.fileListWidget.currentRow()
tmin_indice = np.where( tmin_indice = np.where(
np.abs( np.abs(
stg.time[data_id][0, :] - np.nanmin(stg.time[data_id][0, :]) stg.time[file_id][0, :] - np.nanmin(stg.time[file_id][0, :])
) == np.nanmin( ) == np.nanmin(
np.abs( np.abs(
stg.time[data_id][0, :] stg.time[file_id][0, :]
- np.nanmin(stg.time[data_id][0, :]) - np.nanmin(stg.time[file_id][0, :])
) )
) )
)[0][0] )[0][0]
tmin_value = np.round( tmin_value = np.round(
np.nanmin(stg.time[data_id][0, :]), 2 np.nanmin(stg.time[file_id][0, :]), 2
) )
stg.tmin[data_id] = (tmin_indice, tmin_value) stg.tmin[file_id] = (tmin_indice, tmin_value)
tmax_indice = np.where( tmax_indice = np.where(
np.abs( np.abs(
stg.time[data_id][0, :] - np.nanmax(stg.time[data_id][0, :]) stg.time[file_id][0, :] - np.nanmax(stg.time[file_id][0, :])
) == np.nanmin( ) == np.nanmin(
np.abs( np.abs(
stg.time[data_id][0, :] stg.time[file_id][0, :]
- np.nanmax(stg.time[data_id][0, :]) - np.nanmax(stg.time[file_id][0, :])
) )
) )
)[0][0] )[0][0]
tmax_value = np.round(np.nanmax(stg.time[data_id][0, :]), 2) tmax_value = np.round(np.nanmax(stg.time[file_id][0, :]), 2)
stg.tmax[data_id] = (tmax_indice + 1, tmax_value) stg.tmax[file_id] = (tmax_indice + 1, tmax_value)
self.set_range_for_time_boundaries_option() self.set_range_for_time_boundaries_option()
def set_range_for_time_boundaries_option(self): def set_range_for_time_boundaries_option(self):
data_id = self.fileListWidget.currentRow()
self.label_time_min.clear() self.label_time_min.clear()
self.label_time_min.setText( self.label_time_min.setText("%.5s" % str(stg.time[self.fileListWidget.currentRow()][0, 0]))
f"{stg.time[data_id][0, 0]:.1f}"
)
self.label_time_max.clear() self.label_time_max.clear()
self.label_time_max.setText( self.label_time_max.setText("%.5s" % str(stg.time[self.fileListWidget.currentRow()][0, -1]))
f"{stg.time[data_id][0, -1]:.1f}"
) if stg.time_cross_section[self.fileListWidget.currentRow()].shape != (0,):
self.lineEdit_time_min_limits.setText("%.5s" % str(stg.time_cross_section[self.fileListWidget.currentRow()][0, 0]))
self.lineEdit_time_max_limits.setText("%.5s" % str(stg.time_cross_section[self.fileListWidget.currentRow()][0, -1]))
if stg.time_cross_section[data_id].shape != (0,):
self.lineEdit_time_min_limits.setText(
f"{stg.time_cross_section[data_id][0, 0]:.1f}"
)
self.lineEdit_time_max_limits.setText(
f"{stg.time_cross_section[data_id][0, -1]:.1f}"
)
else: else:
self.lineEdit_time_min_limits.setText(
f"{stg.time[data_id][0, 0]:.1f}" self.lineEdit_time_min_limits.setText("%.5s" % str(stg.time[self.fileListWidget.currentRow()][0, 0]))
) self.lineEdit_time_max_limits.setText("%.5s" % str(stg.time[self.fileListWidget.currentRow()][0, -1]))
self.lineEdit_time_max_limits.setText(
f"{stg.time[data_id][0, -1]:.1f}"
)
def compute_time_cross_section(self): def compute_time_cross_section(self):
''' tmin and tmax are updated with double slider of time ''' ''' tmin and tmax are updated with double slider of time '''
data_id = max(0, self.fileListWidget.currentRow())
time_min = float(self.lineEdit_time_min_limits.text().replace(",", "."))
time_max = float(self.lineEdit_time_max_limits.text().replace(",", "."))
stg.tmin[data_id] = (( stg.tmin[self.fileListWidget.currentRow()] = ((
np.where( np.where(np.abs(np.round(stg.time[self.fileListWidget.currentRow()][0, :], 2) -
np.abs( float(self.lineEdit_time_min_limits.text().replace(",", "."))) ==
np.round( np.nanmin(np.abs(np.round(stg.time[self.fileListWidget.currentRow()][0, :],
stg.time[data_id][0, :], 2 2) - float(self.lineEdit_time_min_limits.text().replace(",", ".")))))[0][0],
) - time_min float(self.lineEdit_time_min_limits.text().replace(",", "."))
) == np.nanmin(
np.abs(
np.round(
stg.time[data_id][0, :], 2
) - time_min
)
)
)[0][0],
time_min
)) ))
stg.tmax[data_id] = (( stg.tmax[self.fileListWidget.currentRow()] = ((
np.where( np.where(np.abs(np.round(stg.time[self.fileListWidget.currentRow()][0, :], 2) -
np.abs( float(self.lineEdit_time_max_limits.text().replace(",", "."))) ==
np.round( np.nanmin(np.abs(np.round(stg.time[self.fileListWidget.currentRow()][0, :],
stg.time[data_id][0, :], 2) 2) - float(self.lineEdit_time_max_limits.text().replace(",", ".")))))[0][0]+1,
- time_max float(self.lineEdit_time_max_limits.text().replace(",", "."))
) == np.nanmin( ))
np.abs(
np.round(
stg.time[data_id][0, :],2)
- time_max
)
)
)[0][0] + 1,
time_max
))
stg.time_cross_section[data_id] = ( stg.time_cross_section[self.fileListWidget.currentRow()] = (
stg.time[data_id][ stg.time[self.fileListWidget.currentRow()][:, stg.tmin[self.fileListWidget.currentRow()][0]:
:, stg.tmin[data_id][0]: stg.tmax[data_id][0] stg.tmax[self.fileListWidget.currentRow()][0]]
]
) )
def compute_rmin_rmax(self): def compute_rmin_rmax(self):
''' rmin and rmax are filled with min and max of depth when data are uploaded and ''' rmin and rmax are filled with min and max of depth when data are uploaded and
double slider of depth are updated with these values ''' double slider of depth are updated with these values '''
if self.fileListWidget.currentRow() == -1: if self.fileListWidget.currentRow() != -1:
return
data_id = self.fileListWidget.currentRow() # --- rmim / rmax ---
rmin_indice = np.where(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmin(
stg.depth[self.fileListWidget.currentRow()][0, :])) ==
np.nanmin(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmin(
stg.depth[self.fileListWidget.currentRow()][0, :]))))[0][0]
rmin_value = np.round(np.nanmin(stg.depth[self.fileListWidget.currentRow()][0, :]), 2)
stg.rmin[self.fileListWidget.currentRow()] = (rmin_indice, rmin_value)
# --- rmim / rmax --- rmax_indice = np.where(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmax(
rmin_indice = np.where( stg.depth[self.fileListWidget.currentRow()][0, :])) ==
np.abs( np.nanmin(np.abs(stg.depth[self.fileListWidget.currentRow()][0, :] - np.nanmax(
stg.depth[data_id][0, :] - np.nanmin(stg.depth[data_id][0, :]) stg.depth[self.fileListWidget.currentRow()][0, :]))))[0][0]
) == np.nanmin( rmax_value = np.round(np.nanmax(stg.depth[self.fileListWidget.currentRow()][0, :]), 2)
np.abs( stg.rmax[self.fileListWidget.currentRow()] = (rmax_indice + 1, rmax_value)
stg.depth[data_id][0, :]
- np.nanmin(stg.depth[data_id][0, :])
)
)
)[0][0]
rmin_value = np.round(np.nanmin(stg.depth[data_id][0, :]), 2) self.set_range_for_depth_boundaries_option()
stg.rmin[data_id] = (rmin_indice, rmin_value)
rmax_indice = np.where(
np.abs(
stg.depth[data_id][0, :] - np.nanmax(stg.depth[data_id][0, :])
) == np.nanmin(
np.abs(
stg.depth[data_id][0, :]
- np.nanmax(stg.depth[data_id][0, :])
)
)
)[0][0]
rmax_value = np.round(np.nanmax(stg.depth[data_id][0, :]), 2)
stg.rmax[data_id] = (rmax_indice + 1, rmax_value)
self.set_range_for_depth_boundaries_option()
def set_range_for_depth_boundaries_option(self): def set_range_for_depth_boundaries_option(self):
data_id = self.fileListWidget.currentRow()
self.label_depth_min.clear() self.label_depth_min.clear()
self.label_depth_min.setText("-" + str("%.5s" % stg.depth[data_id][0, -1])) self.label_depth_min.setText("-" + str("%.5s" % stg.depth[self.fileListWidget.currentRow()][0, -1]))
self.label_depth_max.clear() self.label_depth_max.clear()
self.label_depth_max.setText("-" + str("%.5s" % stg.depth[data_id][0, 0])) self.label_depth_max.setText("-" + str("%.5s" % stg.depth[self.fileListWidget.currentRow()][0, 0]))
if stg.depth_cross_section[self.fileListWidget.currentRow()].shape != (0,):
self.lineEdit_depth_min_limits.setText("-" + str("%.5s" % stg.depth_cross_section[self.fileListWidget.currentRow()][0, -1]))
self.lineEdit_depth_max_limits.setText("-" + str("%.5s" % stg.depth_cross_section[self.fileListWidget.currentRow()][0, 0]))
if stg.depth_cross_section[data_id].shape != (0,):
self.lineEdit_depth_min_limits.setText(
"-" + str("%.5s" % stg.depth_cross_section[data_id][0, -1])
)
self.lineEdit_depth_max_limits.setText(
"-" + str("%.5s" % stg.depth_cross_section[data_id][0, 0])
)
else: else:
self.lineEdit_depth_min_limits.setText(
"-" + str("%.5s" % stg.depth[data_id][0, -1]) self.lineEdit_depth_min_limits.setText("-" + str("%.5s" % stg.depth[self.fileListWidget.currentRow()][0, -1]))
) self.lineEdit_depth_max_limits.setText("-" + str("%.5s" % stg.depth[self.fileListWidget.currentRow()][0, 0]))
self.lineEdit_depth_max_limits.setText(
"-" + str("%.5s" % stg.depth[data_id][0, 0])
)
def compute_depth_cross_section(self): def compute_depth_cross_section(self):
''' rmin and rmax are updated with double slider of depth ''' ''' rmin and rmax are updated with double slider of depth '''
data_id = self.fileListWidget.currentRow()
stg.rmin[data_id] = (( stg.rmin[self.fileListWidget.currentRow()] = ((
np.where( np.where(np.abs(np.round(stg.depth[self.fileListWidget.currentRow()][0, :], 2) -
np.abs( float("".join(findall("[.0-9]", self.lineEdit_depth_max_limits.text())))) ==
np.round( np.nanmin(np.abs(np.round(stg.depth[self.fileListWidget.currentRow()][0, :],
stg.depth[data_id][0, :], 2 2) - (float("".join(findall("[.0-9]", self.lineEdit_depth_max_limits.text()))))
) - float( )))[0][0]+1,
"".join( float("".join(findall("[.0-9]", self.lineEdit_depth_max_limits.text())))
findall(
"[.0-9]",
self.lineEdit_depth_max_limits.text()
)
)
)
) == np.nanmin(
np.abs(
np.round(stg.depth[data_id][0, :], 2)
- float(
"".join(
findall(
"[.0-9]",
self.lineEdit_depth_max_limits.text()
)
)
)
)
)
)[0][0]+1,
float(
"".join(
findall(
"[.0-9]",
self.lineEdit_depth_max_limits.text()
)
)
)
)) ))
stg.rmax[data_id] = (( stg.rmax[self.fileListWidget.currentRow()] = ((
np.where( np.where(np.abs(np.round(stg.depth[self.fileListWidget.currentRow()][0, :], 2) -
np.abs( float("".join(findall("[.0-9]", self.lineEdit_depth_min_limits.text())))) ==
np.round( np.nanmin(np.abs(np.round(stg.depth[self.fileListWidget.currentRow()][0, :],
stg.depth[data_id][0, :], 2 2) - (float("".join(findall("[.0-9]", self.lineEdit_depth_min_limits.text()))))
) - float( )))[0][0],
"".join( float("".join(findall("[.0-9]", self.lineEdit_depth_min_limits.text())))
findall(
"[.0-9]",
self.lineEdit_depth_min_limits.text()
)
)
)
) == np.nanmin(
np.abs(
np.round(stg.depth[data_id][0, :], 2)
- float(
"".join(
findall(
"[.0-9]",
self.lineEdit_depth_min_limits.text()
)
)
)
)
)
)[0][0],
float(
"".join(
findall(
"[.0-9]",
self.lineEdit_depth_min_limits.text()
)
)
)
)) ))
stg.depth_cross_section[data_id] = (
stg.depth[data_id][:, stg.depth_cross_section[self.fileListWidget.currentRow()] = (
stg.rmin[data_id][0]:stg.rmax[data_id][0]] stg.depth[self.fileListWidget.currentRow()][:,
stg.rmin[self.fileListWidget.currentRow()][0]:stg.rmax[self.fileListWidget.currentRow()][0]]
) )
def compute_BS_cross_section(self): def compute_BS_cross_section(self):
if self.fileListWidget.currentRow() == -1: if self.fileListWidget.currentRow() != -1:
return
data_id = self.fileListWidget.currentRow() self.compute_depth_cross_section()
self.compute_time_cross_section()
self.compute_depth_cross_section() stg.BS_cross_section[self.fileListWidget.currentRow()] = (
self.compute_time_cross_section() stg.BS_raw_data[self.fileListWidget.currentRow()]
[:, stg.rmin[self.fileListWidget.currentRow()][0]:stg.rmax[self.fileListWidget.currentRow()][0],
stg.BS_cross_section[data_id] = ( stg.tmin[self.fileListWidget.currentRow()][0]:stg.tmax[self.fileListWidget.currentRow()][0]])
stg.BS_raw_data[data_id][
:,
stg.rmin[data_id][0]:stg.rmax[data_id][0],
stg.tmin[data_id][0]:stg.tmax[data_id][0]
]
)
def update_frequency_combobox(self): def update_frequency_combobox(self):
data_id = self.fileListWidget.currentRow() if self.fileListWidget.currentRow() != -1:
self.combobox_frequency_bathymetry.clear()
if data_id == -1: self.combobox_frequency_bathymetry.addItems([f for f in stg.freq_text[self.fileListWidget.currentRow()]])
return self.combobox_frequency_profile.clear()
self.combobox_frequency_profile.addItems([f for f in stg.freq_text[self.fileListWidget.currentRow()]])
self.combobox_frequency_bathymetry.clear()
self.combobox_frequency_bathymetry.addItems(
[f for f in stg.freq_text[data_id]]
)
self.combobox_frequency_profile.clear()
self.combobox_frequency_profile.addItems(
[f for f in stg.freq_text[data_id]]
)
def set_range_for_doubleRangeSlider_intg_area(self): def set_range_for_doubleRangeSlider_intg_area(self):
if self.fileListWidget.currentRow() == -1: if self.fileListWidget.currentRow() != -1:
return
data_id = self.fileListWidget.currentRow() if stg.depth_cross_section[self.fileListWidget.currentRow()].shape == (0,):
self.doubleRangeSlider_intg_area.setRange(
min=-stg.depth[self.fileListWidget.currentRow()][0, -1],
max=-stg.depth[self.fileListWidget.currentRow()][0, 0])
if stg.depth_cross_section[data_id].shape == (0,): self.doubleRangeSlider_intg_area.setValue(
self.doubleRangeSlider_intg_area.setRange( value=(-stg.depth[self.fileListWidget.currentRow()][0, -1],
min=-stg.depth[data_id][0, -1], -stg.depth[self.fileListWidget.currentRow()][0, 0]))
max=-stg.depth[data_id][0, 0]
)
self.doubleRangeSlider_intg_area.setValue( else:
value=(
-stg.depth[data_id][0, -1],
-stg.depth[data_id][0, 0]
)
)
else:
self.doubleRangeSlider_intg_area.setRange(
min=-stg.depth_cross_section[data_id][0, -1],
max=-stg.depth_cross_section[data_id][0, 0]
)
self.doubleRangeSlider_intg_area.setValue( self.doubleRangeSlider_intg_area.setRange(
value=( min=-stg.depth_cross_section[self.fileListWidget.currentRow()][0, -1],
-stg.depth_cross_section[data_id][0, -1], max=-stg.depth_cross_section[self.fileListWidget.currentRow()][0, 0])
-stg.depth_cross_section[data_id][0, 0]
) self.doubleRangeSlider_intg_area.setValue(
) value=(-stg.depth_cross_section[self.fileListWidget.currentRow()][0, -1],
-stg.depth_cross_section[self.fileListWidget.currentRow()][0, 0]))
def set_range_for_spinboxes_bathymetry(self): def set_range_for_spinboxes_bathymetry(self):
if self.fileListWidget.currentRow() == -1: if self.fileListWidget.currentRow() != -1:
return
data_id = self.fileListWidget.currentRow() if stg.depth_cross_section[self.fileListWidget.currentRow()].shape != (0,):
if stg.depth_cross_section[data_id].shape != (0,): # self.spinbox_depth_min_bathy.setValue(stg.depth_cross_section[self.fileListWidget.currentRow()][0, 0])
self.lineEdit_depth_min_bathy.setText( self.lineEdit_depth_min_bathy.setText(
"-" + str("%.5s" % stg.depth_cross_section[data_id][0, -1]) "-" + str("%.5s" % stg.depth_cross_section[self.fileListWidget.currentRow()][0, -1]))
) # self.spinbox_depth_max_bathy.setValue(stg.depth_cross_section[self.fileListWidget.currentRow()][0, -1])
self.lineEdit_depth_max_bathy.setText( self.lineEdit_depth_max_bathy.setText(
"-" + str("%.5s" % stg.depth_cross_section[data_id][0, 0]) "-" + str("%.5s" % stg.depth_cross_section[self.fileListWidget.currentRow()][0, 0]))
)
else: else:
self.lineEdit_depth_min_bathy.setText(
"-" + str("%.5s" % stg.depth[data_id][0, -1]) self.lineEdit_depth_min_bathy.setText(
) "-" + str("%.5s" % stg.depth[self.fileListWidget.currentRow()][0, -1]))
self.lineEdit_depth_max_bathy.setText( self.lineEdit_depth_max_bathy.setText(
"-" + str("%.5s" % stg.depth[data_id][0, 0]) "-" + str("%.5s" % stg.depth[self.fileListWidget.currentRow()][0, 0]))
)
def plot_backscattered_acoustic_signal_recording(self): def plot_backscattered_acoustic_signal_recording(self):
if self.fileListWidget.count() <= 0: if self.fileListWidget.count() <= 0:
@ -2600,7 +2466,7 @@ class AcousticDataTab(QWidget):
msgBox.exec() msgBox.exec()
return return
data_id = max(0, self.fileListWidget.currentRow()) data_id = self.fileListWidget.currentRow()
if data_id == -1: if data_id == -1:
return return
@ -2890,6 +2756,8 @@ class AcousticDataTab(QWidget):
float(self.lineEdit_slider.text().replace(",", ".")))))[0][0])) float(self.lineEdit_slider.text().replace(",", ".")))))[0][0]))
def update_lineEdit_by_moving_slider(self): def update_lineEdit_by_moving_slider(self):
print("min ", np.nanmin(stg.time[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex()]))
print("max ", np.nanmax(stg.time[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex()]))
if stg.time_cross_section[self.fileListWidget.currentRow()].shape != (0,): if stg.time_cross_section[self.fileListWidget.currentRow()].shape != (0,):
self.lineEdit_slider.setText( self.lineEdit_slider.setText(
str(stg.time_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), self.slider.value()-1])) str(stg.time_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), self.slider.value()-1]))
@ -2947,7 +2815,7 @@ class AcousticDataTab(QWidget):
self.detect_bottom_compute() self.detect_bottom_compute()
def detect_bottom_compute(self): def detect_bottom_compute(self):
data_id = max(0, self.fileListWidget.currentRow()) data_id = self.fileListWidget.currentRow()
freq_id = self.combobox_frequency_bathymetry.currentIndex() freq_id = self.combobox_frequency_bathymetry.currentIndex()
freq_text = self.combobox_frequency_bathymetry.currentText() freq_text = self.combobox_frequency_bathymetry.currentText()
@ -3082,7 +2950,7 @@ class AcousticDataTab(QWidget):
def detect_bottom_compute_plot_BS_with_bathymetry( def detect_bottom_compute_plot_BS_with_bathymetry(
self, BS_data, time_data, depth_data self, BS_data, time_data, depth_data
): ):
data_id = max(0, self.fileListWidget.currentRow()) data_id = self.fileListWidget.currentRow()
freq_id = self.combobox_frequency_bathymetry.currentIndex() freq_id = self.combobox_frequency_bathymetry.currentIndex()
for f, _ in enumerate(stg.freq[data_id]): for f, _ in enumerate(stg.freq[data_id]):

View File

@ -431,13 +431,11 @@ class SignalProcessingTab(QWidget):
self.widget_scrollArea_list_preprocessed_data.setLayout(self.verticalLayout_scrollArea_list_pre_processed_data) self.widget_scrollArea_list_preprocessed_data.setLayout(self.verticalLayout_scrollArea_list_pre_processed_data)
# Add content to the widget (labels in this example) # Add content to the widget (labels in this example)
self.lineEdit_list_pre_processed_data = []
for i in range(20): for i in range(20):
self.lineEdit_list_pre_processed_data.append(QLineEdit()) exec("self.lineEdit_list_pre_processed_data_" + str(i) + "= QLineEdit()")
self.verticalLayout_scrollArea_list_pre_processed_data.addWidget( eval("self.verticalLayout_scrollArea_list_pre_processed_data.addWidget("
self.lineEdit_list_pre_processed_data[i] "self.lineEdit_list_pre_processed_data_" + str(i) + ")")
) eval("self.lineEdit_list_pre_processed_data_" + str(i) + ".setDisabled(True)")
self.lineEdit_list_pre_processed_data[i].setDisabled(True)
# Set the widget as the scroll area's widget # Set the widget as the scroll area's widget
@ -533,7 +531,7 @@ class SignalProcessingTab(QWidget):
self.blockSignals(False) self.blockSignals(False)
def full_update_fill_text(self): def full_update_fill_text(self):
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex()) data_id = self.combobox_acoustic_data_choice.currentIndex()
self.lineEdit_profile_tail_value.setText( self.lineEdit_profile_tail_value.setText(
str(stg.noise_value[data_id]) str(stg.noise_value[data_id])
@ -561,7 +559,7 @@ class SignalProcessingTab(QWidget):
msgBox.setStandardButtons(QMessageBox.Ok) msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec() msgBox.exec()
else: else:
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex()) data_id = self.combobox_acoustic_data_choice.currentIndex()
self.combobox_acoustic_data_choice.blockSignals(True) self.combobox_acoustic_data_choice.blockSignals(True)
self.combobox_freq_noise_from_profile_tail.blockSignals(True) self.combobox_freq_noise_from_profile_tail.blockSignals(True)
@ -594,7 +592,7 @@ class SignalProcessingTab(QWidget):
self.combobox_acoustic_data_choice.blockSignals(False) self.combobox_acoustic_data_choice.blockSignals(False)
def _is_correct_shape(self, data): def _is_correct_shape(self, data):
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex()) data_id = self.combobox_acoustic_data_choice.currentIndex()
if stg.time_cross_section[data_id].shape != (0,): if stg.time_cross_section[data_id].shape != (0,):
x_time = stg.time_cross_section[data_id] x_time = stg.time_cross_section[data_id]
@ -621,7 +619,7 @@ class SignalProcessingTab(QWidget):
return (y == depth_shape and z == time_shape) return (y == depth_shape and z == time_shape)
def recompute(self): def recompute(self):
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex()) data_id = self.combobox_acoustic_data_choice.currentIndex()
self.compute_average_profile_tail() self.compute_average_profile_tail()
@ -641,21 +639,19 @@ class SignalProcessingTab(QWidget):
self.plot_pre_processed_profile() self.plot_pre_processed_profile()
def activate_list_of_pre_processed_data(self): def activate_list_of_pre_processed_data(self):
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
for i in range(self.combobox_acoustic_data_choice.count()): for i in range(self.combobox_acoustic_data_choice.count()):
self.lineEdit_list_pre_processed_data[i].setDisabled(True) eval("self.lineEdit_list_pre_processed_data_" + str(i) + ".setDisabled(True)")
eval("self.lineEdit_list_pre_processed_data_" + str(
self.combobox_acoustic_data_choice.currentIndex()) + ".setEnabled(True)")
eval("self.lineEdit_list_pre_processed_data_" + str(
self.combobox_acoustic_data_choice.currentIndex()) + ".returnPressed.connect(self.rename_preprocessed_data)")
self.lineEdit_list_pre_processed_data[data_id].setEnabled(True) eval("self.lineEdit_list_pre_processed_data_" + str(self.combobox_acoustic_data_choice.currentIndex()) +
self.lineEdit_list_pre_processed_data[data_id]\ ".setText(stg.filename_BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()])")
.returnPressed.connect(self.rename_preprocessed_data)
self.lineEdit_list_pre_processed_data[data_id]\
.setText(stg.filename_BS_raw_data[data_id])
def rename_preprocessed_data(self): def rename_preprocessed_data(self):
stg.data_preprocessed[data_id] = \ exec("stg.data_preprocessed[self.combobox_acoustic_data_choice.currentIndex()] = "
self.lineEdit_list_pre_processed_data[data_id].text() "self.lineEdit_list_pre_processed_data_" + str(self.combobox_acoustic_data_choice.currentIndex()) + ".text()")
# ------------------------------------------------------ # ------------------------------------------------------
@ -707,7 +703,7 @@ class SignalProcessingTab(QWidget):
# ------------------------------------------------------ # ------------------------------------------------------
def compute_average_profile_tail(self): def compute_average_profile_tail(self):
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex()) data_id = self.combobox_acoustic_data_choice.currentIndex()
freq_noise_id = self.combobox_freq_noise_from_profile_tail.currentIndex() freq_noise_id = self.combobox_freq_noise_from_profile_tail.currentIndex()
if ((float(self.lineEdit_val1.text()) == 0) if ((float(self.lineEdit_val1.text()) == 0)
@ -794,7 +790,7 @@ class SignalProcessingTab(QWidget):
msgBox.exec() msgBox.exec()
else: else:
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex()) data_id = self.combobox_acoustic_data_choice.currentIndex()
freq_noise_id = self.combobox_freq_noise_from_profile_tail.currentIndex() freq_noise_id = self.combobox_freq_noise_from_profile_tail.currentIndex()
if stg.BS_mean[data_id].shape == (0,): if stg.BS_mean[data_id].shape == (0,):
@ -855,35 +851,35 @@ class SignalProcessingTab(QWidget):
# ------------------------------------------------------ # ------------------------------------------------------
def combobox_acoustic_data_choice_change_index(self): def combobox_acoustic_data_choice_change_index(self):
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex())
self.combobox_frequency_profile.blockSignals(True) self.combobox_frequency_profile.blockSignals(True)
self.compute_average_profile_tail() self.compute_average_profile_tail()
logger.debug(f"stg.SNR_filter_value: {stg.SNR_filter_value}")
self.lineEdit_SNR_criterion.setText( self.lineEdit_SNR_criterion.setText(
str(stg.SNR_filter_value[data_id]) str(stg.SNR_filter_value[
self.combobox_acoustic_data_choice.currentIndex()
])
) )
self.lineEdit_horizontal_average.setText( self.lineEdit_horizontal_average.setText(
str(stg.Nb_cells_to_average_BS_signal[data_id]) str(stg.Nb_cells_to_average_BS_signal[
self.combobox_acoustic_data_choice.currentIndex()
])
) )
self.combobox_frequency_profile.clear() self.combobox_frequency_profile.clear()
self.combobox_frequency_profile.addItems( self.combobox_frequency_profile.addItems(
[f for f in stg.freq_text[data_id]] [f for f in stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()]])
)
self.recompute()
self.replot() self.replot()
if self.combobox_acoustic_data_choice.count() > 0: if self.combobox_acoustic_data_choice.count() > 0:
for i in range(self.combobox_acoustic_data_choice.count()):
self.lineEdit_list_pre_processed_data[i].setDisabled(True)
self.lineEdit_list_pre_processed_data[data_id].setEnabled(True) for i in range(self.combobox_acoustic_data_choice.count()):
eval("self.lineEdit_list_pre_processed_data_" + str(i) + ".setDisabled(True)")
#
eval("self.lineEdit_list_pre_processed_data_" + str(
self.combobox_acoustic_data_choice.currentIndex()) + ".setEnabled(True)")
self.combobox_frequency_profile.blockSignals(False) self.combobox_frequency_profile.blockSignals(False)
@ -891,7 +887,7 @@ class SignalProcessingTab(QWidget):
if len(stg.filename_BS_raw_data) == 0: if len(stg.filename_BS_raw_data) == 0:
pass pass
else: else:
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex()) data_id = self.combobox_acoustic_data_choice.currentIndex()
stg.BS_noise_raw_data[data_id] = np.array([]) stg.BS_noise_raw_data[data_id] = np.array([])
stg.BS_noise_averaged_data[data_id] = np.array([]) stg.BS_noise_averaged_data[data_id] = np.array([])
@ -1030,7 +1026,7 @@ class SignalProcessingTab(QWidget):
def load_noise_data_and_compute_SNR(self): def load_noise_data_and_compute_SNR(self):
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex()) data_id = self.combobox_acoustic_data_choice.currentIndex()
stg.noise_method[data_id] = 0 stg.noise_method[data_id] = 0
@ -1084,7 +1080,7 @@ class SignalProcessingTab(QWidget):
pnw.exec() pnw.exec()
def compute_noise_from_profile_tail_value(self): def compute_noise_from_profile_tail_value(self):
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex()) data_id = self.combobox_acoustic_data_choice.currentIndex()
stg.noise_method[data_id] = 1 stg.noise_method[data_id] = 1
stg.noise_value[data_id] = ( stg.noise_value[data_id] = (
@ -1137,6 +1133,7 @@ class SignalProcessingTab(QWidget):
stg.BS_noise_raw_data[data_id] ** 2)) # stg.BS_noise_raw_data[data_id] ** 2)) #
else: else:
stg.BS_noise_raw_data[data_id] = ( stg.BS_noise_raw_data[data_id] = (
np.full(stg.BS_raw_data[data_id].shape, np.full(stg.BS_raw_data[data_id].shape,
float(self.lineEdit_profile_tail_value.text().replace(",", ".")))) float(self.lineEdit_profile_tail_value.text().replace(",", "."))))
@ -1215,7 +1212,7 @@ class SignalProcessingTab(QWidget):
# elif self.canvas_SNR == None: # elif self.canvas_SNR == None:
else: else:
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex()) data_id = self.combobox_acoustic_data_choice.currentIndex()
if ((data_id != -1) if ((data_id != -1)
and (stg.BS_noise_raw_data[data_id].shape != (0,))): and (stg.BS_noise_raw_data[data_id].shape != (0,))):
@ -1344,7 +1341,7 @@ class SignalProcessingTab(QWidget):
msgBox.exec() msgBox.exec()
else: else:
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex()) data_id = self.combobox_acoustic_data_choice.currentIndex()
stg.SNR_filter_value[data_id] = ( stg.SNR_filter_value[data_id] = (
float(self.lineEdit_SNR_criterion.text().replace(",", "."))) float(self.lineEdit_SNR_criterion.text().replace(",", ".")))
@ -1391,7 +1388,7 @@ class SignalProcessingTab(QWidget):
self.compute_averaged_BS_data() self.compute_averaged_BS_data()
def plot_pre_processed_BS_signal(self): def plot_pre_processed_BS_signal(self):
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex()) data_id = self.combobox_acoustic_data_choice.currentIndex()
self.lineEdit_horizontal_average.setText( self.lineEdit_horizontal_average.setText(
str(stg.Nb_cells_to_average_BS_signal[data_id]) str(stg.Nb_cells_to_average_BS_signal[data_id])
@ -1520,18 +1517,16 @@ class SignalProcessingTab(QWidget):
.addWidget(self.scroll_BS) .addWidget(self.scroll_BS)
def update_label_cells_sec(self): def update_label_cells_sec(self):
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex()) print("Je change la valeur du moyennage")
print(stg.nb_profiles_per_sec)
print(stg.nb_profiles_per_sec[self.combobox_acoustic_data_choice.currentIndex()][0])
print(self.combobox_acoustic_data_choice.currentIndex())
self.label_cells_horizontal.clear() self.label_cells_horizontal.clear()
self.label_cells_horizontal.setText( self.label_cells_horizontal.setText(
"cells = +/- " "cells = +/- " +
+ str( str((float(self.lineEdit_horizontal_average.text().replace(",", ".")) // 2) *
(float( (1 / stg.nb_profiles_per_sec[self.combobox_acoustic_data_choice.currentIndex()][0])) +
self.lineEdit_horizontal_average.text().replace(",", ".") " sec")
) // 2)
* (1 / stg.nb_profiles_per_sec[data_id][0])
) + " sec"
)
def compute_averaged_BS_data(self): def compute_averaged_BS_data(self):
if len(stg.filename_BS_raw_data) == 0: if len(stg.filename_BS_raw_data) == 0:
@ -1549,7 +1544,7 @@ class SignalProcessingTab(QWidget):
msgBox.setStandardButtons(QMessageBox.Ok) msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec() msgBox.exec()
else: else:
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex()) data_id = self.combobox_acoustic_data_choice.currentIndex()
n_average = 2 * int(float(self.lineEdit_horizontal_average.text().replace(",", "."))) + 1 n_average = 2 * int(float(self.lineEdit_horizontal_average.text().replace(",", "."))) + 1
kernel_avg = np.ones(n_average) kernel_avg = np.ones(n_average)
logger.debug(f"kernel_avg: {kernel_avg}") logger.debug(f"kernel_avg: {kernel_avg}")
@ -1633,7 +1628,7 @@ class SignalProcessingTab(QWidget):
) )
def plot_pre_processed_profile(self): def plot_pre_processed_profile(self):
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex()) data_id = self.combobox_acoustic_data_choice.currentIndex()
if ((data_id != -1) and if ((data_id != -1) and
(stg.BS_noise_raw_data[data_id].shape != (0,))): (stg.BS_noise_raw_data[data_id].shape != (0,))):
@ -1865,7 +1860,7 @@ class SignalProcessingTab(QWidget):
self.slider.setMaximum(10) self.slider.setMaximum(10)
def update_plot_pre_processed_profile(self): def update_plot_pre_processed_profile(self):
data_id = max(0, self.combobox_acoustic_data_choice.currentIndex()) data_id = self.combobox_acoustic_data_choice.currentIndex()
if ((data_id != -1) and if ((data_id != -1) and
(stg.BS_noise_raw_data[data_id].shape != (0,))): (stg.BS_noise_raw_data[data_id].shape != (0,))):