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

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