UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TraceSet.h
1 /* $Id: TraceSet.h,v 1.7 2003/03/13 17:15:51 vlad Exp $ */
2 
3 #ifndef __TraceSet_h
4 
5 #define __TraceSet_h
6 
7 #include <mix/General.h>
8 #include <ldb/vsp_trace.h>
9 #include <ldb/trset.h>
10 #include <ldb/trselect.h>
11 
12 
13 /* class TraceSet
14  data are followed;
15 
16  methods:
17  == Lifetime
18  int OpenTraceSet (TraceSet* pTrSet,
19  const char* szProject, const char* szNmod);
20  void CloseTraceSet (TraceSet* pTrSet);
21 
22  == Information gaining
23  AValue GetGeneralAttr (TraceSet theTrSet, int gaName);
24  -- returns a general attribute (named gaName) of all data in set;
25  AValue GetTraceAttrDirectly (TraceSet theTrSet, IterType it,
26  unsigned int index, int taName);
27  -- returns a trace attribute (named taName) for the indexed
28  -- trace by iter type order without iter session;
29  unsigned int GetSampleIndex (TraceSet theTrSet, float time);
30  -- get index of sample at the the most closest time;
31  IterType WhatIterNow (TraceSet theTrSet);
32  -- returns type of iterator session;
33 
34  == Iterator session opening functions
35  void ForwardIter (TraceSet theTrSet,
36  unsigned int startIndex, unsigned int trCnt);
37  -- start iteration in direct index order;
38  -- from the lowest point to the highest; (upward)
39  void BackwardIter (TraceSet theTrSet,
40  unsigned int startIndex, unsigned int trCnt);
41  -- start iteration in direct index order;
42  -- from the highest point to the lowest; (downward)
43 
44  == Iterator session functions
45  void IterEnd (TraceSet theTrSet);
46  -- end of iteration;
47  void IterStep (TraceSet theTrSet);
48  -- changes current trace in iterator's order; meaningful from IterStart()
49  -- and until IterEnd();
50  int IterWhile (TraceSet theTrSet);
51  -- returns !0 while iterator exist and iterations are not completed;
52  AValue GetTraceAttr (TraceSet theTrSet, int taName);
53  -- returns trace attribute with name taName; meaningful from IterStart()
54  -- and until IterEnd();
55  float* GetTraceData (TraceSet theTrSet);
56  -- returns pointer on current trace; pointer value is defined
57  -- until IterStep(); meaningful from <way>Iter() and until IterEnd();
58  void ReadTraceDataDirectly (TraceSet theTrSet, IterType it,
59  unsigned int index, float* data)
60  -- read array of samples;
61 
62  == Trace data manipulation
63  float* AllocEmptyTrace (TraceSet theTrSet);
64  -- allocates trace data buffer by means of malloc();
65  float GetAmaxOfTrace (TraceSet theTrSet, float* data);
66  -- finds the greatest amplitude of trace among absolute values;
67  float TraceLevelFloatGapAdjustment(TraceSet theTrSet, float gapWidth,
68  float Aavg, float Amax, float* srcData, float* dstData);
69  -- performs automatic level adjustment for from srcData trace to
70  -- dstData trace by means of float gap with gapWidth {ms};
71 
72  void WriteTraceDataDirectly (TraceSet theTrSet, IterType it,
73  unsigned int index, float* data);
74  -- write trace with index to the cache.
75 */
76 
77 #define GTA_SafeBase 1000
78 
79 #define GABodySize (GTA_SafeBase+0)
80 #define GAEndTime (GTA_SafeBase+1)
81 #define GASamplesCnt (GTA_SafeBase+2)
82 #define GAStartTime (GTA_SafeBase+3)
83 #define GAStepTime (GTA_SafeBase+4)
84 #define GATimeWidth (GTA_SafeBase+5)
85 #define GATraceSize (GTA_SafeBase+6)
86 #define GATracesCnt (GTA_SafeBase+7)
87 #ifndef TAComponent
88 # define TAComponent (GTA_SafeBase+8)
89 #endif
90 #define TA_Component TAComponent
91 #ifndef TAProbeDepth
92 # define TAProbeDepth (GTA_SafeBase+9)
93 #endif
94 #define TADeviceDepth TAProbeDepth
95 #define TA_ProbeDepth TAProbeDepth
96 #define TAIndex (GTA_SafeBase+10)
97 #define TAShotId (GTA_SafeBase+11)
98 #define TA_Actuality (GTA_SafeBase+12)
99 #define TA_Channel (GTA_SafeBase+13)
100 #define TA_Control (GTA_SafeBase+14) /* 1-control, 0-downhole */
101 #define TA_FNumber TAShotId
102 #define TA_Number (GTA_SafeBase+15)
103 #define TA_Xopv (GTA_SafeBase+16)
104 #define TA_Xspv (GTA_SafeBase+17)
105 #define TA_Yopv (GTA_SafeBase+18)
106 #define TA_Yspv (GTA_SafeBase+19)
107 #define TA_Zopv (GTA_SafeBase+20)
108 #define TA_Zspv (GTA_SafeBase+21)
109 #define TAFileIndex (GTA_SafeBase+22)
110 #define TA_Type (GTA_SafeBase+23) /* 'D', 'C', 'S', 'A' */
111 
112 #define itNone 0
113 #define itForward 1
114 #define itBackward (-1)
115 #define itForwardIter itForward
116 #define itBackwardIter itBackward
117 
118 typedef int IterType;
119 typedef float AValue;
120 typedef TrSet* TraceSet;
121 
122 #ifdef __cplusplus
123 extern "C"
124 {
125 #endif
126 
127 /*
128  Constructor of a TraceSet object.
129  Returns:
130  0 - OK, read-only mode;
131  -1 - bad parameters;
132  -2 - memory allocation error;
133  -3 - a file is not found;
134  -4 - reading file error;
135  -5 - not a seismic trace file;
136  -6 - sharing violation;
137 */
138 int OpenTraceSet (TraceSet* pTrSet,
139  const char* szProject, const char* szNmod);
140 
141 /* Destructor of a TrSet object. */
142 void CloseTraceSet (TraceSet* theTrSet);
143 
144 /*
145  Reopen trace set in read-write mode
146 */
147 int ReopenToEdit (TraceSet theTrSet);
148 
149 /*
150  Reopen trace set in read-only mode
151 */
152 int ReopenToRead (TraceSet theTrSet);
153 
154 /*
155  Get values from modification table. If gaName is not defined or
156  theTrSet has bad value the function returns (int)0. Usually
157  a programmer must cast type of returned value to needed one.
158 */
159 AValue GetGeneralAttr (TraceSet theTrSet, int gaName);
160 
161 /*
162  Returns a trace attribute (named taName) for the indexed
163  trace by iter type order without iter session now.
164 */
165 AValue GetTraceAttrDirectly (TraceSet theTrSet, IterType it,
166  unsigned int index, int taName);
167 
168 /* Returns pointer on well name */
169 const char* GetWellName (TraceSet theTrSet);
170 
171 /* Returns shot point number */
172 int GetShotPoint (TraceSet theTrSet);
173 
174 /*
175  Returns current iterator session type or itNoIter
176 */
177 IterType WhatIterNow (TraceSet theTrSet);
178 
179 /*
180  Creates iterator session with natural file order trace access.
181  -> startIndex defines trace index of the first accessable trace.
182  If the trace of this number is not exist due to size of file,
183  effect will be as well as startIndex == 0.
184  -> trCnt defines count of iterations. trCnt == 0 defines iterator
185  for all traces from startIndex to end of file.
186 
187  Returns:
188  0 - OK;
189  -1 - bad parameters;
190  -2 - trace set already has unclosed iterator session;
191  -3 - startIndex or startIndex+trCnt is greater then count of traces in file;
192 */
193 #define UNTIL_END 0
194 int ForwardIter (TraceSet theTrSet,
195  unsigned int startIndex, unsigned int trCnt);
196 
197 int BackwardIter (TraceSet theTrSet,
198  unsigned int startIndex, unsigned int trCnt);
199 
200 /* Closes current iterator session if it exist. */
201 void IterEnd (TraceSet theTrSet);
202 
203 /* Makes iteration step */
204 void IterStep (TraceSet theTrSet);
205 
206 /* Returns hint of iteration end */
207 int IterWhile (TraceSet theTrSet);
208 
209 /*
210  Get value from current trace header. If taName is not defined or
211  theTrSet has bad value or TrSet has not iterator session
212  the function returns (int)0. Usually a programmer must cast type
213  of returned value to needed one.
214 */
215 AValue GetTraceAttr (TraceSet theTrSet, int taName);
216 
217 /* Get array of samples */
218 float* GetTraceData (TraceSet theTrSet);
219 
220 /* Read array of samples */
221 void ReadTraceDataDirectly (TraceSet theTrSet, IterType it,
222  unsigned int index, float* data);
223 
224 /* Allocate array of samples */
225 float* AllocTraceDataDirectly (TraceSet theTrSet, IterType it,
226  unsigned int index);
227 
228 /* Write trace data directly; re-open nmod in read-write mode.
229  Returns:
230  0 - OK, done;
231  -1 - internal error;
232  -2 - common write error (see TrStatus);
233  -3 - can't reopen in read-write mode (see TrStatus);
234  */
235 int WriteTraceDataDirectly (TraceSet theTrSet, IterType it,
236  unsigned int index, float* data);
237 
238 /* Write actuality flag directly; re-open nmod in read-write mode.
239  Returns:
240  0 - OK, done;
241  -1 - internal error;
242  -2 - common write error (see TrStatus);
243  -3 - can't reopen in read-write mode (see TrStatus);
244  */
245 int WriteTraceActualityDirectly (TraceSet theTrSet, IterType it,
246  unsigned int index, Logic act);
247 
248 /* Get index of sample at the the most closest time */
249 unsigned int GetSampleIndex (TraceSet theTrSet, float time);
250 
251 /* Finds the greatest amplitude of trace among absolute values */
252 float GetAmaxOfTrace (TraceSet theTrSet, float* data);
253 
254 /* Apply zero threshold to the trace body */
255 void ApplyZeroThreshold (TraceSet theTrSet, float* data,
256  float zeroAmplLevel, float Amax);
257 
258 /* Allocates trace data buffer by means of malloc() */
259 float* AllocEmptyTrace (TraceSet theTrSet);
260 
261 /* Automatic Gain Control normalization procedure:
262  INPUT:
263  theTrSet - trace set container
264  gapWidth - gain gap width, ms
265  fAGCDynAmplify - AGC amplitude value coefficient (0..1)
266  Amax - source trace |A|max
267  srcData - source trace body
268  OUTPUT:
269  dstData - destination trace body
270  dAmax - |A|max in destination trace body
271 */
272 void AGCnormProc (TraceSet theTrSet, float gapWidth, float fAGCDynAmplify, float Amax,
273  float* srcData, float* dstData, float* dAmax);
274 
275 #ifdef __cplusplus
276 };
277 #endif /* __cplusplus */
278 
279 #endif /* TraceSet.h */
Definition: trset.h:96