diff --git a/Model/acoustic_data_loader.py b/Model/acoustic_data_loader.py index 423185e..5748736 100644 --- a/Model/acoustic_data_loader.py +++ b/Model/acoustic_data_loader.py @@ -5,35 +5,25 @@ import pandas as pd import matplotlib.pyplot as plt from matplotlib.colors import LogNorm -# path_BS_raw_data = "/home/bmoudjed/Documents/2 Data/Confluence_Rhône_Isere_2018/Acoustic_data/20180107123500.aqa" -# path_BS_raw_data = "/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/" \ -# "Data/AcousticNoise_data/20180107121600.aqa" - class AcousticDataLoader: def __init__(self, path_BS_raw_data: str): self.path_BS_raw_data = path_BS_raw_data - print(self.path_BS_raw_data) # --- Load Backscatter acoustic raw data with RawAquascatData class --- self._data_BS = RawAquascatData(self.path_BS_raw_data) - print(self._data_BS.V.shape) 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._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() @@ -48,97 +38,30 @@ class AcousticDataLoader: self._gain_rx = self._data_BS.RxGain.tolist() self._gain_tx = self._data_BS.TxGain.tolist() - # print((self._cell_size)) - # print((self._nb_pings_averaged_per_profile)) - - # print(self._r[0, :][1] - self._r[1, :][0]) - # print(type(self._nb_cells), self._nb_cells) - - # self._snr = np.array([]) - # self._snr_reshape = np.array([]) - # self._time_snr = np.array([]) - - # print(type(self._gain_tx)) - - # print(["BS - " + f for f in self._freq_text]) - # print(self._time.shape[0]*self._r.shape[0]*4) - - # print(self._time[np.where(np.floor(self._time) == 175)]) - # print(np.where((self._time) == 155)[0][0]) - - # fig, ax = plt.subplots(nrows=1, ncols=1) - # # ax.pcolormesh(self._time[0, :2200], -self._r[0, :], (self._BS_raw_data[0, :, :2200]), - # # cmap='viridis', - # # norm=LogNorm(vmin=1e-5, vmax=np.max(self._BS_raw_data[0, :, :2200]))) # , shading='gouraud') - # ax.pcolormesh(range(self._BS_raw_data.shape[2]), range(self._BS_raw_data.shape[1]), self._BS_raw_data[2, :, :], cmap='viridis', - # norm=LogNorm(vmin=1e-5, vmax=np.max(self._BS_raw_data[:, 0, :]))) # , shading='gouraud') - # ax.set_xticks([]) - # ax.set_yticks([]) - # plt.show() - - # --- Plot vertical profile for bottom detection --- - # fig2, ax2 = plt.subplots(nrows=1, ncols=1, layout="constrained") - # ax2.plot(self._BS_raw_data[0, :, 1], -self._r[0], "k.-") - # plt.show() - - # fig, ax = plt.subplots(nrows=1, ncols=1) - # ax.plot(self._BS_raw_data[:, 0, 100] , self._r) - # ax.set_ylim(2, 20) - # plt.show() - - # print(self.reshape_BS_raw_cross_section()[0, 0]) - # self.reshape_BS_raw_cross_section() - # self.reshape_r() - # self.reshape_t() - # self.compute_r_2D() - def reshape_BS_raw_data(self): BS_raw_cross_section = np.reshape(self._BS_raw_data, (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[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): for j in range(self._time.shape[1]): r[j*self._r.shape[1]:(j+1)*self._r.shape[1], i] = self._r[i, :] - - # r[:, i] = np.repeat(self._r[i, :], self._time.shape[1]) - print(r.shape) return r def compute_r_2D(self): r2D = np.zeros((self._freq.shape[0], self._r.shape[1], self._time.shape[1])) for f, _ in enumerate(self._freq): r2D[f, :, :] = np.repeat(np.transpose(self._r[f, :])[:, np.newaxis], self._time.shape[1], axis=1) - print(r2D.shape) 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.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): - # self.reshape_t() - # self.reshape_BS_raw_cross_section() - # # print(self.reshape_t().shape) - # # print(se.lf.reshape_BS_raw_cross_section().shape) - # df = pd.DataFrame(np.concatenate((self.reshape_t(), self.reshape_BS_raw_cross_section()), axis=1), - # columns=["time"] + self._freq_text) - # return df - - -# if __name__ == "__main__": -# AcousticDataLoader(path_BS_raw_data) -