Exemple #1
0
        public IEnumerable <TraceHeader> ReadTraceHeaders(long startTraceIndex, long traceCount)
        {
            if (startTraceIndex > TraceCount)
            {
                throw new ArgumentException($"Cannot read a trace header with trace index: {startTraceIndex}, when file only contains {TraceCount} traces");
            }
            var streamLen = binaryReader.BaseStream.Length;

            int traceDataBytesSz   = BinaryFileHeader.SamplesPerTraceOfFile * dataSampleSize;
            var dataStartIndex     = TextHeaderBytesCount + BinaryHeaderBytesCount + TextHeaderBytesCount * (TextHeaders.Count() - 1);
            var initStreamPosition = dataStartIndex + (240 + BinaryFileHeader.SamplesPerTraceOfFile * dataSampleSize) * startTraceIndex;

            binaryReader.BaseStream.Seek(initStreamPosition, SeekOrigin.Begin);
            var streamPosition = initStreamPosition;

            BigArray <TraceHeader> traceHeaders = new BigArray <TraceHeader>(traceCount);

            for (long tid = 0; tid < traceCount && (streamPosition < streamLen); tid++)
            {
                var traceHeaderByteArr = binaryReader.ReadBytes(TraceHeaderBytesCount);
                var trHeader           = TraceHeader.From(traceHeaderByteArr, BitConverter);
                binaryReader.BaseStream.Seek(traceDataBytesSz, SeekOrigin.Current);
                streamPosition   += 240 + traceDataBytesSz;
                traceHeaders[tid] = trHeader;
            }
            return(traceHeaders);
        }
Exemple #2
0
        public TraceHeader ReadTraceHeader(long traceIndex)
        {
            if (traceIndex > TraceCount)
            {
                throw new ArgumentException($"Cannot read a trace with trace index: {traceIndex}, when file only contains {TraceCount} traces");
            }

            var dataStartIndex     = TextHeaderBytesCount + BinaryHeaderBytesCount + TextHeaderBytesCount * (TextHeaders.Count() - 1);
            var initStreamPosition = dataStartIndex + (240 + BinaryFileHeader.SamplesPerTraceOfFile * this.dataSampleSize) * traceIndex;

            this.binaryReader.BaseStream.Seek(initStreamPosition, SeekOrigin.Begin);

            var traceHeaderByteArr = this.binaryReader.ReadBytes(TraceHeaderBytesCount);
            var trHeader           = TraceHeader.From(traceHeaderByteArr, BitConverter);

            return(trHeader);
        }
Exemple #3
0
        public IEnumerable <Trace> ReadTraces(long startTraceIndex, long traceCount)
        {
            if (startTraceIndex > TraceCount)
            {
                throw new ArgumentException($"Cannot read a trace with trace index: {startTraceIndex}, when file only contains {TraceCount} traces");
            }
            var initStreamPosition = (3600 + ((TextHeaders.Count() - 1) * TextHeaderBytesCount)) + (240 + BinaryFileHeader.SamplesPerTraceOfFile * dataSampleSize) * startTraceIndex;

            binaryReader.BaseStream.Seek(initStreamPosition, SeekOrigin.Begin);

            BigList <Trace> traces = new BigList <Trace>(traceCount);

            for (long tid = 0; tid < traceCount; tid++)
            {
                var traceHeaderByteArr = binaryReader.ReadBytes(TraceHeaderBytesCount);
                var traceData          = traceDataReadingFunc(BinaryFileHeader.SamplesPerTraceOfFile);// _binaryreader.ReadIbmSingles(Header.SamplesPerTraceOfFile);
                var trHeader           = TraceHeader.From(traceHeaderByteArr, BitConverter);
                var seismicTrace       = new Trace(trHeader, traceData);
                traces.Add(seismicTrace);
            }
            return(traces);
        }