lib/App/SeismicUnixGui/sunix/NMO_Vel_Stk/sustack.pm untested

filter: Statementstmt 0.0% 0 / 67 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 11 totaltotal 0.0% 0 / 105 CC 8 SCAR 15.7
CC
8
Cov
0%
headerword
6.0
header_word
6.0
key
6.0
CRAP 4.8
1 package App::SeismicUnixGui::sunix::NMO_Vel_Stk::sustack;
2  
3 =head1 DOCUMENTATION
4  
5 =head2 SYNOPSIS
6  
7 PROGRAM NAME: sustack
8 AUTHOR: Juan Lorenzo (Perl module only)
9 DATE: July 31, 2013
10 DESCRIPTION horizontal summation across
11 a file based on a header word
12 Version 0.0.1
13  
14 =head2 USE
15  
16 =head3 SUNIX NOTES
17  
18 SUSTACK - stack adjacent traces having the same key header word
19  
20 sustack <stdin >stdout [Optional parameters]
21  
22 Required parameters:
23 none
24  
25 Optional parameters:
26 key=cdp header key word to stack on
27 normpow=1.0 each sample is divided by the
28 normpow'th number of non-zero values
29 stacked (normpow=0 selects no division)
30 repeat=0 =1 repeats the stack trace nrepeat times
31 nrepeat=10 repeats stack trace nrepeat times in
32 output file
33 verbose=0 verbose = 1 echos information
34  
35 Notes:
36 ------
37 The offset field is set to zero on the output traces, unless
38 the user is stacking with key=offset. In that case, the value
39 of the offset field is left unchanged.
40  
41 Sushw can be used afterwards if this is not acceptable.
42  
43 For VSP users:
44 The stack trace appears ten times in the output file when
45 setting repeat=1 and nrepeat=10. Corridor stacking can be
46 achieved by properly muting the upgoing data with SUMUTE
47 before stacking.
48  
49  
50 Credits:
51 SEP: Einar Kjartansson
52 CWP: Jack K. Cohen, Dave Hale
53 CENPET: Werner M. Heigl - added repeat trace functionality
54  
55 Note:
56 The "valxxx" subroutines are in su/lib/valpkge.c. In particular,
57 "valcmp" shares the annoying attribute of "strcmp" that
58 if (valcmp(type, val, valnew) {
59 ...
60 }
61 will be performed when val and valnew are different.
62  
63 Trace header fields accessed: ns
64 Trace header fields modified: nhs, tracl, offset
65  
66  
67  
68 =head4 Examples
69  
70 Usage 1:
71 To stack an array of trace
72  
73 Example:
74 $sustack ->clear();
75 $sustack->headerword('cdp');
76 $sustack[1] = $sustack->Step();
77  
78 =head3 SEISMIC UNIX NOTES
79  
80 SUSTACK - stack adjacent traces having the same key header word
81  
82 sustack <stdin >stdout [Optional parameters]
83  
84 Required parameters:
85 none
86  
87 Optional parameters:
88 key=cdp header key word to stack on
89 normpow=1.0 each sample is divided by the
90 normpow'th number of non-zero values
91 stacked (normpow=0 selects no division)
92 repeat=0 =1 repeats the stack trace nrepeat times
93 nrepeat=10 repeats stack trace nrepeat times in
94 output file
95 verbose=0 verbose = 1 echos information
96  
97 Notes:
98 ------
99 The offset field is set to zero on the output traces, unless
100 the user is stacking with key=offset. In that case, the value
101 of the offset field is left unchanged.
102  
103 Sushw can be used afterwards if this is not acceptable.
104  
105 For VSP users:
106 The stack trace appears ten times in the output file when
107 setting repeat=1 and nrepeat=10. Corridor stacking can be
108 achieved by properly muting the upgoing data with SUMUTE
109 before stacking.
110  
111  
112 Credits:
113 SEP: Einar Kjartansson
114 CWP: Jack K. Cohen, Dave Hale
115 CENPET: Werner M. Heigl - added repeat trace functionality
116  
117 Note:
118 The "valxxx" subroutines are in su/lib/valpkge.c. In particular,
119 "valcmp" shares the annoying attribute of "strcmp" that
120 if (valcmp(type, val, valnew) {
121 ...
122 }
123 will be performed when val and valnew are different.
124  
125 Trace header fields accessed: ns
126 Trace header fields modified: nhs, tracl, offset
127  
128 =head2 CHANGES and their DATES
129  
130 =cut
131  
132 use Moose;
133 our $VERSION = '0.0.1';
134 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
135  
136 my $get = L_SU_global_constants->new();
137  
138 my $var = $get->var();
139 my $empty_string = $var->{_empty_string};
140  
141 my $sustack = {
142 _key => '',
143 _normpow => '',
144 _nrepeat => '',
145 _repeat => '',
146 _verbose => '',
147 _Step => '',
148 _note => '',
149 };
150  
151 =head2 sub Step
152  
153 collects switches and assembles bash instructions
154 by adding the program name
155  
156 =cut
157  
158 sub Step {
159  
160 $sustack->{_Step} = 'sustack' . $sustack->{_Step};
161 return ( $sustack->{_Step} );
162  
163 }
164  
165 =head2 sub note
166  
167 collects switches and assembles bash instructions
168 by adding the program name
169  
170 =cut
171  
172 sub note {
173  
174 $sustack->{_note} = 'sustack' . $sustack->{_note};
175 return ( $sustack->{_note} );
176  
177 }
178  
179 =head2 sub clear
180  
181 =cut
182  
183 sub clear {
184  
185 $sustack->{_key} = '';
186 $sustack->{_normpow} = '';
187 $sustack->{_nrepeat} = '';
188 $sustack->{_repeat} = '';
189 $sustack->{_verbose} = '';
190 $sustack->{_Step} = '';
191 $sustack->{_note} = '';
192 }
193  
194 =head2 sub headerword
195  
196 key or headerword (legacy)
197
198 =cut
199  
200 sub headerword {
201  
202 my ( $self, $key ) = @_;
203 if ($key) {
204  
205 $sustack->{_key} = $key;
206 $sustack->{_note} = $sustack->{_note} . ' key=' . $sustack->{_key};
207 $sustack->{_Step} = $sustack->{_Step} . ' key=' . $sustack->{_key};
208  
209 }
210 else {
211 print("sustack, headerword, missing headerword,\n");
212 }
213 }
214  
215 =head2 sub header_word
216  
217 key or header_word
218
219 =cut
220  
221 sub header_word {
222  
223 my ( $self, $key ) = @_;
224 if ($key) {
225  
226 $sustack->{_key} = $key;
227 $sustack->{_note} = $sustack->{_note} . ' key=' . $sustack->{_key};
228 $sustack->{_Step} = $sustack->{_Step} . ' key=' . $sustack->{_key};
229  
230 }
231 else {
232 print("sustack, header_word, missing header_word,\n");
233 }
234 }
235  
236 =head2 sub key
237  
238 key or header_word
239  
240 =cut
241  
242 sub key {
243  
244 my ( $self, $key ) = @_;
245 if ($key) {
246  
247 $sustack->{_key} = $key;
248 $sustack->{_note} = $sustack->{_note} . ' key=' . $sustack->{_key};
249 $sustack->{_Step} = $sustack->{_Step} . ' key=' . $sustack->{_key};
250  
251 }
252 else {
253 print("sustack, key, missing key,\n");
254 }
255 }
256  
257 =head2 sub normpow
258  
259  
260 =cut
261  
262 sub normpow {
263  
264 my ( $self, $normpow ) = @_;
265 if ( $normpow ne $empty_string ) {
266  
267 $sustack->{_normpow} = $normpow;
268 $sustack->{_note} =
269 $sustack->{_note} . ' normpow=' . $sustack->{_normpow};
270 $sustack->{_Step} =
271 $sustack->{_Step} . ' normpow=' . $sustack->{_normpow};
272  
273 }
274 else {
275 print("sustack, normpow, missing normpow,\n");
276 }
277 }
278  
279 =head2 sub nrepeat
280  
281  
282 =cut
283  
284 sub nrepeat {
285  
286 my ( $self, $nrepeat ) = @_;
287 if ( $nrepeat ne $empty_string ) {
288  
289 $sustack->{_nrepeat} = $nrepeat;
290 $sustack->{_note} =
291 $sustack->{_note} . ' nrepeat=' . $sustack->{_nrepeat};
292 $sustack->{_Step} =
293 $sustack->{_Step} . ' nrepeat=' . $sustack->{_nrepeat};
294  
295 }
296 else {
297 print("sustack, nrepeat, missing nrepeat,\n");
298 }
299 }
300  
301 =head2 sub repeat
302  
303  
304 =cut
305  
306 sub repeat {
307  
308 my ( $self, $repeat ) = @_;
309 if ( $repeat ne $empty_string ) {
310  
311 $sustack->{_repeat} = $repeat;
312 $sustack->{_note} =
313 $sustack->{_note} . ' repeat=' . $sustack->{_repeat};
314 $sustack->{_Step} =
315 $sustack->{_Step} . ' repeat=' . $sustack->{_repeat};
316  
317 }
318 else {
319 print("sustack, repeat, missing repeat,\n");
320 }
321 }
322  
323 =head2 sub verbose
324  
325  
326 =cut
327  
328 sub verbose {
329  
330 my ( $self, $verbose ) = @_;
331 if ( $verbose ne $empty_string ) {
332  
333 $sustack->{_verbose} = $verbose;
334 $sustack->{_note} =
335 $sustack->{_note} . ' verbose=' . $sustack->{_verbose};
336 $sustack->{_Step} =
337 $sustack->{_Step} . ' verbose=' . $sustack->{_verbose};
338  
339 }
340 else {
341 print("sustack, verbose, missing verbose,\n");
342 }
343 }
344  
345 =head2 sub get_max_index
346
347 max index = number of input variables -1
348
349 =cut
350  
351 sub get_max_index {
352 my ($self) = @_;
353 my $max_index = 4;
354  
355 return ($max_index);
356 }
357  
358 1;