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

filter: Statementstmt 0.0% 0 / 153 Branchbran 0.0% 0 / 42 Conditioncond 0.0% 0 / 63 MC/DCmcdc 0.0% 0 / 42 Subroutinesub 0.0% 0 / 25 Podpod 0.0% 0 / 23 totaltotal 0.0% 0 / 348 CC 22 SCAR 18.3
CC
22
Cov
0%
update_num_traces
12.0
update_trace_separation
12.0
deriv
6.0
CRAP 6.3
1 package App::SeismicUnixGui::sunix::statsMath::suinterp;
2  
3 =head1 DOCUMENTATION
4  
5 =head2 SYNOPSIS
6  
7 PERL PROGRAM NAME: SUINTERP - interpolate traces using automatic event picking
8 AUTHOR: Juan Lorenzo (Perl module only)
9 DATE: Dec 10 2013,
10 DESCRIPTION:
11 Version:
12  
13 =head2 USE
14  
15 =head3 NOTES
16  
17 suinterp->su.h();
18 suinterp->segy.h();
19 suinterp->signal.h();
20  
21 =head4 Examples
22  
23 =head3 SEISMIC UNIX NOTES
24  
25 SUINTERP - interpolate traces using automatic event picking
26  
27 suinterp < stdin > stdout
28  
29 ninterp=1 number of traces to output between each pair of input traces
30 nxmax=500 maximum number of input traces
31 freq1=4. starting corner frequency of unaliased range
32 freq2=20. ending corner frequency of unaliased range
33 deriv=0 =1 means take vertical derivative on pick section
34 (useful if interpolating velocities instead of seismic)
35 linear=0 =0 means use 8 point sinc temporal interpolation
36 =1 means use linear temporal interpolation
37 (useful if interpolating velocities instead of seismic)
38 lent=5 number of time samples to smooth for dip estimate
39 lenx=1 number of traces to smooth for dip estimate
40 lagc=400 number of ms agc for dip estimate
41 xopt=0 0 compute spatial derivative via FFT
42 (assumes input traces regularly spaced and relatively
43 noise-free)
44 1 compute spatial derivative via differences
45 (will work on irregulary spaced data)
46 iopt=0 0 = interpolate
47 1 = output low-pass model: useful for QC if interpolator failing
48 2 = output dip picks in units of samples/trace
49  
50 verbose=0 verbose = 1 echoes information
51  
52 tmpdir= if non-empty, use the value as a directory path
53 prefix for storing temporary files; else if the
54 the CWP_TMPDIR environment variable is set use
55 its value for the path; else use tmpfile()
56  
57 Notes:
58 This program outputs 'ninterp' interpolated traces between each pair of
59 input traces. The values for lagc, freq1, and freq2 are only used for
60 event tracking. The output data will be full bandwidth with no agc. The
61 default parameters typically will do a satisfactory job of interpolation
62 for dips up to about 12 ms/trace. Using a larger value for freq2 causes
63 the algorithm to do a better job on the shallow dips, but to fail on the
64 steep dips. Only one dip is assumed at each time sample between each pair
65 of input traces.
66  
67 The key assumption used here is that the low frequency data are unaliased
68 and can be used for event tracking. Those dip picks are used to interpolate
69 the original full-bandwidth data, giving some measure of interpolation
70 at higher frequencies which otherwise would be aliased. Using iopt equal
71 to 1 allows you to visually check whether the low-pass picking model is
72 aliased.
73  
74 Trace headers for interpolated traces are not updated correctly.
75 The output header for an interpolated traces equals that for the preceding
76 trace in the original input data. The original input traces are passed
77 through this module without modification.
78  
79 The place this code is most likely to fail is on the first breaks.
80  
81 Example run: suplane | suinterp | suxwigb &
82  
83  
84  
85 Credit: John Anderson (visiting scholar from Mobil) July 1994
86  
87 Trace header fields accessed: ns, dt
88  
89  
90 =head2 CHANGES and their DATES
91  
92 Version: 0.1
93 Juan Lorenzo 0.2 June 3, 2016 Juan lorenzo
94 Juan Lorenzo 0.3 July 11 2016 start adding
95 remaining options
96  
97 =cut
98  
99 use Moose;
100 our $VERSION = '0.0.1';
101 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
102  
103 my $get = L_SU_global_constants->new();
104  
105 my $var = $get->var();
106 my $empty_string = $var->{_empty_string};
107  
108 my $suinterp = {
109 _ninterp => '',
110 _deriv => '',
111 _freq1 => '',
112 _freq2 => '',
113 _iopt => '',
114 _lagc => '',
115 _lent => '',
116 _lenx => '',
117 _linear => '',
118 _ninterp => '',
119 _nxmax => '',
120 _tmpdir => '',
121 _verbose => '',
122 _xopt => '',
123 _Step => '',
124 _note => '',
125 };
126  
127 =head2 sub Step
128  
129 collects switches and assembles bash instructions
130 by adding the program name
131  
132 =cut
133  
134 sub Step {
135  
136 $suinterp->{_Step} = 'suinterp' . $suinterp->{_Step};
137 return ( $suinterp->{_Step} );
138  
139 }
140  
141 =head2 sub note
142  
143 collects switches and assembles bash instructions
144 by adding the program name
145  
146 =cut
147  
148 sub note {
149  
150 $suinterp->{_note} = 'suinterp' . $suinterp->{_note};
151 return ( $suinterp->{_note} );
152  
153 }
154  
155 =head2 sub clear
156  
157 =cut
158  
159 sub clear {
160  
161 $suinterp->{_deriv} = '';
162 $suinterp->{_freq1} = '';
163 $suinterp->{_freq2} = '';
164 $suinterp->{_iopt} = '';
165 $suinterp->{_lagc} = '';
166 $suinterp->{_lent} = '';
167 $suinterp->{_lenx} = '';
168 $suinterp->{_linear} = '';
169 $suinterp->{_ninterp} = '';
170 $suinterp->{_nxmax} = '';
171 $suinterp->{_tmpdir} = '';
172 $suinterp->{_verbose} = '';
173 $suinterp->{_xopt} = '';
174 $suinterp->{_Step} = '';
175 $suinterp->{_note} = '';
176 }
177  
178 =head2 sub deriv
179  
180  
181 =cut
182  
183 sub deriv {
184  
185 my ( $self, $deriv ) = @_;
186  
187 if ( defined $deriv
188 && $deriv ne $empty_string )
189 {
190  
191 $suinterp->{_deriv} = $deriv;
192 $suinterp->{_note} =
193 $suinterp->{_note} . ' deriv=' . $suinterp->{_deriv};
194 $suinterp->{_Step} =
195 $suinterp->{_Step} . ' deriv=' . $suinterp->{_deriv};
196  
197 }
198 else {
199 print("suinterp, deriv, missing deriv,\n");
200 }
201 }
202  
203 =head2 sub fmax
204  
205 same as freq2
206  
207 =cut
208  
209 sub fmax {
210  
211 my ( $self, $freq2 ) = @_;
212 if ( defined $freq2
213 && $freq2 ne $empty_string )
214 {
215  
216 $suinterp->{_freq2} = $freq2;
217 $suinterp->{_note} =
218 $suinterp->{_note} . ' freq2=' . $suinterp->{_freq2};
219 $suinterp->{_Step} =
220 $suinterp->{_Step} . ' freq2=' . $suinterp->{_freq2};
221  
222 }
223 else {
224 print("suinterp, fmax, missing fmax,\n");
225 }
226 }
227  
228 =head2 sub freq1
229  
230  
231 =cut
232  
233 sub freq1 {
234  
235 my ( $self, $freq1 ) = @_;
236 if ( defined $freq1
237 && $freq1 ne $empty_string )
238 {
239  
240 $suinterp->{_freq1} = $freq1;
241 $suinterp->{_note} =
242 $suinterp->{_note} . ' freq1=' . $suinterp->{_freq1};
243 $suinterp->{_Step} =
244 $suinterp->{_Step} . ' freq1=' . $suinterp->{_freq1};
245  
246 }
247 else {
248 print("suinterp, freq1, missing freq1,\n");
249 }
250 }
251  
252 =head2 sub freq2
253  
254  
255 =cut
256  
257 sub freq2 {
258  
259 my ( $self, $freq2 ) = @_;
260 if ( defined $freq2
261 && $freq2 ne $empty_string )
262 {
263  
264 $suinterp->{_freq2} = $freq2;
265 $suinterp->{_note} =
266 $suinterp->{_note} . ' freq2=' . $suinterp->{_freq2};
267 $suinterp->{_Step} =
268 $suinterp->{_Step} . ' freq2=' . $suinterp->{_freq2};
269  
270 }
271 else {
272 print("suinterp, freq2, missing freq2,\n");
273 }
274 }
275  
276 =head2 sub iopt
277  
278  
279 =cut
280  
281 sub iopt {
282  
283 my ( $self, $iopt ) = @_;
284 if ( defined $iopt
285 && $iopt ne $empty_string )
286 {
287  
288 $suinterp->{_iopt} = $iopt;
289 $suinterp->{_note} =
290 $suinterp->{_note} . ' iopt=' . $suinterp->{_iopt};
291 $suinterp->{_Step} =
292 $suinterp->{_Step} . ' iopt=' . $suinterp->{_iopt};
293  
294 }
295 else {
296 print("suinterp, iopt, missing iopt,\n");
297 }
298 }
299  
300 =head2 sub lagc
301  
302  
303 =cut
304  
305 sub lagc {
306  
307 my ( $self, $lagc ) = @_;
308 if ( defined $lagc
309 && $lagc ne $empty_string )
310 {
311  
312 $suinterp->{_lagc} = $lagc;
313 $suinterp->{_note} =
314 $suinterp->{_note} . ' lagc=' . $suinterp->{_lagc};
315 $suinterp->{_Step} =
316 $suinterp->{_Step} . ' lagc=' . $suinterp->{_lagc};
317  
318 }
319 else {
320 print("suinterp, lagc, missing lagc,\n");
321 }
322 }
323  
324 =head2 sub lent
325  
326  
327 =cut
328  
329 sub lent {
330  
331 my ( $self, $lent ) = @_;
332 if ( defined $lent
333 && $lent ne $empty_string )
334 {
335  
336 $suinterp->{_lent} = $lent;
337 $suinterp->{_note} =
338 $suinterp->{_note} . ' lent=' . $suinterp->{_lent};
339 $suinterp->{_Step} =
340 $suinterp->{_Step} . ' lent=' . $suinterp->{_lent};
341  
342 }
343 else {
344 print("suinterp, lent, missing lent,\n");
345 }
346 }
347  
348 =head2 sub lenx
349  
350 number of traces to smooth
351  
352 =cut
353  
354 sub lenx {
355  
356 my ( $self, $lenx ) = @_;
357 if ( defined $lenx
358 && $lenx ne $empty_string )
359 {
360  
361 $suinterp->{_lenx} = $lenx;
362 $suinterp->{_note} =
363 $suinterp->{_note} . ' lenx=' . $suinterp->{_lenx};
364 $suinterp->{_Step} =
365 $suinterp->{_Step} . ' lenx=' . $suinterp->{_lenx};
366  
367 }
368 else {
369 print("suinterp, lenx, missing lenx,\n");
370 }
371 }
372  
373 =head2 sub linear
374  
375  
376 =cut
377  
378 sub linear {
379  
380 my ( $self, $linear ) = @_;
381 if ( defined $linear
382 && $linear ne $empty_string )
383 {
384  
385 $suinterp->{_linear} = $linear;
386 $suinterp->{_note} =
387 $suinterp->{_note} . ' linear=' . $suinterp->{_linear};
388 $suinterp->{_Step} =
389 $suinterp->{_Step} . ' linear=' . $suinterp->{_linear};
390  
391 }
392 else {
393 print("suinterp, linear, missing linear,\n");
394 }
395 }
396  
397 =head2 sub ninterp
398  
399 How many new traces to create between each
400 existing pair
401  
402 =cut
403  
404 sub ninterp {
405  
406 my ( $self, $ninterp ) = @_;
407 if ( defined $ninterp
408 && $ninterp ne $empty_string )
409 {
410  
411 $suinterp->{_ninterp} = $ninterp;
412 $suinterp->{_note} =
413 $suinterp->{_note} . ' ninterp=' . $suinterp->{_ninterp};
414 $suinterp->{_Step} =
415 $suinterp->{_Step} . ' ninterp=' . $suinterp->{_ninterp};
416  
417 }
418 else {
419 print("suinterp, ninterp, missing ninterp,\n");
420 }
421 }
422  
423 =head2 sub num_new_traces2interp
424  
425 same as ninterp
426 number of new traces
427 to crate between existant pairs
428  
429 =cut
430  
431 sub num_new_traces2interp {
432  
433 my ( $self, $ninterp ) = @_;
434  
435 if ( defined $ninterp
436 && $ninterp ne $empty_string )
437 {
438  
439 $suinterp->{_ninterp} = $ninterp;
440 $suinterp->{_note} =
441 $suinterp->{_note} . ' ninterp=' . $suinterp->{_ninterp};
442 $suinterp->{_Step} =
443 $suinterp->{_Step} . ' ninterp=' . $suinterp->{_ninterp};
444  
445 }
446 else {
447 print("suinterp, ninterp, missing ninterp,\n");
448 }
449 }
450  
451 =head2 sub smooth_ntr
452  
453 same as lenx
454 number of traces to smooth
455  
456 =cut
457  
458 sub smooth_ntr {
459  
460 my ( $self, $lenx ) = @_;
461 if ( defined $lenx
462 && $lenx ne $empty_string )
463 {
464  
465 $suinterp->{_lenx} = $lenx;
466 $suinterp->{_note} =
467 $suinterp->{_note} . ' lenx=' . $suinterp->{_lenx};
468 $suinterp->{_Step} =
469 $suinterp->{_Step} . ' lenx=' . $suinterp->{_lenx};
470  
471 }
472 else {
473 print("suinterp, lenx, missing lenx,\n");
474 }
475 }
476  
477 =head2 sub nxmax
478  
479  
480 =cut
481  
482 sub nxmax {
483  
484 my ( $self, $nxmax ) = @_;
485 if ( defined $nxmax
486 && $nxmax ne $empty_string )
487 {
488  
489 $suinterp->{_nxmax} = $nxmax;
490 $suinterp->{_note} =
491 $suinterp->{_note} . ' nxmax=' . $suinterp->{_nxmax};
492 $suinterp->{_Step} =
493 $suinterp->{_Step} . ' nxmax=' . $suinterp->{_nxmax};
494  
495 }
496 else {
497 print("suinterp, nxmax, missing nxmax,\n");
498 }
499 }
500  
501 =head2 sub smooth_ns_t
502  
503 same as lent
504 number of samples to smooth in time
505  
506 =cut
507  
508 sub smooth_ns_t {
509  
510 my ( $self, $lent ) = @_;
511 if ( defined $lent
512 && $lent ne $empty_string )
513 {
514  
515 $suinterp->{_lent} = $lent;
516 $suinterp->{_note} =
517 $suinterp->{_note} . ' lent=' . $suinterp->{_lent};
518 $suinterp->{_Step} =
519 $suinterp->{_Step} . ' lent=' . $suinterp->{_lent};
520  
521 }
522 else {
523 print("suinterp, smooth_ns_t, missing smooth_ns_t,\n");
524 }
525 }
526  
527 =head2 sub tmpdir
528  
529  
530 =cut
531  
532 sub tmpdir {
533  
534 my ( $self, $tmpdir ) = @_;
535 if ( defined $tmpdir
536 && $tmpdir ne $empty_string )
537 {
538  
539 $suinterp->{_tmpdir} = $tmpdir;
540 $suinterp->{_note} =
541 $suinterp->{_note} . ' tmpdir=' . $suinterp->{_tmpdir};
542 $suinterp->{_Step} =
543 $suinterp->{_Step} . ' tmpdir=' . $suinterp->{_tmpdir};
544  
545 }
546 else {
547 print("suinterp, tmpdir, missing tmpdir,\n");
548 }
549 }
550  
551 =head2 sub update_num_traces
552  
553 calculate if we know the original trace separation
554 .e.g. 2 m or 2 feet
555 input the original trace separation
556 return the update trace separation
557 estimate the new trace separation after interpolation
558 confirm that interpolation parameters exist
559  
560 =cut
561  
562 sub update_num_traces {
563  
564 my ( $variable, $old_num_traces ) = @_;
565  
566 if ( defined $old_num_traces
567 && $old_num_traces ne $empty_string )
568 {
569 $suinterp->{_old_num_traces} = $old_num_traces;
570  
571 if ( defined $suinterp->{_ninterp}
572 && $suinterp->{_ninterp} ne $empty_string )
573 {
574  
575 $suinterp->{_update_num_traces} =
576 ( $suinterp->{_old_num_traces} - 1 ) * $suinterp->{_ninterp} +
577 $suinterp->{_old_num_traces};
578  
579 }
580 else {
581 print("Warning: required number of new interpolated traces\n\n");
582 }
583  
584 $suinterp->{_note} =
585 $suinterp->{_note}
586 . ' updated_num_traces='
587 . $suinterp->{_update_num_traces};
588 print(
589 "updated number of traces is $suinterp->{_update_num_traces}\n\n");
590  
591 return $suinterp->{_update_num_traces};
592 }
593 }
594  
595 =head2 sub update_trace_separation
596  
597 calculate if we know the original trace separation
598 e.g., 2 m or 2 feet
599 input the original trace separation
600 return the update trace separation
601 estimate the new trace separation after interpolation
602 confirm that interpolation parameters exist
603  
604 When ninterp=1
605 and interpolation factor=1
606 print ("interpolated trace separation is $suinterp->{_update_trace_separation}\n\n");
607 print ("interpolation factor is $suinterp->{_interpolation_factor}\n\n");
608  
609 =cut
610  
611 sub update_trace_separation {
612  
613 my ( $variable, $old_trace_separation ) = @_;
614  
615 if ( defined $old_trace_separation
616 && $old_trace_separation ne $empty_string )
617 {
618  
619 $suinterp->{_old_trace_separation} = $old_trace_separation;
620  
621 if ( defined $suinterp->{_ninterp}
622 && $suinterp->{_ninterp} ne $empty_string )
623 {
624  
625 $suinterp->{_interpolation_factor} = $suinterp->{_ninterp} + 1;
626 $suinterp->{_update_trace_separation} =
627 $suinterp->{_old_trace_separation} /
628 $suinterp->{_interpolation_factor};
629 $suinterp->{_note} =
630 $suinterp->{_note}
631 . ' updated_trace_separation='
632 . $suinterp->{_update_trace_separation};
633  
634 return $suinterp->{_update_trace_separation};
635  
636 }
637 else {
638 print("Warning: requires number of new traces to interpolate \n\n");
639 }
640 }
641 }
642  
643 =head2 sub verbose
644  
645  
646 =cut
647  
648 sub verbose {
649  
650 my ( $self, $verbose ) = @_;
651 if ( defined $verbose
652 && $verbose ne $empty_string )
653 {
654  
655 $suinterp->{_verbose} = $verbose;
656 $suinterp->{_note} =
657 $suinterp->{_note} . ' verbose=' . $suinterp->{_verbose};
658 $suinterp->{_Step} =
659 $suinterp->{_Step} . ' verbose=' . $suinterp->{_verbose};
660  
661 }
662 else {
663 print("suinterp, verbose, missing verbose,\n");
664 }
665 }
666  
667 =head2 sub xopt
668  
669  
670 =cut
671  
672 sub xopt {
673  
674 my ( $self, $xopt ) = @_;
675 if ( defined $xopt
676 && $xopt ne $empty_string )
677 {
678  
679 $suinterp->{_xopt} = $xopt;
680 $suinterp->{_note} =
681 $suinterp->{_note} . ' xopt=' . $suinterp->{_xopt};
682 $suinterp->{_Step} =
683 $suinterp->{_Step} . ' xopt=' . $suinterp->{_xopt};
684  
685 }
686 else {
687 print("suinterp, xopt, missing xopt,\n");
688 }
689 }
690  
691 =head2 sub get_max_index
692
693 max index = number of input variables -1
694
695 =cut
696  
697 sub get_max_index {
698 my ($self) = @_;
699 my $max_index = 12;
700  
701 return ($max_index);
702 }
703  
704 1;