diff --git a/Model/acoustic_data_loader.py b/Model/acoustic_data_loader.py index be45708..1ad5c0d 100644 --- a/Model/acoustic_data_loader.py +++ b/Model/acoustic_data_loader.py @@ -20,11 +20,20 @@ class AcousticDataLoader(): self._data_BS = RawAquascatData(self.path_BS_raw_data) - self._BS_raw_data = self._data_BS.V - self._r = self._data_BS.r + self._BS_raw_data = np.swapaxes(self._data_BS.V, 0, 1) + print(f"BS raw data shape = {self._BS_raw_data.shape}") + self._freq = self._data_BS.Freq + print(f"freq shape = {self._freq.shape}") self._freq_text = self._data_BS.freqText - self._time = np.array([t / self._data_BS.PingRate for t in range(self._data_BS.NumProfiles)]) + + self._r = np.repeat(np.transpose(self._data_BS.r), self._freq.shape[0], axis=0) + print(f"r shape = {self._r.shape}") + + self._time = np.repeat( + np.transpose(np.array([t / self._data_BS.PingRate for t in range(self._data_BS.NumProfiles)])[:, np.newaxis]), + self._freq.shape[0], axis=0) + print(f"time shape = {self._time.shape}") self._date = self._data_BS.date.date() self._hour = self._data_BS.date.time() @@ -65,19 +74,25 @@ class AcousticDataLoader(): # plt.show() # print(self.reshape_BS_raw_cross_section()[0, 0]) + # self.reshape_BS_raw_cross_section() # self.reshape_r() # self.reshape_t() def reshape_BS_raw_cross_section(self): BS_raw_cross_section = np.reshape(self._BS_raw_data, - (self._r.shape[0]*len(self._time), self._freq.shape[0]), + (self._r.shape[1] * self._time.shape[1], self._freq.shape[0]), order="F") + print(BS_raw_cross_section.shape) return BS_raw_cross_section def reshape_r(self): - r = np.reshape(np.repeat(self._r, self._time.shape[0], axis=1), - self._r.shape[0]*self._time.shape[0], - order="F") + # r = np.reshape(np.repeat(self._r[0, :], self._time.shape[0], axis=1), + # self._r.shape[0]*self._time.shape[0], + # order="F") + r = np.zeros((self._r.shape[1] * self._time.shape[1], self._freq.shape[0])) + for i, _ in enumerate(self._freq): + r[:, i] = np.repeat(self._r[i, :], self._time.shape[1]) + print(r.shape) return r def compute_r_2D(self): @@ -85,7 +100,11 @@ class AcousticDataLoader(): return r2D def reshape_t(self): - t = np.reshape(np.repeat(self._time, self._r.shape[0]), (self._time.shape[0]*self._r.shape[0], 1)) + # t = np.reshape(np.repeat(self._time, self._r.shape[0]), (self._time.shape[0]*self._r.shape[0], 1)) + t = np.zeros((self._r.shape[1] * self._time.shape[1], self._freq.shape[0])) + for i, _ in enumerate(self._freq): + t[:, i] = np.repeat(self._time[i, :], self._r.shape[1]) + print(t.shape) return t # def concatenate_data(self): diff --git a/View/acoustic_data_tab.py b/View/acoustic_data_tab.py index 8c7f6ba..4afb5af 100644 --- a/View/acoustic_data_tab.py +++ b/View/acoustic_data_tab.py @@ -846,51 +846,51 @@ class AcousticDataTab(QWidget): def fill_table(self): - if self.combobox_ABS_system_choice.currentIndex() == 1: - if ((self.lineEdit_acoustic_file.text()) and (self.lineEdit_noise_file.text())): - stg.DataFrame_acoustic = pd.DataFrame( - np.concatenate((stg.time_reshape, stg.BS_raw_data_reshape, stg.snr_reshape), axis=1), - columns=list(map(str, ["Time"] + ["BS - " + f for f in stg.freq_text] + - ["SNR - " + f for f in stg.freq_text]))) - self.tableModel = TableModel(stg.DataFrame_acoustic) - self.tableView.setModel(self.tableModel) - elif self.lineEdit_acoustic_file.text(): - stg.DataFrame_acoustic = pd.DataFrame( - np.concatenate((stg.time_reshape, stg.BS_raw_data_reshape), axis=1), - columns=list(map(str, ["Time"] + ["BS - " + f for f in stg.freq_text]))) - self.tableModel = TableModel(stg.DataFrame_acoustic) - self.tableView.setModel(self.tableModel) - else: - msgBox = QMessageBox() - msgBox.setWindowTitle("Fill table Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("Download files before fill table") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() + # if self.combobox_ABS_system_choice.currentIndex() == 2: + # if ((self.lineEdit_acoustic_file.text()) and (self.lineEdit_noise_file.text())): + # stg.DataFrame_acoustic = pd.DataFrame( + # np.concatenate((stg.time_reshape, stg.BS_raw_data_reshape, stg.snr_reshape), axis=1), + # columns=list(map(str, ["Time"] + ["BS - " + f for f in stg.freq_text] + + # ["SNR - " + f for f in stg.freq_text]))) + # self.tableModel = TableModel(stg.DataFrame_acoustic) + # self.tableView.setModel(self.tableModel) + # elif self.lineEdit_acoustic_file.text(): + # stg.DataFrame_acoustic = pd.DataFrame( + # np.concatenate((stg.time_reshape, stg.BS_raw_data_reshape), axis=1), + # columns=list(map(str, ["Time"] + ["BS - " + f for f in stg.freq_text]))) + # self.tableModel = TableModel(stg.DataFrame_acoustic) + # self.tableView.setModel(self.tableModel) + # else: + # msgBox = QMessageBox() + # msgBox.setWindowTitle("Fill table Error") + # msgBox.setIcon(QMessageBox.Warning) + # msgBox.setText("Download files before fill table") + # msgBox.setStandardButtons(QMessageBox.Ok) + # msgBox.exec() - elif self.combobox_ABS_system_choice.currentIndex() == 2: - if ((self.lineEdit_acoustic_file.text()) and (self.lineEdit_noise_file.text())): - stg.DataFrame_acoustic = pd.DataFrame( - np.concatenate((stg.time_reshape, stg.BS_raw_data_reshape, stg.time_snr_reshape, stg.snr_reshape), axis=1), - columns=list(map(str, ["Time BS - " + f for f in stg.freq_text] + - ["BS - " + f for f in stg.freq_text] + - ["Time SNR - " + f for f in stg.freq_text] + - ["SNR - " + f for f in stg.freq_text]))) - self.tableModel = TableModel(stg.DataFrame_acoustic) - self.tableView.setModel(self.tableModel) - elif self.lineEdit_acoustic_file.text(): - stg.DataFrame_acoustic = pd.DataFrame( - np.concatenate((stg.time_reshape, stg.BS_raw_data_reshape), axis=1), - columns=list(map(str, ["Time BS - " + f for f in stg.freq_text] + ["BS - " + f for f in stg.freq_text]))) - self.tableModel = TableModel(stg.DataFrame_acoustic) - self.tableView.setModel(self.tableModel) - else: - msgBox = QMessageBox() - msgBox.setWindowTitle("Fill table Error") - msgBox.setIcon(QMessageBox.Warning) - msgBox.setText("Download files before fill table") - msgBox.setStandardButtons(QMessageBox.Ok) - msgBox.exec() + # elif self.combobox_ABS_system_choice.currentIndex() == 1: + if ((self.lineEdit_acoustic_file.text()) and (self.lineEdit_noise_file.text())): + stg.DataFrame_acoustic = pd.DataFrame( + np.concatenate((stg.time_reshape, stg.BS_raw_data_reshape, stg.time_snr_reshape, stg.snr_reshape), axis=1), + columns=list(map(str, ["Time BS - " + f for f in stg.freq_text] + + ["BS - " + f for f in stg.freq_text] + + ["Time SNR - " + f for f in stg.freq_text] + + ["SNR - " + f for f in stg.freq_text]))) + self.tableModel = TableModel(stg.DataFrame_acoustic) + self.tableView.setModel(self.tableModel) + elif self.lineEdit_acoustic_file.text(): + stg.DataFrame_acoustic = pd.DataFrame( + np.concatenate((stg.time_reshape, stg.BS_raw_data_reshape), axis=1), + columns=list(map(str, ["Time BS - " + f for f in stg.freq_text] + ["BS - " + f for f in stg.freq_text]))) + self.tableModel = TableModel(stg.DataFrame_acoustic) + self.tableView.setModel(self.tableModel) + else: + msgBox = QMessageBox() + msgBox.setWindowTitle("Fill table Error") + msgBox.setIcon(QMessageBox.Warning) + msgBox.setText("Download files before fill table") + msgBox.setStandardButtons(QMessageBox.Ok) + msgBox.exec() def export_table(self): if self.tableWidget.columnCount() == 10: @@ -978,7 +978,7 @@ class AcousticDataTab(QWidget): print(f"tmax {stg.tmax}") pcm = self.axis_BS[f].pcolormesh( - stg.time[f, int(stg.tmin[f]):int(stg.tmax[f])], stg.r[f, :], + 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)) @@ -1054,7 +1054,7 @@ 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, :, :], + 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)) self.axis_BS[f].text(1, .70, stg.freq_text[f], @@ -1180,7 +1180,7 @@ class AcousticDataTab(QWidget): # print(f"levels = {levels}") # print(f"norm = {norm.boundaries}") - cf = self.axis_SNR[f].contourf(x[f, :, :], y[f, :, :], stg.snr[f, :, :])#, levels, cmap='gist_rainbow', norm=norm) + cf = self.axis_SNR[f].contourf(x[f, :, :], -y[f, :, :], stg.snr[f, :, :])#, levels, cmap='gist_rainbow', norm=norm) self.axis_SNR[f].text(1, .70, stg.freq_text[f], fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, @@ -1314,7 +1314,7 @@ class AcousticDataTab(QWidget): # print(f"norm = {norm.boundaries}") cf = self.axis_SNR[f].contourf(x[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])], - y[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])], + -y[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])], stg.snr[f, :, int(stg.tmin_snr[f]):int(stg.tmax_snr[f])]) # , levels, cmap='gist_rainbow', norm=norm) self.axis_SNR[f].text(1, .70, stg.freq_text[f],