diff --git a/Model/AquascatDataLoader.py b/Model/AquascatDataLoader.py index e2c0885..4282a8f 100644 --- a/Model/AquascatDataLoader.py +++ b/Model/AquascatDataLoader.py @@ -1,1113 +1,3 @@ -# # -*- coding: utf-8 -*- -# """ -# Created on Wen Jun 08 2016 -# -# @author: Adrien Vergne -# """ -# -# ############################################################################### -# # # -# # CLASSES and METHODS for loading AQUASCAT Data # -# # # -# ############################################################################### -# -# # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -# # Adrien VERGNE - Irstea Lyon - 2016 -# # Program Python 3.5 -# # <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -# -# -# ############################################################################### -# # LOADING LIBRARIES # -# ############################################################################### -# -# import numpy as np # Matrix scientific computing -# import os # Path / folder access management -# import datetime # for time management -# # Loading binary data -# import struct as st -# import glob -# import pickle -# import time -# -# # ---------------------------------------------------------------------------# -# # ------------------------------ CLASSES -----------------------------------# -# # ---------------------------------------------------------------------------# -# -# class RawAquascatData: -# """ This class loads Aquascat data from Aquascat text file (aqa.txt) or -# Aquascat raw file (.aqa) located in -# -# Data file info -# @ivar path: string, full file location -# @ivar file_name: string, file name -# @ivar folder_name : string, full folder location -# -# Aquascat data -# @ivar NumProfiles: int, number of profiles -# @ivar ProfileRate: int, profile recording rate in Hz -# @ivar Freq: array of float, frequencies in MHz -# @ivar freqText: list of strings, frequencies in text format in MHz -# @ivar At: array of float, transducer radii -# @ivar NumCells: int, number of cells along one profile -# @ivar V: 3 dimensional array of floats, ABS data -# - dim. 0 : r (distance from the transducer) -# - dim. 1 : freq (transducer frequency) -# - dim. 2 : profile (over all the profiles recorded in a burst) -# @ivar r: array, vector column of int, range of the cells in m from -# the transducer -# @ivar cellSize : float, size of the cells in m -# @ivar TxPulseLength: float, length of the pulse in second -# @ivar RxGain: array of float, gain at reception in dB -# @ivar TxGain: array of float, gain at emission in dB -# @ivar Average: int, number of pings averaged in one profile -# @ivar BeamWidth: array of float, width of the acoustic beam in degree -# @ivar Kt: array of float, Kt constant -# @ivar PingRate: int, number of pings per second, in Hz -# @ivar Regime: string, regime name given when using the Aquascat -# """ -# -# def __init__(self, p): -# """ -# @param p: string, full file location path -# """ -# -# # ___________________ File info _______________________________________# -# -# # Source file full location path -# self.path = p -# # Extracting file name -# self.file_name = os.path.basename(self.path) -# # Extracting folder location -# self.folder_name = os.path.dirname(self.path) -# # Extracting beginning time info -# self.date = datetime.datetime(1, 1, 1) -# -# # ________________________ Data _______________________________________# -# -# # Number of profiles -# self.NumProfiles = 0 -# # Profile rate (Hz) -# self.ProfileRate = 0 -# # Transducer frequencies (float) -# self.Freq = np.array([]) -# # Transducer frequencies (string text in MHz) -# self.freqText = [] -# # Transducer radii -# self.At = np.array([]) -# # Number of cells -# self.NumCells = 0 -# # ABS data -# self.V = np.array([]) -# # Cell range data -# self.r = np.array([]) -# # Cell size -# self.cellSize = 0 -# # Pulse length in second -# self.TxPulseLength = 0 -# # Reception gain in dB -# self.RxGain = np.array([]) -# # Gain at emission -# self.TxGain = np.array([]) -# # Averaging -# self.Average = 0 -# # Beam width -# self.BeamWidth = np.array([]) -# # Kt constant -# self.Kt = np.array([]) -# # Ping rate -# self.PingRate = 0 -# # Regime name -# self.Regime = '' -# -# # _____________ Reading and loading Aquascat Data _____________________# -# if p: -# self.date = datetime.datetime(year=np.int(self.file_name[0:4]), -# month=np.int(self.file_name[4:6]), -# day=np.int(self.file_name[6:8]), -# hour=np.int(self.file_name[8:10]), -# minute=np.int(self.file_name[10:12]), -# second=np.int(self.file_name[12:14])) -# -# if self.file_name[-7:] == 'aqa.txt': -# self.load_txt_file() -# -# if self.file_name[-4:] == '.aqa': -# self.load_aqa_file() -# -# def load_txt_file(self): -# # Opening the file ("r" for "read") -# src = open(self.path, "r") -# -# # Line 1 : skipped -# src.readline().rstrip('\n') -# -# # Lines 2-3 : number of profiles -# src.readline().rstrip('\n') # .rstrip('\n') for removing the "end line" -# # character -# -# temp = np.fromstring(src.readline().rstrip('\n'), dtype=float, sep=',')[ -# 0] # string is converted -# -# self.NumProfiles = int(temp) -# -# # Lines 4-5 : profile rate in Hz -# src.readline().rstrip('\n') -# temp = np.fromstring(src.readline().rstrip('\n'), dtype=float, sep=',')[ -# 0] -# self.ProfileRate = temp -# -# # Lines 6-7 : transducer frequencies -# src.readline().rstrip('\n') -# temp = np.fromstring(src.readline().rstrip('\n'), dtype=float, sep=',') -# self.Freq = temp -# # Creating also an array of strings with the frequencies in MHz -# for i in range(len(self.Freq)): -# self.freqText.append(str(self.Freq[i] / 1e6) + ' MHz') -# -# # Lines 8-9 : transducer radii -# src.readline().rstrip('\n') -# temp = np.fromstring(src.readline().rstrip('\n'), dtype=float, sep=',') -# self.At = temp -# -# # Lines 10-14 : ABS data -# src.readline().rstrip('\n') -# -# # Reading the lines one by one -# for f in range(len(self.Freq)): -# temp = np.fromstring(src.readline().rstrip('\n'), dtype=float, -# sep=',') -# # Computing the number of cells -# self.NumCells = int(len(temp) / self.NumProfiles) -# -# # Converting the 1D numpy array to 2D array -# # dim. 0 : r ; dim.1 : profile -# # Have to take the transpose cause numpy reshape function -# # fills the lines one by one, so one profile will fill one -# # line and not one column as we want -# temp = temp.reshape(self.NumProfiles, self.NumCells).T -# -# # stacking the frequency to the already existing array so we get -# # a 3D array where dim. 2 (last dimension) is corresponds to the -# # frequency -# if f == 0: -# self.V = temp -# else: -# self.V = np.dstack((self.V, temp)) -# -# # Finally we exchange axes 1 and 2 so to get dim.1 = frequency and -# # dim. 2 = profile -# self.V = self.V.swapaxes(1, 2) -# -# # Lines 15-19 : Mean ABS over the burst. Not very useful, skipped -# src.readline().rstrip('\n') -# -# # Reading the lines one by one -# for f in range(len(self.Freq)): -# src.readline().rstrip('\n') -# -# # Lines 20-24 : cell range -# src.readline().rstrip('\n') -# # Only reading the first line, they are all the same -# temp = np.fromstring(src.readline().rstrip('\n'), dtype=float, sep=',') -# # Reshaping the array in a column vector -# temp = temp.reshape(self.NumCells, 1) -# self.r = temp -# -# # Computing the cell size -# self.cellSize = self.r[1, 0]-self.r[0, 0] -# -# # Skipping the other r lines -# for f in range(1, len(self.Freq)): -# src.readline() -# -# # Lines 25-26 : pulse length -# src.readline().rstrip('\n') -# temp = np.fromstring(src.readline().rstrip('\n'), dtype=float, sep=',')[ -# 0] -# self.TxPulseLength = temp -# -# # Lines 27-28 : Gain at reception -# src.readline().rstrip('\n') -# temp = np.fromstring(src.readline().rstrip('\n'), dtype=float, sep=',') -# self.RxGain = temp -# -# # Lines 29-30 : Gain at emission -# src.readline().rstrip('\n') -# temp = np.fromstring(src.readline().rstrip('\n'), dtype=float, sep=',') -# self.TxGain = temp -# -# # Lines 31-32 : Averaging -# src.readline().rstrip('\n') -# temp = np.fromstring(src.readline().rstrip('\n'), dtype=float, sep=',')[ -# 0] -# self.Average = int(temp) -# -# # Lines 33-34 : Beam width -# src.readline().rstrip('\n') -# temp = np.fromstring(src.readline().rstrip('\n'), dtype=float, sep=',') -# self.BeamWidth = temp -# -# # Lines 35-36 : Kt -# src.readline().rstrip('\n') -# temp = np.fromstring(src.readline().rstrip('\n'), dtype=float, sep=',') -# self.Kt = temp -# -# # Lines xxx : looking for ping rate -# line = src.readline().rstrip('\n') -# i = 0 -# while line != 'PingRate' and i < 100: -# line = src.readline().rstrip('\n') -# i += 1 -# temp = eval(src.readline().rstrip('\n')) -# self.PingRate = temp -# -# # Lines xxxx : session title -# src.readline().rstrip('\n') -# temp = src.readline().rstrip('\n') -# # Formating the string -# temp = temp.replace(',', '') -# temp = temp.rstrip('\0') -# self.Regime = temp -# -# # Closing the file -# src.close() -# -# def load_aqa_file(self): -# # -------- From G. Fromant 2017 - LEGI, Grenoble (France) ---------- # -# -# # __________________ sub-functions ________________________________ # -# -# def read_next_aquascat1000_header(f, file_size): -# # Reading packet type -# pkt_type_ = f.read(1) -# pkt_type, = st.unpack("B", pkt_type_) -# # Packet version: skipped -# pkt_version_ = f.read(1) -# st.unpack("B", pkt_version_) -# # Reading packet size -# pkt_size_ = f.read(2) -# pkt_size, = st.unpack("H", pkt_size_) -# # Packet checksum: skipped -# pkt_checksum_ = f.read(2) -# st.unpack("H", pkt_checksum_) -# -# if f.tell() == file_size: -# status = 0 -# else: -# status = 1 -# -# return status, pkt_type, pkt_size -# -# def find_aquascat1000_packet(f, type, file_size): -# f.seek(0) -# while f.tell() != file_size: -# status, pkt_type, pkt_size = read_next_aquascat1000_header( -# f, file_size) -# if status == 0: -# break -# elif pkt_type == type: -# break -# else: -# f.seek(2 * pkt_size, 1) -# return status, pkt_size -# -# # Opening the file -# f = open(self.path, 'rb') -# f.seek(0, 2) -# file_size = f.tell() -# f.seek(0) -# ExpType = 'SINGLE' -# -# # Read File Version from File -# status, pkt_size = find_aquascat1000_packet(f, 19, file_size) -# -# if status == 1: -# sdata = [st.unpack("H", f.read(2))[0] for ui in -# range(1, pkt_size + 1)] -# FileVersionMajor = sdata[1] -# FileVersionMinor = sdata[2] -# else: -# FileVersionMajor = 5 -# FileVersionMinor = 0 -# -# del sdata -# -# # Read in the Burst Start Time Information -# status, pkt_size = find_aquascat1000_packet(f, 54, file_size) -# if status == 1: -# sdata = [st.unpack("H", f.read(2))[0] for ui in range(1, 6 + 1)] -# wake_source_ = f.read(2) -# WakeSource, = st.unpack("H", wake_source_) -# burst_number_ = f.read(4) -# BurstNumber, = st.unpack("I", burst_number_) -# junk_ = f.read(2) -# Junk, = st.unpack("H", junk_) -# BurstTime = datetime.datetime(sdata[0], sdata[1], sdata[2], -# sdata[3], sdata[4], sdata[5]) -# else: -# BurstTime = datetime.datetime(0, 0, 0, 0, 0, 0) -# BurstNumber = 0 -# WakeSource = 0 -# -# del sdata -# -# # Deal with reading the personality -# status, pkt_size = find_aquascat1000_packet(f, 53, file_size) -# -# if status == 0: -# print('Error') -# pass -# else: -# pkt_start_pos = f.tell() -# skip_ = f.read(2) -# st.unpack("H", skip_) # Size of Packet -# st.unpack("H", f.read(2)) -# t1, = st.unpack("H", f.read(2)) -# t2, = st.unpack("H", f.read(2)) -# st.unpack("H", f.read(2)) -# LoggerType = [str(st.unpack("s", f.read(1)))[3] for ui in -# range(1, 32 + 1)] -# st.unpack("H", f.read(2)) -# NumAbsChannels, = st.unpack("H", f.read(2)) -# # Number of ABS channels the system supports -# NumAuxChannels, = st.unpack("H", f.read(2)) -# # Number of AUX channels the system supports (8) -# NumAbsTransducers, = st.unpack("H", f.read(2)) -# # Number of ABS Transducer Information that exist in personality table -# -# # Battery capacity (not recorded at this time) -# BatteryCapacity, = st.unpack("f", f.read(4)) -# StandbyPower, = st.unpack("f", f.read(4)) -# ActivePower, = st.unpack("f", f.read(4)) -# -# ############ -# f.seek(pkt_start_pos + 112, 0) -# # Offsets into the packet -# PtrToAuxInfo, = st.unpack("H", f.read(2)) -# PtrToTransducerInfo, = st.unpack("H", f.read(2)) -# -# # Read in the important information for the Aux Channels -# # First Need to assign the multiple dimension arrays -# AuxChannelName = [] -# AuxChannelUnit = [] -# AuxFlags = [] -# AuxNumGain = [] -# AuxCalDate = [] -# AuxNumCoeff = [] -# AuxGainLabel = [] -# AuxGainCoeff = [] -# AuxGainMin = [] -# AuxGainMax = [] -# for i in range(1, NumAuxChannels + 1): -# PtrToThisAux = pkt_start_pos + PtrToAuxInfo * 2 + 400 * (i - 1) -# # Move to the start of the ABS information -# f.seek(PtrToThisAux, 0) -# skip = [st.unpack("H", f.read(2)) for ui in range(1, 2 + 1)] -# TTmp = [str(st.unpack("s", f.read(1)))[3] for ui in -# range(1, 16 + 1)] -# sss = '' -# TTmp2 = sss.join(TTmp) -# TTmp2 = TTmp2.strip("\\") -# AuxChannelName = np.append(AuxChannelName, [TTmp2], axis=0) -# st.unpack("H", f.read(2)) -# TTmp = [str(st.unpack("s", f.read(1)))[3] for ui in -# range(1, 8 + 1)] -# sss = '' -# TTmp2 = sss.join(TTmp) -# TTmp2 = TTmp2.strip("\\") -# AuxChannelUnit = np.append(AuxChannelUnit, [TTmp2], axis=0) -# st.unpack("H", f.read(2)) -# AuxFlags = np.append(AuxFlags, st.unpack("H", f.read(2))) -# skip = [st.unpack("H", f.read(2)) for ui in range(1, 2 + 1)] -# AuxNumGain = np.append(AuxNumGain, st.unpack("H", f.read(2)), -# axis=0) -# st.unpack("H", f.read(2)) -# TTmp = [str(st.unpack("s", f.read(1)))[3] for ui in -# range(1, 16 + 1)] -# sss = '' -# TTmp2 = sss.join(TTmp) -# TTmp2 = TTmp2.strip("\\") -# AuxCalDate = np.append(AuxCalDate, [TTmp2], axis=0) -# st.unpack("H", f.read(2)) -# AuxNumCoeff = np.append(AuxNumCoeff, st.unpack("H", f.read(2)), -# axis=0) -# skip = [st.unpack("H", f.read(2)) for ui in range(1, 5 + 1)] -# -# f.seek(PtrToThisAux + 80, 0) # ensures aligned -# -# AuxGainLabel.append([]) -# AuxGainCoeff.append([]) -# AuxGainMin.append([]) -# AuxGainMax.append([]) -# for j in range(1, int(AuxNumGain[i - 1] + 1)): -# AuxGainLabel[i - 1].append([]) -# AuxGainCoeff[i - 1].append([]) -# AuxGainMin[i - 1].append([]) -# AuxGainMax[i - 1].append([]) -# TTmp = [str(st.unpack("s", f.read(1)))[3] for ui in -# range(1, 4 + 1)] -# sss = '' -# TTmp2 = sss.join(TTmp) -# TTmp2 = TTmp2.strip("\\") -# AuxGainLabel[i - 1][j - 1] = np.append( -# AuxGainLabel[i - 1][j - 1], [TTmp2], axis=0) -# [st.unpack("H", f.read(2)) for ui in range(1, 4 + 1)] -# TTmp = [st.unpack("f", f.read(4))[0] for ui in -# range(1, 5 + 1)] -# AuxGainCoeff[i - 1][j - 1] = np.append( -# AuxGainCoeff[i - 1][j - 1], TTmp, axis=0) -# AuxGainMin[i - 1][j - 1] = st.unpack("f", f.read(4))[ -# 0] # Minimum value used in calibration data -# AuxGainMax[i - 1][j - 1] = st.unpack("f", f.read( -# 4)) # Maximum value used in calibration data -# skip = [st.unpack("f", f.read(4)) for ui in -# range(1, 10 + 1)] -# -# # Now Jump to the Transducer Info -# TransducerSerialNum = [] -# TransducerFrequency = [] -# TransducerRadius = [] -# TransducerBeamWidth = [] -# TransducerKt = [] -# for i in range(1, NumAbsTransducers + 1): -# f.seek(pkt_start_pos + PtrToTransducerInfo * 2 + 200 * (i - 1), -# 0) # Move to the start of the ABS information -# TTmp = [str(st.unpack("s", f.read(1)))[3] for ui in -# range(1, 20 + 1)] -# sss = '' -# TTmp2 = sss.join(TTmp) -# TTmp2 = TTmp2.strip("\\") -# TransducerSerialNum = np.append(TransducerSerialNum, [TTmp2], -# axis=0) # GV-10 -# st.unpack("H", f.read(2)) -# -# # Transducer frequency in Hz -# TransducerFrequency = np.append(TransducerFrequency, -# st.unpack("f", f.read(4))) -# # Transducer radius in meters -# TransducerRadius = np.append(TransducerRadius, -# st.unpack("f", f.read(4))) -# -# # Transducers beam width in Degrees (3dB beamdidth, derived -# # from acoustic beam pattern) -# TransducerBeamWidth = np.append(TransducerBeamWidth, -# st.unpack("f", f.read(4))[0]) -# -# skip = [st.unpack("f", f.read(4)) for ui in range(1, 4 + 1)] -# -# # Transducer Kt (only if set in the personality) -# TransducerKt = np.append(TransducerKt, -# st.unpack("f", f.read(4))) -# -# # ---------------------------------------------------------------------- -# # Read in the Regime (Logger Set-Up) Information -# # ---------------------------------------------------------------------- -# -# # regime details -# status, pkt_size = find_aquascat1000_packet(f, 21, file_size) -# if 0 == status: -# print('Regime Packet not found abort') -# -# else: -# pkt_start_pos = f.tell() -# # Session Information -# # Not interested in session start time at the moment -# SessionControl = [st.unpack("H", f.read(2)) -# for ui in range(1, 11 + 1)] -# TTmp = [str(st.unpack("s", f.read(1)))[3] for ui in -# range(1, 32 + 1)] -# sss = '' -# TTmp2 = sss.join(TTmp) -# TTmp2 = TTmp2.strip("\\") -# SessionTitle = TTmp2 -# # The Aux channels are sampled at the PingRate divided by -# # the auxPingDiv -# AuxPingDiv, = st.unpack("H", f.read(2)) -# # The serial pressure + Temperature sampling derived as above -# SerialPingDiv, = st.unpack("H", f.read(2)) -# Junk = [st.unpack("H", f.read(2)) for ui in range(1, 2 + 1)] -# # THIS IS INCORRECTLY SAVED BY THE SYSTEM, SHOULD BE 0 or 8 -# NumAuxChans, = st.unpack("H", f.read(2)) -# NumAuxSamples, = st.unpack("I", f.read(4)) -# -# # This is a temp trick to correct---------------------| -# # if NumAuxSamples!=0: -# # NumAuxChans=8 # for NumAuxChans always being 0 -# # # It should be eliminated when corrected by Aquatec---| -# -# Junk = [st.unpack("H", f.read(2)) for ui in range(1, 4 + 1)] -# # Ping rate (base profile rate before averaging) -# PingRate, = st.unpack("H", f.read(2)) -# # This is number of profiles collected prior to averaging -# NumPings, = st.unpack("I", f.read(4)) -# # Number of enabled ABS Channels -# NumAbsTimeSlots, = st.unpack("H", f.read(2)) -# Junk = [st.unpack("H", f.read(2)) for ui in range(1, 3 + 1)] -# -# # These are the offsets into the Packet -# PtrToAuxInfo, = st.unpack("H", f.read(2)) -# PtrToAbsInfo, = st.unpack("H", f.read(2)) -# -# # Calculate Aux Specific Information -# -# # if AuxPingDiv=0 then no aux channels are -# # enabled and NumAuxChannels =0 -# AuxSampleRate = 0 -# if 0 == AuxPingDiv: -# AuxNumSamples = 0 -# NumAuxChans = 0 -# else: -# AuxSampleRate = PingRate / AuxPingDiv -# AuxNumSamples = np.ceil(NumPings / AuxPingDiv) # GV-10 -# if NumAuxChans == 0: -# NumAuxChans = 8 -# -# # Serial Pressure + Temperature information -# if 0 == SerialPingDiv: -# NumSerialSamples = 0 -# SerialSampleRate = 0 -# else: -# NumSerialSamples = np.ceil(NumPings / SerialPingDiv) -# SerialSampleRate = PingRate / SerialPingDiv -# -# # Nothing useful in the channel -# -# # Now read in the ABS Channel information -# -# # Move to the start of the ABS information -# f.seek(pkt_start_pos + PtrToAbsInfo * 2, 0) -# -# AbsComplex = [] -# AbsAverage = [] -# AbsDecimation = [] -# AbsBinLengthMM = [] -# AbsBinLength = [] -# AbsTransducerName = [] -# AbsTransducerRadius = [] -# AbsTransducerBeamWidth = [] -# AbsTransducerKt = [] -# AbsTxFrequency = [] -# AbsRxFrequency = [] -# AbsTxPulseLength = [] -# AbsStartingGain = [] -# AbsTVG = [] -# AbsPowerLevelpc = [] -# AbsPowerLevel = [] -# AbsStartBin = [] -# AbsRxChan = [] -# AbsTxChan = [] -# AbsNumBins = [] -# AbsNumProfiles = [] -# AbsProfileRate = [] -# AbsBinRange = [] -# for j in range(1, NumAbsTimeSlots + 1): -# AbsBinRange.append([]) -# # TransducerRadius = np.append(TransducerRadius, -# # st.unpack("f",f.read(4))) # In meters -# Tmp, = st.unpack("H", f.read(2)) -# # For magnitude=0,complex=2 -# AbsComplex = np.append(AbsComplex, Tmp & 2) -# # No of bursts averaged before saving -# AbsAverage = np.append(AbsAverage, st.unpack("H", f.read(2))) -# # Raw sampling rate along a profile is 19.2MHz, AbsDecimation i -# AbsDecimation = np.append(AbsDecimation, st.unpack("H", -# f.read(2))) -# # Converts to bin size in mm based on speed 1500ms-1 -# AbsBinLengthMM = np.append( -# AbsBinLengthMM, 1.25 * 2 ** AbsDecimation[j - 1]) -# # Stored as time in seconds -# AbsBinLength = AbsBinLengthMM[j - 1] / 1500 -# -# # Using the Trasnducer ID copy the relevant data across -# # Used to look up transducer information from personality -# TransducerId, = st.unpack("H", f.read(2)) -# TransducerId = TransducerId + 1 -# -# AbsTransducerName = np.append( -# AbsTransducerName, TransducerSerialNum[TransducerId - 1]) -# # Transducer radius in m -# AbsTransducerRadius = np.append( -# AbsTransducerRadius, TransducerRadius[TransducerId - 1]) -# # Transducer beam width in degs -# AbsTransducerBeamWidth = np.append( -# AbsTransducerBeamWidth, -# TransducerBeamWidth[TransducerId - 1]) -# AbsTransducerKt = np.append(AbsTransducerKt, -# TransducerKt[TransducerId - 1]) -# -# AbsTxFrequency = np.append(AbsTxFrequency, -# st.unpack("f", f.read(4))) # In Hz -# AbsRxFrequency = np.append(AbsRxFrequency, -# st.unpack("f", f.read(4))) # In Hz -# -# # Pulse length in seconds -# AbsTxPulseLength = np.append( -# AbsTxPulseLength, st.unpack("f", f.read(4))) -# Junk = st.unpack("f", f.read(4)) -# # Gain in dB with reference to default (built-in) Gain of system -# AbsStartingGain = np.append( -# AbsStartingGain, st.unpack("f", f.read(4))) -# # In dB / bin where first bin has StartingGain (not used, =0) -# AbsTVG = np.append(AbsTVG, st.unpack("f", f.read(4))) -# powerlevel, = st.unpack("H", f.read(2)) -# # Power Level in % of Maximum -# AbsPowerLevelpc = np.append(AbsPowerLevelpc, -# 100 / 2 ** (2 * powerlevel)) -# AbsPowerLevel = np.append(AbsPowerLevel, -20 * np.log10( -# 2 ** powerlevel)) # Power Level in dB relative to Maximum Power -# # Number of Bins from Start of Tx pulse before recording -# AbsStartBin = np.append(AbsStartBin, st.unpack("H", f.read(2))) -# # Number of Bins recorded -# AbsNumBins = np.append(AbsNumBins, st.unpack("H", f.read(2))) -# # Indicates which channel on AQUAscat used for TX -# AbsRxChan = np.append(AbsRxChan, st.unpack("B", f.read(1))) -# # Indicates which channel on AQUAscat used for RX -# AbsTxChan = np.append(AbsTxChan, st.unpack("B", f.read(1))) -# -# Junk = [st.unpack("H", f.read(2)) for ui in range(1, 12 + 1)] -# # Calculate the number of profiles that should be recorded -# # for this channel -# AbsNumProfiles = np.append(AbsNumProfiles, -# NumPings / AbsAverage[j - 1]) -# # Calculate the stored profile rate -# AbsProfileRate = np.append(AbsProfileRate, -# PingRate / AbsAverage[j - 1]) -# -# AbsBinRange[j - 1] = np.append( -# AbsBinRange[j - 1], -# np.array([np.arange(( -# AbsStartBin[j - 1]), -# (AbsStartBin[j - 1] + -# AbsNumBins[j - 1]))]) * -# AbsBinLengthMM[j - 1] / 1000) # in m -- -# -# # --------------------------------------------------------------------- -# # Now deal with reading in the data -# # --------------------------------------------------------------------- -# -# # Allocate Memory for the Data -# AuxData = np.zeros((int(AuxNumSamples), NumAuxChans)) -# AbsData = np.zeros((int(AbsNumBins[0]), int(AbsNumProfiles[0]), -# int(NumAbsTimeSlots)), dtype=float, order='C') -# PressTempData = np.zeros((NumSerialSamples, 2)) -# -# AuxIndex = 0 -# SerIndex = 0 -# AbsIndex = np.zeros((NumAbsTimeSlots, 1)) -# f.seek(0, 0) -# -# # Now Read in all the Data -# -# while (f.tell() != file_size): # 0 == feof(fid)) -# status, pktType, pkt_size = read_next_aquascat1000_header(f, -# file_size) -# -# if 1 == status: -# -# if pktType == 22: -# -# # switch(pktType) -# -# # Case 22: Data were saved as magnitude values -# # (normalize by 65536) -# -# # case (22) -# chan = st.unpack("H", f.read(2))[0] + 1 -# AbsIndex[chan - 1] = AbsIndex[ -# chan - 1] + 1 # Increase the Index -# Tmp = [st.unpack("H", f.read(2))[0] for ui in -# np.arange(1, AbsNumBins[chan - 1] + 1)] -# newList = [x / 65536 for x in Tmp] -# AbsData[0:int(AbsNumBins[0]), -# int(AbsIndex[chan - 1] - 1), -# int(chan - 1)] = np.array(newList[:]) -# -# # Case 41: Data were saved as Complex values -# # (normalize by 32768) -# -# elif pktType == 41: # case (41) -# chan = st.unpack("H", f.read(2))[0] + 1 -# AbsIndex[chan - 1] = AbsIndex[ -# chan - 1] + 1 # Increase the Index -# Tmp = [st.unpack("h", f.read(2))[0] for ui in -# np.arange(1, 2 * AbsNumBins[chan - 1] + 1)] -# sss = [x / 32768 for x in Tmp] -# AbsData[:, np.int(AbsIndex[chan - 1]), -# int(chan - 1)] = np.array(sss) -# -# # Case 46: Auxiliary Channel Data -# -# elif pktType == 46: # case (46) -# temp = st.unpack("H", f.read(2))[0] # Gain settings -# AuxGain = [(temp & 3) + 1, ((temp >> 2) & 3) + 1, -# ((temp >> 4) & 3) + 1, ((temp >> 6) & 3) + 1, 1, -# 1, 1, 1] -# Junk = st.unpack("H", f.read(2))[0] # Flags -# AuxIndex = AuxIndex + 1 -# Tmp = [st.unpack("H", f.read(2))[0] for ui in -# np.arange(1, NumAuxChans + 1)] -# try: -# AuxData[AuxIndex - 1, 0:NumAuxChans] = Tmp[:] -# except IndexError: -# pass -# -# # Case 55: External Pressure Channel for upgraded ABS system - -# # details to be provided -# -# elif pktType == 55: # case (55) -# chan = st.unpack("H", f.read(2))[0] + 1 -# SerIndex = SerIndex + 1 # Increase the Index -# Tmp = [st.unpack("f", f.read(4))[0] for ui in -# np.arange(1, 2 + 1)] -# PressTempData[SerIndex - 1, :] = Tmp[:] -# -# else: # otherwise -# f.seek(pkt_size * 2, 1) -# -# -# for i in range(0, NumAuxChans): -# if not AuxGainCoeff[:][i]: -# coeff = np.array(AuxGainCoeff[:][0]) -# AuxGainCoeff[:][i].append(coeff[0] * 0) -# -# # Matlab orders polynomial coeff opposite to Aquatec -# coeff = np.array(AuxGainCoeff[:][i]) -# coeff = coeff.reshape(1, 5) -# coeff = np.fliplr(coeff) -# coeff = coeff.reshape(5) -# AuxData[:, i] = np.polyval(coeff, AuxData[:, i]) -# -# # Need to apply calibration coefficients for the Aux Channels, -# # now that the gain is fixed, auto gain is not supported. -# # Therefore will use last value -# -# ####TO BE DONE USING ACTUAL AUXDATA -# if NumAuxChans == 0: -# AuxData = [] -# -# # ---------------- Add by Adrien Vergne: filling the class ---------- # -# # Number of profiles -# self.NumProfiles = int(AbsNumProfiles[0]) -# # Profile rate -# self.ProfileRate = AbsProfileRate[0] -# # Frequencies -# self.Freq = AbsTxFrequency -# # Frequencies in text format -# for i in range(len(self.Freq)): -# self.freqText.append(str(self.Freq[i] / 1e6) + ' MHz') -# # Transducer radius -# self.At = AbsTransducerRadius -# # Backscatter data -# self.V = AbsData -# # Changing axis order: axis 0 range, axis1 frequency, axis 2 profile -# self.V = self.V.swapaxes(2, 1) -# # Range cells -# self.r = AbsBinRange[0] -# self.r = np.reshape(self.r, (np.size(self.r), 1)) -# # Number of cells -# self.NumCells = np.size(self.r) -# # Cell size -# self.cellSize = self.r[1, 0] - self.r[0, 0] -# # Pulse length -# self.TxPulseLength = AbsTxPulseLength[0] -# # Received gain -# self.RxGain = AbsStartingGain -# # Emitted gain -# self.TxGain = np.round(AbsPowerLevel, 3) -# # Averaging -# self.Average = AbsAverage[0] -# # Beam width -# self.BeamWidth = AbsTransducerBeamWidth -# # Kt -# self.Kt = AbsTransducerKt -# # Ping rate -# self.PingRate = PingRate -# # Session title -# self.Regime = SessionTitle -# -# f.close # Close the *.aqa data file -# -# -# class MeanAquascatProfile: -# """ This class creates an object that contains several data of the mean -# profile computed for one burst -# @ivar file_name: string, name of the raw data file -# @ivar Freq: list of float, frequencies -# @ivar freqText: list of strings, freq in text in MHz -# @ivar NumProfiles: int, number of profiles averaged -# @ivar r: array of float, range cells for the profile -# @ivar rMin: int, minimum range -# @ivar rMax: int, maximum range -# @ivar V: 2D array of float, ABS mean data -# @ivar Average_method: string, 'simple' or 'quadratic' -# @ivar Rx: list of received gain (one for each frequency) -# @ivar Tx: list of emission gain (one for each frequency) -# @ivar average : int, number of pings averaged per profile in the -# initial burst -# @ivar pulseLength: array of floats, length of the pulse in second -# """ -# -# def __init__(self): -# -# # File name of the raw data -# self.file_name = '' -# # Frequencies -# self.Freq = [] -# # Frequencies in text format -# self.freqText = [] -# # Number of profiles averaged -# self.NumProfiles = 0 -# # Range cells -# self.r = np.array([]) -# # Minimum range -# self.rMin = 0 -# # Maximum range -# self.rMax = 0 -# # ABS data -# self.V = np.array([]) -# # Averaging method -# self.Average_method = '' -# # Reception gain -# self.Rx = [] -# # Emission gain -# self.Tx = [] -# # number of pings averaged per profile in the intial burst -# self.average = 0 -# # pulse length (s) -# self.pulseLength = 0 -# -# def compute_mean(self, abs_raw, r_min=0, r_max=-1, mean='quadratic'): -# """This function computes a mean backscatter profile from the -# raw data abs_raw, between r_min and r_max, using average method -# 'quadratic' or 'simple'""" -# # Filling the profile medata -# self.file_name = abs_raw.file_name -# self.Freq = abs_raw.Freq -# self.freqText = abs_raw.freqText -# self.NumProfiles = abs_raw.NumProfiles -# self.Rx = abs_raw.RxGain -# self.Tx = abs_raw.TxGain -# self.average = abs_raw.Average -# self.pulseLength = abs_raw.TxPulseLength -# -# # Filling r values -# if r_min == 0: -# ind_rmin = 0 -# else: -# ind_rmin = np.where(abs_raw.r <= r_min)[0][-1] -# if r_max == -1: -# ind_rmax = abs_raw.r.size -# else: -# ind_rmax = np.where(abs_raw.r >= r_max)[0][0] -# self.r = abs_raw.r[ind_rmin:ind_rmax + 1] -# self.rMin = self.r[0][0] -# self.rMax = self.r[-1][0] -# -# # Filling V values -# if mean == 'quadratic': -# self.Average_method = 'quadratic' -# self.V = np.sqrt( -# np.nanmean(abs_raw.V[ind_rmin:ind_rmax + 1, :, :] ** 2, -# axis=2)) -# elif mean == 'simple': -# self.Average_method = 'simple' -# self.V = np.nanmean(abs_raw.V[ind_rmin:ind_rmax + 1, :, :], axis=2) -# else: -# raise ValueError("mean should be 'quadratic' or 'simple'") -# -# def write_txt_file(self, path): -# """ This method allows to write the mean profile data in a -# text file""" -# -# # Opening the text file to write in -# file = open(path, "w") -# -# # Writing the parameters -# file.write("AQUAscat mean ABS profile\n\n") -# -# # Burst name -# file.write("Initial burst name\n") -# file.write(self.file_name + '\n\n') -# -# # Frequencies -# file.write('Freq\n') -# for i in self.Freq[0:-1]: -# file.write('%s, ' % i) -# file.write(str(self.Freq[-1])+'\n\n') -# -# # Frequencies in text format -# file.write('Freq in text format\n') -# for i in self.freqText[0:-1]: -# file.write(i + ', ') -# file.write(self.freqText[-1]+'\n\n') -# -# # Number of profiles averaged -# file.write('Number of profiles averaged\n') -# file.write('%s \n\n' % self.NumProfiles) -# -# # Range cells -# file.write('r\n') -# for i in self.r[0:-1]: -# file.write('%s, ' % i[0]) -# file.write('%s' % self.r[-1][0]) -# file.write('\n\n') -# -# # Minimum range -# file.write('rMin\n') -# file.write(str(self.rMin) + '\n\n') -# -# # Maximum range -# file.write('rMax\n') -# file.write(str(self.rMax) + '\n\n') -# -# # ABS data -# file.write('V\n') -# for f in range(len(self.Freq)): -# for i in self.V[0:-1, f]: -# file.write('%s, ' % i) -# file.write(str(self.V[-1, f])+'\n') -# file.write('\n') -# -# # Reception gain -# file.write('Rx gain\n') -# for i in self.Rx[0:-1]: -# file.write('%s, ' % i) -# file.write(str(self.Rx[-1])+'\n\n') -# -# # Transmission gain -# file.write('Tx gain\n') -# for i in self.Tx[0:-1]: -# file.write('%s, ' % i) -# file.write(str(self.Tx[-1])+'\n\n') -# -# # Number of pings average -# file.write("Nb pings averaged in 1 profile\n") -# file.write(str(self.average) + '\n\n') -# -# # Pulse length -# file.write("Pulse length (s)\n") -# file.write(str(self.pulseLength) + '\n\n') -# -# file.close() -# -# def load_txt_file(self, path): -# """ This method allows to load the mean profile data from a -# text file""" -# -# # Opening the text file to write in -# file = open(path, "r") -# -# # Line 1 and 2: skipped -# file.readline().rstrip('\n') -# file.readline().rstrip('\n') -# -# # Lines 3-4 : initial burst name -# file.readline().rstrip('\n') # .rstrip('\n') for removing the "end -# # line" character -# temp = file.readline().rstrip('\n') -# self.file_name = temp -# -# # Lines 6-7 : frequencies -# file.readline().rstrip('\n') -# file.readline().rstrip('\n') -# temp = np.fromstring(file.readline().rstrip('\n'), dtype=float, sep=',') -# self.Freq = temp -# -# # Lines 9-10 : frequencies in text format -# file.readline().rstrip('\n') -# file.readline().rstrip('\n') -# temp = file.readline().rstrip('\n') -# self.freqText = temp.split(sep=', ') -# -# # Line 12 - 13 : Number of profiles averaged -# file.readline().rstrip('\n') -# file.readline().rstrip('\n') -# temp = eval(file.readline().rstrip('\n')) -# self.NumProfiles = temp -# -# # Lines 15-16 : range data -# file.readline().rstrip('\n') -# file.readline().rstrip('\n') -# temp = np.fromstring(file.readline().rstrip('\n'), dtype=float, sep=',') -# # Reshaping the array in a column vector -# temp = temp.reshape(len(temp), 1) -# self.r = temp -# -# # Lines 18-19 : minimum range -# file.readline().rstrip('\n') -# file.readline().rstrip('\n') -# temp = eval(file.readline().rstrip('\n')) -# self.rMin = temp -# -# # Lines 21-22 : maximum range -# file.readline().rstrip('\n') -# file.readline().rstrip('\n') -# temp = eval(file.readline().rstrip('\n')) -# self.rMax = temp -# -# # Lines 24 --- ABS data -# file.readline().rstrip('\n') -# file.readline().rstrip('\n') -# # Reading the lines one by one -# for f in range(len(self.Freq)): -# temp = np.fromstring(file.readline().rstrip('\n'), dtype=float, -# sep=', ') -# -# if f == 0: -# self.V = temp -# else: -# # Adding a column -# self.V = np.c_[self.V, temp] -# -# # Rx gain -# file.readline().rstrip('\n') -# file.readline().rstrip('\n') -# temp = np.fromstring(file.readline().rstrip('\n'), dtype=float, sep=',') -# self.Rx = temp -# -# # Tx gain -# file.readline().rstrip('\n') -# file.readline().rstrip('\n') -# temp = np.fromstring(file.readline().rstrip('\n'), dtype=float, sep=',') -# self.Tx = temp -# -# # Number of pings averaged -# file.readline().rstrip('\n') -# file.readline().rstrip('\n') -# temp = np.fromstring(file.readline().rstrip('\n'), dtype=float, sep=',') -# self.average = temp -# -# # Pulse length -# file.readline().rstrip('\n') -# file.readline().rstrip('\n') -# temp = np.fromstring(file.readline().rstrip('\n'), dtype=float, sep=',') -# self.pulseLength = temp -# -# file.close() -# -# # ------------------------- Test --------------------------------------# -# start_time = time.time() -# -# if __name__ == "__main__": -# # path1 = r'C:\Users\vergne\Documents\Donnees_aquascat\2017_juillet - experience cuve sediments fins\2017_07_19 - mercredi eau claire\20170719114700.aqa' -# path1 = r'//home/brahim.moudjed/Documents/3 Software_Project/river_inversion_project/Data/Aquascat data test/20171213135800.aqa' -# data1 = RawAquascatData(path1) -# -# # path2 = r'C:\Users\vergne\Documents\Donnees_aquascat\2017_juillet - experience cuve sediments fins\2017_07_19 - mercredi eau claire\20170719114700.aqa.txt' -# path2 = r'//home/brahim.moudjed/Documents/3 Software_Project/river_inversion_project/Data/Aquascat data test/20171213135800.txt' -# data2 = RawAquascatData(path2) -# -# print(data1.PingRate) -# print(data2.PingRate) -# -# print("Computational time: %.2f min" %((time.time() - start_time)/60) ) - - -# ********************************************************************************************************************** -# ********************************************************************************************************************** -# ********************************************************************************************************************** - # -*- coding: utf-8 -*- """ Created on Wen Jun 08 2016 @@ -1133,14 +23,13 @@ Created on Wen Jun 08 2016 import numpy as np # Matrix scientific computing import os # Path / folder access management -import datetime # for time management +import datetime # for time management # Loading binary data import struct as st import glob import pickle import time - # ---------------------------------------------------------------------------# # ------------------------------ CLASSES -----------------------------------# # ---------------------------------------------------------------------------# @@ -1326,7 +215,7 @@ class RawAquascatData: self.r = temp # Computing the cell size - self.cellSize = self.r[1, 0] - self.r[0, 0] + self.cellSize = self.r[1, 0]-self.r[0, 0] # Skipping the other r lines for f in range(1, len(self.Freq)): @@ -1800,31 +689,31 @@ class RawAquascatData: # Allocate Memory for the Data AuxData = np.zeros((int(AuxNumSamples), int(NumAuxChans))) AbsData = np.zeros((int( - AbsNumBins[0]), int( - AbsNumProfiles[0]), int( - NumAbsTimeSlots)), dtype=float, order='C') + AbsNumBins[0]), int( + AbsNumProfiles[0]), int( + NumAbsTimeSlots)), dtype=float, order='C') PressTempData = np.zeros((NumSerialSamples, 2)) AuxIndex = 0 SerIndex = 0 - AbsIndex = np.zeros((NumAbsTimeSlots, 1)) - 1 + AbsIndex = np.zeros((NumAbsTimeSlots, 1))-1 f.seek(0, 0) # Now Read in all the Data - while (f.tell() != file_size): # 0 == feof(fid)) + while(f.tell() != file_size): # 0 == feof(fid)) status, pktType, pktSize = readNextAQUAscat1000Header(f, file_size) if 1 == status: if pktType == 22: - chan = st.unpack("H", f.read(2))[0] + 1 + chan = st.unpack("H", f.read(2))[0]+1 # Increase the Index - AbsIndex[chan - 1] = AbsIndex[chan - 1] + 1 + AbsIndex[chan-1] = AbsIndex[chan-1] + 1 Tmp = [st.unpack( - "H", f.read(2))[0] for ui in np.arange( - 1, AbsNumBins[chan - 1] + 1)] + "H", f.read(2))[0] for ui in np.arange( + 1, AbsNumBins[chan-1]+1)] newList = [x / 65536 for x in Tmp] AbsData[0:int(AbsNumBins[0]), int( - AbsIndex[chan - 1] - 1), int( - chan - 1)] = np.array(newList[:]) + AbsIndex[chan-1]-1), int( + chan-1)] = np.array(newList[:]) # Case 41: Data were saved as Complex values # (normalize by 32768) @@ -1832,16 +721,17 @@ class RawAquascatData: elif pktType == 41: chan = st.unpack("H", f.read(2))[0] + 1 # Increase the Index + - AbsIndex[chan - 1] = AbsIndex[chan - 1] + 1 + AbsIndex[chan-1] = AbsIndex[chan-1] + 1 Tmp = [st.unpack( - "h", f.read(2))[0] for ui in np.arange( - 1, 2 * AbsNumBins[chan - 1] + 1)] + "h", f.read(2))[0] for ui in np.arange( + 1, 2 * AbsNumBins[chan-1]+1)] sss = [x / 32768 for x in Tmp] - + AbsData[:, int( - AbsIndex[chan - 1]), int(chan - 1)] = np.abs( - np.array(sss[0::2]) + complex(0, 1) * np.array(sss[1::2])) + AbsIndex[chan-1]), int(chan-1)] = np.abs(np.array(sss[0::2])+complex(0,1)*np.array(sss[1::2])) + # Case 46: Auxiliary Channel Data @@ -1849,21 +739,21 @@ class RawAquascatData: elif pktType == 46: # Gain settings temp = st.unpack("H", f.read(2))[0] - AuxGain = [(temp & 3) + 1, ((temp >> 2) & 3) + 1, ( - (temp >> 4) & 3) + 1, ( - (temp >> 6) & 3) + 1, 1, 1, 1, 1] + AuxGain = [(temp & 3) + 1, ((temp >> 2) & 3)+1, ( + (temp >> 4) & 3)+1, ( + (temp >> 6) & 3)+1, 1, 1, 1, 1] # Flags Junk = st.unpack("H", f.read(2))[0] AuxIndex = AuxIndex + 1 Tmp = [st.unpack( - "H", f.read(2))[0] for ui in np.arange( - 1, NumAuxChans + 1)] + "H", f.read(2))[0] for ui in np.arange( + 1, NumAuxChans+1)] - if AuxIndex == AuxNumSamples + 1: - AuxIndex = AuxIndex - 1 + if AuxIndex == AuxNumSamples+1: + AuxIndex = AuxIndex-1 pass else: - AuxData[AuxIndex - 1, 0:NumAuxChans] = Tmp[:] + AuxData[AuxIndex-1, 0:NumAuxChans] = Tmp[:] # AuxData[AuxIndex-1,0:NumAuxChans] = Tmp[:] # Case 55: External Pressure Channel for upgraded @@ -1871,20 +761,20 @@ class RawAquascatData: # case (55) elif pktType == 55: - chan = st.unpack("H", f.read(2))[0] + 1 + chan = st.unpack("H", f.read(2))[0]+1 # Increase the Index SerIndex = SerIndex + 1 Tmp = [st.unpack( - "f", f.read(4))[0] for ui in np.arange(1, 2 + 1)] - PressTempData[SerIndex - 1, :] = Tmp[:] + "f", f.read(4))[0] for ui in np.arange(1, 2+1)] + PressTempData[SerIndex-1, :] = Tmp[:] else: # otherwise f.seek(pktSize * 2, 1) print('Summary of Data Imported') - for j in range(1, NumAbsTimeSlots + 1): - print('Timeslot {} Total Profiles = {}'.format(j - 1, AbsIndex[j - 1])) + for j in range(1, NumAbsTimeSlots+1): + print('Timeslot {} Total Profiles = {}'.format(j-1, AbsIndex[j-1])) print('Total Aux Samples = {}'.format(AuxIndex)) @@ -1901,8 +791,8 @@ class RawAquascatData: coeff = coeff.reshape(5) AuxData[:, i] = np.polyval(coeff, AuxData[:, i]) - # Need to apply calibration coefficients for the Aux Channels, now that the - # gain is fixed, auto gain is not supported. Therefore will use last value + # Need to apply calibration coefficients for the Aux Channels, now that the + # gain is fixed, auto gain is not supported. Therefore will use last value if NumAuxChans == 0: AuxData = [] @@ -2030,7 +920,7 @@ class MeanAquascatProfile: self.Average_method = 'quadratic' self.V = np.sqrt( np.nanmean(abs_raw.V[ind_rmin:ind_rmax + 1, :, :] ** 2, - axis=2)) + axis=2)) elif mean == 'simple': self.Average_method = 'simple' self.V = np.nanmean(abs_raw.V[ind_rmin:ind_rmax + 1, :, :], axis=2) @@ -2055,13 +945,13 @@ class MeanAquascatProfile: file.write('Freq\n') for i in self.Freq[0:-1]: file.write('%s, ' % i) - file.write(str(self.Freq[-1]) + '\n\n') + file.write(str(self.Freq[-1])+'\n\n') # Frequencies in text format file.write('Freq in text format\n') for i in self.freqText[0:-1]: file.write(i + ', ') - file.write(self.freqText[-1] + '\n\n') + file.write(self.freqText[-1]+'\n\n') # Number of profiles averaged file.write('Number of profiles averaged\n') @@ -2087,20 +977,20 @@ class MeanAquascatProfile: for f in range(len(self.Freq)): for i in self.V[0:-1, f]: file.write('%s, ' % i) - file.write(str(self.V[-1, f]) + '\n') + file.write(str(self.V[-1, f])+'\n') file.write('\n') # Reception gain file.write('Rx gain\n') for i in self.Rx[0:-1]: file.write('%s, ' % i) - file.write(str(self.Rx[-1]) + '\n\n') + file.write(str(self.Rx[-1])+'\n\n') # Transmission gain file.write('Tx gain\n') for i in self.Tx[0:-1]: file.write('%s, ' % i) - file.write(str(self.Tx[-1]) + '\n\n') + file.write(str(self.Tx[-1])+'\n\n') # Number of pings average file.write("Nb pings averaged in 1 profile\n") @@ -2207,23 +1097,19 @@ class MeanAquascatProfile: file.close() - # ------------------------- Test --------------------------------------# start_time = time.time() if __name__ == "__main__": - # path1 = r'C:\Users\vergne\Documents\Donnees_aquascat\2017_juillet - experience cuve sediments fins\2017_07_19 - mercredi eau claire\20170719114700.aqa' +# path1 = r'C:\Users\vergne\Documents\Donnees_aquascat\2017_juillet - experience cuve sediments fins\2017_07_19 - mercredi eau claire\20170719114700.aqa' path1 = r'//home/brahim.moudjed/Documents/3 Software_Project/river_inversion_project/Data/Aquascat data test/20171213135800.aqa' data1 = RawAquascatData(path1) - - # path2 = r'C:\Users\vergne\Documents\Donnees_aquascat\2017_juillet - experience cuve sediments fins\2017_07_19 - mercredi eau claire\20170719114700.aqa.txt' + +# path2 = r'C:\Users\vergne\Documents\Donnees_aquascat\2017_juillet - experience cuve sediments fins\2017_07_19 - mercredi eau claire\20170719114700.aqa.txt' path2 = r'//home/brahim.moudjed/Documents/3 Software_Project/river_inversion_project/Data/Aquascat data test/20171213135800.txt' data2 = RawAquascatData(path2) print(data1.PingRate) print(data2.PingRate) -print("Computational time: %.2f min" % ((time.time() - start_time) / 60)) - - - +print("Computational time: %.2f min" %((time.time() - start_time)/60) ) diff --git a/Model/acoustic_data_loader.py b/Model/acoustic_data_loader.py index a4fe4b3..d559951 100644 --- a/Model/acoustic_data_loader.py +++ b/Model/acoustic_data_loader.py @@ -5,8 +5,7 @@ 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_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" @@ -16,11 +15,11 @@ 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}") @@ -38,19 +37,19 @@ class AcousticDataLoader: 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._nb_profiles = [self._data_BS.NumProfiles]*self._freq.shape[0] + self._nb_profiles_per_sec = [self._data_BS.ProfileRate]*self._freq.shape[0] + self._nb_cells = [self._data_BS.NumCells]*self._freq.shape[0] + self._cell_size = [self._data_BS.cellSize]*self._freq.shape[0] + self._pulse_length = [self._data_BS.TxPulseLength]*self._freq.shape[0] + self._nb_pings_per_sec = [self._data_BS.PingRate]*self._freq.shape[0] + self._nb_pings_averaged_per_profile = [self._data_BS.Average]*self._freq.shape[0] + self._kt = self._data_BS.Kt.tolist() + self._gain_rx = self._data_BS.RxGain.tolist() + self._gain_tx = self._data_BS.TxGain.tolist() - print(self._r[0, :][1] - self._r[1, :][0]) - print(self._kt) + # 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([]) diff --git a/Model/acoustic_data_loader_UBSediFlow.py b/Model/acoustic_data_loader_UBSediFlow.py index 82ba3c3..5b2f435 100644 --- a/Model/acoustic_data_loader_UBSediFlow.py +++ b/Model/acoustic_data_loader_UBSediFlow.py @@ -32,7 +32,7 @@ from Model.udt_extract.raw_extract import raw_extract # path_BS_raw_data0 = ("/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data/Raw_data_udt/") # filename0 = "raw_20210519_130643.udt" -# path_BS_raw_data0 = ("/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data/Raw_data_udt/") +# path_BS_raw_data0 = ("/home/bmoudjed/Documents/2 Data/APAVER_2021/Raw_data_udt/") # filename0 = "raw_20210520_085958.udt" # filename = "raw_20210519_115128.udt" @@ -54,23 +54,36 @@ class AcousticDataLoaderUBSediFlow: = raw_extract(self.path_BS_raw_data) print(f"device_name : {device_name}") - print(f"time_begin : {time_begin}") + print(f"date begin : {time_begin.date()}") + print(f"time begin : {time_begin.time()}") print(f"settings_dict : {settings_dict}") - # --- Date and Hour of measurements read on udt data file --- - filename = self.path_BS_raw_data[-23:] - date_and_time = datetime.datetime(year=int(filename[4:8]), - month=int(filename[8:10]), - day=int(filename[10:12]), - hour=int(filename[13:15]), - minute=int(filename[15:17]), - second=int(filename[17:19])) - self._date = date_and_time.date() + # # --- Date and Hour of measurements read on udt data file --- + # filename = self.path_BS_raw_data[-23:] + # date_and_time = datetime.datetime(year=int(filename[4:8]), + # month=int(filename[8:10]), + # day=int(filename[10:12]), + # hour=int(filename[13:15]), + # minute=int(filename[15:17]), + # second=int(filename[17:19])) + self._date = time_begin.date() print(f"date : {self._date}") - self._hour = date_and_time.time() + self._hour = time_begin.time() print(f"time : {self._hour}") self._freq = np.array([[]]) + + self._nb_profiles = [] + self._nb_profiles_per_sec = [] + self._nb_cells = [] + self._cell_size = [] + self._pulse_length = [] + self._nb_pings_per_sec = [] + self._nb_pings_averaged_per_profile = [] + self._kt = [] + self._gain_rx = [] + self._gain_tx = [] + self._r = np.array([[]]) self._time = np.array([[]]) self._time_snr = np.array([[]]) @@ -78,18 +91,29 @@ class AcousticDataLoaderUBSediFlow: # self._SNR_data = np.array([[[]]]) 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") 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(param_us_dicts[config][channel]) + # print("param_us_dicts[config][channel] ", param_us_dicts[config][channel]) + # print("param_us_dicts ", param_us_dicts) # print(data_us_dicts[config][channel]['echo_avg_profile']) # --- Frequencies --- self._freq = np.append(self._freq, param_us_dicts[config][channel]['f0']) + self._nb_cells = np.append(self._nb_cells, param_us_dicts[config][channel]['n_cell']) + self._cell_size = np.append(self._cell_size, param_us_dicts[config][channel]['r_dcell']) + self._pulse_length = np.append(self._pulse_length, 0) + self._nb_pings_per_sec = np.append(self._nb_pings_per_sec, param_us_dicts[config][channel]['prf']) + self._nb_pings_averaged_per_profile = np.append(self._nb_pings_averaged_per_profile, param_us_dicts[config][channel]['n_p']) + self._kt = np.append(self._kt, 0) + self._gain_rx = np.append(self._gain_rx, param_us_dicts[config][channel]['a0']) + self._gain_tx = np.append(self._gain_tx, param_us_dicts[config][channel]['a1']) + # --- Depth for each frequencies --- print("r_dcell : ", param_us_dicts[config][channel]['r_dcell']) print("n_cell : ", param_us_dicts[config][channel]['n_cell']) @@ -145,6 +169,10 @@ class AcousticDataLoaderUBSediFlow: self._time = np.append(self._time, time, axis=0) print(f"self._time.shape {self._time.shape}") + self._nb_profiles = np.append(self._nb_profiles, self._time.shape[1]) + self._nb_profiles_per_sec = np.append(self._nb_profiles_per_sec, + param_us_dicts[config][channel]['n_avg']) + # --- SNR Time for each frequencies --- # time_snr = [[(t - data_us_dicts[config][channel]['snr_doppler_avg_profile']['time'][0]).total_seconds() # for t in data_us_dicts[config][channel]['snr_doppler_avg_profile']['time']]] @@ -600,7 +628,7 @@ class AcousticDataLoaderUBSediFlow: # fig.colorbar(pcm, ax=ax, shrink=1, location='right') # plt.show() - def reshape_BS_raw_cross_section(self): + def reshape_BS_raw_data(self): BS_raw_cross_section = np.reshape(self._BS_raw_data, (self._r.shape[1]*self._time.shape[1], len(self._freq)), order="F") diff --git a/View/acoustic_data_tab.py b/View/acoustic_data_tab.py index 648d0b2..241932d 100644 --- a/View/acoustic_data_tab.py +++ b/View/acoustic_data_tab.py @@ -4,7 +4,8 @@ import sys from PyQt5.QtWidgets import (QWidget, QVBoxLayout, QHBoxLayout, QGroupBox, QPushButton, QComboBox, QLineEdit, QLabel, QGridLayout, QSpinBox, QDoubleSpinBox, QTableView, QTableWidget, QSpacerItem, QSizePolicy, QAbstractScrollArea, QFileDialog, QTableWidgetItem, QMessageBox, QScrollBar, QScrollArea, - QProgressBar, QRadioButton, QFormLayout, QSlider, QAbstractItemView, QMenu, QItemDelegate) + QProgressBar, QRadioButton, QFormLayout, QSlider, QAbstractItemView, QMenu, QItemDelegate, + QCheckBox) from PyQt5.QtGui import QPixmap, QIcon, QFont, QMouseEvent from PyQt5.QtCore import Qt, QCoreApplication, pyqtSignal, pyqtSlot, QEvent @@ -39,24 +40,31 @@ from Model.acoustic_data_loader import AcousticDataLoader from Model.acoustic_data_loader_UBSediFlow import AcousticDataLoaderUBSediFlow # from View.window_noise_level_averaged_profile import WindowNoiseLevelTailAveragedProfile -from View.sample_data_tab import SampleDataTab - import settings as stg _translate = QCoreApplication.translate -class FloatDelegate(QItemDelegate): - def __init__(self, decimals, parent=None): - QItemDelegate.__init__(self, parent=parent) - self.nDecimals = decimals +# class FloatDelegate(QItemDelegate): +# def __init__(self, decimals, parent=None): +# QItemDelegate.__init__(self, parent=parent) +# self.nDecimals = decimals +# +# def paint(self, painter, option, index): +# value = index.model().data(index, Qt.EditRole) +# try: +# number = float(value) +# painter.drawText(option.rect, Qt.AlignLeft, "{:.{}f}".format(number, self.nDecimals)) +# except : +# QItemDelegate.paint(self, painter, option, index) - def paint(self, painter, option, index): - value = index.model().data(index, Qt.EditRole) - try: - number = float(value) - painter.drawText(option.rect, Qt.AlignLeft, "{:.{}f}".format(number, self.nDecimals)) - except : - QItemDelegate.paint(self, painter, option, index) +# class WidgetPlot(QWidget): +# def __init__(self, *args, **kwargs): +# QWidget.__init__(self, *args, **kwargs) +# self.setLayout(QVBoxLayout()) +# self.canvas = FigureCanvas(self) +# self.toolbar = NavigationToolBar(self.canvas, self) +# self.layout().addWidget(self.toolbar) +# self.layout().addWidget(self.canvas) class AcousticDataTab(QWidget): @@ -69,6 +77,9 @@ class AcousticDataTab(QWidget): fileRemoved = pyqtSignal(list) newValueChanged = pyqtSignal(float) + # path_icon = "./icons/" + # icon_triangle_left_to_begin = path_icon + "triangle_left_to_begin.png" + def __init__(self, tab_widget): super().__init__() @@ -76,11 +87,14 @@ class AcousticDataTab(QWidget): self.path_icon = "./icons/" self.icon_folder = QIcon(self.path_icon + "folder.png") + self.icon_apply_limits = QIcon(self.path_icon + "circle_green_arrow_right.png") + self.icon_triangle_left_to_begin = QIcon(self.path_icon + "triangle_left_to_begin.png") self.icon_triangle_left = QIcon(self.path_icon + "triangle_left.png") self.icon_triangle_right = QIcon(self.path_icon + "triangle_right.png") - self.icon_add_svg = QIcon(self.path_icon + "add.png") - self.icon_delete_svg = QIcon(self.path_icon + "delete.png") - self.icon_clear_svg = QIcon(self.path_icon + "clear.png") + self.icon_triangle_right_to_end = QIcon(self.path_icon + "triangle_right_to_end.png") + self.icon_add = QIcon(self.path_icon + "add.png") + self.icon_delete = QIcon(self.path_icon + "delete.png") + self.icon_clear = QIcon(self.path_icon + "clear.png") ### --- General layout of widgets --- @@ -101,7 +115,7 @@ class AcousticDataTab(QWidget): self.horizontalLayoutTop.addWidget(self.groupbox_download, 3) self.verticalLayout_goupbox_info_groupbox_table = QVBoxLayout() - self.horizontalLayoutTop.addLayout(self.verticalLayout_goupbox_info_groupbox_table, 4) + self.horizontalLayoutTop.addLayout(self.verticalLayout_goupbox_info_groupbox_table, 3) self.groupbox_info = QGroupBox() # self.verticalLayout_goupbox_info_groupbox_table.addWidget(self.groupbox_info, 5) @@ -161,21 +175,23 @@ class AcousticDataTab(QWidget): self.spacerItem_FileList = QSpacerItem(5, 10, QSizePolicy.Expanding, QSizePolicy.Minimum) self.gridLayout_groupbox_acoustic_file.addItem(self.spacerItem_FileList, 0, 1, 1, 1) - self.addBtn = SvgButton() - self.addBtn.setIcon("../icons/add.svg") - # self.addBtn = QPushButton() - # # self.addBtn.setText("Add") - # self.pushbutton_add.setIcon(self.icon_add_svg) - self.delBtn = SvgButton() - self.delBtn.setIcon("../icons/delete.svg") - # self.delBtn = QPushButton() - # # self.delBtn.setText("Del") - # self.delBtn.setIcon(self.icon_delete_svg) - self.clearBtn = SvgButton() - self.clearBtn.setIcon("../icons/clear.svg") - # self.clearBtn = QPushButton() - # # self.clearBtn.setText("Clear") - # self.clearBtn.setIcon(self.icon_clear_svg) + # self.addBtn = SvgButton() + # self.addBtn.setIcon("../icons/add.svg") + self.addBtn = QPushButton() + # self.addBtn.setText("Add") + self.addBtn.setIcon(self.icon_add) + + # self.delBtn = SvgButton() + # self.delBtn.setIcon("../icons/delete.svg") + self.delBtn = QPushButton() + # self.delBtn.setText("Del") + self.delBtn.setIcon(self.icon_delete) + + # self.clearBtn = SvgButton() + # self.clearBtn.setIcon("../icons/clear.svg") + self.clearBtn = QPushButton() + # self.clearBtn.setText("Clear") + self.clearBtn.setIcon(self.icon_clear) self.gridLayout_groupbox_acoustic_file.addWidget(self.addBtn, 0, 2, 1, 1) self.gridLayout_groupbox_acoustic_file.addWidget(self.delBtn, 0, 3, 1, 1) @@ -350,27 +366,56 @@ class AcousticDataTab(QWidget): # self.label_hour_acoustic_file = QLabel() # self.gridLayout_goupbox_info.addWidget(self.label_hour_acoustic_file, 1, 1, 1, 1) + self.label_ABS_name = QLabel() + self.label_date_acoustic_file = QLabel() self.label_hour_acoustic_file = QLabel() - self.label_profiles = QLabel() - self.label_profiles_per_sec = QLabel() - self.label_cells = QLabel() # n_cell in UBSediFlow parameters - self.label_cell_size = QLabel() # r_em in UBSediFlow parameters - self.label_pulse_length = QLabel() # n_p / PRF with n_p = n_ech, nb of pulses to calculate one instantaneous profile - self.label_pings_per_sec = QLabel() # PRF in UBSediFlow parameters - self.label_pings_per_profile = QLabel() # n_profile/n_avg in UBSediFlow parameters - self.label_freq = QLabel() - self.label_kt = QLabel() - self.label_rx = QLabel() # a0 in UBSediFlow parameters - self.label_tx = QLabel() # a1 in UBSediFlow parameters - # --- Information for UBSediFlow --- - self.label_tr_out = QLabel() - self.label_tr_out.setText("Channel : ") - self.label_r_cell1 = QLabel() - self.label_r_cell1.setText("1st cell size : ") - self.label_r_dcell = QLabel() - self.label_r_dcell.setText("Inter-cell distance : ") + self.label_freq = QLabel() + self.combobox_frequency_information = QComboBox() + + self.label_profiles = QLabel() + self.label_profiles_value = QLabel() + self.label_profiles_per_sec = QLabel() + self.label_profiles_per_sec_value = QLabel() + self.label_cells = QLabel() # n_cell in UBSediFlow parameters + self.label_cells_value = QLabel() + self.label_cell_size = QLabel() # r_em in UBSediFlow parameters + self.label_cell_size_value = QLabel() + self.label_pulse_length = QLabel() # n_p / PRF with n_p = n_ech, nb of pulses to calculate one instantaneous profile + self.label_pulse_length_value = QLabel() + self.label_pings_per_sec = QLabel() # PRF in UBSediFlow parameters + self.label_pings_per_sec_value = QLabel() + self.label_pings_per_profile = QLabel() # n_profile/n_avg in UBSediFlow parameters + self.label_pings_per_profile_value = QLabel() + + self.label_kt = QLabel() + self.spinbox_kt = QDoubleSpinBox() + self.spinbox_kt.setMaximum(1e6) + self.checkbox_kt = QCheckBox() + + self.label_rx = QLabel() # a0 in UBSediFlow parameters + self.spinbox_rx = QDoubleSpinBox() + self.spinbox_rx.setMaximum(1e6) + self.checkbox_rx = QCheckBox() + + self.label_tx = QLabel() # a1 in UBSediFlow parameters + self.spinbox_tx = QDoubleSpinBox() + self.spinbox_tx.setMaximum(1e6) + self.checkbox_tx = QCheckBox() + + # # --- Parameters for UBSediFlow --- + # self.label_config = QLabel() + # self.combobox_config = QComboBox() + # self.label_transducer = QLabel() + # + # # --- Information for UBSediFlow --- + # self.label_tr_out = QLabel() + # self.label_tr_out.setText("Channel : ") + # self.label_r_cell1 = QLabel() + # self.label_r_cell1.setText("1st cell size : ") + # self.label_r_dcell = QLabel() + # self.label_r_dcell.setText("Inter-cell distance : ") # self.groupbox_measurement_information_Aquascat() @@ -499,6 +544,7 @@ class AcousticDataTab(QWidget): self.gridLayout_groupbox_display_option_limits.addWidget(self.label_depth_unit_meter, 0, 2, 1, 1) self.pushbutton_apply_depth_limits = QPushButton() + self.pushbutton_apply_depth_limits.setIcon(self.icon_apply_limits) self.gridLayout_groupbox_display_option_limits.addWidget(self.pushbutton_apply_depth_limits, 0, 3, 1, 1) # -------------------------------- @@ -526,6 +572,7 @@ class AcousticDataTab(QWidget): self.gridLayout_groupbox_display_option_limits.addWidget(self.label_recording_time_unit_meter, 1, 2, 1, 1) self.pushbutton_apply_recording_time_limits = QPushButton() + self.pushbutton_apply_recording_time_limits.setIcon(self.icon_apply_limits) self.gridLayout_groupbox_display_option_limits.addWidget(self.pushbutton_apply_recording_time_limits, 1, 3, 1, 1) # --------------------------------- @@ -551,8 +598,9 @@ class AcousticDataTab(QWidget): self.label_distance_from_bank_unit_meter = QLabel("meters") self.gridLayout_groupbox_display_option_limits.addWidget(self.label_distance_from_bank_unit_meter, 2, 2, 1, 1) - self.pushbutton_apply_distance_from_bank__limits = QPushButton() - self.gridLayout_groupbox_display_option_limits.addWidget(self.pushbutton_apply_distance_from_bank__limits, 2, 3, 1, 1) + self.pushbutton_apply_distance_from_bank_limits = QPushButton() + self.pushbutton_apply_distance_from_bank_limits.setIcon(self.icon_apply_limits) + self.gridLayout_groupbox_display_option_limits.addWidget(self.pushbutton_apply_distance_from_bank_limits, 2, 3, 1, 1) # --------------------------------------- @@ -782,10 +830,17 @@ class AcousticDataTab(QWidget): # self.canvas_BS = None # self.scroll_BS = None + + # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.toolbar_BS) + # self.fig_BS, self.axis_BS = plt.subplots(nrows=4, ncols=1, sharex=True, sharey=False, # layout="constrained") # self.canvas_BS = FigureCanvas(self.fig_BS) self.canvas_BS = FigureCanvas() + + self.toolbar_BS = NavigationToolBar(self.canvas_BS, ) + self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.toolbar_BS) + # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.scroll_BS) self.scroll_BS = QScrollArea() self.scroll_BS.setWidget(self.canvas_BS) @@ -834,9 +889,9 @@ class AcousticDataTab(QWidget): self.horizontalLayout_spacerItem_combobox_frequency_profile = QHBoxLayout() self.verticalLayout_groupbox_plot_the_vertical_profile_for_a_frequency.addLayout(self.horizontalLayout_spacerItem_combobox_frequency_profile) self.spacerItem_frequency_profile = QSpacerItem(50, 10, QSizePolicy.Expanding, QSizePolicy.Minimum) - self.horizontalLayout_spacerItem_combobox_frequency_profile.addSpacerItem(self.spacerItem_frequency_profile) + # self.horizontalLayout_spacerItem_combobox_frequency_profile.addSpacerItem(self.spacerItem_frequency_profile) self.combobox_frequency_profile = QComboBox() - self.horizontalLayout_spacerItem_combobox_frequency_profile.addWidget(self.combobox_frequency_profile) + # self.horizontalLayout_spacerItem_combobox_frequency_profile.addWidget(self.combobox_frequency_profile) self.groupbox_plot_profile = QGroupBox() self.groupbox_plot_profile.setTitle("Profile") @@ -846,6 +901,12 @@ class AcousticDataTab(QWidget): # self.fig_profile, self.axis_profile = plt.subplots(nrows=1, ncols=1, layout="constrained") # self.canvas_plot_profile = FigureCanvas(self.fig_profile) self.canvas_plot_profile = FigureCanvas() + + self.toolbar_profile = NavigationToolBar(self.canvas_plot_profile, ) + # print("navigation toolbar item", self.toolbar_profile.toolitems) + self.horizontalLayout_spacerItem_combobox_frequency_profile.addWidget(self.toolbar_profile) + self.horizontalLayout_spacerItem_combobox_frequency_profile.addWidget(self.combobox_frequency_profile) + self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_plot_profile) # self.canvas_plot_profile = None @@ -854,19 +915,27 @@ class AcousticDataTab(QWidget): self.horizontalLayout_slider = QHBoxLayout() self.verticalLayout_groupbox_plot_the_vertical_profile_for_a_frequency.addLayout(self.horizontalLayout_slider) + self.pushbutton_slider_left_to_begin = QPushButton() + self.pushbutton_slider_left_to_begin.setIcon(self.icon_triangle_left_to_begin) + self.horizontalLayout_slider.addWidget(self.pushbutton_slider_left_to_begin) + self.pushbutton_slider_left = QPushButton() self.pushbutton_slider_left.setIcon(self.icon_triangle_left) self.horizontalLayout_slider.addWidget(self.pushbutton_slider_left) - self.pushbutton_slider_right = QPushButton() - self.pushbutton_slider_right.setIcon(self.icon_triangle_right) - self.horizontalLayout_slider.addWidget(self.pushbutton_slider_right) - self.lineEdit_slider = QLineEdit() self.lineEdit_slider.setText("1") self.lineEdit_slider.setFixedWidth(50) self.horizontalLayout_slider.addWidget(self.lineEdit_slider) + self.pushbutton_slider_right = QPushButton() + self.pushbutton_slider_right.setIcon(self.icon_triangle_right) + self.horizontalLayout_slider.addWidget(self.pushbutton_slider_right) + + self.pushbutton_slider_right_to_end = QPushButton() + self.pushbutton_slider_right_to_end.setIcon(self.icon_triangle_right_to_end) + self.horizontalLayout_slider.addWidget(self.pushbutton_slider_right_to_end) + self.slider = QSlider() self.horizontalLayout_slider.addWidget(self.slider, 9) @@ -905,6 +974,7 @@ class AcousticDataTab(QWidget): self.fileListWidget.itemSelectionChanged.connect(self.plot_profile) self.fileListWidget.itemSelectionChanged.connect(self.update_plot_backscattered_acoustic_signal_recording) self.fileListWidget.itemSelectionChanged.connect(self.update_plot_profile) + self.fileListWidget.itemSelectionChanged.connect(self.set_range_for_doubleRangeSlider_intg_area) # self.fileListWidget.installEventFilter() # self.fileListWidget.clicked.connect(self.rename_file_in_ListWidget) @@ -943,10 +1013,14 @@ class AcousticDataTab(QWidget): self.pushbutton_apply_bathymetry.clicked.connect(self.detect_bottom) + self.pushbutton_slider_left_to_begin.clicked.connect(self.slide_profile_number_to_begin) + self.pushbutton_slider_left.clicked.connect(self.slide_profile_number_to_left) self.pushbutton_slider_right.clicked.connect(self.slide_profile_number_to_right) + self.pushbutton_slider_right_to_end.clicked.connect(self.slide_profile_number_to_end) + self.lineEdit_slider.returnPressed.connect(self.profile_number_on_lineEdit) self.slider.valueChanged.connect(self.update_lineEdit_by_moving_slider) @@ -1088,7 +1162,9 @@ class AcousticDataTab(QWidget): self.groupbox_gps_file.setEnabled(True) def ABS_system_choice(self): - if self.combobox_ABS_system_choice.currentText() == "Aquascat 1000R": + if self.combobox_ABS_system_choice.currentText() == " ": + self.groupbox_measurement_information_no_ABS() + elif self.combobox_ABS_system_choice.currentText() == "Aquascat 1000R": self.groupbox_measurement_information_Aquascat() # self.lineEdit_acoustic_file.clear() elif self.combobox_ABS_system_choice.currentText() == "UB-SediFlow": @@ -1099,49 +1175,19 @@ class AcousticDataTab(QWidget): # self.label_hour_groupbox_acoustic_file.clear() # self.label_hour_groupbox_acoustic_file.setText(_translate("CONSTANT_STRING", cs.HOUR) + ": ") - def groupbox_measurement_information_Aquascat(self): - # self.gridLayout_goupbox_info.itemAt(0).widget().deleteLater() - # self.label_to_do.hide() + def groupbox_measurement_information_no_ABS(self): - self.label_freq.hide() - - self.label_date_acoustic_file.show() - self.label_hour_acoustic_file.show() - self.label_temperature.show() - self.label_profiles.show() - self.label_profiles_per_sec.show() - self.label_cells.show() - self.label_cell_size.show() - self.label_pulse_length.show() - self.label_pings_per_sec.show() - self.label_pings_per_profile.show() - self.label_freq.show() - self.label_kt.show() - self.label_rx.show() - self.label_tx.show() - - self.gridLayout_goupbox_info.addWidget(self.label_date_acoustic_file, 0, 0, 1, 2) - self.gridLayout_goupbox_info.addWidget(self.label_hour_acoustic_file, 0, 2, 1, 1) - self.gridLayout_goupbox_info.addWidget(self.label_temperature, 1, 0, 1, 1) - # self.gridLayout_goupbox_info.addWidget(self.spinbox_temperature, 1, 1, 1, 1) - self.gridLayout_goupbox_info.addWidget(self.label_profiles, 2, 0, 1, 1) - self.gridLayout_goupbox_info.addWidget(self.label_profiles_per_sec, 2, 2, 1, 1) - self.gridLayout_goupbox_info.addWidget(self.label_cells, 3, 0, 1, 1) - self.gridLayout_goupbox_info.addWidget(self.label_cell_size, 3, 2, 1, 1) - self.gridLayout_goupbox_info.addWidget(self.label_pulse_length, 4, 0, 1, 1) - self.gridLayout_goupbox_info.addWidget(self.label_pings_per_sec, 5, 0, 1, 1) - self.gridLayout_goupbox_info.addWidget(self.label_pings_per_profile, 5, 2, 1, 1) - self.gridLayout_goupbox_info.addWidget(self.label_freq, 6, 0, 1, 2) - self.gridLayout_goupbox_info.addWidget(self.label_kt, 7, 0, 1, 2) - self.gridLayout_goupbox_info.addWidget(self.label_rx, 8, 0, 1, 2) - self.gridLayout_goupbox_info.addWidget(self.label_tx, 9, 0, 1, 2) - - def groupbox_measurement_information_UBSediFlow(self): - # self.gridLayout_goupbox_info.itemAt(0).widget().deleteLater() + self.label_ABS_name.hide() self.label_date_acoustic_file.hide() self.label_hour_acoustic_file.hide() + self.label_temperature.hide() + self.spinbox_temperature.hide() + + self.label_freq.hide() + self.combobox_frequency_information.hide() + self.label_profiles.hide() self.label_profiles_per_sec.hide() self.label_cells.hide() @@ -1149,22 +1195,216 @@ class AcousticDataTab(QWidget): self.label_pulse_length.hide() self.label_pings_per_sec.hide() self.label_pings_per_profile.hide() - self.label_freq.hide() - self.label_kt.hide() - self.label_rx.hide() - self.label_tx.hide() - # self.label_to_do.show() - # - # self.gridLayout_goupbox_info.addWidget(self.label_to_do, 0, 0, 1, 1) + self.label_kt.hide() + self.spinbox_kt.hide() + self.checkbox_kt.hide() + + self.label_rx.hide() + self.spinbox_rx.hide() + self.checkbox_rx.hide() + + self.label_tx.hide() + self.spinbox_tx.hide() + self.checkbox_tx.hide() + + def groupbox_measurement_information_Aquascat(self): + # --- Hide UBSediFlow information and remove widget from grid layout --- + self.label_ABS_name.hide() + + self.label_date_acoustic_file.hide() + self.label_hour_acoustic_file.hide() + + self.label_temperature.hide() + self.spinbox_temperature.hide() + + self.label_freq.hide() + self.combobox_frequency_information.hide() + + self.label_profiles.hide() + self.label_profiles_per_sec.hide() + self.label_cells.hide() + self.label_cell_size.hide() + self.label_pulse_length.hide() + self.label_pings_per_sec.hide() + self.label_pings_per_profile.hide() + + self.label_kt.hide() + self.spinbox_kt.hide() + self.checkbox_kt.hide() + + self.label_rx.hide() + self.spinbox_rx.hide() + self.checkbox_rx.hide() + + self.label_tx.hide() + self.spinbox_tx.hide() + self.checkbox_tx.hide() + + for i in reversed(range(self.gridLayout_goupbox_info.count())): + widgetToRemove = self.gridLayout_goupbox_info.itemAt(i).widget() + # remove it from the layout list + self.gridLayout_goupbox_info.removeWidget(widgetToRemove) + # remove it from the gui + widgetToRemove.setParent(None) + + # --- Show Aquascat information --- + + self.label_ABS_name.show() + self.label_ABS_name.setText("Acoustic Backscatter System: AQUAscat") + self.gridLayout_goupbox_info.addWidget(self.label_ABS_name, 0, 0, 1, 2) + + self.label_date_acoustic_file.show() + self.gridLayout_goupbox_info.addWidget(self.label_date_acoustic_file, 1, 0, 1, 1) + self.label_hour_acoustic_file.show() + self.gridLayout_goupbox_info.addWidget(self.label_hour_acoustic_file, 1, 1, 1, 1) + + self.label_temperature.show() + self.gridLayout_goupbox_info.addWidget(self.label_temperature, 2, 0, 1, 1) + self.spinbox_temperature.show() + self.gridLayout_goupbox_info.addWidget(self.spinbox_temperature, 2, 1, 1, 1) self.label_freq.show() + self.gridLayout_goupbox_info.addWidget(self.label_freq, 3, 0, 1, 1) + self.combobox_frequency_information.show() + self.gridLayout_goupbox_info.addWidget(self.combobox_frequency_information, 3, 1, 1, 1) - self.gridLayout_goupbox_info.addWidget(self.label_freq, 0, 0, 1, 1) + self.label_profiles.show() + self.gridLayout_goupbox_info.addWidget(self.label_profiles, 4, 0, 1, 1) + self.label_profiles_per_sec.show() + self.gridLayout_goupbox_info.addWidget(self.label_profiles_per_sec, 5, 0, 1, 1) + self.label_cells.show() + self.gridLayout_goupbox_info.addWidget(self.label_cells, 6, 0, 1, 1) + self.label_cell_size.show() + self.gridLayout_goupbox_info.addWidget(self.label_cell_size, 7, 0, 1, 1) + self.label_pulse_length.show() + self.gridLayout_goupbox_info.addWidget(self.label_pulse_length, 8, 0, 1, 1) + self.label_pings_per_sec.show() + self.gridLayout_goupbox_info.addWidget(self.label_pings_per_sec, 9, 0, 1, 1) + self.label_pings_per_profile.show() + self.gridLayout_goupbox_info.addWidget(self.label_pings_per_profile, 10, 0, 1, 1) + + self.label_kt.show() + self.gridLayout_goupbox_info.addWidget(self.label_kt, 11, 0, 1, 1) + self.spinbox_kt.show() + self.gridLayout_goupbox_info.addWidget(self.spinbox_kt, 11, 1, 1, 1) + self.checkbox_kt.show() + self.gridLayout_goupbox_info.addWidget(self.checkbox_kt, 11, 2, 1, 1) + + self.label_rx.show() + self.gridLayout_goupbox_info.addWidget(self.label_rx, 12, 0, 1, 1) + self.spinbox_rx.show() + self.gridLayout_goupbox_info.addWidget(self.spinbox_rx, 12, 1, 1, 1) + self.checkbox_rx.show() + self.gridLayout_goupbox_info.addWidget(self.checkbox_rx, 12, 2, 1, 1) + + self.label_tx.show() + self.gridLayout_goupbox_info.addWidget(self.label_tx, 13, 0, 1, 1) + self.spinbox_tx.show() + self.gridLayout_goupbox_info.addWidget(self.spinbox_tx, 13, 1, 1, 1) + self.checkbox_tx.show() + self.gridLayout_goupbox_info.addWidget(self.checkbox_tx, 13, 2, 1, 1) + + def groupbox_measurement_information_UBSediFlow(self): + # --- Hide Aquascat information --- + self.label_ABS_name.hide() + + self.label_date_acoustic_file.hide() + self.label_hour_acoustic_file.hide() + + self.label_temperature.hide() + self.spinbox_temperature.hide() + + self.label_freq.hide() + self.combobox_frequency_information.hide() + + self.label_profiles.hide() + self.label_profiles_per_sec.hide() + self.label_cells.hide() + self.label_cell_size.hide() + self.label_pulse_length.hide() + self.label_pings_per_sec.hide() + self.label_pings_per_profile.hide() + + self.label_kt.hide() + self.spinbox_kt.hide() + self.checkbox_kt.hide() + + self.label_rx.hide() + self.spinbox_rx.hide() + self.checkbox_rx.hide() + + self.label_tx.hide() + self.spinbox_tx.hide() + self.checkbox_tx.hide() + + for i in reversed(range(self.gridLayout_goupbox_info.count())): + widgetToRemove = self.gridLayout_goupbox_info.itemAt(i).widget() + # remove it from the layout list + self.gridLayout_goupbox_info.removeWidget(widgetToRemove) + # remove it from the gui + widgetToRemove.setParent(None) + + # --- Show UBSediFlow information --- + self.label_ABS_name.show() + self.label_ABS_name.setText("Acoustic Backscatter System: UBSediFlow") + self.gridLayout_goupbox_info.addWidget(self.label_ABS_name, 0, 0, 1, 2) + + self.label_date_acoustic_file.show() + self.gridLayout_goupbox_info.addWidget(self.label_date_acoustic_file, 1, 0, 1, 1) + self.label_hour_acoustic_file.show() + self.gridLayout_goupbox_info.addWidget(self.label_hour_acoustic_file, 1, 1, 1, 1) + + self.label_temperature.show() + self.gridLayout_goupbox_info.addWidget(self.label_temperature, 2, 0, 1, 1) + self.spinbox_temperature.show() + self.gridLayout_goupbox_info.addWidget(self.spinbox_temperature, 2, 1, 1, 1) + + self.label_freq.show() + self.gridLayout_goupbox_info.addWidget(self.label_freq, 3, 0, 1, 1) + self.combobox_frequency_information.show() + self.gridLayout_goupbox_info.addWidget(self.combobox_frequency_information, 3, 1, 1, 1) + + self.label_profiles.show() + self.gridLayout_goupbox_info.addWidget(self.label_profiles, 4, 0, 1, 1) + self.label_profiles_per_sec.show() + self.gridLayout_goupbox_info.addWidget(self.label_profiles_per_sec, 5, 0, 1, 1) + self.label_cells.show() + self.gridLayout_goupbox_info.addWidget(self.label_cells, 6, 0, 1, 1) + self.label_cell_size.show() + self.gridLayout_goupbox_info.addWidget(self.label_cell_size, 7, 0, 1, 1) + self.label_pulse_length.show() + self.gridLayout_goupbox_info.addWidget(self.label_pulse_length, 8, 0, 1, 1) + self.label_pings_per_sec.show() + self.gridLayout_goupbox_info.addWidget(self.label_pings_per_sec, 9, 0, 1, 1) + self.label_pings_per_profile.show() + self.gridLayout_goupbox_info.addWidget(self.label_pings_per_profile, 10, 0, 1, 1) + + self.label_kt.show() + self.gridLayout_goupbox_info.addWidget(self.label_kt, 11, 0, 1, 1) + self.spinbox_kt.show() + self.gridLayout_goupbox_info.addWidget(self.spinbox_kt, 11, 1, 1, 1) + self.checkbox_kt.show() + self.gridLayout_goupbox_info.addWidget(self.checkbox_kt, 11, 2, 1, 1) + + self.label_rx.show() + self.gridLayout_goupbox_info.addWidget(self.label_rx, 12, 0, 1, 1) + self.spinbox_rx.show() + self.gridLayout_goupbox_info.addWidget(self.spinbox_rx, 12, 1, 1, 1) + self.checkbox_rx.show() + self.gridLayout_goupbox_info.addWidget(self.checkbox_rx, 12, 2, 1, 1) + + self.label_tx.show() + self.gridLayout_goupbox_info.addWidget(self.label_tx, 13, 0, 1, 1) + self.spinbox_tx.show() + self.gridLayout_goupbox_info.addWidget(self.spinbox_tx, 13, 1, 1, 1) + self.checkbox_tx.show() + self.gridLayout_goupbox_info.addWidget(self.checkbox_tx, 13, 2, 1, 1) def temperature_value(self): - stg.temperature[self.fileListWidget.currentRow()] = self.spinbox_temperature.value() - print(f"stg.temperature : {stg.temperature}") + if self.fileListWidget.count() > 0: + stg.temperature[self.fileListWidget.currentRow()] = self.spinbox_temperature.value() + # print(f"stg.temperature : {stg.temperature}") def clicked_pushbutton_noise_level(self): self.WindowNoiseLevelTailAveragedProfile().show() @@ -1183,14 +1423,16 @@ class AcousticDataTab(QWidget): msgBox.exec() elif self.combobox_ABS_system_choice.currentIndex() == 1: filename = QFileDialog.getOpenFileName(self, "Open file", - "/home/bmoudjed/Documents/3 SSC acoustic meas project/Graphical interface project/Data", + [stg.path_BS_raw_data[-1] if self.fileListWidget.count() > 0 else ""][0], "Aquascat file (*.aqa)") dir_name = path.dirname(filename[0]) name = path.basename(filename[0]) print(f"dir name : {dir_name} & file name : {name}") # print(dir_name, name) elif self.combobox_ABS_system_choice.currentIndex() == 2: - filename = QFileDialog.getOpenFileName(self, "Open file", "", "UBSediFlow file (*.udt)") + filename = QFileDialog.getOpenFileName(self, "Open file", + [stg.path_BS_raw_data[-1] if self.fileListWidget.count() > 0 else ""][0], + "UBSediFlow file (*.udt)") dir_name = path.dirname(filename[0]) name = path.basename(filename[0]) print(f"dir name : {dir_name} & file name : {name}") @@ -1305,60 +1547,165 @@ class AcousticDataTab(QWidget): def remove_file_from_ListWidget(self): if self.fileListWidget.count() > 0: + + # --- Clear files included in list Widget --- current_row = self.fileListWidget.currentRow() if current_row >= 0: current_item = self.fileListWidget.takeItem(current_row) del current_item - stg.BS_raw_data.pop(current_row) - stg.time.pop(current_row) + # --- Clear variables --- + list_to_pop1 = ["stg.acoustic_data", "stg.date", "stg.hour", "stg.freq", "stg.freq_text", "stg.temperature", + "stg.nb_profiles", "stg.nb_profiles_per_sec", "stg.nb_cells", "stg.cell_size", + "stg.pulse_length", "stg.nb_pings_per_sec", "stg.nb_pings_averaged_per_profile", + "stg.kt", "stg.gain_rx", "stg.gain_tx", + "stg.BS_raw_data", "stg.time", "stg.depth", + "stg.BS_raw_data_reshape", "stg.time_reshape", "stg.depth_reshape"] - if len(stg.tmax) == len(stg.time): - stg.tmin.pop(current_row) - stg.tmax.pop(current_row) - stg.t_cross_section.pop(current_row) - stg.BS_cross_section.pop(current_row) + for p in list_to_pop1: + print(p) + exec(p + ".pop(current_row)") + + print("stg.freq after remove: ", stg.freq) + + if stg.BS_cross_section: + + list_to_pop2 = ["stg.rmin", "stg.rmax", "stg.tmin", "stg.tmax", + "stg.time_cross_section", "stg.BS_cross_section"] + + for k in list_to_pop2: + exec(k + ".pop(current_row)") + + if self.fileListWidget.count() == 0: + + # --- Clear measurements information --- + self.label_date_acoustic_file.clear() + self.label_date_acoustic_file.setText("Date: ") + self.label_hour_acoustic_file.clear() + self.label_hour_acoustic_file.setText("Hour: ") + self.spinbox_temperature.clear() + self.combobox_frequency_information.clear() + self.label_profiles_value.clear() + self.label_profiles_per_sec_value.clear() + self.label_cells_value.clear() + self.label_cell_size_value.clear() + self.label_pulse_length_value.clear() + self.label_pings_per_sec_value.clear() + self.label_pings_per_profile_value.clear() + self.spinbox_kt.clear() + self.spinbox_rx.clear() + self.spinbox_tx.clear() + + # --- Clear display options --- + + self.doubleRangeSlider_depth.setRange(min=0, max=50) + self.doubleRangeSlider_depth.setValue(value=(5, 40)) + + self.doubleRangeSlider_recording_time.setRange(min=0, max=50) + self.doubleRangeSlider_recording_time.setValue(value=(5, 40)) + + self.doubleRangeSlider_distance_from_bank.setRange(min=0, max=50) + self.doubleRangeSlider_distance_from_bank.setValue(value=(5, 40)) + + self.combobox_frequency_bathymetry.clear() + self.doubleRangeSlider_intg_area.setRange(min=0, max=50) + self.doubleRangeSlider_intg_area.setValue(value=(5, 40)) + self.spinbox_offset_next_cell.setValue(0.00) + + # --- Clear table of values --- + self.tableView.reset() + data = pd.DataFrame(np.zeros((10, 10))) + self.tableModel = TableModel(data) + self.tableView.setModel(self.tableModel) + + # --- Clear figures --- + self.canvas_BS.figure.clear() + self.fig_BS.clf() + print("axis BS : ", self.axis_BS) + self.axis_BS.tolist().clear() + print("clear axis BS : ", self.axis_BS) + self.canvas_plot_profile.figure.clear() + self.fig_profile.clear() + self.axis_profile.clear() + self.slider.setValue(0) + self.slider.setMaximum(10) def clear_files_from_ListWidget(self): - if self.fileListWidget.count() > 0: - self.fileListWidget.clear() + # if self.fileListWidget.count() > 0: - stg.BS_raw_data.clear() - stg.time.clear() - stg.tmin.clear() - stg.tmax.clear() - stg.t_cross_section.clear() - stg.BS_cross_section.clear() + list_to_clear = ["stg.acoustic_data", "stg.date", "stg.hour", "stg.freq", "stg.freq_text", "stg.temperature", + "stg.nb_profiles", "stg.nb_profiles_per_sec", "stg.nb_cells", "stg.cell_size", + "stg.pulse_length", "stg.nb_pings_per_sec", "stg.nb_pings_averaged_per_profile", + "stg.kt", "stg.gain_rx", "stg.gain_tx", + "stg.BS_raw_data", "stg.time", "stg.depth", + "stg.BS_raw_data_reshape", "stg.time_reshape", "stg.depth_reshape", + "stg.rmin", "stg.rmax", "stg.tmin", "stg.tmax", + "stg.time_cross_section", "stg.depth_cross_section", "stg.BS_cross_section"] + for k in list_to_clear: + exec(k + ".clear()") + + self.fileListWidget.clear() + + if self.fileListWidget.count() == 0: # --- Clear measurmeents information --- + self.label_date_acoustic_file.clear() + self.label_date_acoustic_file.setText("Date: ") + self.label_hour_acoustic_file.clear() + self.label_hour_acoustic_file.setText("Hour: ") self.spinbox_temperature.clear() - self.ABS_system_choice() + self.combobox_frequency_information.clear() + self.label_profiles_value.clear() + self.label_profiles_per_sec_value.clear() + self.label_cells_value.clear() + self.label_cell_size_value.clear() + self.label_pulse_length_value.clear() + self.label_pings_per_sec_value.clear() + self.label_pings_per_profile_value.clear() + self.spinbox_kt.clear() + self.spinbox_rx.clear() + self.spinbox_tx.clear() # --- Clear display options --- - self.spinbox_tmin.setValue(0) - self.spinbox_tmax.setValue(0) - self.spinbox_xmin.setValue(0) - self.spinbox_xmax.setValue(0) + + self.doubleRangeSlider_depth.setRange(min=0, max=50) + self.doubleRangeSlider_depth.setValue(value=(5, 40)) + + self.doubleRangeSlider_recording_time.setRange(min=0, max=50) + self.doubleRangeSlider_recording_time.setValue(value=(5, 40)) + + self.doubleRangeSlider_distance_from_bank.setRange(min=0, max=50) + self.doubleRangeSlider_distance_from_bank.setValue(value=(5, 40)) + self.combobox_frequency_bathymetry.clear() - self.spinbox_depth_min.setValue(0) - self.spinbox_depth_max.setValue(0) - self.doublespinbox_next_cell.setValue(0) + self.doubleRangeSlider_intg_area.setRange(min=0, max=50) + self.doubleRangeSlider_intg_area.setValue(value=(5, 40)) + self.spinbox_offset_next_cell.setValue(0.00) + + # --- Clear table of values --- + self.tableView.reset() + data = pd.DataFrame(np.zeros((10, 10))) + self.tableModel = TableModel(data) + self.tableView.setModel(self.tableModel) # --- Clear figure area for backscattered acoutsic signal recording --- - self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.scroll_BS) - self.canvas_BS = FigureCanvas() - self.scroll_BS.setWidget(self.canvas_BS) - self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.scroll_BS) - - # --- Clear figure area for profile --- + self.canvas_BS.figure.clear() + self.canvas_plot_profile.figure.clear() self.combobox_frequency_profile.clear() + # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.scroll_BS) + # self.canvas_BS = FigureCanvas() + # self.scroll_BS.setWidget(self.canvas_BS) + # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.scroll_BS) - if self.fig_profile: - self.axis_profile.cla() - self.fig_profile.clf() - self.verticalLayout_groupbox_plot_profile.removeWidget(self.canvas_plot_profile) - self.canvas_plot_profile = FigureCanvas() - self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_plot_profile) + # --- Clear figure area for profile --- + + + # if self.fig_profile: + # self.axis_profile.cla() + # self.fig_profile.clf() + # self.verticalLayout_groupbox_plot_profile.removeWidget(self.canvas_plot_profile) + # self.canvas_plot_profile = FigureCanvas() + # self.verticalLayout_groupbox_plot_profile.addWidget(self.canvas_plot_profile) self.slider.setValue(0) self.slider.setMaximum(10) @@ -1450,32 +1797,56 @@ class AcousticDataTab(QWidget): acoustic_data = AcousticDataLoaderUBSediFlow(stg.path_BS_raw_data[-1] + "/" + stg.filename_BS_raw_data[-1]) - if self.fileListWidget.count() == 0: + stg.ABS_name.append(self.combobox_ABS_system_choice.currentText()) + stg.BS_raw_data.append(acoustic_data._BS_raw_data) + stg.BS_raw_data_reshape.append(acoustic_data.reshape_BS_raw_data()) + stg.depth.append(acoustic_data._r) + stg.depth_2D.append(acoustic_data.compute_r_2D()) + stg.depth_reshape.append(acoustic_data.reshape_r()) + stg.time.append(acoustic_data._time) + stg.time_reshape.append(acoustic_data.reshape_t()) + stg.freq.append(acoustic_data._freq) + stg.freq_text.append(acoustic_data._freq_text) + stg.date.append(acoustic_data._date) + stg.hour.append(acoustic_data._hour) + stg.nb_profiles.append(acoustic_data._nb_profiles) + stg.nb_profiles_per_sec.append(acoustic_data._nb_profiles_per_sec) + stg.nb_cells.append(acoustic_data._nb_cells) + stg.cell_size.append(acoustic_data._cell_size) + stg.pulse_length.append(acoustic_data._cell_size) + stg.nb_pings_per_sec.append(acoustic_data._nb_pings_per_sec) + stg.nb_pings_averaged_per_profile.append(acoustic_data._nb_pings_averaged_per_profile) + stg.kt.append(acoustic_data._kt) + stg.gain_rx.append(acoustic_data._gain_rx) + stg.gain_tx.append(acoustic_data._gain_tx) + stg.temperature.append(self.spinbox_temperature.value()) - stg.ABS_name = [self.combobox_ABS_system_choice.currentText()] - stg.date = [acoustic_data._date] - stg.hour = [acoustic_data._hour] - stg.freq = [acoustic_data._freq] - stg.time = [acoustic_data._time] - stg.depth = [acoustic_data._r] - stg.depth_2D = [acoustic_data.compute_r_2D()] - stg.freq_text = [acoustic_data._freq_text] - stg.BS_raw_data = [acoustic_data._BS_raw_data] - # stg.BS_raw_data_reshape = acoustic_data.reshape_BS_raw_cross_section() - # stg.depth_reshape = acoustic_data.reshape_r() - # stg.time_reshape = acoustic_data.reshape_t() - - else: - - stg.ABS_name.append(self.combobox_ABS_system_choice.currentText()) - stg.date.append(acoustic_data._date) - stg.hour.append(acoustic_data._hour) - stg.freq.append(acoustic_data._freq) - stg.time.append(acoustic_data._time) - stg.depth.append(acoustic_data._r) - stg.depth_2D.append(acoustic_data.compute_r_2D()) - stg.freq_text.append(acoustic_data._freq_text) - stg.BS_raw_data.append(acoustic_data._BS_raw_data) + # if self.fileListWidget.count() == 0: + # + # stg.ABS_name = [self.combobox_ABS_system_choice.currentText()] + # stg.date = [acoustic_data._date] + # stg.hour = [acoustic_data._hour] + # stg.freq = [acoustic_data._freq] + # stg.time = [acoustic_data._time] + # stg.depth = [acoustic_data._r] + # stg.depth_2D = [acoustic_data.compute_r_2D()] + # stg.freq_text = [acoustic_data._freq_text] + # stg.BS_raw_data = [acoustic_data._BS_raw_data] + # stg.BS_raw_data_reshape = acoustic_data.reshape_BS_raw_data() + # stg.depth_reshape = acoustic_data.reshape_r() + # stg.time_reshape = acoustic_data.reshape_t() + # + # else: + # + # stg.ABS_name.append(self.combobox_ABS_system_choice.currentText()) + # stg.date.append(acoustic_data._date) + # stg.hour.append(acoustic_data._hour) + # stg.freq.append(acoustic_data._freq) + # stg.time.append(acoustic_data._time) + # stg.depth.append(acoustic_data._r) + # stg.depth_2D.append(acoustic_data.compute_r_2D()) + # stg.freq_text.append(acoustic_data._freq_text) + # stg.BS_raw_data.append(acoustic_data._BS_raw_data) # stg.SNR_data = acoustic_data._SNR_data @@ -1515,7 +1886,7 @@ class AcousticDataTab(QWidget): # # stg.SNR_reshape = noise_data.reshape_SNR_data() def fill_measurements_information_groupbox(self): - if self.combobox_ABS_system_choice.currentIndex() == 1: + # if self.combobox_ABS_system_choice.currentIndex() == 1: # self.label_date_acoustic_file.setText( # _translate("CONSTANT_STRING", cs.DATE) + ": " + str(stg.date[self.fileListWidget.currentRow()])) @@ -1547,28 +1918,64 @@ class AcousticDataTab(QWidget): # self.label_tx.setText( # _translate("CONSTANT_STRING", cs.GAIN_TX) + ": " + ', '.join(map(str, stg.gain_tx[self.fileListWidget.currentRow()]))) - self.label_date_acoustic_file_value = QLabel(str(stg.date[self.fileListWidget.currentRow()])) - self.gridLayout_goupbox_info.addWidget(self.label_date_acoustic_file_value, 0, 1, 1, 1) - self.label_hour_acoustic_file_value = QLabel(str(stg.hour[self.fileListWidget.currentRow()])) - self.gridLayout_goupbox_info.addWidget(self.label_hour_acoustic_file_value, 0, 3, 1, 1) + print("self.fileListWidget.count() ", self.fileListWidget.currentRow()) + if self.fileListWidget.count() > 0: - self.label_profiles_value = QLabel(str(stg.nb_profiles[self.fileListWidget.currentRow()])) - self.gridLayout_goupbox_info.addWidget(self.label_profiles_value, 2, 1, 1, 1) - self.label_profiles_per_sec_value = QLabel(str(stg.nb_profiles_per_sec[self.fileListWidget.currentRow()]) + " Hz") - self.gridLayout_goupbox_info.addWidget(self.label_profiles_per_sec_value, 2, 3, 1, 1) + self.label_date_acoustic_file.clear() + self.label_date_acoustic_file.setText("Date: " + str(stg.date[self.fileListWidget.currentRow()])) + self.gridLayout_goupbox_info.addWidget(self.label_date_acoustic_file, 1, 0, 1, 1) - self.label_cells_value = QLabel(str(stg.nb_cells[self.fileListWidget.currentRow()])) - self.gridLayout_goupbox_info.addWidget(self.label_cells_value, 3, 1, 1, 1) - self.label_cell_size_value = QLabel(str(100*round(stg.cell_size[self.fileListWidget.currentRow()], 3)) + " cm") - self.gridLayout_goupbox_info.addWidget(self.label_cell_size_value, 3, 3, 1, 1) + self.label_hour_acoustic_file.clear() + self.label_hour_acoustic_file.setText("Hour: " + str(stg.hour[self.fileListWidget.currentRow()])) + self.gridLayout_goupbox_info.addWidget(self.label_hour_acoustic_file, 1, 1, 1, 1) - self.label_pulse_length_value = QLabel(str(round(stg.pulse_length[self.fileListWidget.currentRow()], 6)) + " sec") - self.gridLayout_goupbox_info.addWidget(self.label_pulse_length_value, 4, 1, 1, 1) + self.combobox_frequency_information.clear() + self.combobox_frequency_information.addItems(stg.freq_text[self.fileListWidget.currentRow()]) + self.combobox_frequency_information.currentIndexChanged.connect(self.combobox_frequency_information_update) - self.label_pings_per_sec_value = QLabel(str(stg.nb_pings_per_sec[self.fileListWidget.currentRow()]) + " Hz") - self.gridLayout_goupbox_info.addWidget(self.label_pings_per_sec_value, 5, 1, 1, 1) - self.label_pings_per_profile_value = QLabel(str(stg.nb_pings_averaged_per_profile[self.fileListWidget.currentRow()])) - self.gridLayout_goupbox_info.addWidget(self.label_pings_per_profile_value, 5, 3, 1, 1) + self.label_profiles_value.setText(str(stg.nb_profiles[self.fileListWidget.currentRow()] + [self.combobox_frequency_information.currentIndex()])) + self.gridLayout_goupbox_info.addWidget(self.label_profiles_value, 4, 1, 1, 1) + + self.label_profiles_per_sec_value.setText(str(stg.nb_profiles_per_sec[self.fileListWidget.currentRow()] + [self.combobox_frequency_information.currentIndex()]) + " Hz") + self.gridLayout_goupbox_info.addWidget(self.label_profiles_per_sec_value, 5, 1, 1, 1) + + self.label_cells_value.setText(str(stg.nb_cells[self.fileListWidget.currentRow()] + [self.combobox_frequency_information.currentIndex()])) + self.gridLayout_goupbox_info.addWidget(self.label_cells_value, 6, 1, 1, 1) + + self.label_cell_size_value.setText(str(100*round(stg.cell_size[self.fileListWidget.currentRow()] + [self.combobox_frequency_information.currentIndex()], 3)) + " cm") + self.gridLayout_goupbox_info.addWidget(self.label_cell_size_value, 7, 1, 1, 1) + + self.label_pulse_length_value.setText(str(round(stg.pulse_length[self.fileListWidget.currentRow()] + [self.combobox_frequency_information.currentIndex()], 6)) + " sec") + self.gridLayout_goupbox_info.addWidget(self.label_pulse_length_value, 8, 1, 1, 1) + + self.label_pings_per_sec_value.setText(str(stg.nb_pings_per_sec[self.fileListWidget.currentRow()] + [self.combobox_frequency_information.currentIndex()]) + " Hz") + self.gridLayout_goupbox_info.addWidget(self.label_pings_per_sec_value, 9, 1, 1, 1) + + self.label_pings_per_profile_value.setText(str(stg.nb_pings_averaged_per_profile[self.fileListWidget.currentRow()] + [self.combobox_frequency_information.currentIndex()])) + self.gridLayout_goupbox_info.addWidget(self.label_pings_per_profile_value, 10, 1, 1, 1) + + self.spinbox_kt.setValue(stg.kt[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()]) + self.spinbox_kt.setSuffix(f" V.m^{1.5}") + self.spinbox_kt.setEnabled(False) + self.checkbox_kt.stateChanged.connect(self.activate_unactivate_spinbox_kt) + self.spinbox_kt.valueChanged.connect(self.kt_value) + + self.spinbox_rx.setValue(stg.gain_rx[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()]) + self.spinbox_rx.setEnabled(False) + self.checkbox_rx.stateChanged.connect(self.activate_unactivate_spinbox_rx) + self.spinbox_rx.valueChanged.connect(self.gain_rx_value) + + self.spinbox_tx.setValue(stg.gain_tx[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()]) + self.spinbox_tx.setEnabled(False) + self.checkbox_tx.stateChanged.connect(self.activate_unactivate_spinbox_tx) + self.spinbox_kt.valueChanged.connect(self.gain_tx_value) # for find, fval in enumerate(stg.freq[self.fileListWidget.currentRow()]): # print(f"find {find} fval {fval}") @@ -1584,12 +1991,168 @@ class AcousticDataTab(QWidget): # self.gridLayout_goupbox_info.addWidget(', '.join(map(str, stg.gain_tx[self.fileListWidget.currentRow()]))) - self.spinbox_kt = QDoubleSpinBox() - elif self.combobox_ABS_system_choice.currentIndex() == 2: - self.label_freq.setText( - _translate("CONSTANT_STRING", cs.FREQUENCY) + ": " + ', '.join(stg.freq_text)) + # elif self.combobox_ABS_system_choice.currentIndex() == 2: + # + # # self.label_freq.setText( + # # _translate("CONSTANT_STRING", cs.FREQUENCY) + ": " + ', '.join(stg.freq_text[self.fileListWidget.currentRow()])) + # + # self.label_freq = QLabel("Date: " + str(stg.date[self.fileListWidget.currentRow()])) + # self.gridLayout_goupbox_info.addWidget(self.label_freq, 0, 0, 1, 1) + # self.label_freq = QLabel("Hour: " + str(stg.hour[self.fileListWidget.currentRow()])) + # self.gridLayout_goupbox_info.addWidget(self.label_freq, 0, 1, 1, 1) + # + # self.combobox_frequency_information.clear() + # self.combobox_frequency_information.addItems(stg.freq_text[self.fileListWidget.currentRow()]) + # self.combobox_frequency_information.currentIndexChanged.connect(self.combobox_frequency_information_update) + # + # self.label_profiles_value.clear() + # self.label_profiles_value.setText(str(stg.nb_profiles[self.fileListWidget.currentRow()] + # [self.combobox_frequency_information.currentIndex()])) + # self.gridLayout_goupbox_info.addWidget(self.label_profiles_value, 3, 1, 1, 1) + # + # self.label_profiles_per_sec_value.clear() + # self.label_profiles_per_sec_value.setText(str(stg.nb_profiles_per_sec[self.fileListWidget.currentRow()] + # [self.combobox_frequency_information.currentIndex()]) + " Hz") + # self.gridLayout_goupbox_info.addWidget(self.label_profiles_per_sec_value, 4, 1, 1, 1) + # + # self.label_cells_value.clear() + # self.label_cells_value.setText(str(stg.nb_cells[self.fileListWidget.currentRow()] + # [self.combobox_frequency_information.currentIndex()])) + # self.gridLayout_goupbox_info.addWidget(self.label_cells_value, 5, 1, 1, 1) + # + # self.label_cell_size_value.clear() + # self.label_cell_size_value.setText(str(100 * round(stg.cell_size[self.fileListWidget.currentRow()] + # [self.combobox_frequency_information.currentIndex()], + # 3)) + " cm") + # self.gridLayout_goupbox_info.addWidget(self.label_cell_size_value, 6, 1, 1, 1) + # + # self.label_pulse_length_value.clear() + # self.label_pulse_length_value.setText(str(round(stg.pulse_length[self.fileListWidget.currentRow()] + # [self.combobox_frequency_information.currentIndex()], + # 6)) + " sec") + # self.gridLayout_goupbox_info.addWidget(self.label_pulse_length_value, 7, 1, 1, 1) + # + # self.label_pings_per_sec_value.clear() + # self.label_pings_per_sec_value.setText(str(stg.nb_pings_per_sec[self.fileListWidget.currentRow()] + # [self.combobox_frequency_information.currentIndex()]) + " Hz") + # self.gridLayout_goupbox_info.addWidget(self.label_pings_per_sec_value, 8, 1, 1, 1) + # + # self.label_pings_per_profile_value.clear() + # self.label_pings_per_profile_value.setText( + # str(stg.nb_pings_averaged_per_profile[self.fileListWidget.currentRow()] + # [self.combobox_frequency_information.currentIndex()])) + # self.gridLayout_goupbox_info.addWidget(self.label_pings_per_profile_value, 9, 1, 1, 1) + # + # self.spinbox_kt.setValue( + # stg.kt[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()]) + # self.spinbox_kt.setSuffix(f" V.m^{1.5}") + # self.spinbox_kt.setEnabled(False) + # self.checkbox_kt.stateChanged.connect(self.activate_unactivate_spinbox_kt) + # self.spinbox_kt.valueChanged.connect(self.kt_value) + # + # self.spinbox_rx.setValue( + # stg.gain_rx[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()]) + # self.spinbox_rx.setEnabled(False) + # self.checkbox_rx.stateChanged.connect(self.activate_unactivate_spinbox_rx) + # self.spinbox_rx.valueChanged.connect(self.gain_rx_value) + # + # self.spinbox_tx.setValue( + # stg.gain_tx[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()]) + # self.spinbox_tx.setEnabled(False) + # self.checkbox_tx.stateChanged.connect(self.activate_unactivate_spinbox_tx) + # self.spinbox_kt.valueChanged.connect(self.gain_tx_value) + + def combobox_frequency_information_update(self): + if self.fileListWidget.count() > 0: + + self.label_profiles_value.clear() + self.gridLayout_goupbox_info.removeWidget(self.label_profiles_value) + self.label_profiles_value.setText(str(stg.nb_profiles[self.fileListWidget.currentRow()] + [self.combobox_frequency_information.currentIndex()])) + self.gridLayout_goupbox_info.addWidget(self.label_profiles_value, 4, 1, 1, 1) + + self.label_profiles_per_sec_value.clear() + self.label_profiles_per_sec_value.setText( + str(stg.nb_profiles_per_sec[self.fileListWidget.currentRow()] + [self.combobox_frequency_information.currentIndex()]) + " Hz") + self.gridLayout_goupbox_info.addWidget(self.label_profiles_per_sec_value, 5, 1, 1, 1) + + self.label_cells_value.clear() + self.label_cells_value.setText(str(stg.nb_cells[self.fileListWidget.currentRow()] + [self.combobox_frequency_information.currentIndex()])) + self.gridLayout_goupbox_info.addWidget(self.label_cells_value, 6, 1, 1, 1) + + self.label_cell_size_value.clear() + self.gridLayout_goupbox_info.removeWidget(self.label_cell_size_value) + self.label_cell_size_value.setText( + str(100 * round(stg.cell_size[self.fileListWidget.currentRow()] + [self.combobox_frequency_information.currentIndex()], 3)) + " cm") + self.gridLayout_goupbox_info.addWidget(self.label_cell_size_value, 7, 1, 1, 1) + + self.label_pulse_length_value.clear() + self.label_pulse_length_value.setText( + str(round(stg.pulse_length[self.fileListWidget.currentRow()] + [self.combobox_frequency_information.currentIndex()], 6)) + " sec") + self.gridLayout_goupbox_info.addWidget(self.label_pulse_length_value, 8, 1, 1, 1) + + self.label_pings_per_sec_value.clear() + self.label_pings_per_sec_value.setText(str(stg.nb_pings_per_sec[self.fileListWidget.currentRow()] + [self.combobox_frequency_information.currentIndex()]) + " Hz") + self.gridLayout_goupbox_info.addWidget(self.label_pings_per_sec_value, 9, 1, 1, 1) + + self.label_pings_per_profile_value.clear() + self.label_pings_per_profile_value.setText( + str(stg.nb_pings_averaged_per_profile[self.fileListWidget.currentRow()] + [self.combobox_frequency_information.currentIndex()])) + self.gridLayout_goupbox_info.addWidget(self.label_pings_per_profile_value, 10, 1, 1, 1) + + self.spinbox_kt.clear() + self.spinbox_kt.setValue(stg.kt[self.fileListWidget.currentRow()] + [self.combobox_frequency_information.currentIndex()]) + self.spinbox_kt.setSuffix(f"V.m^{1.5}") + + self.spinbox_rx.clear() + self.spinbox_rx.setValue(stg.gain_rx[self.fileListWidget.currentRow()] + [self.combobox_frequency_information.currentIndex()]) + + self.spinbox_tx.clear() + self.spinbox_tx.setValue(stg.gain_tx[self.fileListWidget.currentRow()] + [self.combobox_frequency_information.currentIndex()]) + + def activate_unactivate_spinbox_kt(self): + if self.checkbox_kt.isChecked(): + self.spinbox_kt.setEnabled(True) + else: + self.spinbox_kt.setDisabled(True) + + def activate_unactivate_spinbox_rx(self): + if self.checkbox_rx.isChecked(): + self.spinbox_rx.setEnabled(True) + else: + self.spinbox_rx.setDisabled(True) + + def activate_unactivate_spinbox_tx(self): + if self.checkbox_tx.isChecked(): + self.spinbox_tx.setEnabled(True) + else: + self.spinbox_tx.setDisabled(True) + + def kt_value(self): + stg.kt[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()] =\ + self.spinbox_kt.value() + # print(f"stg.kt : {stg.kt}") + + def gain_rx_value(self): + stg.gain_rx[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()] =\ + self.spinbox_rx.value() + # print(f"stg.rx : {stg.gain_rx}") + + def gain_tx_value(self): + stg.gain_tx[self.fileListWidget.currentRow()][self.combobox_frequency_information.currentIndex()] =\ + self.spinbox_tx.value() + # print(f"stg.tx : {stg.gain_tx}") def fill_table(self): @@ -1742,19 +2305,19 @@ class AcousticDataTab(QWidget): print(f" tmin = {stg.tmin} , tmax = {stg.tmax}") - # --- t_cross_section --- - stg.t_cross_section = [stg.time[self.fileListWidget.currentRow()][:, + # --- time_cross_section --- + stg.time_cross_section = [stg.time[self.fileListWidget.currentRow()][:, stg.tmin[self.fileListWidget.currentRow()][0]:stg.tmax[self.fileListWidget.currentRow()][0]]] - print(f"t = {stg.t_cross_section}") + print(f"t = {stg.time_cross_section}") # --- spinbox tmin / tmax --- - # self.spinbox_tmin.setValue(stg.t_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]]) - # self.spinbox_tmax.setValue(stg.t_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1]) + # self.spinbox_tmin.setValue(stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]]) + # self.spinbox_tmax.setValue(stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1]) # self.doubleRangeSlider_recording_time.update() # self.doubleRangeSlider_recording_time.setValue((0, 500)) - # (stg.t_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]], - # stg.t_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1])) + # (stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]], + # stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1])) print("self.doubleRangeSlider_recording_time ", self.doubleRangeSlider_recording_time.value()) @@ -1783,18 +2346,18 @@ class AcousticDataTab(QWidget): stg.tmax.append((tmax_indice+1, tmax_value)) print(f" tmin = {stg.tmin} , tmax = {stg.tmax}") - # --- t_cross_section --- - stg.t_cross_section = stg.t_cross_section + [stg.time[self.fileListWidget.currentRow()][:, + # --- time_cross_section --- + stg.time_cross_section = stg.time_cross_section + [stg.time[self.fileListWidget.currentRow()][:, stg.tmin[self.fileListWidget.currentRow()][0]: stg.tmax[self.fileListWidget.currentRow()][0]]] # --- spinbox tmin / tmax --- - # self.spinbox_tmin.setValue(stg.t_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]]) - # self.spinbox_tmax.setValue(stg.t_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1]) + # self.spinbox_tmin.setValue(stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]]) + # self.spinbox_tmax.setValue(stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1]) # self.doubleRangeSlider_recording_time.setValue(value=( - # stg.t_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]], - # stg.t_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1])) + # stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]], + # stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1])) print("self.doubleRangeSlider_recording_time ", self.doubleRangeSlider_recording_time.value()) @@ -1807,8 +2370,8 @@ class AcousticDataTab(QWidget): # --- spinbox tmin / tmax --- # self.spinbox_tmin.setValue( - # stg.t_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]]) - # self.spinbox_tmax.setValue(stg.t_cross_section[self.fileListWidget.currentRow()][ + # stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]]) + # self.spinbox_tmax.setValue(stg.time_cross_section[self.fileListWidget.currentRow()][ # 0, stg.tmax[self.fileListWidget.currentRow()][0]-1]) # print("tmin = ", stg.tmin) @@ -1817,15 +2380,15 @@ class AcousticDataTab(QWidget): # print("stg.tmin[self.fileListWidget.currentRow()][0] ", stg.tmin[self.fileListWidget.currentRow()][0]) # print("stg.tmax[self.fileListWidget.currentRow()][0] - 1 ", stg.tmax[self.fileListWidget.currentRow()][0]-1) # - # print("t_cross_section min ", stg.t_cross_section[self.fileListWidget.currentRow()][ + # print("time_cross_section min ", stg.time_cross_section[self.fileListWidget.currentRow()][ # 0, stg.tmin[self.fileListWidget.currentRow()][0]]) - # print("t_cross_section max ", stg.t_cross_section[self.fileListWidget.currentRow()][ + # print("time_cross_section max ", stg.time_cross_section[self.fileListWidget.currentRow()][ # 0, stg.tmax[self.fileListWidget.currentRow()][0]]) # # self.doubleRangeSlider_recording_time.setValue(value=(stg.tmin[self.fileListWidget.currentRow()][1], stg.tmax[self.fileListWidget.currentRow()][1])) # # self.doubleRangeSlider_recording_time.setValue(value=( - # stg.t_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]], - # stg.t_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1] + # stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmin[self.fileListWidget.currentRow()][0]], + # stg.time_cross_section[self.fileListWidget.currentRow()][0, stg.tmax[self.fileListWidget.currentRow()][0]-1] # )) # # print("self.doubleRangeSlider_recording_time ", self.doubleRangeSlider_recording_time.value()) @@ -1835,8 +2398,8 @@ class AcousticDataTab(QWidget): self.doubleRangeSlider_recording_time.setRange(min=stg.time[self.fileListWidget.currentRow()][0, 0], max=stg.time[self.fileListWidget.currentRow()][0, -1]) - self.doubleRangeSlider_recording_time.setValue(value=(stg.t_cross_section[self.fileListWidget.currentRow()][0, 0], - stg.t_cross_section[self.fileListWidget.currentRow()][0, -1])) + self.doubleRangeSlider_recording_time.setValue(value=(stg.time_cross_section[self.fileListWidget.currentRow()][0, 0], + stg.time_cross_section[self.fileListWidget.currentRow()][0, -1])) def set_tmin_tmax_for_doubleRangeSider_time(self): @@ -1857,7 +2420,7 @@ class AcousticDataTab(QWidget): )) print("tmax = ", stg.tmax) - stg.t_cross_section[self.fileListWidget.currentRow()] = ( + stg.time_cross_section[self.fileListWidget.currentRow()] = ( stg.time[self.fileListWidget.currentRow()][:, stg.tmin[self.fileListWidget.currentRow()][0]:stg.tmax[self.fileListWidget.currentRow()][0]] ) @@ -1866,14 +2429,14 @@ class AcousticDataTab(QWidget): # if Qt.Key_Return: # # stg.tmax[self.fileListWidget.currentRow()] = (( - # np.where(np.abs(np.round(stg.t_cross_section[self.fileListWidget.currentRow()][0, :], 2) - self.spinbox_tmax.value()) == - # np.nanmin(np.abs(np.round(stg.t_cross_section[self.fileListWidget.currentRow()][0, :], + # np.where(np.abs(np.round(stg.time_cross_section[self.fileListWidget.currentRow()][0, :], 2) - self.spinbox_tmax.value()) == + # np.nanmin(np.abs(np.round(stg.time_cross_section[self.fileListWidget.currentRow()][0, :], # 2) - self.spinbox_tmax.value())))[0][0], # self.spinbox_tmax.value() # )) # print("tmax = ", stg.tmax) # - # stg.t_cross_section[self.fileListWidget.currentRow()] = ( + # stg.time_cross_section[self.fileListWidget.currentRow()] = ( # stg.time[self.fileListWidget.currentRow()][:, stg.tmin[self.fileListWidget.currentRow()][0]:stg.tmax[self.fileListWidget.currentRow()][0]] # ) @@ -2085,7 +2648,6 @@ class AcousticDataTab(QWidget): np.log(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, :]), # np.log(stg.BS_raw_data[self.fileListWidget.currentRow()][f, :, int(stg.tmin[self.fileListWidget.currentRow()]):int(stg.tmax[self.fileListWidget.currentRow()])]), cmap='Blues') - pcm.draw_idle() self.axis_BS[f].text(1, .70, stg.freq_text[self.fileListWidget.currentRow()][f], fontsize=14, fontweight='bold', fontname="Ubuntu", c="black", alpha=0.5, horizontalalignment='right', verticalalignment='bottom', @@ -2104,6 +2666,7 @@ class AcousticDataTab(QWidget): cbar = self.fig_BS.colorbar(pcm, ax=self.axis_BS[:], shrink=1, location='right') cbar.set_label(label='Acoustic backscatter signal (V)', rotation=270, labelpad=10) self.fig_BS.canvas.draw_idle() + # plt.close(self.fig_BS) # self.plot_profile() @@ -2160,6 +2723,11 @@ class AcousticDataTab(QWidget): elif len(stg.BS_cross_section) != 0: + if len(self.axis_BS.tolist()) != stg.freq[self.fileListWidget.currentRow()].shape[0]: + self.fig_BS, self.axis_BS = plt.subplots(nrows=stg.freq[self.fileListWidget.currentRow()].shape[0], + ncols=1, + sharex=True, sharey=False, layout="constrained") + # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.removeWidget(self.scroll_BS) # self.verticalLayout_groupbox_transect_2Dplot_raw_BS_data.addWidget(self.scroll_BS) @@ -2218,7 +2786,8 @@ class AcousticDataTab(QWidget): # # stg.t = np.append(stg.t, np.array([stg.time[f, int(stg.tmin[f]):int(stg.tmax[f])]]), axis=0) # # # print("stg.t[self.fileListWidget.currentRow()].shape() ", stg.t[self.fileListWidget.currentRow()].shape()) - + # print("0/ stg.freq before plot : ", stg.freq) + # print("2/ stg.freq after plot : ", stg.freq[self.fileListWidget.currentRow()]) for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]): # print(f"f = {f}") @@ -2275,6 +2844,8 @@ class AcousticDataTab(QWidget): # [self.slider.value() - 1 if self.slider.value() - 1 <= stg.t.shape[1] - 1 else np.max( # stg.t.shape[1] - 1)][0]]) + # print("self.axis_BS ", self.axis_BS) + # print(f"self.axis_BS[{f}] ", self.axis_BS[f]) self.axis_BS[f].cla() val_min = np.nanmin(stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :]) @@ -2286,12 +2857,12 @@ class AcousticDataTab(QWidget): # print("stg.depth[f, :].shape ", stg.depth[f, :]) if self.combobox_ABS_system_choice.currentIndex() == 1: - pcm = self.axis_BS[f].pcolormesh(stg.t_cross_section[self.fileListWidget.currentRow()][f, :], + pcm = self.axis_BS[f].pcolormesh(stg.time_cross_section[self.fileListWidget.currentRow()][f, :], -stg.depth_cross_section[self.fileListWidget.currentRow()][f, :], stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) elif self.combobox_ABS_system_choice.currentIndex() == 2: - pcm = self.axis_BS[f].pcolormesh(stg.t_cross_section[self.fileListWidget.currentRow()][f, :], + pcm = self.axis_BS[f].pcolormesh(stg.time_cross_section[self.fileListWidget.currentRow()][f, :], -stg.depth_cross_section[self.fileListWidget.currentRow()][f, :], np.log(stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :]), cmap='Blues') @@ -2299,18 +2870,20 @@ class AcousticDataTab(QWidget): # --- Plot river bottom line --- if (len(stg.depth_bottom) != 0) and (len(stg.depth_bottom) == self.fileListWidget.count()): - print("stg.depth_bottom ", stg.depth_bottom) - print("len(stg.depth_bottom) ", len(stg.depth_bottom)) - self.axis_BS[f].plot(stg.t_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_bathymetry.currentIndex(), :], - -stg.depth_bottom[self.fileListWidget.currentRow()], - color='black', linewidth=1, linestyle="solid") + if stg.depth_bottom[self.fileListWidget.currentRow()].shape != (0,): + + print("stg.depth_bottom ", stg.depth_bottom) + print("len(stg.depth_bottom) ", len(stg.depth_bottom)) + self.axis_BS[f].plot(stg.time_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_bathymetry.currentIndex(), :], + -stg.depth_bottom[self.fileListWidget.currentRow()], + color='black', linewidth=1, linestyle="solid") # --- Plot red solid line on transect to visualize position of plotted profile --- - slider_value = [self.slider.value() - 1 if self.slider.value() -1 <= stg.t_cross_section[self.fileListWidget.currentRow()].shape[1]-1 - else np.max(stg.t_cross_section[self.fileListWidget.currentRow()].shape[1]-1)][0] + slider_value = [self.slider.value() - 1 if self.slider.value() -1 <= stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]-1 + else np.max(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]-1)][0] self.axis_BS[self.combobox_frequency_profile.currentIndex()].plot( - stg.t_cross_section[self.fileListWidget.currentRow()][0, # self.combobox_frequency_profile.currentIndex(), + stg.time_cross_section[self.fileListWidget.currentRow()][0, # self.combobox_frequency_profile.currentIndex(), slider_value] * np.ones(stg.depth_cross_section[self.fileListWidget.currentRow()].shape[1]), -stg.depth_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), :], color='red', linestyle="solid", linewidth=2) @@ -2323,6 +2896,7 @@ class AcousticDataTab(QWidget): self.fig_BS.supxlabel('Time (sec)', fontsize=10) self.fig_BS.supylabel('Depth (m)', fontsize=10) self.fig_BS.canvas.draw_idle() + # plt.close(self.fig_BS) def plot_profile(self): @@ -2333,7 +2907,7 @@ class AcousticDataTab(QWidget): self.update_plot_backscattered_acoustic_signal_recording) # self.slider.setMaximum(stg.BS_raw_data[self.fileListWidget.currentRow()].shape[2]) - self.slider.setMaximum(stg.t_cross_section[self.fileListWidget.currentRow()].shape[1]) + self.slider.setMaximum(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]) self.verticalLayout_groupbox_plot_profile.removeWidget(self.canvas_plot_profile) @@ -2345,8 +2919,8 @@ class AcousticDataTab(QWidget): # for f, _ in enumerate(stg.freq[0]): slider_value = [ - self.slider.value() - 1 if self.slider.value() - 1 <= stg.t_cross_section[self.fileListWidget.currentRow()].shape[ - 1] - 1 else np.max(stg.t_cross_section[self.fileListWidget.currentRow()].shape[1] - 1)][0] + self.slider.value() - 1 if self.slider.value() - 1 <= stg.time_cross_section[self.fileListWidget.currentRow()].shape[ + 1] - 1 else np.max(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1] - 1)][0] # --- Profile plot --- # self.axis_profile.cla() @@ -2363,31 +2937,34 @@ class AcousticDataTab(QWidget): # --- Plot bottom line --- if (len(stg.depth_bottom) != 0) and (len(stg.depth_bottom) == self.fileListWidget.count()): - self.axis_profile.plot([0, - np.nanmax(stg.BS_cross_section[self.fileListWidget.currentRow()][ - self.combobox_frequency_profile.currentIndex(), - :, slider_value])], - -stg.depth[self.fileListWidget.currentRow()][ - self.combobox_frequency_profile.currentIndex(), - stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]] * np.ones(2), - linestyle='solid', color='r', linewidth=1) + if stg.depth_bottom[self.fileListWidget.currentRow()].shape != (0,): - position_x = (stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), - stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]] / - np.nanmax( - stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), - :])) + self.axis_profile.plot([0, + np.nanmax(stg.BS_cross_section[self.fileListWidget.currentRow()][ + self.combobox_frequency_profile.currentIndex(), + :, slider_value])], + -stg.depth[self.fileListWidget.currentRow()][ + self.combobox_frequency_profile.currentIndex(), + stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]] * np.ones(2), + linestyle='solid', color='r', linewidth=1) - self.axis_profile.text(.95, 1 - position_x + 0.05, "River bed", - fontsize=10, fontweight='normal', fontname="Times New Roman", - fontstyle="italic", c="red", alpha=0.2, - horizontalalignment='right', verticalalignment='bottom', - transform=self.axis_profile.transAxes) + position_x = (stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), + stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]] / + np.nanmax( + stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), + :])) + + self.axis_profile.text(.95, 1 - position_x + 0.05, "River bed", + fontsize=10, fontweight='normal', fontname="Times New Roman", + fontstyle="italic", c="red", alpha=0.2, + horizontalalignment='right', verticalalignment='bottom', + transform=self.axis_profile.transAxes) self.fig_profile.supxlabel("Acoustic Backscatter Signal (V)") self.fig_profile.supylabel("Depth (m)") self.fig_profile.canvas.draw_idle() + # plt.close(self.fig_profile) # self.plot_transect_with_BS_raw_data() @@ -2414,13 +2991,14 @@ class AcousticDataTab(QWidget): self.fig_profile.supxlabel("Acoustic Backscatter Signal (V)") self.fig_profile.supylabel("Depth (m)") self.fig_profile.canvas.draw_idle() + # plt.close(self.fig_profile) elif len(stg.BS_cross_section) != 0: - self.slider.setMaximum(stg.t_cross_section[self.fileListWidget.currentRow()].shape[1]) + self.slider.setMaximum(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]) - slider_value = [self.slider.value() - 1 if self.slider.value() -1 <= stg.t_cross_section[self.fileListWidget.currentRow()].shape[1]-1 - else np.max(stg.t_cross_section[self.fileListWidget.currentRow()].shape[1]-1)][0] + slider_value = [self.slider.value() - 1 if self.slider.value() -1 <= stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]-1 + else np.max(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]-1)][0] self.axis_profile.cla() @@ -2454,24 +3032,31 @@ class AcousticDataTab(QWidget): # print("self.fileListWidget.currentRow() ", self.fileListWidget.count()) if (len(stg.depth_bottom) != 0) and (len(stg.depth_bottom) == self.fileListWidget.count()): - self.axis_profile.plot([0, - np.nanmax(stg.BS_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), - :, slider_value])], - -stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]]*np.ones(2), - linestyle='solid', color='r', linewidth=1) + if stg.depth_bottom[self.fileListWidget.currentRow()].shape != (0,): - position_x = (stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]] / - np.nanmax(stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), :])) + self.axis_profile.plot([0, + np.nanmax(stg.BS_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), + :, slider_value])], + -stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]]*np.ones(2), + linestyle='solid', color='r', linewidth=1) - self.axis_profile.text(.95, 1-position_x + 0.05, "River bed", - fontsize=10, fontweight='normal', fontname="Ubuntu", - fontstyle="italic", c="red", alpha=0.2, - horizontalalignment='right', verticalalignment='bottom', - transform=self.axis_profile.transAxes) + position_x = (stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), stg.ind_bottom[self.fileListWidget.currentRow()][slider_value]] / + np.nanmax(stg.depth[self.fileListWidget.currentRow()][self.combobox_frequency_profile.currentIndex(), :])) + + self.axis_profile.text(.95, 1-position_x + 0.05, "River bed", + fontsize=10, fontweight='normal', fontname="Ubuntu", + fontstyle="italic", c="red", alpha=0.2, + horizontalalignment='right', verticalalignment='bottom', + transform=self.axis_profile.transAxes) self.fig_profile.supxlabel("Acoustic Backscatter Signal (V)") self.fig_profile.supylabel("Depth (m)") self.fig_profile.canvas.draw_idle() + # plt.close(self.fig_profile) + + def slide_profile_number_to_begin(self): + self.slider.setValue(int(self.slider.minimum())) + self.lineEdit_slider.setText(str(self.slider.value())) def slide_profile_number_to_right(self): self.slider.setValue(int(self.slider.value()) + 1) @@ -2481,6 +3066,10 @@ class AcousticDataTab(QWidget): self.slider.setValue(int(self.slider.value()) - 1) self.lineEdit_slider.setText(str(self.slider.value())) + def slide_profile_number_to_end(self): + self.slider.setValue(int(self.slider.maximum())) + self.lineEdit_slider.setText(str(self.slider.value())) + def profile_number_on_lineEdit(self): self.slider.setValue(int(self.lineEdit_slider.text())) @@ -2792,29 +3381,42 @@ class AcousticDataTab(QWidget): # msgBox.setStandardButtons(QMessageBox.Ok) # msgBox.exec() elif self.canvas_BS != None: - # else: + # --- Record frequency choose for bottom detection --- - if ((self.fileListWidget.count() == 1) and (len(stg.freq_bottom_detection) == 0)): + # if ((self.fileListWidget.count() == 1) and (len(stg.freq_bottom_detection) == 0)): + # + # stg.freq_bottom_detection = [self.combobox_frequency_bathymetry.currentIndex()] + # + # elif len(stg.rmax) < self.fileListWidget.count(): + # + # stg.freq_bottom_detection.append(self.combobox_frequency_bathymetry.currentIndex()) - stg.freq_bottom_detection = [self.combobox_frequency_bathymetry.currentIndex()] + if stg.depth_bottom == []: + stg.freq_bottom_detection = [np.array([])]*self.fileListWidget.count() + stg.depth_bottom = [np.array([])]*self.fileListWidget.count() + stg.val_bottom = [np.array([])]*self.fileListWidget.count() + stg.ind_bottom = [np.array([])]*self.fileListWidget.count() - elif len(stg.rmax) < self.fileListWidget.count(): + # print("stg.freq_bottom_detection : ", stg.freq_bottom_detection) + # print("stg.depth_bottom : ", stg.depth_bottom) + # print("stg.val_bottom : ", stg.val_bottom) + # print("stg.ind_bottom : ", stg.ind_bottom) - stg.freq_bottom_detection.append(self.combobox_frequency_bathymetry.currentIndex()) + stg.freq_bottom_detection[self.fileListWidget.currentRow()] = self.combobox_frequency_bathymetry.currentIndex() # Selecting the range in which we look for the bottom reflection # rmin = np.float32(self.doubleRangeSlider_intg_area.value()[0].text().replace(",", ".")) # rmax = np.float32(self.doubleRangeSlider_intg_area.value()[1].text().replace(",", ".")) rmin = -self.doubleRangeSlider_intg_area.value()[1] rmax = -self.doubleRangeSlider_intg_area.value()[0] - # print(f"rmin = {rmin}") - # print(f"rmax = {rmax}") + print(f"rmin = {rmin}") + print(f"rmax = {rmax}") # empty result arrays # r_bottom = np.zeros(stg.nb_profiles) # val_bottom = np.zeros(stg.nb_profiles) - r_bottom = np.zeros(stg.t_cross_section[self.fileListWidget.currentRow()].shape[1]) - val_bottom = np.zeros(stg.t_cross_section[self.fileListWidget.currentRow()].shape[1]) + r_bottom = np.zeros(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]) + val_bottom = np.zeros(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]) r_bottom_ind = [] # print(f"r_bottom shape with zeros : {r_bottom.shape}") @@ -2830,7 +3432,7 @@ class AcousticDataTab(QWidget): # ----------- Detecting the bottom ------------- # for d in range(stg.nb_profiles): - for d in range(stg.t_cross_section[self.fileListWidget.currentRow()].shape[1]): + for d in range(stg.time_cross_section[self.fileListWidget.currentRow()].shape[1]): # Index of the range where we look for the peak # print(f"self.combobox_freq_choice.currentIndex() : {self.combobox_freq_choice.currentIndex()}") # print(f"r = {stg.r}") @@ -2893,7 +3495,7 @@ class AcousticDataTab(QWidget): # print(f"r_bootom shape : {r_bottom.shape}") BS_section_bottom = np.zeros((stg.depth_cross_section[self.fileListWidget.currentRow()].shape[1], - stg.t_cross_section[self.fileListWidget.currentRow()].shape[1])) + stg.time_cross_section[self.fileListWidget.currentRow()].shape[1])) for i in range(BS_section_bottom.shape[0]): try: @@ -2940,10 +3542,6 @@ class AcousticDataTab(QWidget): stg.ind_bottom[self.fileListWidget.currentRow()] = r_bottom_ind - print("stg.depth_bottom : ", stg.depth_bottom) - print("stg.val_bottom : ", stg.val_bottom) - print("stg.ind_bottom : ", stg.ind_bottom) - BS_stream_bed_copy = deepcopy(stg.BS_cross_section[self.fileListWidget.currentRow()]) for f, _ in enumerate(stg.freq[self.fileListWidget.currentRow()]): for k, _ in enumerate(stg.depth_bottom[self.fileListWidget.currentRow()]): @@ -2984,12 +3582,12 @@ class AcousticDataTab(QWidget): # cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) if self.combobox_ABS_system_choice.currentIndex() == 1: - pcm = self.axis_BS[f].pcolormesh(stg.t_cross_section[self.fileListWidget.currentRow()][f, :], + pcm = self.axis_BS[f].pcolormesh(stg.time_cross_section[self.fileListWidget.currentRow()][f, :], -stg.depth_cross_section[self.fileListWidget.currentRow()][f, :], stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :], cmap='viridis', norm=LogNorm(vmin=val_min, vmax=val_max)) elif self.combobox_ABS_system_choice.currentIndex() == 2: - pcm = self.axis_BS[f].pcolormesh(stg.t_cross_section[self.fileListWidget.currentRow()][f, :], + pcm = self.axis_BS[f].pcolormesh(stg.time_cross_section[self.fileListWidget.currentRow()][f, :], -stg.depth_cross_section[self.fileListWidget.currentRow()][f, :], np.log(stg.BS_cross_section[self.fileListWidget.currentRow()][f, :, :]), cmap='Blues') @@ -3003,7 +3601,7 @@ class AcousticDataTab(QWidget): # print("stg.t[self.combobox_freq_choice.currentIndex(), :] : ", stg.t[self.combobox_freq_choice.currentIndex(), :].shape) # print("-stg.r_bottom : ", stg.r_bottom.shape) - self.axis_BS[f].plot(stg.t_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_bathymetry.currentIndex(), :], + self.axis_BS[f].plot(stg.time_cross_section[self.fileListWidget.currentRow()][self.combobox_frequency_bathymetry.currentIndex(), :], -stg.depth_bottom[self.fileListWidget.currentRow()], color='black', linewidth=1, linestyle="solid") @@ -3018,6 +3616,10 @@ class AcousticDataTab(QWidget): self.fig_BS.canvas.draw_idle() + # print("stg.freq_bottom_detection : ", stg.freq_bottom_detection) + # print("stg.depth_bottom : ", stg.depth_bottom) + # print("stg.val_bottom : ", stg.val_bottom) + # print("stg.ind_bottom : ", stg.ind_bottom) # # --- Plot transect SNR with bathymetry --- # if self.canvas_SNR != None: @@ -3187,3 +3789,6 @@ class AcousticDataTab(QWidget): # self.fig_SNR.canvas.draw_idle() # return r_bottom, val_bottom, r_bottom_ind, BS_section_bottom + + + diff --git a/settings.py b/settings.py index daeaec4..d80a436 100644 --- a/settings.py +++ b/settings.py @@ -61,13 +61,14 @@ BS_stream_bed = [] # BS_data_section = BS data in the section. Values NaN o BS_noise_cross_section = np.array([]) # BS_noise_cros_section = BS_noise_data[:, :, tmin:tmax] (former Noise_data) SNR_cross_section = np.array([]) # SNR_data = snr[:, :, tmin:tmax] SNR_stream_bed = np.array([]) -t_cross_section = [] +time_cross_section = [] t_snr = np.array([]) depth_cross_section = [] depth_bottom = [] val_bottom = [] ind_bottom = [] freq_bottom_detection = [] +depth_bottom_detection_1st_int_area = [] # --- Processed data in Signal Processing Tab --- # BS_cross_section_SNR_filter = np.array([[[]]]) # BS data filtered with SNR values (remove point if SNR < value) - bottom is not detected @@ -164,6 +165,8 @@ filename_save_as = "" dirname_open = "" filename_open = "" +read_table_trigger = 0 +