def __init__(self, filename): try: with open(filename, 'rb') as fhand: self.FILE_PATH = filename self.version = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.frameCount = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.frameRate = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.highResolution = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.numRawBeams = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.sampleRate = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.samplesPerChannel = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.receiverGain = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.windowStart = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.windowLength = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.reverse = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.serialNumber = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.strDate = struct.unpack(utils.cType["char[32]"], fhand.read( utils.c("char[32]")))[0] self.strHeaderID = struct.unpack( utils.cType["char[256]"], fhand.read(utils.c("char[256]")))[0] self.userID1 = struct.unpack(utils.cType["int32_t"], fhand.read(utils.c("int32_t")))[0] self.userID2 = struct.unpack(utils.cType["int32_t"], fhand.read(utils.c("int32_t")))[0] self.userID3 = struct.unpack(utils.cType["int32_t"], fhand.read(utils.c("int32_t")))[0] self.userID4 = struct.unpack(utils.cType["int32_t"], fhand.read(utils.c("int32_t")))[0] self.startFrame = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.endFrame = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.timelapse = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.recordInterval = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.radioSecond = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.frameInterval = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.flags = struct.unpack(utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.auxFlags = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.soundVelocity = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.flags3D = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.softwareVersion = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.waterTemp = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.salinity = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.pulseLength = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.TxMode = struct.unpack(utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.versionFPGA = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.versionPSuC = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.thumbnailFI = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.fileSize = struct.unpack(utils.cType["uint64_t"], fhand.read( utils.c("uint64_t")))[0] self.optionalHeaderSize = struct.unpack( utils.cType["uint64_t"], fhand.read(utils.c("uint64_t")))[0] self.optionalTailSize = struct.unpack( utils.cType["uint64_t"], fhand.read(utils.c("uint64_t")))[0] self.versionMinor = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.largeLens = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] except FileNotFoundError as e: raise FileNotFoundError(e.errno, e.strerror, filename) self.FRAME_SIZE = self.getFrameSize() self.FILE_SIZE = self.getFileSize() self.FILE_HEADER_SIZE = self.getFileHeaderSize() self.ALL_FRAMES_SIZE = self.getAllFramesSize() self.sanity = self.sanityChecks()
def __init__(self, filename, frameIndexInp, frameSize): # frameIndex = frameIndexInp - 1 self.FRAME_NUMBER = frameIndexInp try: with open(filename, "rb") as fhand: frameoffset = (1024 + (frameIndexInp * (1024 + (frameSize)))) fhand.seek(frameoffset, 0) self.frameIndex = struct.unpack( utils.cType["uint64_t"], fhand.read(utils.c("uint64_t")))[0] self.frameTime = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.version = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.status = struct.unpack(utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.sonarTimeStamp = struct.unpack( utils.cType["uint64_t"], fhand.read(utils.c("uint64_t")))[0] self.TS_Day = struct.unpack(utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.TS_Hour = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.TS_Minute = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.TS_Second = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.TS_Hsecond = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.transmitMode = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.windowStart = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.windowLength = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.threshold = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.intensity = struct.unpack(utils.cType["int32_t"], fhand.read( utils.c("int32_t")))[0] self.receiverGain = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.degC1 = struct.unpack(utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.degC2 = struct.unpack(utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.humidity = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.focus = struct.unpack(utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.battery = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.userVal1 = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.userVal2 = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.userVal3 = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.userVal4 = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.userVal5 = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.userVal6 = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.userVal7 = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.userVal8 = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.velocity = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.depth = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.altitude = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.pitch = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.pitchRate = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.roll = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.rollRate = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.heading = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.headingRate = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.compassHeading = struct.unpack( utils.cType["float"], fhand.read(utils.c("float")))[0] self.compassPitch = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.compassRoll = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.latitude = struct.unpack(utils.cType["double"], fhand.read(utils.c("double")))[0] self.longitude = struct.unpack(utils.cType["double"], fhand.read( utils.c("double")))[0] self.sonarPosition = struct.unpack( utils.cType["float"], fhand.read(utils.c("float")))[0] self.configFlags = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.beamTilt = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.targetRange = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.targetBearing = struct.unpack( utils.cType["float"], fhand.read(utils.c("float")))[0] self.targetPresent = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.firmwareRev = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.flags = struct.unpack(utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.sourceFrame = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.waterTemp = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.timerPeriod = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.sonarX = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.sonarY = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.sonarZ = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.sonarPan = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.sonarTilt = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.sonarRoll = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.panPNNL = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.tiltPNNL = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.rollPNNL = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.vehicleTime = struct.unpack(utils.cType["double"], fhand.read( utils.c("double")))[0] self.timeGGK = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.dateGGK = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.qualityGGK = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.numStatsGGK = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.DOPGGK = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.EHTGGK = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.heaveTSS = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.yearGPS = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.monthGPS = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.dayGPS = struct.unpack(utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.hourGPS = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.minuteGPS = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.secondGPS = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.HSecondGPS = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.sonarPanOffset = struct.unpack( utils.cType["float"], fhand.read(utils.c("float")))[0] self.sonarTiltOffset = struct.unpack( utils.cType["float"], fhand.read(utils.c("float")))[0] self.sonarRollOffset = struct.unpack( utils.cType["float"], fhand.read(utils.c("float")))[0] self.sonarXOffset = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.sonarYOffset = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.sonarZOffset = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.Tmatrix1 = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.Tmatrix2 = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.Tmatrix3 = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.Tmatrix4 = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.Tmatrix5 = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.Tmatrix6 = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.Tmatrix7 = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.Tmatrix8 = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.Tmatrix9 = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.Tmatrix10 = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.Tmatrix11 = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.Tmatrix12 = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.Tmatrix13 = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.Tmatrix14 = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.Tmatrix15 = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.Tmatrix16 = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.sampleRate = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.accelX = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.accelY = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.accelZ = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.pingMode = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.freq = struct.unpack(utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.pulseWidth = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.cyclePeriod = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.samplePeriod = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.transmitEnable = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.frameRate = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.soundSpeed = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.samplesPerBeam = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.enable150V = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.sampleStartDelay = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.largeLens = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.systemType = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.sonarSerialNumber = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.reservedEK = struct.unpack( utils.cType["uint64_t"], fhand.read(utils.c("uint64_t")))[0] self.ARISErrorFlags = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.missedPackets = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.ARISAppVersion = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.available2 = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.reordered = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.salinity = struct.unpack(utils.cType["uint32_t"], fhand.read( utils.c("uint32_t")))[0] self.pressure = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.batteryVoltage = struct.unpack( utils.cType["float"], fhand.read(utils.c("float")))[0] self.mainVoltage = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.switchVoltage = struct.unpack( utils.cType["float"], fhand.read(utils.c("float")))[0] self.focusMotorMoving = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.voltageChanging = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.focusTimeoutFault = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.focusOverCurrentFault = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.focusNotFoundFault = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.focusStalledFault = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.FPGATimeoutFault = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.FPGABusyFault = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.FPGAStuckFault = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.CPUTempFault = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.PSUTempFault = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.waterTempFault = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.humidityFault = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.pressureFault = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.voltageReadFault = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.voltageWriteFault = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.focusCurrentPosition = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.targetPan = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.targetTilt = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.targetRoll = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.panMotorErrorCode = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.tiltMotorErrorCode = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.rollMotorErrorCode = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.panAbsPos = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.tiltAbsPos = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.rollAbsPos = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.panAccelX = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.panAccelY = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.panAccelZ = struct.unpack(utils.cType["float"], fhand.read(utils.c("float")))[0] self.tiltAccelX = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.tiltAccelY = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.tiltAccelZ = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.rollAccelX = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.rollAccelY = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.rollAccelZ = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.appliedSett = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.constrainedSett = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.invalidSett = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.enableInterpacketDelay = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.interpacketDelayPeriod = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.uptime = struct.unpack(utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.ARISAppVersionMajor = struct.unpack( utils.cType["uint16_t"], fhand.read(utils.c("uint16_t")))[0] self.ARISAppVersionMinor = struct.unpack( utils.cType["uint16_t"], fhand.read(utils.c("uint16_t")))[0] self.goTime = struct.unpack(utils.cType["uint64_t"], fhand.read(utils.c("uint64_t")))[0] self.panVelocity = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.tiltVelocity = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.rollVelocity = struct.unpack(utils.cType["float"], fhand.read( utils.c("float")))[0] self.GPSTimeAge = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.systemVariant = struct.unpack( utils.cType["uint32_t"], fhand.read(utils.c("uint32_t")))[0] self.padding = struct.unpack(utils.cType["char[288]"], fhand.read( utils.c("char[288]")))[0] ########################### # Functions Section ########################### self.BEAM_COUNT = self.getBeamsFromPingMode(self.pingMode) self.FRAME_DATA = self.readData(frameoffset, fhand) except FileNotFoundError as e: raise FileNotFoundError(e.errno, e.strerror, filename) self.Tmatrix = self.getTransformationMatrix() self.IMAGE = self.constructImage() return
def v3_getAllFramesData(fhand, version, cls): """Opens a .ddf file and extracts all bytes for all frames and returns a list containing all frames data, to be used in drawing the images. For images to be drawn from frames, the following attributes are needed from this function: - SONAR Sample Data --> `allFrames` - Number of Beams [fl] --> `numRawBeams` - Samples Per Beam [fl] --> `samplesPerChannel` - Type of Lens [fr] --> `largeLens` - Sample Start Delay[fr]--> `sampleStartDelay` - Sound Velocity[fr] --> `soundSpeed` - Sample Period[fr] --> `samplePeriod` """ ## TODO _ cls.version = "DDF_03" fileAttributesList = [ "numRawBeams", "samplesPerChannel", "frameCount", "highResolution", "serialNumber" ] frameAttributesList = ["configFlags", "windowStart", "windowLengthIndex"] fileHeader = utils.getFileHeaderValue(version, fileAttributesList) frameHeader = utils.getFrameHeaderValue(version, frameAttributesList) print("inside v3_getAllFramesData(fhand)") # Reading Number of frames in the file [from file header] fhand.seek(fileHeader["frameCount"]["location"], 0) cls.frameCount = struct.unpack( utils.cType[fileHeader["frameCount"]["size"]], fhand.read(utils.c(fileHeader["frameCount"]["size"])))[0] # Reading highResolution value to detect whether Hi/Lo frequency # [from file header] fhand.seek(fileHeader["highResolution"]["location"], 0) highResolution = struct.unpack( utils.cType[fileHeader["highResolution"]["size"]], fhand.read(utils.c(fileHeader["highResolution"]["size"])))[0] # Reading number of beams in each frame [from file header] fhand.seek(fileHeader["numRawBeams"]["location"], 0) cls.BEAM_COUNT = struct.unpack( utils.cType[fileHeader["numRawBeams"]["size"]], fhand.read(utils.c(fileHeader["numRawBeams"]["size"])))[0] # Reading number of samples in each beam [from file header] fhand.seek(fileHeader["samplesPerChannel"]["location"], 0) cls.samplesPerBeam = struct.unpack( utils.cType[fileHeader["samplesPerChannel"]["size"]], fhand.read(utils.c(fileHeader["samplesPerChannel"]["size"])))[0] # Reading Serial number of file format to decide configuration flags later # [from file header] fhand.seek(fileHeader["serialNumber"]["location"], 0) serialNumber = struct.unpack( utils.cType[fileHeader["serialNumber"]["size"]], fhand.read(utils.c(fileHeader["serialNumber"]["size"])))[0] frameoffset = cls.FILE_HEADER_SIZE # Reading Sample Period [from frame header] # fhand.seek(frameoffset + fhand.seek(frameHeader["samplePeriod"]["location"], 0)) # cls.samplePeriod = struct.unpack( # utils.cType[frameHeader["samplePeriod"]["size"]], # fhand.read(utils.c(frameHeader["samplePeriod"]["size"])))[0] # Reading window start length [from frame header] fhand.seek(frameoffset + fhand.seek(frameHeader["windowStart"]["location"], 0)) cls.windowStart = struct.unpack( utils.cType[frameHeader["windowStart"]["size"]], fhand.read(utils.c(frameHeader["windowStart"]["size"])))[0] # Reading window length index [from frame header] # will be modified and used to determine window length later fhand.seek(frameoffset + fhand.seek(frameHeader["windowLengthIndex"]["location"], 0)) windowLengthIndex = struct.unpack( utils.cType[frameHeader["windowLengthIndex"]["size"]], fhand.read(utils.c(frameHeader["windowLengthIndex"]["size"])))[0] # Reading configuration flags [from frame header] if (serialNumber < 19): configFlags = 1 elif (serialNumber == 15): configFlags = 3 else: fhand.seek(frameoffset + fhand.seek(frameHeader["configFlags"]["location"], 0)) configFlags = struct.unpack( utils.cType[frameHeader["configFlags"]["size"]], fhand.read(utils.c(frameHeader["configFlags"]["size"])))[0] ## bit0: 1=classic, 0=extended windows; bit1: 0=Standard, 1=LR configFlagsStr = bin(configFlags) configFlags = 2 * int(configFlagsStr[-2]) + int(configFlagsStr[-1]) ## TODO _ : this needs to be completed windowLengthIndex = windowLengthIndex + 1 + 2 * (cls.highResolution == 0) setWindowLength(configFlags, windowLengthIndex, cls) setWindowStart(configFlags, highResolution, cls) setFirstBeamAngle(not highResolution, cls) frameSize = cls.BEAM_COUNT * cls.samplesPerBeam frameoffset = cls.FILE_HEADER_SIZE + cls.FRAME_HEADER_SIZE fhand.seek(frameoffset, 0) strCat = frameSize * "B" cls.FRAMES = np.array(struct.unpack(strCat, fhand.read(frameSize)), dtype=np.uint8) cls.FRAMES = cv2.flip( cls.FRAMES.reshape((cls.samplesPerBeam, cls.BEAM_COUNT)), 0) cls.DATA_SHAPE = cls.FRAMES.shape cls.FRAMES = cls.constructImages() return
def v5_getAllFramesData(fhand, version, cls): """Opens a .aris file and extracts all bytes for all frames and returns a list containing all frames data, to be used in drawing the images. For images to be drawn from frames, the following attributes are needed from this function: - SONAR Sample Data --> `allFrames` - Number of Beams [fl] --> `numRawBeams` - Samples Per Beam [fl] --> `samplesPerChannel` - Type of Lens [fr] --> `largeLens` - Sample Start Delay[fr]--> `sampleStartDelay` - Sound Velocity[fr] --> `soundSpeed` - Sample Period[fr] --> `samplePeriod` """ ## TODO _ cls.version = "ARIS" fileAttributesList = ["numRawBeams", "samplesPerChannel", "frameCount"] frameAttributesList = [ "largeLens", "sampleStartDelay", "soundSpeed", "samplePeriod" ] fileHeader = utils.getFileHeaderValue(version, fileAttributesList) frameHeader = utils.getFrameHeaderValue(version, frameAttributesList) print("inside v5_getAllFramesData(fhand)") # Reading Number of frames in the file [from file header] fhand.seek(fileHeader["frameCount"]["location"], 0) cls.frameCount = struct.unpack( utils.cType[fileHeader["frameCount"]["size"]], fhand.read(utils.c(fileHeader["frameCount"]["size"])))[0] # Reading number of beams in each frame [from file header] fhand.seek(fileHeader["numRawBeams"]["location"], 0) cls.BEAM_COUNT = struct.unpack( utils.cType[fileHeader["numRawBeams"]["size"]], fhand.read(utils.c(fileHeader["numRawBeams"]["size"])))[0] # Reading number of samples in each beam [from file header] fhand.seek(fileHeader["samplesPerChannel"]["location"], 0) cls.samplesPerBeam = struct.unpack( utils.cType[fileHeader["samplesPerChannel"]["size"]], fhand.read(utils.c(fileHeader["samplesPerChannel"]["size"])))[0] # Reading Sample Period [from frame header] fhand.seek(cls.FILE_HEADER_SIZE + fhand.seek(frameHeader["samplePeriod"]["location"], 0)) cls.samplePeriod = struct.unpack( utils.cType[frameHeader["samplePeriod"]["size"]], fhand.read(utils.c(frameHeader["samplePeriod"]["size"])))[0] # Reading Sound Velocity in Water [from frame header] fhand.seek(cls.FILE_HEADER_SIZE + fhand.seek(frameHeader["soundSpeed"]["location"], 0)) cls.soundSpeed = struct.unpack( utils.cType[frameHeader["soundSpeed"]["size"]], fhand.read(utils.c(frameHeader["soundSpeed"]["size"])))[0] # Reading Sample Start Delay [from frame header] fhand.seek(cls.FILE_HEADER_SIZE + fhand.seek(frameHeader["sampleStartDelay"]["location"], 0)) cls.sampleStartDelay = struct.unpack( utils.cType[frameHeader["sampleStartDelay"]["size"]], fhand.read(utils.c(frameHeader["sampleStartDelay"]["size"])))[0] # Reading availability of large lens [from frame header] fhand.seek(cls.FILE_HEADER_SIZE + fhand.seek(frameHeader["largeLens"]["location"], 0)) cls.largeLens = struct.unpack( utils.cType[frameHeader["largeLens"]["size"]], fhand.read(utils.c(frameHeader["largeLens"]["size"])))[0] frameSize = cls.BEAM_COUNT * cls.samplesPerBeam # the first frame data offset from file start is 2048 frameoffset = 2048 fhand.seek(frameoffset, 0) strCat = frameSize * "B" cls.FRAMES = np.array(struct.unpack(strCat, fhand.read(frameSize)), dtype=np.uint8) cls.FRAMES = cv2.flip( cls.FRAMES.reshape((cls.samplesPerBeam, cls.BEAM_COUNT)), 0) cls.DATA_SHAPE = cls.FRAMES.shape cls.windowStart = cls.sampleStartDelay * 0.000001 * cls.soundSpeed / 2 cls.windowLength = cls.samplePeriod * cls.samplesPerBeam * 0.000001 * cls.soundSpeed / 2 cls.firstBeamAngle = beamLookUp.BeamLookUp(cls.BEAM_COUNT, cls.largeLens)[-1] #cls.FRAMES = cls.constructImages() cls.FRAMES = cls.constructImages(cls.FRAMES) return