from Model.AquascatDataLoader import RawAquascatData import numpy as np import pandas as pd import matplotlib.pyplot as plt from matplotlib.colors import LogNorm # path_BS_raw_data = "/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/" \ # "Data/Acoustic_data/20180107123500.aqa" # path_noise_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 # --- Load Backscatter acoustic raw data with RawAquascatData class --- self._data_BS = RawAquascatData(self.path_BS_raw_data) self._BS_raw_data = self._data_BS.V self._r = self._data_BS.r self._freq = self._data_BS.Freq 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._date = self._data_BS.date.date() self._hour = self._data_BS.date.time() self._nb_profiles = self._data_BS.NumProfiles self._nb_profiles_per_sec = self._data_BS.ProfileRate self._nb_cells = self._data_BS.NumCells self._cell_size = self._data_BS.cellSize self._pulse_length = self._data_BS.TxPulseLength self._nb_pings_per_sec = self._data_BS.PingRate self._nb_pings_averaged_per_profile = self._data_BS.Average self._kt = self._data_BS.Kt self._gain_rx = self._data_BS.RxGain self._gain_tx = self._data_BS.TxGain # 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, self._r, (self._BS_raw_data[:, 1, :]), # cmap='viridis', # norm=LogNorm(vmin=1e-5, vmax=np.max(self._BS_raw_data[:, 0, :]))) # , 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') # 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_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]), order="F") 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") return r def reshape_t(self): t = np.reshape(np.repeat(self._time, self._r.shape[0]), (self._time.shape[0]*self._r.shape[0], 1)) 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)