Sediment calibration: Some refactoring.
parent
4a8b318ea4
commit
fbda28eb86
|
|
@ -2149,35 +2149,46 @@ class SedimentCalibrationTab(QWidget):
|
|||
self.lineEdit_zeta_freq2.setText(str("%.5f" % zeta_freq2))
|
||||
|
||||
def save_calibration(self):
|
||||
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
||||
|
||||
freq1 = stg.frequencies_for_calibration[0][1]
|
||||
freq2 = stg.frequencies_for_calibration[1][1]
|
||||
|
||||
if stg.alpha_s:
|
||||
directory = ""
|
||||
if stg.path_calibration_file != "":
|
||||
directory = stg.path_calibration_file
|
||||
elif self.combobox_acoustic_data_choice.count() > 0:
|
||||
directory = stg.path_BS_raw_data[-1]
|
||||
|
||||
dir_save_cal = QFileDialog.getExistingDirectory(
|
||||
caption="Save calibration",
|
||||
directory=[stg.path_calibration_file if stg.path_calibration_file else stg.path_BS_raw_data[-1] if self.combobox_acoustic_data_choice.count() > 0 else ""][0],
|
||||
options=QFileDialog.DontUseNativeDialog)
|
||||
directory=directory,
|
||||
options=QFileDialog.DontUseNativeDialog
|
||||
)
|
||||
|
||||
if dir_save_cal:
|
||||
|
||||
stg.path_calibration_file = os.path.dirname(dir_save_cal)
|
||||
|
||||
cal_array = [[' ', stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()][stg.frequencies_for_calibration[0][1]],
|
||||
stg.freq_text[self.combobox_acoustic_data_choice.currentIndex()][stg.frequencies_for_calibration[1][1]]],
|
||||
cal_array = [
|
||||
[
|
||||
' ', stg.freq_text[data_id][freq1],
|
||||
stg.freq_text[data_id][freq2]
|
||||
],
|
||||
['ks', stg.ks[0], stg.ks[1]],
|
||||
['sv', stg.sv[0], stg.sv[1]],
|
||||
['X', stg.X_exponent[0], 0],
|
||||
['alphas', stg.alpha_s[0], stg.alpha_s[1]],
|
||||
['zeta', stg.zeta[0], stg.zeta[1]]]
|
||||
|
||||
eval("np.savetxt('"+ dir_save_cal + "/Sediment_calibration_" +
|
||||
str(stg.filename_BS_raw_data[self.combobox_acoustic_data_choice.currentIndex()][:-4]) + ".csv' ," +
|
||||
"cal_array, " +
|
||||
"delimiter=',' ," +
|
||||
"fmt ='% s'" +
|
||||
")")
|
||||
['zeta', stg.zeta[0], stg.zeta[1]]
|
||||
]
|
||||
|
||||
np.savetxt(
|
||||
f"{dir_save_cal}/Sediment_calibration_"
|
||||
+ f"{stg.filename_BS_raw_data[data_id][:-4]}.csv",
|
||||
cal_array,
|
||||
delimiter=',', fmt ='% s'
|
||||
)
|
||||
else:
|
||||
|
||||
msgBox = QMessageBox()
|
||||
msgBox.setWindowTitle("Save Error")
|
||||
msgBox.setIcon(QMessageBox.Warning)
|
||||
|
|
@ -2190,68 +2201,49 @@ class SedimentCalibrationTab(QWidget):
|
|||
# ------------ Computing real cell size ------------ #
|
||||
def range_cells_function(self):
|
||||
""" Computing the real cell size, that depends on the temperature """
|
||||
|
||||
if stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
|
||||
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
||||
|
||||
aquascat_cell_size = []
|
||||
tau = []
|
||||
real_cell_size = []
|
||||
|
||||
stg.depth_real = np.zeros(stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape)
|
||||
if stg.depth_cross_section[data_id].shape != (0,):
|
||||
depth_data = stg.depth_cross_section
|
||||
else:
|
||||
depth_data = stg.depth
|
||||
|
||||
for f in range(stg.freq[self.combobox_acoustic_data_choice.currentIndex()].shape[0]):
|
||||
stg.depth_real = np.zeros(depth_data[data_id].shape)
|
||||
|
||||
for f in range(stg.freq[data_id].shape[0]):
|
||||
# defaut Aquascat cell size
|
||||
aquascat_cell_size.append(
|
||||
stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, 1] -
|
||||
stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, 0])
|
||||
depth_data[data_id][f, 1] - depth_data[data_id][f, 0]
|
||||
)
|
||||
|
||||
# Pulse duration
|
||||
tau.append(aquascat_cell_size[f] * 2 / 1500) # figure 2.9 1500 vitesse du son entrée pour le paramètrage des mesures aquascat
|
||||
# Pulse duration: figure 2.9 1500 vitesse du son entrée
|
||||
# pour le paramètrage des mesures aquascat
|
||||
tau.append(aquascat_cell_size[f] * 2 / 1500)
|
||||
|
||||
# Real cell size
|
||||
real_cell_size.append(stg.water_velocity * tau[f] / 2) # voir fig 2.9
|
||||
# voir fig 2.9
|
||||
real_cell_size.append(stg.water_velocity * tau[f] / 2)
|
||||
|
||||
# Converting to real cell profile
|
||||
stg.depth_real[f, :] = (stg.depth_cross_section[self.combobox_acoustic_data_choice.currentIndex()][f, :]
|
||||
/ aquascat_cell_size[f] * real_cell_size[f])
|
||||
stg.depth_real[f, :] = (
|
||||
depth_data[data_id][f, :]
|
||||
/ aquascat_cell_size[f]
|
||||
* real_cell_size[f]
|
||||
)
|
||||
|
||||
|
||||
if stg.time_cross_section[data_id].shape != (0,):
|
||||
time_data = stg.time_cross_section
|
||||
else:
|
||||
time_data = stg.time
|
||||
|
||||
aquascat_cell_size = []
|
||||
tau = []
|
||||
real_cell_size = []
|
||||
|
||||
stg.depth_real = (np.zeros(stg.depth[self.combobox_acoustic_data_choice.currentIndex()].shape))
|
||||
|
||||
for f in range(stg.freq[self.combobox_acoustic_data_choice.currentIndex()].shape[0]):
|
||||
|
||||
# defaut Aquascat cell size
|
||||
aquascat_cell_size.append(
|
||||
stg.depth[self.combobox_acoustic_data_choice.currentIndex()][f, 1] -
|
||||
stg.depth[self.combobox_acoustic_data_choice.currentIndex()][f, 0])
|
||||
|
||||
# Pulse duration
|
||||
tau.append(aquascat_cell_size[f] * 2 / 1500) # figure 2.9 1500 vitesse du son entrée pour le paramètrage des mesures aquascat
|
||||
|
||||
# Real cell size
|
||||
real_cell_size.append(stg.water_velocity * tau[f] / 2) # voir fig 2.9
|
||||
|
||||
# Converting to real cell profile
|
||||
|
||||
stg.depth_real[f, :] = (stg.depth[self.combobox_acoustic_data_choice.currentIndex()][f, :] /
|
||||
aquascat_cell_size[f] * real_cell_size[f])
|
||||
|
||||
if stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape != (0,):
|
||||
|
||||
stg.depth_real = \
|
||||
(np.repeat(stg.depth_real[:, :, np.newaxis],
|
||||
stg.time_cross_section[self.combobox_acoustic_data_choice.currentIndex()].shape[1], axis=2))
|
||||
|
||||
else:
|
||||
|
||||
stg.depth_real = (
|
||||
np.repeat(stg.depth_real[:, :, np.newaxis],
|
||||
stg.time[self.combobox_acoustic_data_choice.currentIndex()].shape[1], axis=2))
|
||||
stg.depth_real = np.repeat(
|
||||
stg.depth_real[:, :, np.newaxis],
|
||||
time_data[data_id].shape[1], axis=2
|
||||
)
|
||||
|
||||
def compute_FCB(self):
|
||||
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
||||
|
|
|
|||
Loading…
Reference in New Issue