lib/App/SeismicUnixGui/sunix/statsMath/suxcor.pm untested

filter: Statementstmt 0.0% 0 / 124 Branchbran 0.0% 0 / 26 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 22 Podpod 0.0% 0 / 17 totaltotal 0.0% 0 / 189 CC 14 SCAR 16.0
CC
14
Cov
0%
filter
6.0
first
6.0
ftwin
6.0
CRAP 5.0
1 package App::SeismicUnixGui::sunix::statsMath::suxcor;
2  
3 =head1 DOCUMENTATION
4  
5 =head2 SYNOPSIS
6  
7 PERL PROGRAM NAME: SUXCOR - correlation with user-supplied filter
8 AUTHOR: Juan Lorenzo (Perl module only)
9 DATE:
10 DESCRIPTION:
11 Version:
12  
13 =head2 USE
14  
15 =head3 NOTES
16  
17 =head4 Examples
18  
19 =head3 SEISMIC UNIX NOTES
20  
21 SUXCOR - correlation with user-supplied filter
22  
23 suxcor <stdin >stdout filter= [optional parameters]
24  
25 Required parameters: ONE of
26 sufile= file containing SU traces to use as filter
27 filter= user-supplied correlation filter (ascii)
28  
29 Optional parameters:
30 vibroseis=0 =nsout for correlating vibroseis data
31 first=1 supplied trace is default first element of
32 correlation. =0 for it to be second.
33 panel=0 use only the first trace of sufile as filter
34 =1 xcor trace by trace an entire gather
35 ftwin=0 first sample on the first trace of the window
36 (only with panel=1)
37 ltwin=0 first sample on the last trace of the window
38 (only with panel=1)
39 ntwin=nt number of samples in the correlation window
40 (only with panel=1)
41 ntrc=48 number of traces on a gather
42 (only with panel=1)
43  
44 Trace header fields accessed: ns
45 Trace header fields modified: ns
46  
47 Notes: It is quietly assumed that the time sampling interval on the
48 single trace and the output traces is the same as that on the traces
49 in the input file. The sufile may actually have more than one trace,
50 but only the first trace is used when panel=0. When panel=1 the number
51 of traces in the sufile MUST be the same as the number of traces in
52 the input.
53  
54 Examples:
55 suplane | suwind min=12 max=12 >TRACE
56 suxcor<DATA sufile=TRACE |...
57 Here, the su data file, "DATA", is correlated trace by trace with the
58 the single su trace, "TRACE".
59  
60 suxcor<DATA filter=1,2,1 | ...
61 Here, the su data file, "DATA", is correlated trace by trace with the
62 the filter shown.
63  
64 Correlating vibroseis data with a vibroseis sweep:
65 suxcor < data sufile=sweep vibroseis=nsout |...
66  
67 is equivalent to, but more efficient than:
68  
69 suxcor < data sufile=sweep |
70 suwind itmin=nsweep itmax=nsweep+nsout | sushw key=delrt a=0.0 |...
71  
72 sweep=vibroseis sweep in SU format, nsweep=number of samples on
73 the vibroseis sweep, nsout eqis equal to the
74 desired number of samples on output
75  
76 or
77 suxcor < data sufile=sweep |
78 suwind itmin=nsweep itmax=nsweep+nsout | sushw key=delrt a=0.0 |...
79  
80 tsweep=sweep length in seconds, tout=desired output trace length in seconds
81  
82 In the spatially variant case (panel=1), a window with linear slope
83 can be defined:
84 ftwin is the first sample of the first trace in the gather,
85 ltwin is the first sample of the last trace in the gather,
86 ntwin is the lengthe of the window,
87 ntrc is the the number of traces in a gather.
88  
89 If the data consists of a number gathers which need to be
90 correlated with the same number gathers in the sufile, ntrc
91 assures that the correlating window re-starts for each gather.
92  
93 The default window is non-sloping and takes the entire trace
94 into account (ftwin=ltwin=0, ntwin=nt).
95  
96  
97 Credits:
98 CWP: Jack K. Cohen, Michel Dietrich
99 CWP: modified by Ttjan to include cross correlation of panels
100 permitting spatially and temporally varying cross correlation.
101 UTK: modified by Rick Williams for vibroseis correlation option.
102  
103 CAVEATS:
104 In the option, panel=1 the number of traces in the sufile must be
105 the same as the number of traces on the input.
106  
107 Trace header fields accessed: ns
108 Trace header fields modified: ns
109  
110 =head2 CHANGES and their DATES
111  
112 =cut
113  
114 use Moose;
115 our $VERSION = '0.0.1';
116 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
117 use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config';
118  
119 my $get = L_SU_global_constants->new();
120 my $Project = Project_config->new();
121  
122 my $var = $get->var();
123 my $empty_string = $var->{_empty_string};
124  
125 my $suxcor = {
126 _filter => '',
127 _first => '',
128 _ftwin => '',
129 _itmin => '',
130 _ltwin => '',
131 _nsout => '',
132 _ntrc => '',
133 _ntwin => '',
134 _panel => '',
135 _sufile => '',
136 _sweep => '',
137 _tsweep => '',
138 _vibroseis => '',
139 _Step => '',
140 _note => '',
141 };
142  
143 =head2 sub Step
144  
145 collects switches and assembles bash instructions
146 by adding the program name
147 Keeps track of actions for execution in the system
148  
149 =cut
150  
151 sub Step {
152  
153 $suxcor->{_Step} = 'suxcor' . $suxcor->{_Step};
154 return ( $suxcor->{_Step} );
155  
156 }
157  
158 =head2 sub note
159  
160 collects switches and assembles bash instructions
161 by adding the program name
162  
163 =cut
164  
165 sub note {
166  
167 $suxcor->{_note} = 'suxcor' . $suxcor->{_note};
168 return ( $suxcor->{_note} );
169  
170 }
171  
172 =head2 sub clear
173  
174 =cut
175  
176 sub clear {
177  
178 $suxcor->{_filter} = '';
179 $suxcor->{_first} = '';
180 $suxcor->{_ftwin} = '';
181 $suxcor->{_itmin} = '';
182 $suxcor->{_ltwin} = '';
183 $suxcor->{_nsout} = '';
184 $suxcor->{_ntrc} = '';
185 $suxcor->{_ntwin} = '';
186 $suxcor->{_panel} = '';
187 $suxcor->{_sufile} = '';
188 $suxcor->{_sweep} = '';
189 $suxcor->{_tsweep} = '';
190 $suxcor->{_vibroseis} = '';
191 $suxcor->{_Step} = '';
192 $suxcor->{_note} = '';
193 }
194  
195 =head2 sub filter
196  
197 ASCII data filter
198  
199 =cut
200  
201 sub filter {
202  
203 my ( $self, $filter ) = @_;
204 if ( $filter ne $empty_string ) {
205  
206 $suxcor->{_filter} = $filter;
207 $suxcor->{_note} = $suxcor->{_note} . ' filter=' . $suxcor->{_filter};
208 $suxcor->{_Step} = $suxcor->{_Step} . ' filter=' . $suxcor->{_filter};
209  
210 }
211 else {
212 print("suxcor, filter, missing filter,\n");
213 }
214 }
215  
216 =head2 sub first
217  
218 supplied trace is default first element of correlation if 1
219 0 for it to be second
220  
221 =cut
222  
223 sub first {
224  
225 my ( $self, $first ) = @_;
226 if ( $first ne $empty_string ) {
227  
228 $suxcor->{_first} = $first;
229 $suxcor->{_note} = $suxcor->{_note} . ' first=' . $suxcor->{_first};
230 $suxcor->{_Step} = $suxcor->{_Step} . ' first=' . $suxcor->{_first};
231  
232 }
233 else {
234 print("suxcor, first, missing first,\n");
235 }
236 }
237  
238 =head2 sub ftwin
239  
240 first sample on the first trace of the window
241 panel =1
242  
243 =cut
244  
245 sub ftwin {
246  
247 my ( $self, $ftwin ) = @_;
248 if ( $ftwin ne $empty_string ) {
249  
250 $suxcor->{_ftwin} = $ftwin;
251 $suxcor->{_note} = $suxcor->{_note} . ' ftwin=' . $suxcor->{_ftwin};
252 $suxcor->{_Step} = $suxcor->{_Step} . ' ftwin=' . $suxcor->{_ftwin};
253  
254 }
255 else {
256 print("suxcor, ftwin, missing ftwin,\n");
257 }
258 }
259  
260 =head2 sub itmin
261  
262  
263 =cut
264  
265 sub itmin {
266  
267 my ( $self, $itmin ) = @_;
268 if ( $itmin ne $empty_string ) {
269  
270 $suxcor->{_itmin} = $itmin;
271 $suxcor->{_note} = $suxcor->{_note} . ' itmin=' . $suxcor->{_itmin};
272 $suxcor->{_Step} = $suxcor->{_Step} . ' itmin=' . $suxcor->{_itmin};
273  
274 }
275 else {
276 print("suxcor, itmin, missing itmin,\n");
277 }
278 }
279  
280 =head2 sub ltwin
281  
282 first sample on the last trace of the window
283 panel =1
284  
285 =cut
286  
287 sub ltwin {
288  
289 my ( $self, $ltwin ) = @_;
290 if ( $ltwin ne $empty_string ) {
291  
292 $suxcor->{_ltwin} = $ltwin;
293 $suxcor->{_note} = $suxcor->{_note} . ' ltwin=' . $suxcor->{_ltwin};
294 $suxcor->{_Step} = $suxcor->{_Step} . ' ltwin=' . $suxcor->{_ltwin};
295  
296 }
297 else {
298 print("suxcor, ltwin, missing ltwin,\n");
299 }
300 }
301  
302 =head2 sub nsout
303  
304  
305 =cut
306  
307 sub nsout {
308  
309 my ( $self, $nsout ) = @_;
310 if ( $nsout ne $empty_string ) {
311  
312 $suxcor->{_nsout} = $nsout;
313 $suxcor->{_note} = $suxcor->{_note} . ' nsout=' . $suxcor->{_nsout};
314 $suxcor->{_Step} = $suxcor->{_Step} . ' nsout=' . $suxcor->{_nsout};
315  
316 }
317 else {
318 print("suxcor, nsout, missing nsout,\n");
319 }
320 }
321  
322 =head2 sub ntrc
323  
324  
325 =cut
326  
327 sub ntrc {
328  
329 my ( $self, $ntrc ) = @_;
330 if ( $ntrc ne $empty_string ) {
331  
332 $suxcor->{_ntrc} = $ntrc;
333 $suxcor->{_note} = $suxcor->{_note} . ' ntrc=' . $suxcor->{_ntrc};
334 $suxcor->{_Step} = $suxcor->{_Step} . ' ntrc=' . $suxcor->{_ntrc};
335  
336 }
337 else {
338 print("suxcor, ntrc, missing ntrc,\n");
339 }
340 }
341  
342 =head2 sub ntwin
343  
344  
345 =cut
346  
347 sub ntwin {
348  
349 my ( $self, $ntwin ) = @_;
350 if ( $ntwin ne $empty_string ) {
351  
352 $suxcor->{_ntwin} = $ntwin;
353 $suxcor->{_note} = $suxcor->{_note} . ' ntwin=' . $suxcor->{_ntwin};
354 $suxcor->{_Step} = $suxcor->{_Step} . ' ntwin=' . $suxcor->{_ntwin};
355  
356 }
357 else {
358 print("suxcor, ntwin, missing ntwin,\n");
359 }
360 }
361  
362 =head2 sub panel
363  
364 decide whether to use first trace of sufile as filter (=0)
365 or to xcor trace by trace an entire gather
366  
367 =cut
368  
369 sub panel {
370  
371 my ( $self, $panel ) = @_;
372 if ( $panel ne $empty_string ) {
373  
374 $suxcor->{_panel} = $panel;
375 $suxcor->{_note} = $suxcor->{_note} . ' panel=' . $suxcor->{_panel};
376 $suxcor->{_Step} = $suxcor->{_Step} . ' panel=' . $suxcor->{_panel};
377  
378 }
379 else {
380 print("suxcor, panel, missing panel,\n");
381 }
382 }
383  
384 =head2 sub sufile
385  
386 Define the data to be used as the correlation
387 This is the 'filter'
388  
389 =cut
390  
391 sub sufile {
392  
393 my ( $self, $sufile ) = @_;
394 if ( $sufile ne $empty_string ) {
395  
396 use App::SeismicUnixGui::misc::SeismicUnix qw($suffix_su);
397 use File::Basename;
398  
399 my ($DATA_SEISMIC_SU) = $Project->DATA_SEISMIC_SU();
400 my $new_file_name = $sufile;
401  
402 # forcing a suffix 12.8.21
403 $new_file_name = basename($sufile);
404  
405 #print("1. suxcor sufile, new_file_name= $new_file_name\n");
406  
407 $suxcor->{_sufile} = $DATA_SEISMIC_SU . '/' . $new_file_name;
408  
409 $suxcor->{_note} = $suxcor->{_note} . ' sufile=' . $suxcor->{_sufile};
410 $suxcor->{_Step} = $suxcor->{_Step} . ' sufile=' . $suxcor->{_sufile};
411  
412 }
413 else {
414 print("suxcor, sufile, missing sufile,\n");
415 }
416 }
417  
418 =head2 sub sweep
419  
420  
421 =cut
422  
423 sub sweep {
424  
425 my ( $self, $sweep ) = @_;
426 if ( $sweep ne $empty_string ) {
427  
428 $suxcor->{_sweep} = $sweep;
429 $suxcor->{_note} = $suxcor->{_note} . ' sweep=' . $suxcor->{_sweep};
430 $suxcor->{_Step} = $suxcor->{_Step} . ' sweep=' . $suxcor->{_sweep};
431  
432 }
433 else {
434 print("suxcor, sweep, missing sweep,\n");
435 }
436 }
437  
438 =head2 sub tsweep
439  
440  
441 =cut
442  
443 sub tsweep {
444  
445 my ( $self, $tsweep ) = @_;
446 if ( $tsweep ne $empty_string ) {
447  
448 $suxcor->{_tsweep} = $tsweep;
449 $suxcor->{_note} = $suxcor->{_note} . ' tsweep=' . $suxcor->{_tsweep};
450 $suxcor->{_Step} = $suxcor->{_Step} . ' tsweep=' . $suxcor->{_tsweep};
451  
452 }
453 else {
454 print("suxcor, tsweep, missing tsweep,\n");
455 }
456 }
457  
458 =head2 sub vibroseis
459  
460  
461 =cut
462  
463 sub vibroseis {
464  
465 my ( $self, $vibroseis ) = @_;
466 if ( $vibroseis ne $empty_string ) {
467  
468 $suxcor->{_vibroseis} = $vibroseis;
469 $suxcor->{_note} =
470 $suxcor->{_note} . ' vibroseis=' . $suxcor->{_vibroseis};
471 $suxcor->{_Step} =
472 $suxcor->{_Step} . ' vibroseis=' . $suxcor->{_vibroseis};
473  
474 }
475 else {
476 print("suxcor, vibroseis, missing vibroseis,\n");
477 }
478 }
479  
480 =head2 sub get_max_index
481
482 max index = number of input variables -1
483
484 =cut
485  
486 sub get_max_index {
487 my ($self) = @_;
488 my $max_index = 8;
489  
490 return ($max_index);
491 }
492  
493 1;