Inversion: Some refactoring.

dev
Pierre-Antoine 2025-04-16 10:57:30 +02:00
parent 6256ddd1d7
commit 9260797c8f
1 changed files with 279 additions and 283 deletions

View File

@ -450,17 +450,20 @@ class AcousticInversionTab(QWidget):
logger.debug(f"{__name__}: Update") logger.debug(f"{__name__}: Update")
self.blockSignals(True) self.blockSignals(True)
self.update_acoustic_data_choice()
# TODO: Update all widgets # TODO: Update all widgets
self.blockSignals(False) self.blockSignals(False)
def update_acoustic_data_choice(self): def update_acoustic_data_choice(self):
self.combobox_acoustic_data_choice.clear() self.combobox_acoustic_data_choice.clear()
for i in range(len(stg.filename_BS_raw_data)): for i in range(len(stg.filename_BS_raw_data)):
self.combobox_acoustic_data_choice.addItem(stg.data_preprocessed[i]) self.combobox_acoustic_data_choice.addItem(stg.data_preprocessed[i])
self.combobox_acoustic_data_choice.currentIndexChanged.connect(self.combobox_acoustic_data_choice_currentIndexChanged) self.combobox_acoustic_data_choice\
.currentIndexChanged\
.connect(self.combobox_acoustic_data_choice_currentIndexChanged)
def combobox_acoustic_data_choice_currentIndexChanged(self): def combobox_acoustic_data_choice_currentIndexChanged(self):
self.fill_combobox_fine_sample() self.fill_combobox_fine_sample()
@ -475,27 +478,28 @@ class AcousticInversionTab(QWidget):
def function_run_inversion(self): def function_run_inversion(self):
if (stg.alpha_s[0] < 0) or (stg.alpha_s[1] < 0): if (stg.alpha_s[0] < 0) or (stg.alpha_s[1] < 0):
msgBox = QMessageBox() msgBox = QMessageBox()
msgBox.setWindowTitle("Alpha computation error") msgBox.setWindowTitle("Alpha computation error")
msgBox.setIconPixmap( msgBox.setIconPixmap(
QPixmap(self.path_icon + "no_approved.png").scaledToHeight(32, Qt.SmoothTransformation)) QPixmap(
self.path_icon + "no_approved.png"
).scaledToHeight(32, Qt.SmoothTransformation)
)
msgBox.setText("Sediment sound attenuation is negative !") msgBox.setText("Sediment sound attenuation is negative !")
msgBox.setStandardButtons(QMessageBox.Ok) msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec() msgBox.exec()
elif isinf(stg.alpha_s[0]) or isinf(stg.alpha_s[1]): elif isinf(stg.alpha_s[0]) or isinf(stg.alpha_s[1]):
msgBox = QMessageBox() msgBox = QMessageBox()
msgBox.setWindowTitle("Alpha computation error") msgBox.setWindowTitle("Alpha computation error")
msgBox.setIconPixmap( msgBox.setIconPixmap(
QPixmap(self.path_icon + "no_approved.png").scaledToHeight(32, Qt.SmoothTransformation)) QPixmap(
self.path_icon + "no_approved.png"
).scaledToHeight(32, Qt.SmoothTransformation)
)
msgBox.setText("Sediment sound attenuation is infinite !") msgBox.setText("Sediment sound attenuation is infinite !")
msgBox.setStandardButtons(QMessageBox.Ok) msgBox.setStandardButtons(QMessageBox.Ok)
msgBox.exec() msgBox.exec()
else: else:
self.compute_VBI() self.compute_VBI()
self.compute_SSC_fine() self.compute_SSC_fine()
self.compute_SSC_sand() self.compute_SSC_sand()
@ -530,39 +534,56 @@ class AcousticInversionTab(QWidget):
) )
def compute_SSC_fine(self): def compute_SSC_fine(self):
stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()] = np.array([]) stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()] = np.array([])
stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()] = self.inv_hc.SSC_fine( stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()] = self.inv_hc.SSC_fine(
zeta=stg.zeta[1], zeta=stg.zeta[1],
r2D=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][ r2D=stg.depth_2D[
stg.frequency_for_inversion[1]], self.combobox_acoustic_data_choice.currentIndex()
VBI=stg.VBI_cross_section[self.combobox_acoustic_data_choice.currentIndex()], ][
stg.frequency_for_inversion[1]
],
VBI=stg.VBI_cross_section[
self.combobox_acoustic_data_choice.currentIndex()
],
freq=stg.frequencies_for_calibration[1][0], freq=stg.frequencies_for_calibration[1][0],
X=stg.X_exponent[0], X=stg.X_exponent[0],
j_cross_section=stg.J_cross_section[self.combobox_acoustic_data_choice.currentIndex()][1], j_cross_section=stg.J_cross_section[
alpha_w=np.full(shape=stg.depth_2D[self.combobox_acoustic_data_choice.currentIndex()][ self.combobox_acoustic_data_choice.currentIndex()
stg.frequency_for_inversion[1]].shape, ][1],
fill_value=stg.water_attenuation[self.combobox_acoustic_data_choice.currentIndex()][ alpha_w=np.full(
stg.frequency_for_inversion[1]]) shape=stg.depth_2D[
self.combobox_acoustic_data_choice.currentIndex()
][
stg.frequency_for_inversion[1]
].shape,
fill_value=stg.water_attenuation[
self.combobox_acoustic_data_choice.currentIndex()
][
stg.frequency_for_inversion[1]
]
)
) )
def compute_SSC_sand(self): def compute_SSC_sand(self):
data_id = self.combobox_acoustic_data_choice.currentIndex()
stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()] = np.array([]) stg.SSC_sand[data_id] = np.array([])
stg.SSC_sand[self.combobox_acoustic_data_choice.currentIndex()] = self.inv_hc.SSC_sand( stg.SSC_sand[data_id] = self.inv_hc.SSC_sand(
VBI=stg.VBI_cross_section[self.combobox_acoustic_data_choice.currentIndex()], VBI=stg.VBI_cross_section[data_id],
freq=stg.frequencies_for_calibration[1][0], freq=stg.frequencies_for_calibration[1][0],
X=stg.X_exponent, X=stg.X_exponent,
ks=stg.ks[1]) ks=stg.ks[1]
)
def plot_SSC_fine(self): def plot_SSC_fine(self):
data_id = self.combobox_acoustic_data_choice.currentIndex()
if self.combobox_acoustic_data_choice.count() > 0: if self.combobox_acoustic_data_choice.count() <= 0:
return
if stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape == (0,):
if stg.SSC_fine[data_id].shape == (0,):
self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.toolbar_SSC_fine) self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.toolbar_SSC_fine)
self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.canvas_SSC_fine) self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.canvas_SSC_fine)
@ -572,73 +593,55 @@ class AcousticInversionTab(QWidget):
self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.toolbar_SSC_fine) self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.toolbar_SSC_fine)
self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.canvas_SSC_fine) self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.canvas_SSC_fine)
elif stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): elif stg.SSC_fine[data_id].shape != (0,):
self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.toolbar_SSC_fine) self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.toolbar_SSC_fine)
self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.canvas_SSC_fine) self.verticalLayout_groupbox_plot_SSC_fine.removeWidget(self.canvas_SSC_fine)
self.figure_SSC_fine, self.axis_SSC_fine = plt.subplots(nrows=1, ncols=1, layout="constrained") self.figure_SSC_fine, self.axis_SSC_fine = plt.subplots(
nrows=1, ncols=1, layout="constrained"
)
self.canvas_SSC_fine = FigureCanvas(self.figure_SSC_fine) self.canvas_SSC_fine = FigureCanvas(self.figure_SSC_fine)
self.toolbar_SSC_fine = NavigationToolBar(self.canvas_SSC_fine, self) self.toolbar_SSC_fine = NavigationToolBar(self.canvas_SSC_fine, self)
self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.toolbar_SSC_fine) self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.toolbar_SSC_fine)
self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.canvas_SSC_fine) self.verticalLayout_groupbox_plot_SSC_fine.addWidget(self.canvas_SSC_fine)
val_min = np.nanmin(stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()]) val_min = np.nanmin(stg.SSC_fine[data_id])
val_max = np.nanmax(stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()]) val_max = np.nanmax(stg.SSC_fine[data_id])
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
pcm_SSC_fine = self.axis_SSC_fine.pcolormesh(
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()],
cmap='rainbow', norm=LogNorm(vmin=1e0, vmax=15), shading='gouraud')
if stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_SSC_fine.plot(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
-stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()],
color='black', linewidth=1, linestyle="solid")
self.pcm_SSC_fine_vertical_line, = self.axis_SSC_fine.plot(
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1],
self.slider_fine.value() - 1] *
np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]].shape),
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
linestyle="solid", color='r', linewidth=2)
if stg.time_cross_section[data_id].shape != (0,):
time_data = stg.time_cross_section
depth_data = stg.depth_cross_section
else: else:
time_data = stg.time
depth_data = stg.depth
pcm_SSC_fine = self.axis_SSC_fine.pcolormesh( pcm_SSC_fine = self.axis_SSC_fine.pcolormesh(
stg.time[self.combobox_acoustic_data_choice.currentIndex()][ time_data[data_id][stg.frequency_for_inversion[1]],
stg.frequency_for_inversion[1]], -depth_data[data_id][stg.frequency_for_inversion[1]],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ stg.SSC_fine[data_id],
stg.frequency_for_inversion[1]], cmap='rainbow', norm=LogNorm(vmin=1e0, vmax=15),
stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()], shading='gouraud'
cmap='rainbow', norm=LogNorm(vmin=1e0, vmax=15), shading='gouraud') )
if stg.depth_bottom[data_id].shape != (0,):
self.axis_SSC_fine.plot(
time_data[data_id][stg.frequency_for_inversion[1]],
-stg.depth_bottom[data_id],
color='black', linewidth=1, linestyle="solid"
)
self.pcm_SSC_fine_vertical_line, = self.axis_SSC_fine.plot( self.pcm_SSC_fine_vertical_line, = self.axis_SSC_fine.plot(
stg.time[self.combobox_acoustic_data_choice.currentIndex()][ time_data[data_id][stg.frequency_for_inversion[1],
stg.frequency_for_inversion[1], self.slider_fine.value() - 1]
self.slider_fine.value() - 1] * * np.ones(
np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ depth_data[data_id][
stg.frequency_for_inversion[ stg.frequency_for_inversion[1]
1]].shape), ].shape
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ ),
stg.frequency_for_inversion[1]], -depth_data[data_id][stg.frequency_for_inversion[1]],
linestyle="solid", color='r', linewidth=2) linestyle="solid", color='r', linewidth=2
)
if stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
self.axis_SSC_fine.plot(stg.time[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
-stg.depth_bottom[self.combobox_acoustic_data_choice.currentIndex()],
color='black', linewidth=1, linestyle="solid")
# --- Plot samples of fine sediments --- # --- Plot samples of fine sediments ---
time_fine_temp = deepcopy(stg.time_fine) time_fine_temp = deepcopy(stg.time_fine)
@ -646,8 +649,11 @@ class AcousticInversionTab(QWidget):
for s in stg.fine_sample_profile: for s in stg.fine_sample_profile:
time_fine_temp.remove(stg.time_fine[s[1]]) time_fine_temp.remove(stg.time_fine[s[1]])
depth_fine_temp.remove(stg.depth_fine[s[1]]) depth_fine_temp.remove(stg.depth_fine[s[1]])
self.pcm_SSC_fine_meas_vs_inv, = self.axis_SSC_fine.plot( self.pcm_SSC_fine_meas_vs_inv, = self.axis_SSC_fine.plot(
time_fine_temp, depth_fine_temp, ls=" ", marker="o", ms=5, mec="k", mfc="k") time_fine_temp, depth_fine_temp,
ls=" ", marker="o", ms=5, mec="k", mfc="k"
)
time_fine_temp = deepcopy(stg.time_fine) time_fine_temp = deepcopy(stg.time_fine)
depth_fine_temp = deepcopy(stg.depth_fine) depth_fine_temp = deepcopy(stg.depth_fine)
@ -659,21 +665,27 @@ class AcousticInversionTab(QWidget):
for i in range(len(sample_fine_temp)): for i in range(len(sample_fine_temp)):
self.pcm_SSC_fine_meas_vs_inv_text = self.axis_SSC_fine.text( self.pcm_SSC_fine_meas_vs_inv_text = self.axis_SSC_fine.text(
time_fine_temp[i], time_fine_temp[i],
depth_fine_temp[i], sample_fine_temp[i][0]) depth_fine_temp[i], sample_fine_temp[i][0]
)
time_fine_temp, depth_fine_temp = stg.time_fine, stg.depth_fine time_fine_temp, depth_fine_temp = stg.time_fine, stg.depth_fine
self.pcm_SSC_fine_meas_vs_inv_sample_calibration, = self.axis_SSC_fine.plot( self.pcm_SSC_fine_meas_vs_inv_sample_calibration, = self.axis_SSC_fine.plot(
[time_fine_temp[s[1]] for s in stg.fine_sample_profile], [time_fine_temp[s[1]] for s in stg.fine_sample_profile],
[depth_fine_temp[s[1]] for s in stg.fine_sample_profile], [depth_fine_temp[s[1]] for s in stg.fine_sample_profile],
ls=" ", marker="*", ms=12, mec="r", mfc="r") ls=" ", marker="*", ms=12, mec="r", mfc="r"
)
time_fine_temp, depth_fine_temp = stg.time_fine, stg.depth_fine time_fine_temp, depth_fine_temp = stg.time_fine, stg.depth_fine
for i, j in stg.fine_sample_profile: for i, j in stg.fine_sample_profile:
self.pcm_SSC_fine_meas_vs_inv_sample_calibration_text = self.axis_SSC_fine.text( self.pcm_SSC_fine_meas_vs_inv_sample_calibration_text = self.axis_SSC_fine.text(
time_fine_temp[j]+5, depth_fine_temp[j]+0.05, i, color='r', fontweight='bold') time_fine_temp[j]+5, depth_fine_temp[j]+0.05, i,
color='r', fontweight='bold'
)
cbar_SSC_fine = self.figure_SSC_fine.colorbar(pcm_SSC_fine, ax=self.axis_SSC_fine, shrink=1, cbar_SSC_fine = self.figure_SSC_fine.colorbar(
location='right') pcm_SSC_fine, ax=self.axis_SSC_fine, shrink=1,
location='right'
)
cbar_SSC_fine.set_label(label='Fine SSC (g/L', rotation=270, labelpad=15) cbar_SSC_fine.set_label(label='Fine SSC (g/L', rotation=270, labelpad=15)
self.figure_SSC_fine.supxlabel("Time (sec)", fontsize=10) self.figure_SSC_fine.supxlabel("Time (sec)", fontsize=10)
@ -681,82 +693,86 @@ class AcousticInversionTab(QWidget):
self.figure_SSC_fine.canvas.draw_idle() self.figure_SSC_fine.canvas.draw_idle()
def plot_SSC_fine_vertical_profile(self): def plot_SSC_fine_vertical_profile(self):
if self.combobox_acoustic_data_choice.count() <= 0:
return
if self.combobox_acoustic_data_choice.count() > 0: data_id = self.combobox_acoustic_data_choice.currentIndex()
if stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape == (0,): if stg.SSC_fine[data_id].shape == (0,):
self.verticalLayout_groupbox_plot_vertical_profile_fine\
self.verticalLayout_groupbox_plot_vertical_profile_fine.removeWidget(self.toolbar_profile_fine) .removeWidget(self.toolbar_profile_fine)
self.verticalLayout_groupbox_plot_vertical_profile_fine.removeWidget(self.canvas_profile_fine) self.verticalLayout_groupbox_plot_vertical_profile_fine\
.removeWidget(self.canvas_profile_fine)
self.canvas_profile_fine = FigureCanvas() self.canvas_profile_fine = FigureCanvas()
self.toolbar_profile_fine = NavigationToolBar(self.canvas_profile_fine, self) self.toolbar_profile_fine = NavigationToolBar(self.canvas_profile_fine, self)
self.verticalLayout_groupbox_plot_vertical_profile_fine.addWidget(self.toolbar_profile_fine) self.verticalLayout_groupbox_plot_vertical_profile_fine\
self.verticalLayout_groupbox_plot_vertical_profile_fine.addWidget(self.canvas_profile_fine) .addWidget(self.toolbar_profile_fine)
self.verticalLayout_groupbox_plot_vertical_profile_fine\
.addWidget(self.canvas_profile_fine)
if stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): if stg.SSC_fine[data_id].shape != (0,):
self.slider_fine.setMaximum(
stg.SSC_fine[data_id].shape[1]
)
self.slider_fine.setMaximum(stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape[1]) self.verticalLayout_groupbox_plot_vertical_profile_fine\
.removeWidget(self.toolbar_profile_fine)
self.verticalLayout_groupbox_plot_vertical_profile_fine\
.removeWidget(self.canvas_profile_fine)
self.verticalLayout_groupbox_plot_vertical_profile_fine.removeWidget(self.toolbar_profile_fine) fig, ax = plt.subplots(nrows=1, ncols=1, layout="constrained")
self.verticalLayout_groupbox_plot_vertical_profile_fine.removeWidget(self.canvas_profile_fine) self.figure_vertical_profile_SSC_fine = fig
self.axis_vertical_profile_SSC_fine = ax
self.figure_vertical_profile_SSC_fine, self.axis_vertical_profile_SSC_fine = plt.subplots(
nrows=1, ncols=1, layout="constrained")
self.canvas_profile_fine = FigureCanvas(self.figure_vertical_profile_SSC_fine) self.canvas_profile_fine = FigureCanvas(self.figure_vertical_profile_SSC_fine)
self.toolbar_profile_fine = NavigationToolBar(self.canvas_profile_fine, self) self.toolbar_profile_fine = NavigationToolBar(self.canvas_profile_fine, self)
self.verticalLayout_groupbox_plot_vertical_profile_fine.addWidget(self.toolbar_profile_fine) self.verticalLayout_groupbox_plot_vertical_profile_fine\
self.verticalLayout_groupbox_plot_vertical_profile_fine.addWidget(self.canvas_profile_fine) .addWidget(self.toolbar_profile_fine)
self.verticalLayout_groupbox_plot_vertical_profile_fine\
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): .addWidget(self.canvas_profile_fine)
self.plot_fine , = self.axis_vertical_profile_SSC_fine.plot(
stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][:, self.slider_fine.value() -1],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
linestyle="solid", linewidth=1, color="k")
self.pcm_SSC_fine_vertical_line.set_data(
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1],
self.slider_fine.value() - 1] *
np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]].shape),
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])
self.figure_SSC_fine.canvas.draw_idle()
self.axis_vertical_profile_SSC_fine.set_ylim(
[-np.nanmax(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]]),
-np.nanmin(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])])
if stg.depth_cross_section[data_id].shape != (0,):
time_data = stg.time_cross_section
depth_data = stg.depth_cross_section
else: else:
time_data = stg.time
depth_data = stg.depth
self.plot_fine , = self.axis_vertical_profile_SSC_fine.plot( self.plot_fine , = self.axis_vertical_profile_SSC_fine.plot(
stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][:, self.slider_fine.value() -1], stg.SSC_fine[data_id][:, self.slider_fine.value() -1],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ -depth_data[data_id][stg.frequency_for_inversion[1]],
stg.frequency_for_inversion[1]], linestyle="solid", linewidth=1, color="k"
linestyle="solid", linewidth=1, color="k") )
self.pcm_SSC_fine_vertical_line.set_data( self.pcm_SSC_fine_vertical_line.set_data(
stg.time[self.combobox_acoustic_data_choice.currentIndex()][ time_data[data_id][
stg.frequency_for_inversion[1], self.slider_fine.value() - 1] * stg.frequency_for_inversion[1],
np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ self.slider_fine.value() - 1
stg.frequency_for_inversion[1]].shape), ]
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ * np.ones(
stg.frequency_for_inversion[1]]) depth_data[data_id][
stg.frequency_for_inversion[1]
].shape
),
-depth_data[data_id][
stg.frequency_for_inversion[1]
]
)
self.figure_SSC_fine.canvas.draw_idle() self.figure_SSC_fine.canvas.draw_idle()
self.axis_vertical_profile_SSC_fine.set_ylim( self.axis_vertical_profile_SSC_fine.set_ylim(
[-np.nanmax(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ [
stg.frequency_for_inversion[1]]), -np.nanmax(
-np.nanmin(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][ depth_data[data_id][stg.frequency_for_inversion[1]]
stg.frequency_for_inversion[1]])]) ),
-np.nanmin(
depth_data[data_id][stg.frequency_for_inversion[1]]
)
]
)
self.axis_vertical_profile_SSC_fine.set_xlim(0, 10) self.axis_vertical_profile_SSC_fine.set_xlim(0, 10)
self.axis_vertical_profile_SSC_fine.set_xlabel("Inverted Fine SSC (g/L)") self.axis_vertical_profile_SSC_fine.set_xlabel("Inverted Fine SSC (g/L)")
@ -764,108 +780,88 @@ class AcousticInversionTab(QWidget):
self.figure_vertical_profile_SSC_fine.canvas.draw_idle() self.figure_vertical_profile_SSC_fine.canvas.draw_idle()
def update_plot_SSC_fine_vertical_profile(self): def update_plot_SSC_fine_vertical_profile(self):
if len(stg.filename_BS_noise_data) == 0:
return
if stg.filename_BS_noise_data != []: data_id = self.combobox_acoustic_data_choice.currentIndex()
if stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): if stg.SSC_fine[data_id].shape == (0,):
return
self.axis_vertical_profile_SSC_fine.cla() self.axis_vertical_profile_SSC_fine.cla()
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,): if stg.depth_cross_section[data_id].shape != (0,):
time_data = stg.time_cross_section
depth_data = stg.depth_cross_section
else:
time_data = stg.time
depth_data = stg.depth
self.axis_vertical_profile_SSC_fine.plot( self.axis_vertical_profile_SSC_fine.plot(
stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][:, stg.SSC_fine[data_id][:, self.slider_fine.value() - 1],
self.slider_fine.value() - 1], -depth_data[data_id][stg.frequency_for_inversion[1]],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ linestyle="solid", linewidth=1, color="k"
stg.frequency_for_inversion[1]], )
linestyle="solid", linewidth=1, color="k")
self.pcm_SSC_fine_vertical_line.set_data( self.pcm_SSC_fine_vertical_line.set_data(
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ time_data[data_id][stg.frequency_for_inversion[1],
self.slider_fine.value() - 1]
* np.ones(depth_data[data_id][
stg.frequency_for_inversion[1]
].shape),
-depth_data[data_id][stg.frequency_for_inversion[1]]
)
self.figure_SSC_fine.canvas.draw_idle()
self.axis_vertical_profile_SSC_fine.set_ylim(
[
-np.nanmax(
depth_data[data_id][stg.frequency_for_inversion[1]]
),
-np.nanmin(
depth_data[data_id][stg.frequency_for_inversion[1]]
)
]
)
for f in stg.fine_sample_profile:
time_fine_calibration = (
np.where(
np.abs(
time_data[data_id][stg.frequency_for_inversion[1]]
- stg.time_fine[f[1]]
) == np.nanmin(
np.abs(
time_data[data_id][
stg.frequency_for_inversion[1]
]
- stg.time_fine[f[1]]
)
)
)[0][0]
)
if (time_data[data_id][
stg.frequency_for_inversion[1], stg.frequency_for_inversion[1],
self.slider_fine.value() - 1] * int(self.slider_fine.value())
np.ones(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ ] == time_data[data_id][
stg.frequency_for_inversion[1]].shape), stg.frequency_for_inversion[1],
-stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][ int(time_fine_calibration)
stg.frequency_for_inversion[1]]) ]):
self.figure_SSC_fine.canvas.draw_idle()
self.axis_vertical_profile_SSC_fine.set_ylim(
[-np.nanmax(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]]),
-np.nanmin(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])])
else:
self.axis_vertical_profile_SSC_fine.plot(
stg.SSC_fine[self.combobox_acoustic_data_choice.currentIndex()][:,
self.slider_fine.value() - 1],
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]],
linestyle="solid", linewidth=1, color="k")
self.pcm_SSC_fine_vertical_line.set_data(
stg.time[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1], self.slider_fine.value() - 1] *
np.ones(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]].shape),
-stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])
self.figure_SSC_fine.canvas.draw_idle()
self.axis_vertical_profile_SSC_fine.set_ylim(
[-np.nanmax(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]]),
-np.nanmin(stg.depth[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]])])
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
for f in stg.fine_sample_profile:
time_fine_calibration = (
np.where(np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_fine[f[1]]) ==
np.nanmin(np.abs(stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_fine[f[1]])))[0][0]
)
if (stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1], int(self.slider_fine.value())] ==
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1], int(time_fine_calibration)]):
self.axis_vertical_profile_SSC_fine.scatter( self.axis_vertical_profile_SSC_fine.scatter(
stg.Ctot_fine[f[1]], stg.depth_fine[f[1]], stg.Ctot_fine[f[1]], stg.depth_fine[f[1]],
marker='*', s=48, c='r', edgecolors='r') marker='*', s=48, c='r', edgecolors='r'
self.axis_vertical_profile_SSC_fine.text(stg.Ctot_fine[f[1]], stg.depth_fine[f[1]], f[0]) )
self.axis_vertical_profile_SSC_fine.text(
else: stg.Ctot_fine[f[1]],
stg.depth_fine[f[1]], f[0]
for f in stg.fine_sample_profile:
time_fine_calibration = (
np.where(np.abs(stg.time[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_fine[f[1]]) ==
np.nanmin(np.abs(
stg.time[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1]] - stg.time_fine[f[1]])))[0][0]
) )
if (stg.time[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1], int(self.slider_fine.value())] ==
stg.time[self.combobox_acoustic_data_choice.currentIndex()][
stg.frequency_for_inversion[1], int(time_fine_calibration)]):
self.axis_vertical_profile_SSC_fine.scatter(
stg.Ctot_fine[f[1]], stg.depth_fine[f[1]],
marker='*', s=48, c='r', edgecolors='r')
self.axis_vertical_profile_SSC_fine.text(stg.Ctot_fine[f[1]], stg.depth_fine[f[1]], f[0])
self.axis_vertical_profile_SSC_fine.set_xlim(0, 10) self.axis_vertical_profile_SSC_fine.set_xlim(0, 10)
self.axis_vertical_profile_SSC_fine.set_xlabel("Inverted Fine SSC (g/L)") self.axis_vertical_profile_SSC_fine\
self.axis_vertical_profile_SSC_fine.set_ylabel("Depth (m)") .set_xlabel("Inverted Fine SSC (g/L)")
self.axis_vertical_profile_SSC_fine\
.set_ylabel("Depth (m)")
self.figure_vertical_profile_SSC_fine.canvas.draw_idle() self.figure_vertical_profile_SSC_fine.canvas.draw_idle()
def slider_profile_number_to_begin_fine(self): def slider_profile_number_to_begin_fine(self):