UBSediFlow data successfully loaded
parent
7d359983f0
commit
b01b4541bb
|
|
@ -8,16 +8,34 @@ from matplotlib.colors import LogNorm, BoundaryNorm
|
|||
|
||||
from Model.udt_extract.raw_extract import raw_extract
|
||||
# raw_20210519_102332.udt raw_20210520_135452.udt raw_20210525_092759.udt raw_20210525_080454.udt
|
||||
path_BS_raw_data0 = ("/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data/APAVER_2021/"
|
||||
"Rhone_20210519/Rhone_20210519/record/")
|
||||
filename0 = "raw_20210526_153310.udt"
|
||||
|
||||
# path_BS_raw_data0 = ("/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data/APAVER_2021/Raw_data_udt/")
|
||||
# filename0 = "raw_20210519_135400.udt"
|
||||
|
||||
# path_BS_raw_data0 = ("/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data/"
|
||||
# "APAVER_2021/transect_ubsediflow/01-raw_20210519_115128/Raw_data_udt/")
|
||||
# filename0 = "raw_20210519_115128.udt"
|
||||
|
||||
# path_BS_raw_data0 = ("/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data/"
|
||||
# "APAVER_2021/transect_ubsediflow/02-bb0077eda128f3f7887052eb3e8b0884/Raw_data_udt/")
|
||||
# filename0 = "raw_20210519_161400.udt"
|
||||
|
||||
# path_BS_raw_data0 = ("/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data/"
|
||||
# "APAVER_2021/transect_ubsediflow/04-fb53d0e92c9c88e2a6cf45e0320fbc76/Raw_data_udt/")
|
||||
# filename0 = "raw_20210520_133200.udt"
|
||||
|
||||
# ("/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data/APAVER_2021/"
|
||||
# "Rhone_20210519/Rhone_20210519/record/")
|
||||
|
||||
# filename = "raw_20210519_115128.udt"
|
||||
# "raw_20210526_153310.udt"
|
||||
|
||||
|
||||
class AcousticDataLoaderUBSediFlow():
|
||||
|
||||
def __init__(self, path_BS_raw_data: str):
|
||||
|
||||
path_BS_raw_data = path_BS_raw_data0 + filename0
|
||||
# path_BS_raw_data = path_BS_raw_data0 + filename0
|
||||
self.path_BS_raw_data = path_BS_raw_data
|
||||
|
||||
# --- Extract Backscatter acoustic raw data with class ---
|
||||
|
|
@ -49,12 +67,12 @@ class AcousticDataLoaderUBSediFlow():
|
|||
time_len = []
|
||||
time_snr_len = []
|
||||
for config in param_us_dicts.keys():
|
||||
# print("-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x")
|
||||
# print(f"config : {config} \n")
|
||||
print("-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x")
|
||||
print(f"config : {config} \n")
|
||||
for channel in param_us_dicts[config].keys():
|
||||
# print("-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x")
|
||||
# print(f"channel : {channel} \n")
|
||||
print(data_us_dicts[config][channel].keys())
|
||||
print("-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x")
|
||||
print(f"channel : {channel} \n")
|
||||
# print(param_us_dicts[1][1])
|
||||
# print(data_us_dicts[config][channel]['echo_avg_profile'])
|
||||
|
||||
# --- Frequencies ---
|
||||
|
|
@ -126,28 +144,80 @@ class AcousticDataLoaderUBSediFlow():
|
|||
# print(f"self._time.shape {self._time.shape}")
|
||||
|
||||
# --- US Backscatter raw signal + SNR data ---
|
||||
for f, freq in enumerate(self._freq):
|
||||
if f == 0:
|
||||
# print(data_us_dicts[config][channel]['echo_avg_profile']['data'])
|
||||
self._BS_raw_data = np.array([np.reshape(data_us_dicts[config][channel]['echo_avg_profile']['data'],
|
||||
(self._time.shape[1], self._r.shape[1])).transpose()])
|
||||
# print(self._BS_raw_data.shape)
|
||||
self._SNR_data = np.array(
|
||||
[np.reshape(np.abs(data_us_dicts[config][channel]['snr_doppler_avg_profile']['data']),
|
||||
(self._time.shape[1], self._r.shape[1])).transpose()])
|
||||
else:
|
||||
BS_data = np.array([[]])
|
||||
|
||||
if config == 1:
|
||||
BS_data = np.array([data_us_dicts[config][channel]['echo_avg_profile']['data'][0]])
|
||||
print("BS_data shape ", BS_data.shape)
|
||||
for i in range(self._time.shape[1]):
|
||||
BS_data = np.append(BS_data,
|
||||
np.array([data_us_dicts[config][channel]['echo_avg_profile']['data'][i]]),
|
||||
axis=0)
|
||||
print("BS_data shape ", BS_data.shape)
|
||||
|
||||
self._BS_raw_data = np.array([BS_data[:self._time.shape[1], :].transpose()])
|
||||
|
||||
print("BS_raw_data shape ", self._BS_raw_data.shape)
|
||||
|
||||
# fig, ax = plt.subplots(nrows=1, ncols=1, layout="constrained")
|
||||
# pcm = ax.pcolormesh(list(range(self._BS_raw_data.shape[2])), list(range(self._BS_raw_data.shape[1])),
|
||||
# np.log(self._BS_raw_data[0, :, :]),
|
||||
# cmap='Blues')
|
||||
# fig.colorbar(pcm, ax=ax, shrink=1, location='right')
|
||||
# plt.show()
|
||||
|
||||
else:
|
||||
|
||||
BS_data = np.array([data_us_dicts[config][channel]['echo_avg_profile']['data'][0]])
|
||||
print("BS_data shape ", BS_data.shape)
|
||||
for i in range(self._time.shape[1]):
|
||||
BS_data = np.append(BS_data,
|
||||
np.array(
|
||||
[data_us_dicts[config][channel]['echo_avg_profile']['data'][i]]),
|
||||
axis=0)
|
||||
print("BS_data shape ", BS_data.shape)
|
||||
|
||||
if BS_data.shape[0] > self._BS_raw_data.shape[2]:
|
||||
self._BS_raw_data = np.append(self._BS_raw_data,
|
||||
np.array([np.reshape(np.array(
|
||||
data_us_dicts[config][channel]['echo_avg_profile']['data']),
|
||||
(self._time.shape[1], self._r.shape[1])).transpose()]),
|
||||
np.array([BS_data[:self._BS_raw_data.shape[2], :].transpose()]),
|
||||
axis=0)
|
||||
|
||||
self._SNR_data = np.append(self._SNR_data,
|
||||
np.array([np.reshape(np.array(
|
||||
np.abs(data_us_dicts[config][channel]['snr_doppler_avg_profile']['data'])),
|
||||
(self._time.shape[1], self._r.shape[1])).transpose()]),
|
||||
elif BS_data.shape[0] < self._BS_raw_data.shape[2]:
|
||||
self._BS_raw_data = np.append(self._BS_raw_data[config-1, :, BS_data.shape[0]],
|
||||
np.array([BS_data.transpose()]),
|
||||
axis=0)
|
||||
# print(self._BS_raw_data.shape)
|
||||
else:
|
||||
self._BS_raw_data = np.append(self._BS_raw_data, np.array([BS_data.transpose()]), axis=0)
|
||||
|
||||
|
||||
print("BS_raw_data shape ", self._BS_raw_data.shape)
|
||||
|
||||
# if f == 0:
|
||||
# print(np.array(data_us_dicts[config][channel]['echo_avg_profile']['data'][0]).shape)
|
||||
# self._BS_raw_data[f, :, :] = np.array([data_us_dicts[config][channel]['echo_avg_profile']['data'][0]])
|
||||
# # self._BS_raw_data = np.array([np.reshape(data_us_dicts[config][channel]['echo_avg_profile']['data'],
|
||||
# # (self._time.shape[1], self._r.shape[1])).transpose()])
|
||||
# print("self._BS_raw_data.shape ", self._BS_raw_data.shape)
|
||||
# self._SNR_data = np.array(
|
||||
# [np.reshape(np.abs(data_us_dicts[config][channel]['snr_doppler_avg_profile']['data']),
|
||||
# (self._time.shape[1], self._r.shape[1])).transpose()])
|
||||
# else:
|
||||
# # self._BS_raw_data = np.append(self._BS_raw_data,
|
||||
# # np.array(data_us_dicts[config][channel]['echo_avg_profile']['data']),
|
||||
# # (self._r.shape[1], self._time.shape[1]))]),
|
||||
# # axis=0)
|
||||
# # self._BS_raw_data = np.append(self._BS_raw_data,
|
||||
# # np.array([np.reshape(np.array(
|
||||
# # data_us_dicts[config][channel]['echo_avg_profile']['data']),
|
||||
# # (self._time.shape[1], self._r.shape[1])).transpose()]),
|
||||
# # axis=0)
|
||||
#
|
||||
# self._SNR_data = np.append(self._SNR_data,
|
||||
# np.array([np.reshape(np.array(
|
||||
# np.abs(data_us_dicts[config][channel]['snr_doppler_avg_profile']['data'])),
|
||||
# (self._time.shape[1], self._r.shape[1])).transpose()]),
|
||||
# axis=0)
|
||||
# # print(self._BS_raw_data.shape)
|
||||
|
||||
# --- US Backscatter raw signal ---
|
||||
|
||||
|
|
@ -155,6 +225,15 @@ class AcousticDataLoaderUBSediFlow():
|
|||
# print(len(self._BS_raw_data))
|
||||
# print(self._BS_raw_data)
|
||||
|
||||
if self._time.shape[1] > self._BS_raw_data.shape[2]:
|
||||
self._time = self._time[:, :self._BS_raw_data.shape[2]]
|
||||
elif self._time.shape[1] < self._BS_raw_data.shape[2]:
|
||||
self._BS_raw_data = self._BS_raw_data[:, :, :self._time.shape[1]]
|
||||
else:
|
||||
self._time = self._time
|
||||
self._BS_raw_data = self._BS_raw_data
|
||||
|
||||
self._time = self._time[:, :self._BS_raw_data.shape[2]]
|
||||
print("self._time.shape ", self._time.shape)
|
||||
|
||||
print("self._r.shape ", self._r.shape)
|
||||
|
|
@ -166,8 +245,8 @@ class AcousticDataLoaderUBSediFlow():
|
|||
# self._BS_raw_data = np.array(np.reshape(self._BS_raw_data, (len(self._freq), self._r.shape[1], self._time.shape[1])))
|
||||
print("self._BS_raw_data.shape ", self._BS_raw_data.shape)
|
||||
|
||||
print("self._SNR_data.shape ", self._SNR_data.shape)
|
||||
print(self._SNR_data)
|
||||
# print("self._SNR_data.shape ", self._SNR_data.shape)
|
||||
# print(self._SNR_data)
|
||||
|
||||
# print("device_name ", device_name, "\n")
|
||||
|
||||
|
|
@ -217,12 +296,30 @@ class AcousticDataLoaderUBSediFlow():
|
|||
# print(np.where((self._time) == 155)[0][0])
|
||||
|
||||
# --- Plot Backscatter US data ---
|
||||
# fig, ax = plt.subplots(nrows=len(self._freq), ncols=1)
|
||||
|
||||
# fig, ax = plt.subplots(nrows=1, ncols=1, layout="constrained")
|
||||
# # pcm = ax.pcolormesh(self._time[0, :], self._r[0, :], np.log(self._BS_raw_data[0, :, :]),
|
||||
# # cmap='Blues')#, shading='gouraud')
|
||||
# pcm = ax.pcolormesh(list(range(self._BS_raw_data.shape[2])), list(range(self._BS_raw_data.shape[1])),
|
||||
# np.log(self._BS_raw_data[0, :, :]),
|
||||
# cmap='Blues') # , shading='gouraud')
|
||||
# # norm=LogNorm(vmin=np.min(self._BS_raw_data[f, :, :]), vmax=np.max(self._BS_raw_data[f, :, :])), shading='gouraud')
|
||||
# # ax.pcolormesh(range(self._BS_raw_data.shape[2]), range(self._BS_raw_data.shape[0]), self._BS_raw_data[:, 1, :], cmap='viridis',
|
||||
# # norm=LogNorm(vmin=1e-5, vmax=np.max(self._BS_raw_data[:, 0, :]))) # , shading='gouraud')
|
||||
# fig.colorbar(pcm, ax=ax, shrink=1, location='right')
|
||||
# plt.show()
|
||||
|
||||
# fig, ax = plt.subplots(nrows=len(self._freq), ncols=1, layout="constrained")
|
||||
# for f, freq in enumerate(self._freq):
|
||||
# # print(f"{f} : {freq} \n")
|
||||
# pcm = ax[f].pcolormesh(self._time[f, :], self._r[f, :], (self._BS_raw_data[f, :, :self._time.shape[1]]),
|
||||
# cmap='viridis',
|
||||
# norm=LogNorm(vmin=np.min(self._BS_raw_data[f, :, :]), vmax=np.max(self._BS_raw_data[f, :, :])), shading='gouraud')
|
||||
# print(f"{f} : {freq} \n")
|
||||
# # pcm = ax[f].imshow(np.log(self._BS_raw_data[f, :, :self._time.shape[1]]),
|
||||
# # cmap='Blues')
|
||||
# # pcm = ax[f].pcolormesh(list(range(self._BS_raw_data.shape[2])), list(range(self._BS_raw_data.shape[1])),
|
||||
# # np.log(self._BS_raw_data[f, :, :]),
|
||||
# # cmap='Blues', shading='gouraud')
|
||||
# pcm = ax[f].pcolormesh(self._time[f, :], self._r[f, :], np.log(self._BS_raw_data[f, :, :]),
|
||||
# cmap='viridis', shading='gouraud')
|
||||
# # norm=LogNorm(vmin=np.min(self._BS_raw_data[f, :, :]), vmax=np.max(self._BS_raw_data[f, :, :])), shading='gouraud')
|
||||
# # ax.pcolormesh(range(self._BS_raw_data.shape[2]), range(self._BS_raw_data.shape[0]), self._BS_raw_data[:, 1, :], cmap='viridis',
|
||||
# # norm=LogNorm(vmin=1e-5, vmax=np.max(self._BS_raw_data[:, 0, :]))) # , shading='gouraud')
|
||||
# fig.colorbar(pcm, ax=ax[:], shrink=1, location='right')
|
||||
|
|
@ -277,6 +374,36 @@ class AcousticDataLoaderUBSediFlow():
|
|||
# self.reshape_r()
|
||||
# self.reshape_t()
|
||||
|
||||
# Lecture du fichier excel
|
||||
|
||||
# path = ("/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data/APAVER_2021/"
|
||||
# "transect_ubsediflow/01-raw_20210519_115128/Raw_data_csv/config_1/"
|
||||
# "echo_avg_profile_1_1_20210519_115128.csv")
|
||||
#
|
||||
# df = pd.read_csv(path, sep="\t")
|
||||
#
|
||||
# arr = []
|
||||
# for column in df.columns:
|
||||
# arr.append(df[column].to_numpy())
|
||||
# # arr = np.append(arr, np.array([df[column].to_numpy()]), axis=0)
|
||||
# arr = arr[1:]
|
||||
# print(len(arr))
|
||||
#
|
||||
# matrix = np.array([arr[0]])
|
||||
# print(matrix.shape)
|
||||
# for i in range(len(arr)-1):
|
||||
# matrix = np.append(matrix, np.array([arr[i]]), axis=0)
|
||||
# print(matrix.shape)
|
||||
|
||||
# fig, ax = plt.subplots(nrows=1, ncols=1, layout="constrained")
|
||||
# pcm = ax.pcolormesh(list(range(matrix.shape[1])), list(range(matrix.shape[0])), np.log(matrix),
|
||||
# cmap='Blues')#, shading='gouraud')
|
||||
# # norm=LogNorm(vmin=np.min(self._BS_raw_data[f, :, :]), vmax=np.max(self._BS_raw_data[f, :, :])), shading='gouraud')
|
||||
# # ax.pcolormesh(range(self._BS_raw_data.shape[2]), range(self._BS_raw_data.shape[0]), self._BS_raw_data[:, 1, :], cmap='viridis',
|
||||
# # norm=LogNorm(vmin=1e-5, vmax=np.max(self._BS_raw_data[:, 0, :]))) # , shading='gouraud')
|
||||
# fig.colorbar(pcm, ax=ax, shrink=1, location='right')
|
||||
# plt.show()
|
||||
|
||||
def reshape_BS_raw_cross_section(self):
|
||||
BS_raw_cross_section = np.reshape(self._BS_raw_data,
|
||||
(self._r.shape[1]*self._time.shape[1], len(self._freq)),
|
||||
|
|
@ -284,12 +411,12 @@ class AcousticDataLoaderUBSediFlow():
|
|||
# print(BS_raw_cross_section.shape)
|
||||
return BS_raw_cross_section
|
||||
|
||||
def reshape_SNR_data(self):
|
||||
SNR_data = np.reshape(self._SNR_data,
|
||||
(self._r.shape[1]*self._time.shape[1], len(self._freq)),
|
||||
order="F")
|
||||
# print(BS_raw_cross_section.shape)
|
||||
return SNR_data
|
||||
# def reshape_SNR_data(self):
|
||||
# SNR_data = np.reshape(self._SNR_data,
|
||||
# (self._r.shape[1]*self._time.shape[1], len(self._freq)),
|
||||
# order="F")
|
||||
# # print(BS_raw_cross_section.shape)
|
||||
# return SNR_data
|
||||
|
||||
def reshape_r(self):
|
||||
r = np.zeros((self._r.shape[1]*self._time.shape[1], len(self._freq)))
|
||||
|
|
@ -326,7 +453,7 @@ class AcousticDataLoaderUBSediFlow():
|
|||
# return df
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
AcousticDataLoaderUBSediFlow(path_BS_raw_data0 + filename0)
|
||||
# if __name__ == "__main__":
|
||||
# AcousticDataLoaderUBSediFlow(path_BS_raw_data0 + filename0)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -703,18 +703,23 @@ class AcousticDataTab(QWidget):
|
|||
filename = QFileDialog.getOpenFileName(self, "Open file", "", "UBSediFlow file (*.udt)")
|
||||
dir_name = path.dirname(filename[0])
|
||||
name = path.basename(filename[0])
|
||||
print(dir_name, name)
|
||||
|
||||
|
||||
# --- Fill lineEdit with path and file names + load acoustic data ---
|
||||
# --- fill date, hour and measurements information + fill frequency combobox for bottom detection ---
|
||||
if self.combobox_ABS_system_choice.currentIndex() != 0:
|
||||
if self.sender().objectName() == "pushbutton_acoustic_file":
|
||||
# stg.path_BS_raw_data = dir_name
|
||||
# stg.filename_BS_raw_data = name
|
||||
# self.load_BS_acoustic_raw_data()
|
||||
try:
|
||||
stg.path_BS_raw_data = dir_name
|
||||
stg.filename_BS_raw_data = name
|
||||
self.load_BS_acoustic_raw_data()
|
||||
print("0 Je suis sur la donnée BS")
|
||||
except ValueError as e:
|
||||
print("error : ", e)
|
||||
print("1 Je suis sur la donnée BS")
|
||||
msgBox = QMessageBox()
|
||||
msgBox.setWindowTitle("Download Error")
|
||||
|
|
@ -793,7 +798,7 @@ class AcousticDataTab(QWidget):
|
|||
stg.r_reshape = acoustic_data.reshape_r()
|
||||
stg.time_reshape = acoustic_data.reshape_t()
|
||||
stg.snr = acoustic_data._SNR_data
|
||||
stg.snr_reshape = acoustic_data.reshape_SNR_data()
|
||||
# stg.snr_reshape = acoustic_data.reshape_SNR_data()
|
||||
|
||||
def load_noise_data_and_compute_SNR(self):
|
||||
if self.combobox_ABS_system_choice.currentIndex() == 1:
|
||||
|
|
@ -990,8 +995,8 @@ class AcousticDataTab(QWidget):
|
|||
|
||||
pcm = self.axis_BS[f].pcolormesh(
|
||||
stg.time[f, int(stg.tmin[f]):int(stg.tmax[f])], -stg.r[f, :],
|
||||
stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[f])],
|
||||
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
|
||||
np.log(stg.BS_raw_data[f, :, int(stg.tmin[f]):int(stg.tmax[f])]),
|
||||
cmap='Blues')#, norm=LogNorm(vmin=val_min, vmax=val_max))
|
||||
|
||||
self.axis_BS[f].text(1, .70, stg.freq_text[f],
|
||||
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
|
||||
|
|
@ -1065,8 +1070,8 @@ class AcousticDataTab(QWidget):
|
|||
|
||||
# print("stg.t[f, :].shape ", stg.t[f])
|
||||
# print("stg.r[f, :].shape ", stg.r[f, :])
|
||||
pcm = self.axis_BS[f].pcolormesh(stg.t[f, :], -stg.r[f, :], stg.BS_data[f, :, :],
|
||||
cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max))
|
||||
pcm = self.axis_BS[f].pcolormesh(stg.t[f, :], -stg.r[f, :], np.log(stg.BS_data[f, :, :]),
|
||||
cmap='Blues')#, norm=LogNorm(vmin=val_min, vmax=val_max))
|
||||
|
||||
self.axis_BS[f].text(1, .70, stg.freq_text[f],
|
||||
fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5,
|
||||
|
|
|
|||
Loading…
Reference in New Issue