OpendTect  6.3
segyhdr.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*+
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: A.H. Bril
8  Date: 10-5-1995
9 ________________________________________________________________________
10 
11 -*/
12 
13 #include "segythdef.h"
14 #include "coord.h"
15 #include "samplingdata.h"
16 #include "datachar.h"
17 class SeisTrcInfo;
18 class od_ostream;
19 
20 
21 namespace SEGY
22 {
23 class Hdrdef;
24 
25 #define SegyTxtHeaderLength 3200
26 #define SegyBinHeaderLength 400
27 #define SegyTrcHeaderLength 240
28 
37 {
38 public:
39 
40  TxtHeader() : revision_(1) { clearText(); }
41  TxtHeader(int rev);
42  void clear() { clearText(); setLineStarts(); }
43 
44  void setUserInfo(const char*);
45  void setPosInfo(const TrcHeaderDef&);
46  void setStartPos(float);
47 
48  void getText(BufferString&) const;
49  void setText(const char*);
50 
51  bool isAscii() const;
52  void setAscii();
53  void setEbcdic();
54 
55  unsigned char txt_[SegyTxtHeaderLength];
56 
57  static bool& info2D();
58 
59  void setLineStarts();
60  void dump(od_ostream&) const;
61 
62 protected:
63 
64  int revision_;
65 
66  void putAt(int,int,int,const char*);
67  void getFrom(int,int,int,char*) const;
68 
69  void clearText();
70 };
71 
72 
76 {
77 public:
78 
79  BinHeader();
80  void setInput(const void*,bool needswap=false);
81  void setForWrite();
82 
83  int bytesPerSample() const
84  { return formatBytes( format() ); }
85  static int formatBytes( int frmt )
86  { return frmt == 3 ? 2 : (frmt == 8 ? 1 : 4); }
87  static bool isValidFormat( int f )
88  { return f==1 || f==2 || f==3 || f==5 || f==8; }
89  static DataCharacteristics getDataChar(int frmt,bool dataswapped);
90 
91  int valueAt(int bytenr);
92  void setValueAt(int bytenr,int);
93  inline int entryVal( int idx ) const
94  { return hdrDef()[idx]->getValue(buf_,needswap_); }
95  inline void setEntryVal( int idx, int val )
96  { return hdrDef()[idx]->putValue(buf_,val); }
97 
98  short format() const { return (short) entryVal(EntryFmt()); }
99  int nrSamples() const { return entryVal(EntryNs()); }
100  float sampleRate(bool isdpth) const;
101  bool isInFeet() const { return entryVal(EntryMFeet()) == 2; }
102  int revision() const;
103  bool isRev0() const { return revision() < 1; }
104  int skipRev1Stanzas(od_istream&);
105 
106  void setIsSwapped( bool yn ) { needswap_ = yn; }
107  bool isSwapped() const { return needswap_; }
108  void guessIsSwapped();
109  void unSwap();
110 
111  void setFormat( short i ) { setEntryVal(EntryFmt(),i); }
112  void setNrSamples( int i ) { setEntryVal(EntryNs(),i); }
113  void setSampleRate(float,bool isdpth);
114  void setInFeet( bool yn ) { setEntryVal(EntryMFeet(),yn?2:1); }
115 
116  void dump(od_ostream&) const;
117 
118  static const HdrDef& hdrDef();
119  unsigned char* buf() { return buf_; }
120  const unsigned char* buf() const { return buf_; }
121 
122 protected:
123 
124  unsigned char buf_[SegyBinHeaderLength];
125  bool forwrite_;
126  bool needswap_;
127 
128 public:
129 
130  // 'well-known' headers, not often abused
131  static int EntryJobID() { return 0; }
132  static int EntryLino() { return 1; }
133  static int EntryDt() { return 5; }
134  static int EntryNs() { return 7; }
135  static int EntryFmt() { return 9; }
136  static int EntryTsort() { return 11; }
137  static int EntryMFeet() { return 24; }
138  static int EntryRevCode() { return 147; }
139 
140 };
141 
142 
144 {
145 public:
146 
147  TrcHeader(unsigned char*,const TrcHeaderDef&,bool rev0,
148  bool manbuf=false);
149  TrcHeader( const TrcHeader& oth )
150  : buf_(0), mybuf_(false), hdef_(oth.hdef_)
151  { *this = oth; }
152  void initRead();
153  ~TrcHeader();
154  TrcHeader& operator =(const TrcHeader&);
155 
156  static const HdrDef& hdrDef();
157 
158  unsigned short nrSamples() const;
159  void putSampling(SamplingData<float>,unsigned short);
160 
161  void use(const SeisTrcInfo&);
162  void fill(SeisTrcInfo&,bool is2d,float) const;
163  void setNeedSwap( bool yn=true ) { needswap_ = yn; }
164 
165  float postScale(int numbfmt) const;
166  Coord getCoord(bool rcv,float extcoordsc) const;
167 
168  unsigned char* buf_;
170  bool isrev0_;
171 
172  bool isusable; // trid < 2 ; mostly ignored but not always
173  bool nonrectcoords; // counit == 1, 2 or 3
174 
175  void dump(od_ostream&) const;
176 
177 protected:
178 
179  bool mybuf_;
180  bool needswap_;
181  int previnl_;
182  int seqnr_;
184 
185  double getCoordScale(float extcoordsc) const;
186 
187  void putRev1Flds(const SeisTrcInfo&) const;
188  void getRev1Flds(SeisTrcInfo&,bool is2d) const;
189 
190 public:
191 
192  // 'well-known' headers
193  static int EntryTracl() { return 0; }
194  static int EntryTracr() { return 1; }
195  static int EntryFldr() { return 2; }
196  static int EntryCdp() { return 5; }
197  static int EntryTrid() { return 7; }
198  static int EntryDUse() { return 10; }
199  static int EntryOffset() { return 11; }
200  static int EntryScalel() { return 19; }
201  static int EntryScalco() { return 20; }
202  static int EntrySx() { return 21; }
203  static int EntrySy() { return 22; }
204  static int EntryGx() { return 23; }
205  static int EntryGy() { return 24; }
206  static int EntryCoUnit() { return 25; }
207  static int EntryLagA() { return 33; }
208  static int EntryLagB() { return 34; }
209  static int EntryDelRt() { return 35; }
210  static int EntryNs() { return 38; }
211  static int EntryDt() { return 39; }
212  static int EntryTrwf() { return 65; }
213  static int EntryXcdp() { return 71; }
214  static int EntryYcdp() { return 72; }
215  static int EntryInline() { return 73; }
216  static int EntryCrossline() { return 74; }
217  static int EntrySP() { return 75; }
218  static int EntrySPscale() { return 76; }
219 
220  inline int entryVal( int idx ) const
221  { return hdrDef()[idx]->getValue(buf_,needswap_); }
222  inline void setEntryVal( int idx, int val ) const
223  { return hdrDef()[idx]->putValue(buf_,val); }
224 
225 };
226 
227 } // namespace
stores HdrEntry info of the needed fields from the trace header.
Definition: segythdef.h:27
#define mExpClass(module)
Definition: commondefs.h:157
Definition: segyhdr.h:143
static int EntryTsort()
Definition: segyhdr.h:136
Seismics.
Definition: segydirectdef.h:20
static int EntryJobID()
Definition: segyhdr.h:131
void setEntryVal(int idx, int val)
Definition: segyhdr.h:95
OD class for stream write common access to the user log file, or std::cout in batch progs...
Definition: od_ostream.h:25
static int EntryTrid()
Definition: segyhdr.h:197
static int EntryYcdp()
Definition: segyhdr.h:214
static int EntryFmt()
Definition: segyhdr.h:135
static int EntryNs()
Definition: segyhdr.h:134
400 byte SEG-Y binary header
Definition: segyhdr.h:75
static int EntrySPscale()
Definition: segyhdr.h:218
int entryVal(int idx) const
Definition: segyhdr.h:93
void clear()
Definition: segyhdr.h:42
int bytesPerSample() const
Definition: segyhdr.h:83
void setFormat(short i)
Definition: segyhdr.h:111
const TrcHeaderDef & hdef_
Definition: segyhdr.h:169
unsigned char * buf_
Definition: segyhdr.h:168
static int EntryFldr()
Definition: segyhdr.h:195
int revision_
Definition: segyhdr.h:64
static int EntryDelRt()
Definition: segyhdr.h:209
bool isInFeet() const
Definition: segyhdr.h:101
static int formatBytes(int frmt)
Definition: segyhdr.h:85
static int EntryTracl()
Definition: segyhdr.h:193
static int EntryDUse()
Definition: segyhdr.h:198
static int EntryXcdp()
Definition: segyhdr.h:213
static int EntryDt()
Definition: segyhdr.h:133
static int EntryRevCode()
Definition: segyhdr.h:138
OD class for stream read.
Definition: od_istream.h:23
static bool isValidFormat(int f)
Definition: segyhdr.h:87
static int EntrySx()
Definition: segyhdr.h:202
const unsigned char * buf() const
Definition: segyhdr.h:120
short format() const
Definition: segyhdr.h:98
TrcHeader(const TrcHeader &oth)
Definition: segyhdr.h:149
void setNrSamples(int i)
Definition: segyhdr.h:112
static int EntrySP()
Definition: segyhdr.h:217
static int EntryTrwf()
Definition: segyhdr.h:212
byte-level data characteristics of stored data.
Definition: datachar.h:35
static int EntryLagA()
Definition: segyhdr.h:207
Definition: segyhdrdef.h:82
bool mybuf_
Definition: segyhdr.h:179
void setNeedSwap(bool yn=true)
Definition: segyhdr.h:163
bool isrev0_
Definition: segyhdr.h:170
bool needswap_
Definition: segyhdr.h:126
bool isusable
Definition: segyhdr.h:172
bool nonrectcoords
Definition: segyhdr.h:173
static int EntryGy()
Definition: segyhdr.h:205
Information for a seismic trace, AKA trace header info.
Definition: seisinfo.h:24
void setIsSwapped(bool yn)
Definition: segyhdr.h:106
int seqnr_
Definition: segyhdr.h:182
bool isSwapped() const
Definition: segyhdr.h:107
static int EntryCdp()
Definition: segyhdr.h:196
unsigned char * buf()
Definition: segyhdr.h:119
static int EntryLagB()
Definition: segyhdr.h:208
#define SegyBinHeaderLength
Definition: segyhdr.h:26
int entryVal(int idx) const
Definition: segyhdr.h:220
static int EntryMFeet()
Definition: segyhdr.h:137
static int EntryNs()
Definition: segyhdr.h:210
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:38
TxtHeader()
Definition: segyhdr.h:40
#define SegyTxtHeaderLength
Definition: segyhdr.h:25
static int EntryOffset()
Definition: segyhdr.h:199
bool forwrite_
Definition: segyhdr.h:125
void setInFeet(bool yn)
Definition: segyhdr.h:114
static int EntryCoUnit()
Definition: segyhdr.h:206
3200 byte SEG-Y text header.
Definition: segyhdr.h:36
static int EntryGx()
Definition: segyhdr.h:204
static int EntryLino()
Definition: segyhdr.h:132
int nrSamples() const
Definition: segyhdr.h:99
Keys that should be used with od_process_segyio.cc.
Definition: segybatchio.h:18
static int EntryScalco()
Definition: segyhdr.h:201
static int EntryCrossline()
Definition: segyhdr.h:216
bool isRev0() const
Definition: segyhdr.h:103
int lineseqnr_
Definition: segyhdr.h:183
2D point or vector class.
Definition: commontypes.h:58
int previnl_
Definition: segyhdr.h:181
void setEntryVal(int idx, int val) const
Definition: segyhdr.h:222
static int EntryScalel()
Definition: segyhdr.h:200
static int EntryTracr()
Definition: segyhdr.h:194
static int EntryDt()
Definition: segyhdr.h:211
static int EntrySy()
Definition: segyhdr.h:203
bool needswap_
Definition: segyhdr.h:180
static int EntryInline()
Definition: segyhdr.h:215

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2017