Compare commits
No commits in common. "0dd38af7a92b33f76c9ba6a25592102ff93c96c8" and "2df094f4506820208d979e3faab2be320e331943" have entirely different histories.
0dd38af7a9
...
2df094f450
|
|
@ -1590,6 +1590,7 @@ class SedimentCalibrationTab(QWidget):
|
||||||
self.animaiton_groupbox_compute.start()
|
self.animaiton_groupbox_compute.start()
|
||||||
|
|
||||||
def import_calibration_file(self):
|
def import_calibration_file(self):
|
||||||
|
|
||||||
if self.combobox_acoustic_data_choice.count() == 0:
|
if self.combobox_acoustic_data_choice.count() == 0:
|
||||||
msgBox = QMessageBox()
|
msgBox = QMessageBox()
|
||||||
msgBox.setWindowTitle("Calibration import error")
|
msgBox.setWindowTitle("Calibration import error")
|
||||||
|
|
@ -1601,81 +1602,35 @@ class SedimentCalibrationTab(QWidget):
|
||||||
msgBox.setText("Update data before importing calibration")
|
msgBox.setText("Update data before importing calibration")
|
||||||
msgBox.setStandardButtons(QMessageBox.Ok)
|
msgBox.setStandardButtons(QMessageBox.Ok)
|
||||||
msgBox.exec()
|
msgBox.exec()
|
||||||
return
|
|
||||||
|
|
||||||
path = ""
|
|
||||||
if stg.path_calibration_file:
|
|
||||||
path = stg.path_calibration_file
|
|
||||||
elif self.combobox_acoustic_data_choice.count() > 0:
|
|
||||||
path = stg.path_BS_raw_data[-1]
|
|
||||||
|
|
||||||
file_type = {
|
|
||||||
"Calibration Files (*.csv *.ods *.xls *.xlsx)":
|
|
||||||
self.read_calibration_dispatch,
|
|
||||||
"CSV Files (*.csv)": self.read_calibration_csv,
|
|
||||||
"Excel Files (*.xlsx *.xls)": self.read_calibration_excel,
|
|
||||||
"LibreOffice Calc Files (*.ods)": self.read_calibration_ods,
|
|
||||||
}
|
|
||||||
|
|
||||||
filename, ftype = QFileDialog.getOpenFileName(
|
|
||||||
self, "Open calibration file", path,
|
|
||||||
";;".join(file_type),
|
|
||||||
options=QFileDialog.DontUseNativeDialog
|
|
||||||
)
|
|
||||||
|
|
||||||
if filename == '':
|
|
||||||
return
|
|
||||||
|
|
||||||
dir_name = os.path.dirname(filename)
|
|
||||||
name = os.path.basename(filename)
|
|
||||||
|
|
||||||
stg.path_calibration_file = dir_name
|
|
||||||
stg.filename_calibration_file = name
|
|
||||||
|
|
||||||
self.lineEdit_import_calibration.clear()
|
|
||||||
self.lineEdit_import_calibration.setText(name)
|
|
||||||
|
|
||||||
self.lineEdit_import_calibration.setToolTip(dir_name)
|
|
||||||
|
|
||||||
self.compute_depth_2D()
|
|
||||||
try:
|
|
||||||
parser = file_type[ftype]
|
|
||||||
data = parser(filename)
|
|
||||||
|
|
||||||
self.fill_calibration_select_frequencies(data)
|
|
||||||
self.fill_calibration_parameters(data)
|
|
||||||
except Exception as e:
|
|
||||||
logger.warning(f"read calibration failed: {str(e)}")
|
|
||||||
|
|
||||||
def read_calibration_dispatch(self, filename):
|
|
||||||
if ".csv" in filename:
|
|
||||||
return self.read_calibration_csv(filename)
|
|
||||||
elif ".ods" in filename:
|
|
||||||
return self.read_calibration_ods(filename)
|
|
||||||
else:
|
else:
|
||||||
return self.read_calibration_excel(filename)
|
|
||||||
|
|
||||||
def read_calibration_csv(self, filename):
|
filename = QFileDialog.getOpenFileName(
|
||||||
data = pd.read_csv(
|
self, "Open calibration",
|
||||||
filename, header=0, index_col=0,
|
[
|
||||||
)
|
stg.path_calibration_file
|
||||||
logger.debug(f"Calibration data: {data}")
|
if stg.path_calibration_file
|
||||||
return data
|
else stg.path_BS_raw_data[-1]
|
||||||
|
if self.combobox_acoustic_data_choice.count() > 0
|
||||||
|
else ""
|
||||||
|
][0],
|
||||||
|
"Calibration file (*.xls, *.ods, *csv)",
|
||||||
|
options=QFileDialog.DontUseNativeDialog
|
||||||
|
)
|
||||||
|
|
||||||
def read_calibration_ods(self, filename):
|
dir_name = os.path.dirname(filename[0])
|
||||||
data = pd.read_excel(
|
name = os.path.basename(filename[0])
|
||||||
filename, header=0, index_col=0,
|
|
||||||
engine="odf"
|
|
||||||
)
|
|
||||||
logger.debug(f"Calibration data: {data}")
|
|
||||||
return data
|
|
||||||
|
|
||||||
def read_calibration_excel(self, filename):
|
stg.path_calibration_file = dir_name
|
||||||
data = pd.read_excel(
|
stg.filename_calibration_file = name
|
||||||
filename, header=0, index_col=0,
|
|
||||||
)
|
self.lineEdit_import_calibration.clear()
|
||||||
logger.debug(f"Calibration data: {data}")
|
self.lineEdit_import_calibration.setText(name)
|
||||||
return data
|
|
||||||
|
self.lineEdit_import_calibration.setToolTip(dir_name)
|
||||||
|
|
||||||
|
self.compute_depth_2D()
|
||||||
|
self.read_calibration_file_and_fill_parameter()
|
||||||
|
|
||||||
def update_label_freq1_for_calibration(self):
|
def update_label_freq1_for_calibration(self):
|
||||||
self.label_freq1.clear()
|
self.label_freq1.clear()
|
||||||
|
|
@ -1713,51 +1668,69 @@ class SedimentCalibrationTab(QWidget):
|
||||||
str('%.4f' % stg.kt_read[freq_2])
|
str('%.4f' % stg.kt_read[freq_2])
|
||||||
)
|
)
|
||||||
|
|
||||||
def fill_calibration_select_frequencies(self, data):
|
def read_calibration_file_and_fill_parameter(self):
|
||||||
if stg.filename_calibration_file == "":
|
if stg.filename_calibration_file == "":
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# --- Read calibration file ---
|
||||||
|
data = pd.read_csv(
|
||||||
|
os.path.join(
|
||||||
|
stg.path_calibration_file,
|
||||||
|
stg.filename_calibration_file
|
||||||
|
), header=0, index_col=0
|
||||||
|
)
|
||||||
|
|
||||||
# --- Fill spinboxes of calibration parameter ---
|
# --- Fill spinboxes of calibration parameter ---
|
||||||
self.label_temperature.clear()
|
self.label_temperature.clear()
|
||||||
self.label_temperature.setText(
|
self.label_temperature.setText(
|
||||||
"T = " + str(stg.temperature) + " °C"
|
"T = " + str(stg.temperature) + " °C"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.label_freq1.clear()
|
||||||
|
self.label_freq1.setText(data.columns[0])
|
||||||
|
|
||||||
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
data_id = self.combobox_acoustic_data_choice.currentIndex()
|
||||||
|
|
||||||
stg.calib_acoustic_data = data_id
|
stg.calib_acoustic_data = data_id
|
||||||
|
|
||||||
|
index_freq1 = np.where(
|
||||||
|
np.asarray(
|
||||||
|
stg.freq_text[data_id]
|
||||||
|
) == data.columns[0]
|
||||||
|
)[0][0]
|
||||||
|
|
||||||
stg.frequencies_for_calibration.clear()
|
stg.frequencies_for_calibration.clear()
|
||||||
|
stg.frequencies_for_calibration.append(
|
||||||
for label, column in [
|
(
|
||||||
(self.label_freq1, 0),
|
stg.freq[data_id][index_freq1],
|
||||||
(self.label_freq2, 1)
|
index_freq1
|
||||||
]:
|
|
||||||
label.clear()
|
|
||||||
label.setText(data.columns[0])
|
|
||||||
|
|
||||||
index = next(
|
|
||||||
map(
|
|
||||||
lambda e: e[0],
|
|
||||||
filter(
|
|
||||||
lambda e: e[1] == data.columns[column],
|
|
||||||
enumerate(stg.freq_text[data_id])
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
stg.calib_freq_1 = index_freq1
|
||||||
|
|
||||||
stg.frequencies_for_calibration.append(
|
self.label_freq2.clear()
|
||||||
(
|
self.label_freq2.setText(data.columns[1])
|
||||||
stg.freq[data_id][index],
|
|
||||||
index
|
index_freq2 = np.where(
|
||||||
)
|
np.asarray(
|
||||||
|
stg.freq_text[data_id]
|
||||||
|
) == data.columns[1]
|
||||||
|
)[0][0]
|
||||||
|
|
||||||
|
stg.frequencies_for_calibration.append(
|
||||||
|
(
|
||||||
|
stg.freq[data_id][index_freq2],
|
||||||
|
index_freq2
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
stg.calib_freq_2 = index_freq2
|
||||||
|
|
||||||
logger.debug(f"Select freq {index}: {stg.freq_text[data_id][index]}")
|
stg.frequency_for_inversion = tuple()
|
||||||
|
stg.frequency_for_inversion = (
|
||||||
|
stg.freq[data_id][index_freq2],
|
||||||
|
index_freq2
|
||||||
|
)
|
||||||
|
|
||||||
stg.calib_freq_1 = stg.frequencies_for_calibration[0][1]
|
|
||||||
stg.calib_freq_2 = stg.frequencies_for_calibration[1][1]
|
|
||||||
|
|
||||||
def fill_calibration_parameters(self, data):
|
|
||||||
self.lineEdit_ks_freq1.clear()
|
self.lineEdit_ks_freq1.clear()
|
||||||
self.lineEdit_ks_freq1.setText(
|
self.lineEdit_ks_freq1.setText(
|
||||||
str("%.5f" % float(data.iloc[0][0]))
|
str("%.5f" % float(data.iloc[0][0]))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue