/// <summary> /// initilize trace structure /// </summary> /// <param name="isBigEndian">is the file big endian or little endian</param> /// <param name="format">format of data word length according to SEGY standard</param> /// <param name="number_of_points_in_trace">format of data word length according to SEGY standard</param> /// public void Intialize(bool isBigEndian, int format, int number_of_points_in_trace = 0) { iSEGYTraceData = new SEGYTraceData(); iSEGYTraceData.Initialize(format, isBigEndian, number_of_points_in_trace); iSEGYTraceHeader = new SEGYTraceHeader(); iSEGYTraceHeader.Initialize(isBigEndian); iformat = format; }
/// <summary> /// read the file header from disk /// </summary> /// <param name="br">binary reader stream</param> /// <returns>true if successful</returns> public bool ReadFileHeader(BinaryReader br) { this.br = br; // read text header byte[] t0 = br.ReadBytes(3200); //remove pre-initialized vaue this.ExtendedTextHeader.Clear(); this.ExtendedTextHeader.Add(t0); // note 1st TextHeader block is alwats the firsr 3200 bytes in the file // read file header byte[] fh = br.ReadBytes(400); this.BinaryFileHeader = fh; // check byte order BigEndian = isBigEndian(); positionOfStartOfDataTraces = br.BaseStream.Position; // record the positionTraceReacorded of the start of the data traces // check SEGY revision - SEGY Version 1.0 encoded as 0100 base 16. if (this.segyFormatRevisionNumber >= 256) { if ((int)this.numberOfExtendedTextualFileHeaderRecordsFollowing < 100) { // may have extended headers for (int i = 0; i < (int)this.numberOfExtendedTextualFileHeaderRecordsFollowing; i++) { t0 = br.ReadBytes(3200); this.ExtendedTextHeader.Add(t0); } } else { this.detectedSEGYVer0 = true; // probably } } long saveposition = br.BaseStream.Position; // sometimes the file is SEGY rev 0 and there is crap in the header fields // let's check to see is the next trace makes sense SEGYTraceHeader th = new SEGYTraceHeader(); th.Initialize(this.isBigEndian()); th.TraceHeaderBuffer = br.ReadBytes(240); if (th.yearDataRecorded < 1950 || th.yearDataRecorded > 2050) { this.detectedSEGYVer0 = true; } if (th.dayOfYear < 1 || th.dayOfYear > 366) { this.detectedSEGYVer0 = true; } if (th.hourOfDay < 0 || th.hourOfDay > 24) { this.detectedSEGYVer0 = true; } if (th.minuteOfHour < 0 || th.minuteOfHour > 60) { this.detectedSEGYVer0 = true; } if (th.secondOfMinute < 0 || th.secondOfMinute > 60) { this.detectedSEGYVer0 = true; } if (this.detectedSEGYVer0) { br.BaseStream.Position = positionOfStartOfDataTraces; this.ExtendedTextHeader.RemoveRange(1, ExtendedTextHeader.Count - 1); } else { br.BaseStream.Position = br.BaseStream.Position - 240; // backup last header read } positionOfStartOfDataTraces = br.BaseStream.Position; // record the positionTraceReacorded of the start of the data traces isSEGYFileHeaderAscii = isFileHeaderASCII(); return(true); }