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); }
public void Write(TraceHeader traceHeader, long traceIndex) { if (TraceCount < traceIndex) { throw new ArgumentException("There are fewer traces in the file then intended trace headers to write"); } var traceStartBytePosition = (TextHeaders.Count() * TextHeaderBytesCount) + BinaryHeaderBytesCount + (traceIndex * (TraceHeaderBytesCount + (BinaryFileHeader.SamplesPerTraceOfFile * dataSampleSize))); binaryWriter.BaseStream.Seek(traceStartBytePosition, SeekOrigin.Begin); var traceHeaderBytes = traceHeader.ToBytes(this.BitConverter); binaryWriter.Write(traceHeaderBytes); }
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); }
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); }
public void Write(TraceHeader traceHeader, int traceIndex) { Write(traceHeader, (long)traceIndex); }
public static TraceHeader From(byte[] bytes, EndianBitConverter bitConverter) { TraceHeader hdr = new TraceHeader(); Func <byte[], int, short> bytesToInt16 = bitConverter.ToInt16; Func <byte[], int, int> bytesToInt32 = bitConverter.ToInt32; hdr.TraceNumInLine = bytesToInt32(bytes, 0); hdr.TraceNumInFile = bytesToInt32(bytes, 4); hdr.ShotNumOrStackTraceNum = bytesToInt32(bytes, 8); hdr.TraceNumInShot = bytesToInt32(bytes, 12); hdr.EnergySourcePtNum = bytesToInt32(bytes, 16); hdr.CdpNum = bytesToInt32(bytes, 20); hdr.TraceNumber = bytesToInt32(bytes, 24); hdr.TraceId = bytesToInt16(bytes, 28); hdr.NumVerticalStackedTraces = bytesToInt16(bytes, 30); hdr.CdpFold = bytesToInt16(bytes, 32); hdr.DataUse = bytesToInt16(bytes, 34); hdr.SourceReceiverDistance = bytesToInt32(bytes, 36); hdr.RecieverGroupElevation = bytesToInt32(bytes, 40); hdr.SurfaceElevationAtSource = bytesToInt32(bytes, 44); hdr.SourceDepthBelowSurf = bytesToInt32(bytes, 48); hdr.DatumElevAtRecieverGroup = bytesToInt32(bytes, 52); hdr.DatumElevationAtSource = bytesToInt32(bytes, 56); hdr.WaterDepthAtSource = bytesToInt32(bytes, 60); hdr.WaterDepthAtRecieverGroup = bytesToInt32(bytes, 64); hdr.ScalarForElevationAndDepth = bytesToInt16(bytes, 68); hdr.ScalarForCoordinates = bytesToInt16(bytes, 70); hdr.XSourceCoordinate = bytesToInt32(bytes, 72); hdr.YSourceCoordinate = bytesToInt32(bytes, 76); hdr.XRecieverGroupCoordinate = bytesToInt32(bytes, 80); hdr.YRecieverGroupCoordinate = bytesToInt32(bytes, 84); hdr.CoordinateUnit = bytesToInt16(bytes, 88); hdr.WeatheringVelocity = bytesToInt16(bytes, 90); hdr.SubweatheringVelocity = bytesToInt16(bytes, 92); hdr.UpholeTimeAtSource = bytesToInt16(bytes, 94); hdr.UpholeTimeAtReceiverGroup = bytesToInt16(bytes, 96); hdr.SourceStaticCorrection = bytesToInt16(bytes, 98); hdr.ReceiverGroupStaticCorrection = bytesToInt16(bytes, 100); hdr.TotalStaticApplied = bytesToInt16(bytes, 102); hdr.HeaderTimeBreakLagMs = bytesToInt16(bytes, 104); hdr.TimeBreakShotLagMs = bytesToInt16(bytes, 106); hdr.ShotRecordingLag = bytesToInt16(bytes, 108); hdr.MuteTimeStart = bytesToInt16(bytes, 110); hdr.MuteTimeEnd = bytesToInt16(bytes, 112); hdr.SampleCount = (ushort)bytesToInt16(bytes, 114); hdr.SampleIntervalMs = (ushort)bytesToInt16(bytes, 116); hdr.GainType = bytesToInt16(bytes, 118); hdr.GainConst = bytesToInt16(bytes, 120); hdr.EarlyGainDb = bytesToInt16(bytes, 122); hdr.Correlated = bytesToInt16(bytes, 124); hdr.SweepFrequencyStart = bytesToInt16(bytes, 126); hdr.SweepFrequencyEnd = bytesToInt16(bytes, 128); hdr.SweepLengthMs = bytesToInt16(bytes, 130); hdr.SweepType = bytesToInt16(bytes, 132); hdr.SweepTaperTraceLengthStartMs = bytesToInt16(bytes, 134); hdr.SweepTaperTraceLengthEndMs = bytesToInt16(bytes, 136); hdr.TaperType = bytesToInt16(bytes, 138); hdr.AliasFilterFrequency = bytesToInt16(bytes, 140); hdr.AliasFilterSlope = bytesToInt16(bytes, 142); hdr.NotchFilterFrequency = bytesToInt16(bytes, 144); hdr.NotchFilterSlope = bytesToInt16(bytes, 146); hdr.LowCutFrequency = bytesToInt16(bytes, 148); hdr.HighCutFrequency = bytesToInt16(bytes, 150); hdr.LowCutSlope = bytesToInt16(bytes, 152); hdr.HighCutSlope = bytesToInt16(bytes, 154); hdr.Yr = bytesToInt16(bytes, 156); hdr.Day = bytesToInt16(bytes, 158); hdr.Hour = bytesToInt16(bytes, 160); hdr.Minute = bytesToInt16(bytes, 162); hdr.Second = bytesToInt16(bytes, 164); hdr.TimeBasis = bytesToInt16(bytes, 166); hdr.TraceWeightFactor = bytesToInt16(bytes, 168); hdr.GeophoneGroupNumOfRollSwitchPositionOne = bytesToInt16(bytes, 170); hdr.GeophoneGroupNumOfFirstTraceOrigRecord = bytesToInt16(bytes, 172); hdr.GeophoneGroupNumOfLastTraceOrigRecord = bytesToInt16(bytes, 174); hdr.GapSize = bytesToInt16(bytes, 176); hdr.TaperOverTravel = bytesToInt16(bytes, 178); hdr.XCdp = bytesToInt32(bytes, 180); hdr.YCdp = bytesToInt32(bytes, 184); hdr.Inline = bytesToInt32(bytes, 188); hdr.Crossline = bytesToInt32(bytes, 192); hdr.ShotPoint = bytesToInt32(bytes, 196); hdr.ShotPointScalar = bytesToInt16(bytes, 200); hdr.TraceValueMeasurementUnit = bytesToInt16(bytes, 202); hdr.TransductionConstantMantissa = bytesToInt32(bytes, 204); hdr.TransductionConstantPower = bytesToInt16(bytes, 208); hdr.TransductionUnit = bytesToInt16(bytes, 210); hdr.TraceIdentifier = bytesToInt16(bytes, 212); hdr.ScalarTraceHeader = bytesToInt16(bytes, 214); hdr.SourceType = bytesToInt16(bytes, 216); hdr.SourceEnergyDirectionMantissa = bytesToInt32(bytes, 218); hdr.SourceEnergyDirectionExponent = bytesToInt16(bytes, 222); hdr.SourceMeasurementMantissa = bytesToInt32(bytes, 224); hdr.SourceMeasurementExponent = bytesToInt16(bytes, 228); hdr.SourceMeasurementUnit = bytesToInt16(bytes, 230); hdr.UnassignedInt1 = bytesToInt32(bytes, 232); hdr.UnassignedInt2 = bytesToInt32(bytes, 236); return(hdr); }