lib/App/SeismicUnixGui/sunix/shapeNcut/sumute.pm untested

filter: Statementstmt 0.0% 0 / 420 Branchbran 0.0% 0 / 70 Conditioncond 0.0% 0 / 21 MC/DCmcdc 0.0% 0 / 12 Subroutinesub 0.0% 0 / 39 Podpod 0.0% 0 / 27 totaltotal 0.0% 0 / 589 CC 36 SCAR 30.2
CC
36
Cov
0%
Step
110.0
type
20.0
_get_par_sets
12.0
CRAP 20.4
1 package App::SeismicUnixGui::sunix::shapeNcut::sumute;
2  
3 =head2 SYNOPSIS
4  
5 PERL PROGRAM NAME:
6  
7 AUTHOR: Juan Lorenzo (Perl module only)
8  
9 DATE:
10  
11 DESCRIPTION:
12  
13 Version:
14  
15 =head2 USE
16  
17 =head3 NOTES
18  
19 =head4 Examples
20  
21 =head2 SYNOPSIS
22  
23 =head3 SEISMIC UNIX NOTES
24 SUMUTE - MUTE above (or below) a user-defined polygonal curve with ",
25  
26 the distance along the curve specified by key header word
27  
28  
29  
30 sumute <stdin >stdout xmute= tmute= [optional parameters]
31  
32  
33  
34 Required parameters:
35  
36 xmute= array of position values as specified by
37  
38 the `key' parameter
39  
40 tmute= array of corresponding time values (sec)
41  
42 in case of air wave muting, correspond to
43  
44 air blast duration
45  
46 ... or input via files:
47  
48 nmute= number of x,t values defining mute
49  
50 xfile= file containing position values as specified by
51  
52 the `key' parameter
53  
54 tfile= file containing corresponding time values (sec)
55  
56 ... or via header:
57  
58 hmute= key header word specifying mute time
59  
60  
61  
62 Optional parameters:
63  
64 key=offset Key header word specifying trace offset
65  
66 =tracl use trace number instead
67  
68 ntaper=0 number of points to taper before hard
69  
70 mute (sine squared taper)
71  
72 mode=0 mute ABOVE the polygonal curve
73  
74 =1 to zero BELOW the polygonal curve
75  
76 =2 to mute below AND above a straight line. In this case
77  
78 xmute,tmute describe the total time length of
79  
80 the muted zone as a function of xmute the slope
81  
82 of the line is given by the velocity linvel=
83  
84 =3 to mute below AND above a constant velocity hyperbola
85  
86 as in mode=2 xmute,tmute describe the total time
87  
88 length of the mute zone as a function of xmute,
89  
90 the velocity is given by the value of linvel=
91  
92 =4 to mute below AND above a user defined polygonal line
93  
94 given by xmute, tmute pairs. The widths in time ",
95  
96 of the muted zone are given by the twindow vector
97  
98 linvel=330 constant velocity for linear or hyperbolic mute
99  
100 tm0=0 time shift of linear or hyperbolic mute at
101  
102 \'key\'=0
103  
104 twindow= vector of mute zone widths in time, operative only in mode=4
105  
106 ... or input via file:
107  
108 twfile=
109  
110  
111  
112 Notes:
113  
114 The tmute interpolant is extrapolated to the left by the smallest time
115  
116 sample on the trace and to the right by the last value given in the
117  
118 tmute array.
119  
120  
121  
122 The files tfile and xfile are files of binary (C-style) floats.
123  
124  
125  
126 In the context of this program "above" means earlier time and
127  
128 "below" means later time (above and below as seen on a seismic section.
129  
130  
131  
132 The mode=2 option is intended for removing air waves. The mute is
133  
134 is over a narrow window above and below the line specified by the
135  
136 the line specified by the velocity "linvel". Here the values of
137  
138 tmute, xmute or tfile and xfile define the total time width of the mute.
139  
140  
141  
142 If data are spatial, such as the (z-x) output of a migration, then
143  
144 depth values are used in place of times in tmute and tfile. The value
145  
146 of the depth sampling interval is given by the d1 header field
147  
148 You must use the option key=tracl in sumute in this case.
149  
150  
151  
152 Caveat: if data are seismic time sections, then tr.dt must be set. If
153  
154 data are seismic depth sections, then tr.trid must be set to the value
155  
156 of TRID_DEPTH and the tr.d1 header field must be set.
157  
158 To find the value of TRID_DEPTH:
159  
160 type:
161  
162 sukeyword trid
163  
164 and look for the entry for "Depth-Range (z-x) traces
165  
166  
167  
168  
169  
170 Credits:
171  
172  
173  
174 SEP: Shuki Ronen
175  
176 CWP: Jack K. Cohen, Dave Hale, John Stockwell
177  
178 DELPHI: Alexander Koek added airwave mute.
179  
180 CWP: John Stockwell added modes 3 and 4
181  
182 USBG: Florian Bleibinhaus added hmute + some range checks on mute times
183  
184 Trace header fields accessed: ns, dt, delrt, key=keyword, trid, d1
185  
186 Trace header fields modified: muts or mute
187  
188  
189  
190 =head2 User's notes (Juan Lorenzo)
191  
192 V 0.0.2
193  
194 Normally, sumute can only apply one set muting coordinates to one gather
195 at a time.
196  
197 In this manner you would use a
198 "par_file" e.g.,
199  
200 tmute=0.128544,0.245747
201  
202 xmute=73.2464,95.6714
203  
204 For this particular case, the mute pick coordinates
205 in the "x" direction are tracr values.
206  
207 sumute sp_fldr4.su par=par_file key=tracr mode=0 |
208 sugain agc=1 wagc=0.1 | suxwigb clip=1.5 &
209  
210 Now, we have added some options to allow the user to mute a file
211 that contains many gathers at one time. You will need to supply
212 a "multi-gather", mute-type parameter file. That is, sumute.pm
213 can use a concatenated collection of the contents of these individual
214 parfiles. The name of this file is called the "multi_gather_par_file"".
215  
216 You can create a multi-gather parameter file in two ways:
217  
218 (1) Manually concatenate the individual parfiles into one file
219 (e.g.,use the Sucat tool)
220  
221 (2) Use the Tool: iTop_Mute to interactively pick mute coordinates.
222 The iTopMute Tool generates the "parfiles" (x,t values) in SUnix "par" format
223 iTopMute saves the picked values
224 into individual "parfiles" named according to
225 their corresponding gather (e.g. ep or cdp etc.)
226  
227 wE have added the new following options to su mute
228 to sumute:
229  
230 gather_type = ep (shotpoint),cdp (cdp gathers),fldr(field data gathers)
231  
232 ---This parameter specifies the type of gather in the multi-gather su file. It is not
233 needed when you are muting single files in the traditional way.
234  
235 multi_gather_par_file = a concatenated file of the individual parfiles
236  
237 multi_gather_su_file = the *.su file which was muted interactively to
238 create each of the parfiles, while using the Tool: iTop_Mute
239  
240 In the case of a cdp gather, a multi-parameter-file looks as follows:
241  
242 cdp=1,2
243  
244 tmute=0.141777,0.251418
245 xmute=73,96
246  
247 tmute=0.131777,0.241418
248 xmute=85,96
249  
250  
251 Internally, sumute uses "susplit" to break a large multi-gather file into individual
252 shotpoint gathers (ep), or cdp gathers or fldr (gathers) according to Segy
253 key header words.
254  
255 An example:
256  
257 Data consists of a single CDP gather, digitized in iTopMute as a function
258 of tracr (x-co-ordinate)
259  
260 The parameter values in sumute are:
261 gather_type=cdp
262  
263 header-word=tracr
264  
265 multi_gather_par_file=list
266  
267 multi_gather_su_file=sp_fldr4
268  
269  
270 the file "list" is as follows:
271  
272 cdp=1
273  
274 tmute=0.141777,0.251418
275  
276 xmute=73,96
277  
278  
279 Note, when you use a multi-parameter mute paramter file you DO NOT include a separate
280 "data_in" file in the flow. The "data_in" is not necessary
281 because the new option in sumute reads multi_gather_su_file automatically.
282  
283 --------------------------------------------------------------------
284 Interactive top mute picks are made using the Tool: iTopMute
285  
286 The iTopMute Tool generates the "parfiles" (x,t values) in SUnix "par" format
287 iTopMute saves the picked values
288 into individual "parfiles" named according to
289 their corresponding gather (e.g. ep or cdp etc.)
290  
291 =cut
292  
293 =head2 CHANGES and their DATES
294  
295 Nov. 2022, V 0.0.2
296 June 2023, split files are read from DATA_SEISMIC_SU directory
297 March, 2024, V 0.0.3
298 corrected error in removal of extra ".su" in output muted file name
299  
300 =cut
301  
302 use Moose;
303 our $VERSION = '0.0.3';
304  
305 =head2 Import packages
306  
307 =cut
308  
309 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
310 use App::SeismicUnixGui::misc::SeismicUnix
311 qw($go $in $itop_mute_par_ $ibot_mute_par_ $off $on $out $ps $to $suffix_ascii $suffix_bin
312 $suffix_ps $suffix_segy $suffix_su $tmute $xmute);
313 use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config';
314 use aliased 'App::SeismicUnixGui::misc::manage_files_by2';
315 use App::SeismicUnixGui::misc::control '0.0.3';
316 use aliased 'App::SeismicUnixGui::misc::control';
317 use aliased 'App::SeismicUnixGui::sunix::shapeNcut::susplit';
318 use aliased 'App::SeismicUnixGui::misc::flow';
319 use aliased 'App::SeismicUnixGui::misc::message';
320  
321 =head2 instantiation of packages
322  
323 =cut
324  
325 my $get = L_SU_global_constants->new();
326 my $Project = Project_config->new();
327 my $DATA_SEISMIC_SU = $Project->DATA_SEISMIC_SU();
328 my $DATA_SEISMIC_BIN = $Project->DATA_SEISMIC_BIN();
329 my $DATA_SEISMIC_TXT = $Project->DATA_SEISMIC_TXT();
330 my $PL_SEISMIC = $Project->PL_SEISMIC();
331 my $PS_SEISMIC = $Project->PS_SEISMIC();
332 my $log = message->new();
333  
334 my $var = $get->var();
335 my $on = $var->{_on};
336 my $off = $var->{_off};
337 my $true = $var->{_true};
338 my $false = $var->{_false};
339 my $empty_string = $var->{_empty_string};
340  
341 my ($imute_par_);
342 my ( @tmute, @xmute, @output, @Steps, @gather_number, @par_file );
343  
344 =head2 Encapsulated
345 hash of private variables
346  
347 =cut
348  
349 my $sumute = {
350 _par_gather_number_aref => '',
351 _gather_type => '',
352 _hmute => '',
353 _key => '',
354 _linvel => '',
355 _multi_gather_par_file => '',
356 _multi_gather_su_file => '',
357 _mode => '',
358 _nmute => '',
359 _ntaper => '',
360 _par => '',
361 _par_directory => '',
362 _susplit_stem => 'split4sumute',
363 _tfile => '',
364 _tm0 => '',
365 _tmute => '',
366 _twindow => '',
367 _xfile => '',
368 _xmute => '',
369 _Step => '',
370 _note => '',
371  
372 };
373  
374 =head2 sub _get_par_sets
375  
376 =cut
377  
378 sub _get_par_sets {
379  
380 my (@self) = @_;
381  
382 if ( $sumute->{_multi_gather_par_file} ne $empty_string
383 and $sumute->{_gather_type} ne $empty_string )
384 {
385  
386 =head2 instantiate classes
387  
388 =cut
389  
390 my $files = manage_files_by2->new();
391 my $control = control->new();
392  
393 =head2 private definitions
394  
395 =cut
396  
397 my ( @time_picks_aref2, @x_picks_aref2 );
398 my @par_gather;
399 my $multi_par_file_w_path;
400 my $row = 0;
401 my $inbound;
402 my @time_picks_aref;
403 my $par_gather_number;
404 my $par_gather_count;
405  
406 $multi_par_file_w_path = $sumute->{_multi_gather_par_file};
407 $inbound = $multi_par_file_w_path;
408  
409 # print("sumute,_get_par_sets, inbound=$inbound\n");
410  
411 =head2 read i/p file
412  
413 =cut
414  
415 $control->set_back_slashBgone($inbound);
416 $inbound = $control->get_back_slashBgone();
417  
418 # open multi-gather_par_file
419 # which contains a list of the
420 # individual par files
421 my $ref_file_name = \$inbound;
422 my ( $items_aref2, $numberOfItems_aref ) =
423 $files->read_par($ref_file_name);
424  
425 # print("multi-gather-parameter file #0 contains: @{@{$items_aref2}[0]}\n");
426  
427 # first array member is gather name
428 # ,e.g. 'cdp' or 'tmute=', or or just 'gather'
429 # and a list of par_gather numbers
430 @par_gather = @{ @{$items_aref2}[0] };
431 my $gather_type = $par_gather[0];
432 # print("sumute, _get_par_sets, gather_type=--$gather_type\n");
433  
434 =head2 capture errors
435  
436 =cut
437  
438 if ( length $gather_type
439 && $gather_type eq $sumute->{_gather_type} )
440 {
441  
442 # print("sumute, _get_par_sets, gather type=$gather_type and $sumute->{_gather_type}\n");
443 # print("sumute, _get_par_sets, gather type OK\n");
444  
445 }
446 else {
447 print(
448 "sumute, _get_par_sets, gather type missing in 1 or 2 places\n"
449 );
450 print(
451 "sumute, _get_par_sets, gather=--$gather_type-- versus --$sumute->{_gather_type}--\n"
452 );
453 }
454  
455 =head2 share values with namespace
456 Use splice to remove the first element (index =0)
457 which is not a number but a gather type of
458 gather name, e.g. cdp or ep or gather
459  
460 =cut
461  
462 my $number_of_par_gathers = ( scalar @par_gather ) - 1;
463 my $last_par_index = ( scalar @par_gather ) - 1;
464 my @number_of_picks = @$numberOfItems_aref;
465  
466 # print("sumute, _get_par_sets,last_par_index=$last_par_index\n");
467 # print("sumute, _get_par_sets,number_of_par_gathers=$number_of_par_gathers\n");
468 # print("sumute, _get_par_sets,old par_gather=@par_gather\n");
469  
470 my @new_par_gather = @par_gather[ 1 .. $last_par_index ];
471 $sumute->{_par_gather_number_aref} = \@new_par_gather;
472  
473 # print("sumute, _get_par_sets,new_par_gather=@new_par_gather\n");
474 # print("sumute, _get_par_sets,gather_type=$gather_type\n");
475 # print("sumute, _get_par_sets,number_of_gathers=$number_of_par_gathers\n");
476  
477 =head2 collect tmute and xmute
478 for each gather
479  
480 =cut
481  
482 for (
483 my $par_gather_count = 1, my $i = 0 ;
484 $par_gather_count <= $number_of_par_gathers ;
485 $par_gather_count++, $i++
486 )
487 {
488  
489 # print("sumute,_get_par_sets, par_gather_count: $par_gather_count\n");
490 $par_gather_number = $par_gather[$par_gather_count];
491  
492 # print("sumute,_get_par_sets, par_gather_number: $par_gather_number\n");
493 $row = ( $par_gather_count * 2 ) - 1;
494  
495 # print("sumute,_get_par_sets, row: $row\n");
496  
497 my $last_sample_index =
498 scalar @{ @{$items_aref2}[ ( $row + 1 ) ] } - 1;
499  
500 my @new_x_picks =
501 @{ @{$items_aref2}[ ( $row + 1 ) ] }[ 1 .. $last_sample_index ];
502  
503 # print("sumute,_get_par_sets, new_x_picks:@new_x_picks,last_sample_index:$last_sample_index\n");
504 $x_picks_aref2[$i] = \@new_x_picks;
505  
506 my @new_time_picks =
507 @{ @{$items_aref2}[ ($row) ] }[ 1 .. $last_sample_index ];
508  
509 # print("sumute,_get_par_sets, new_time_picks:@new_time_picks,last_sample_index:$last_sample_index\n");
510 $time_picks_aref2[$i] = \@new_time_picks;
511  
512 } # no. gathers with parameter sets
513  
514 # remove fist item of the time and x picks which,
515 # when read from the multu-par_file is actually
516 # a string linke tmute or xmute
517 # Actual first = 'tmute' and 'xmute'-- not numbers
518 # last 2 returns are string arrays
519  
520 return ( \@time_picks_aref2, \@x_picks_aref2, $tmute, $xmute );
521  
522 }
523 else {
524 print(
525 "sumute,_get_par_sets, missing multi_gather_par_file or
526 missing definition of gather type\n"
527 );
528 return ();
529 }
530  
531 }
532  
533 =head2 sub Step
534  
535 collects switches and assembles bash instructions
536 by adding the program name
537  
538 Keeps track of actions for execution in the system
539 collects switches and assembles bash instructions
540 by adding the program name
541  
542 =cut
543  
544 sub Step {
545 my ($self) = @_;
546  
547 my $result;
548  
549 =head2 CASE
550  
551 with multi_gather_su_file
552  
553 =cut
554  
555 if ( $sumute->{_multi_gather_par_file} ne $empty_string
556 && $sumute->{_multi_gather_su_file} ne $empty_string
557 && $sumute->{_par_gather_number_aref} ne $empty_string
558 && $sumute->{_gather_type} ne $empty_string )
559 {
560  
561 =head2 local definitions
562  
563 =cut
564  
565 my $inbound = $sumute->{_multi_gather_su_file};
566  
567 =head2 get modules
568  
569 =cut
570  
571 =head2 instantiate modules
572  
573 =cut
574  
575 my $susplit = susplit->new();
576 my $run = flow->new();
577 my $control = control->new();
578  
579 =head2 declare local variables
580  
581 =cut
582  
583 my @susplit;
584 my @flow;
585 my @split_file_matches;
586 my @muted_output;
587 my $number_of_split_files = 0;
588 my ( @time_picks_aref2, @x_picks_aref2 );
589 my ( $time_picks_aref2, $x_picks_aref2, $first_name, $second_name );
590  
591 =head2 Set up
592
593 susplit parameter values
594  
595 =cut
596 # print("sumute, inbound= $inbound\n");
597 $susplit->clear();
598 $susplit->close( quotemeta(1) );
599 $susplit->su_base_file_name($inbound);
600 $susplit->key( $sumute->{_gather_type} );
601 $susplit->stem( $sumute->{_susplit_stem} );
602 $susplit->verbose( quotemeta(1) );
603 $susplit->suffix($suffix_su);
604 $susplit[0] = $susplit->Step();
605  
606 =head2 clear past temporary, past
607  
608 single-gather split from composite su file
609  
610 =cut
611  
612 # my $delete_files = '.split_' . '*';
613 # system("rm -rf $delete_files");
614  
615 =head2 DEFINE
616  
617 Collect FLOW(s)
618 Run flow in system independently of sumute
619  
620  
621 =cut
622  
623 my @items = ( $susplit[0]);
624 $flow[0] = $run->modules( \@items );
625  
626 =head2 RUN FLOW(s)
627  
628 =cut
629  
630 $run->flow( \$flow[0] );
631  
632 =head2 LOG FLOW(s)
633  
634 to screen and FILE
635  
636 =cut
637  
638 $log->screen( $flow[0] );
639 my $time = localtime;
640 $log->time();
641 $log->file( $flow[0] );
642  
643 =head2 collect output split file names from the DATA_SU_SEISMIC directory
644  
645 =cut
646  
647 opendir( my $dh, $DATA_SEISMIC_SU, );
648 my $search = $sumute->{_susplit_stem};
649 my @split_file_names = grep( /$search/, readdir($dh) );
650 closedir($dh);
651  
652 $number_of_split_files = scalar @split_file_names;
653  
654 # print("2. sumute,Step,list length = $number_of_split_files\n");
655 # print("2. sumute,Step,list[0] $split_file_names[0]\n");
656  
657 # print("2. sumute,Step,list[1] $split_file_names[1]\n");
658 # print("2. sumute,Step,split_files = @split_file_names\n");
659  
660 =head2 prepare sumute with split files
661  
662 =cut
663  
664 =head2 local error check
665  
666 =cut
667  
668 my $number_of_par_sets = scalar @{ $sumute->{_par_gather_number_aref} };
669  
670 if ( $number_of_split_files ne $number_of_par_sets ) {
671  
672 print(
673 "\n sumute, Step, N.B.: # of split files (= $number_of_split_files)\n"
674 );
675 print(
676 " may not equal # of par files (= $number_of_par_sets) \n"
677 );
678  
679 }
680 elsif ($sumute->{_multi_gather_par_file} eq $empty_string
681 && $sumute->{_multi_gather_su_file} eq $empty_string )
682 {
683  
684 print(" sumute,Step, case2 \n");
685 $result = 'sumute' . $sumute->{_Step};
686 return ($result);
687  
688 }
689 else {
690  
691 # NADA
692 }
693  
694 =head2 get the temporary, single-gather
695  
696 parameter files
697 that match split data files
698  
699 =cut
700  
701 ( $time_picks_aref2, $x_picks_aref2, $first_name, $second_name ) =
702 _get_par_sets();
703  
704 my @par_gather_number = @{ $sumute->{_par_gather_number_aref} };
705  
706 if ( $number_of_split_files >= 0 ) {
707  
708 for ( my $i = 0 ; $i < $number_of_par_sets ; $i++ ) {
709  
710 # match on par file gather number
711 my $par_gather_number =
712 '0' . $par_gather_number[$i] . $suffix_su;
713  
714 my @matches = grep { /$par_gather_number/ } @split_file_names;
715  
716 # print("2 sumute,Step,gather_number= $par_gather_number[$i]\n");
717 # print("2 sumute,Step,matches = @matches\n");
718 my $length = scalar @matches;
719  
720 # print("2 sumute,Step,mo. matches = $length\n");
721  
722 =head2 error check
723  
724 get match to an
725 existing split file
726  
727 =cut
728  
729 if ( $length > 1 ) {
730  
731 # print("sumute,Step,match error Only one file SHOULD exist\n");
732 # print("sumute,Step,But matches= @matches\n");
733  
734 }
735 elsif ( ( scalar @matches ) == 1 ) {
736  
737 $split_file_matches[$i] = $matches[0];
738  
739 # print("sumute,Step,split_file_matches[$i]=$split_file_matches[$i]\n");
740  
741 }
742 elsif ( ( scalar @matches ) == 0 ) {
743  
744 print(
745 "sumute,Step,match error At least one file SHOULD exist\n"
746 );
747  
748 }
749 else {
750 print("sumute,Step,error check\n");
751 }
752  
753 } # for all parameter sets
754  
755 } # if split files exist
756  
757 =head2 First case
758  
759 i=0
760  
761 =cut
762  
763 my $number_of_split_file_matches = scalar @split_file_matches;
764  
765 if ( $number_of_split_file_matches > 0 ) {
766  
767 $muted_output[0] = $split_file_matches[0];
768 $muted_output[0] =~ s/\.su//;
769 $muted_output[0] =
770 $DATA_SEISMIC_SU . '/' . $muted_output[0] . '_mute' . $suffix_su;
771  
772 my @time_picks = @{ @{$time_picks_aref2}[0] };
773 my @x_picks = @{ @{$x_picks_aref2}[0] };
774  
775 my $time_picks_w_commas = $control->commify( \@time_picks );
776 my $x_picks_w_commas = $control->commify( \@x_picks );
777  
778 # print("2 sumute,Step,time_picks_aref2[0]=@time_picks\n");
779 print("sumute,Step,muted_output: $muted_output[0], case 0 \n");
780 # print("sumute,Step,split_file_match: $split_file_matches[0], case 0 \n");
781 # print("1 sumute,Step,time_picks_aref2[0]=@{@{$time_picks_aref2}[0]}\n");
782 # print("1 sumute,Step,x_picks_w_commas=$x_picks_w_commas\n");
783 # print("1 sumute,Step,time_picks_w_commas=$time_picks_w_commas\n");
784  
785 $result =
786 ' sumute'
787 . $in
788 . $DATA_SEISMIC_SU . '/'
789 . $split_file_matches[0]
790 . $out
791 . $muted_output[0]
792 . $sumute->{_Step}
793 . ' tmute='
794 . $time_picks_w_commas
795 . ' xmute='
796 . $x_picks_w_commas . "\n";
797  
798 # print("A sumute,Step,result so far \n$result\n");
799  
800 =head2 intermediate muting cases
801  
802 =cut
803  
804 for ( my $i = 1 ; $i < ( $number_of_par_sets - 1 ) ; $i++ ) {
805  
806 $muted_output[$i] = $split_file_matches[$i];
807  
808 # print("2 sumute,Step,muted_output: $muted_output[$i] case i=$i\n");
809 $muted_output[$i] =~ s/\.su//;
810 $muted_output[$i] =
811 $DATA_SEISMIC_SU . '/'
812 . $muted_output[$i] . '_mute'
813 . $suffix_su;
814  
815 my @time_picks = @{ @{$time_picks_aref2}[$i] };
816 my @x_picks = @{ @{$x_picks_aref2}[$i] };
817  
818 my $time_picks_w_commas = $control->commify( \@time_picks );
819 my $x_picks_w_commas = $control->commify( \@x_picks );
820  
821 $result =
822 $result
823 . ' sumute'
824 . $in
825 . $DATA_SEISMIC_SU . '/'
826 . $split_file_matches[$i]
827 . $out
828 . $muted_output[$i]
829 . $sumute->{_Step}
830 . ' tmute='
831 . $time_picks_w_commas
832 . ' xmute='
833 . $x_picks_w_commas . "\n";
834  
835 } # for all parameter sets
836  
837 =head2 last case
838  
839 =cut
840  
841 my $last_case = $number_of_par_sets - 1;
842  
843 $muted_output[$last_case] = $split_file_matches[$last_case];
844  
845 # print("2 sumute,Step,muted_output: $muted_output[$last_case] case i=$last_case\n");
846 $muted_output[$last_case] =~ s/\.su//;
847 $muted_output[$last_case] =
848 $DATA_SEISMIC_SU . '/'
849 . $muted_output[$last_case] . '_mute'
850 . $suffix_su;
851  
852 @time_picks = @{ @{$time_picks_aref2}[$last_case] };
853 @x_picks = @{ @{$x_picks_aref2}[$last_case] };
854  
855 $time_picks_w_commas = $control->commify( \@time_picks );
856 $x_picks_w_commas = $control->commify( \@x_picks );
857  
858 $result =
859 $result
860 . ' sumute'
861 . $in
862 . $DATA_SEISMIC_SU . '/'
863 . $split_file_matches[$last_case]
864 . $out
865 . $muted_output[$last_case]
866 . $sumute->{_Step}
867 . ' tmute='
868 . $time_picks_w_commas
869 . ' xmute='
870 . $x_picks_w_commas . "\n";
871  
872 # print("2 sumute,Step,result for everything\n$result\n");
873  
874 =head2 concatenate muted results
875  
876 create concatenated output file name
877  
878 =cut
879  
880 my $string = $sumute->{_multi_gather_su_file};
881 $string =~ s/\.su//;
882 my $outbound_concatenated_mute_file =
883 $DATA_SEISMIC_SU . '/' . $string . '_mute' . $suffix_su;
884  
885 # print(" sumute,Step, concatenated_mute_file: $outbound_concatenated_mute_file \n");
886  
887 =head2 cat first case
888 and then the rest in a loop
889  
890 =cut
891  
892 $result = $result . 'cat' . ' ' . $muted_output[0] . ' ';
893  
894 for ( my $i = 1 ; $i < $number_of_par_sets ; $i++ ) {
895  
896 $result = $result . $muted_output[$i] . ' ';
897  
898 }
899  
900 =head2 finish concatenation
901  
902 =cut
903  
904 # $result = $result
905 # . $out
906 # . $outbound_concatenated_mute_file;
907 # print("4. sumute,Step,result=$result \n");
908 return ($result);
909  
910 }
911 else {
912 print("sumute,Step,unexpected number_of_split_file_matches \n");
913 return ();
914 } # split_file matches exist
915  
916 }
917 elsif ($sumute->{_multi_gather_par_file} eq $empty_string
918 && $sumute->{_multi_gather_su_file} eq $empty_string )
919 {
920  
921 # print(" sumute,Step, case2 \n");
922 $result = 'sumute' . $sumute->{_Step};
923 return ($result);
924  
925 }
926 else {
927 print(" sumute, Step, unexpected value\n");
928 print(
929 " sumute, Step,multi_gather_par_file=$sumute->{_multi_gather_par_file} \n"
930 );
931 print(
932 " sumute, Step,multi_gather_su_file=$sumute->{_multi_gather_su_file} \n"
933 );
934 print(
935 " sumute, Step,par_gather_number_aref=$sumute->{_par_gather_number_aref} \n"
936 );
937 print(" sumute, Step,gather_type=$sumute->{_gather_type} \n");
938 return ();
939  
940 } # sub pre-conditions
941  
942 print("sumute,Step,result=$result \n");
943  
944 }
945  
946 =head2 Subroutine Steps
947  
948 Keeps track of actions for execution in the system
949 when more that one gather is being processed in the flow
950 at a time
951 Place contents of each line of the mute tables (t and index)
952 array into either a tmute or an xmute array for each file
953  
954 print("$output[$line]\n\n");
955 print ("tmute is $sumute->{_tmute}\n\n");
956 print ("$sumute->{_Steps}\n\n");
957 #print (" sub Steps shows: $sumute->{_Steps_array}[$i]\n\n");
958  
959 =cut
960  
961 sub Steps {
962  
963 use App::SeismicUnixGui::misc::SeismicUnix qw($in $out $to $suffix_su);
964 use App::SeismicUnixGui::misc::flow;
965  
966 my ($DATA_SEISMIC_SU) = $Project->DATA_SEISMIC_SU();
967 my $run = flow->new();
968 my ( @items, @outbound );
969  
970 for ( my $i = 1 ; $i <= $sumute->{_number_of_par_files} ; $i++ ) {
971 tmute( $sumute->{_tmute_array}[$i] );
972 xmute( $sumute->{_xmute_array}[$i] );
973  
974 $outbound[$i] =
975 $DATA_SEISMIC_SU . '/'
976 . $sumute->{_file_in} . '_'
977 . $sumute->{_gather_type}
978 . $sumute->{_gather_number_array}[$i]
979 . $suffix_su;
980  
981 @items = (
982 'suwind key='
983 . $sumute->{_gather_type} . ' min='
984 . $sumute->{_gather_number_array}[$i] . ' max='
985 . $sumute->{_gather_number_array}[$i],
986 $in, $DATA_SEISMIC_SU . '/' . $sumute->{_file_in} . $suffix_su,
987 $to, ' sumute ' . $sumute->{_Steps},
988 $out, $outbound[$i]
989 );
990  
991 $sumute->{_Steps_array}[$i] = $run->modules( \@items );
992  
993 print(" sub Steps shows: $sumute->{_Steps_array}[$i]\n\n");
994  
995 } # for many parameter files
996  
997 return (
998 $sumute->{_Steps_array},
999 $sumute->{_number_of_par_files},
1000 $sumute->{_gather_number_array}, \@outbound
1001 );
1002 }
1003  
1004 =head2 sub note
1005  
1006 collects switches and assembles bash instructions
1007 by adding the program name
1008  
1009 =cut
1010  
1011 sub note {
1012  
1013 $sumute->{_note} = 'sumute' . $sumute->{_note};
1014 return ( $sumute->{_note} );
1015  
1016 }
1017  
1018 =head2 sub clear
1019  
1020 =cut
1021  
1022 sub clear {
1023  
1024 $sumute->{_par_gather_number_aref} = '';
1025 $sumute->{_gather_type} = '';
1026 $sumute->{_hmute} = '';
1027 $sumute->{_key} = '';
1028 $sumute->{_linvel} = '';
1029 $sumute->{_mode} = '';
1030 $sumute->{_multi_gather_par_file} = '';
1031 $sumute->{_multi_gather_su_file} = '';
1032 $sumute->{_nmute} = '';
1033 $sumute->{_ntaper} = '';
1034 $sumute->{_par} = '',
1035 $sumute->{_susplit_stem} = 'split4sumute', # maintain, do not clear
1036 $sumute->{_par_directory} = '', $sumute->{_tfile} = '';
1037 $sumute->{_tm0} = '';
1038 $sumute->{_tmute} = '';
1039 $sumute->{_twindow} = '';
1040 $sumute->{_xfile} = '';
1041 $sumute->{_xmute} = '';
1042 $sumute->{_Step} = '';
1043 $sumute->{_note} = '';
1044  
1045 }
1046  
1047 =head2 sub gather_type
1048  
1049 for example, can be ep cdp
1050 and refers to the types of gathers that
1051 are being muted.
1052  
1053 =cut
1054  
1055 sub gather_type {
1056  
1057 my ( $self, $gather_type ) = @_;
1058 if ( $gather_type ne $empty_string ) {
1059  
1060 $sumute->{_gather_type} = $gather_type;
1061  
1062 }
1063 else {
1064 print("sumute, gather_type, missing gather_type,\n");
1065 }
1066 }
1067  
1068 =head2 sub header_word_mute
1069  
1070  
1071 =cut
1072  
1073 sub header_word_mute {
1074  
1075 my ( $self, $key ) = @_;
1076 if ( $key ne $empty_string ) {
1077  
1078 $sumute->{_key} = $key;
1079 $sumute->{_note} = $sumute->{_note} . ' hmute=' . $sumute->{_key};
1080 $sumute->{_Step} = $sumute->{_Step} . ' hmute=' . $sumute->{_key};
1081  
1082 }
1083 else {
1084 print("sumute, header_word, missing key,\n");
1085 }
1086 }
1087  
1088 =head2 sub hmute
1089  
1090  
1091 =cut
1092  
1093 sub hmute {
1094  
1095 my ( $self, $hmute ) = @_;
1096 if ( $hmute ne $empty_string ) {
1097  
1098 $sumute->{_hmute} = $hmute;
1099 $sumute->{_note} = $sumute->{_note} . ' hmute=' . $sumute->{_hmute};
1100 $sumute->{_Step} = $sumute->{_Step} . ' hmute=' . $sumute->{_hmute};
1101  
1102 }
1103 else {
1104 print("sumute, hmute, missing hmute,\n");
1105 }
1106 }
1107  
1108 =head2 sub key
1109  
1110  
1111 =cut
1112  
1113 sub key {
1114  
1115 my ( $self, $key ) = @_;
1116 if ( $key ne $empty_string ) {
1117  
1118 $sumute->{_key} = $key;
1119 $sumute->{_note} = $sumute->{_note} . ' key=' . $sumute->{_key};
1120 $sumute->{_Step} = $sumute->{_Step} . ' key=' . $sumute->{_key};
1121  
1122 }
1123 else {
1124 print("sumute, key, missing key,\n");
1125 }
1126 }
1127  
1128 =head2 sub linvel
1129  
1130  
1131 =cut
1132  
1133 sub linvel {
1134  
1135 my ( $self, $linvel ) = @_;
1136 if ( $linvel ne $empty_string ) {
1137  
1138 $sumute->{_linvel} = $linvel;
1139 $sumute->{_note} = $sumute->{_note} . ' linvel=' . $sumute->{_linvel};
1140 $sumute->{_Step} = $sumute->{_Step} . ' linvel=' . $sumute->{_linvel};
1141  
1142 }
1143 else {
1144 print("sumute, linvel, missing linvel,\n");
1145 }
1146 }
1147  
1148 =head2 sub mode
1149  
1150  
1151 =cut
1152  
1153 sub mode {
1154  
1155 my ( $self, $mode ) = @_;
1156 if ( $mode ne $empty_string ) {
1157  
1158 $sumute->{_mode} = $mode;
1159 $sumute->{_note} = $sumute->{_note} . ' mode=' . $sumute->{_mode};
1160 $sumute->{_Step} = $sumute->{_Step} . ' mode=' . $sumute->{_mode};
1161  
1162 }
1163 else {
1164 print("sumute, mode, missing mode,\n");
1165 }
1166 }
1167  
1168 =head2 sub multi_gather_par_file
1169  
1170 sumute can only handle one
1171 set of mute picks per file
1172 so a multi-gather file has to be
1173 split.
1174  
1175 A multi-gather par file for muting
1176 assembles these picks into one file
1177 using the same format as sunmo
1178 par files.
1179  
1180 However, currently sumute can not
1181 read multi-gather-par files.
1182 The user is unaware of this in SeismicUnixGui
1183  
1184 multi-gather_par_files are
1185 written like sunmo files with cdp numbers on the first line
1186 and tnmo and vnmo alternating on successive lines
1187  
1188 =cut
1189  
1190 sub multi_gather_par_file {
1191  
1192 my ( $self, $multi_gather_par_file ) = @_;
1193  
1194 if ( $multi_gather_par_file ne $empty_string ) {
1195  
1196 =head2 instantiate classes
1197  
1198 =cut
1199  
1200 my $files = manage_files_by2->new();
1201  
1202 =head2 module definitions
1203  
1204 $sumute->{_par_gather_number_aref}
1205  
1206 =cut
1207  
1208 my ( @time_picks_aref2, @x_picks_aref2 );
1209  
1210 $sumute->{_multi_gather_par_file} = $multi_gather_par_file;
1211  
1212 my ( $time_picks_aref2, $x_picks_aref2, $first_name, $second_name ) =
1213 _get_par_sets();
1214  
1215 # collect single-gather mute paramters (tmut and xmute3)
1216 # write tmute and xmute in successive lines
1217  
1218 # run _get_par_sets previously
1219 my $number_of_gathers = scalar @{ $sumute->{_par_gather_number_aref} };
1220  
1221 # print("sumute,multi_gather_par_file, number_of_gathers=$number_of_gathers\n");
1222  
1223 for ( my $i = 0 ; $i < $number_of_gathers ; $i++ ) {
1224  
1225 my $time_picks_ref = @{$time_picks_aref2}[$i];
1226 my $x_picks_ref = @{$x_picks_aref2}[$i];
1227  
1228 # print("sumute,multi_gather_par_file, time_picks=@{$time_picks_ref}\n");
1229 # print("sumute,multi_gather_par_file, x_picks=@{$x_picks_ref}\n");
1230  
1231 }
1232  
1233 }
1234 else {
1235 print("sumute,multi_gather_par_file, missing mult-gather-par file\n");
1236 return ();
1237 }
1238 return ();
1239 }
1240  
1241 =head2 sub multi_gather_su_file
1242  
1243  
1244 =cut
1245  
1246 sub multi_gather_su_file {
1247  
1248 my ( $self, $multi_gather_su_file ) = @_;
1249 if ( $multi_gather_su_file ne $empty_string ) {
1250  
1251 $sumute->{_multi_gather_su_file} = $multi_gather_su_file;
1252  
1253 # print("sumute, multi_gather_su_file=$multi_gather_su_file\n");
1254  
1255 }
1256 else {
1257 print("sumute, multi_gather_su_file, missing multi_gather_su_file,\n");
1258 }
1259 }
1260  
1261 =head2 sub nmute
1262  
1263  
1264 =cut
1265  
1266 sub nmute {
1267  
1268 my ( $self, $nmute ) = @_;
1269 if ( $nmute ne $empty_string ) {
1270  
1271 $sumute->{_nmute} = $nmute;
1272 $sumute->{_note} = $sumute->{_note} . ' nmute=' . $sumute->{_nmute};
1273 $sumute->{_Step} = $sumute->{_Step} . ' nmute=' . $sumute->{_nmute};
1274  
1275 }
1276 else {
1277 print("sumute, nmute, missing nmute,\n");
1278 }
1279 }
1280  
1281 =head2 sub ntaper
1282  
1283  
1284 =cut
1285  
1286 sub ntaper {
1287  
1288 my ( $self, $ntaper ) = @_;
1289 if ( $ntaper ne $empty_string ) {
1290  
1291 $sumute->{_ntaper} = $ntaper;
1292 $sumute->{_note} = $sumute->{_note} . ' ntaper=' . $sumute->{_ntaper};
1293 $sumute->{_Step} = $sumute->{_Step} . ' ntaper=' . $sumute->{_ntaper};
1294  
1295 }
1296 else {
1297 print("sumute, ntaper, missing ntaper,\n");
1298 }
1299 }
1300  
1301 =head2 sub offset_word
1302  
1303  
1304 =cut
1305  
1306 sub offset_word {
1307  
1308 my ( $self, $key ) = @_;
1309 if ( $key ne $empty_string ) {
1310  
1311 $sumute->{_key} = $key;
1312 $sumute->{_note} = $sumute->{_note} . ' key=' . $sumute->{_key};
1313 $sumute->{_Step} = $sumute->{_Step} . ' key=' . $sumute->{_key};
1314  
1315 }
1316 else {
1317 print("sumute, offset_word, missing key,\n");
1318 }
1319 }
1320  
1321 =head2 sub par
1322  
1323  
1324 =cut
1325  
1326 sub par {
1327  
1328 my ( $self, $par ) = @_;
1329 if ( $par ne $empty_string ) {
1330  
1331 $sumute->{_par} = $par;
1332 $sumute->{_note} =
1333 $sumute->{_note} . ' par='
1334 . $sumute->{_par_directory} . '/'
1335 . $sumute->{_par};
1336 $sumute->{_Step} =
1337 $sumute->{_Step} . ' par='
1338 . $sumute->{_par_directory} . '/'
1339 . $sumute->{_par};
1340  
1341 }
1342 else {
1343 print("sumute, par, missing par,or par_directory\n");
1344 }
1345 }
1346  
1347 =head2 sub par_directory
1348  
1349 selection of arbitrary
1350 parfile directory
1351  
1352  
1353 =cut
1354  
1355 sub par_directory {
1356  
1357 my ( $self, $par_directory ) = @_;
1358  
1359 if ( $par_directory ne $empty_string ) {
1360  
1361 if ( $par_directory eq 'DATA_SEISMIC_TXT' ) {
1362  
1363 $par_directory = $DATA_SEISMIC_TXT;
1364 $sumute->{_par_directory} = $par_directory;
1365  
1366 }
1367 else {
1368 print("sumute, par_directory, unexpected par_directory,\n");
1369 }
1370  
1371 }
1372 else {
1373 print("sumute, par_directory, missing par_directory,\n");
1374 }
1375 }
1376  
1377 =head2 sub par_file
1378  
1379  
1380 =cut
1381  
1382 sub par_file {
1383  
1384 my ( $self, $par ) = @_;
1385  
1386 if ( length $par ) {
1387  
1388 $sumute->{_par} = $par;
1389 $sumute->{_note} =
1390 $sumute->{_note} . ' par='
1391 . $sumute->{_par_directory} . '/'
1392 . $sumute->{_par};
1393 $sumute->{_Step} =
1394 $sumute->{_Step} . ' par='
1395 . $sumute->{_par_directory} . '/'
1396 . $sumute->{_par};
1397  
1398 }
1399 else {
1400 print("sumute, par_file, missing par or par_directory,\n");
1401 }
1402 }
1403  
1404 =head2 sub tfile
1405  
1406  
1407 =cut
1408  
1409 sub tfile {
1410  
1411 my ( $self, $tfile ) = @_;
1412 if ( $tfile ne $empty_string ) {
1413  
1414 $sumute->{_tfile} = $tfile;
1415 $sumute->{_note} = $sumute->{_note} . ' tfile=' . $sumute->{_tfile};
1416 $sumute->{_Step} = $sumute->{_Step} . ' tfile=' . $sumute->{_tfile};
1417  
1418 }
1419 else {
1420 print("sumute, tfile, missing tfile,\n");
1421 }
1422 }
1423  
1424 =head2 sub tm0
1425  
1426  
1427 =cut
1428  
1429 sub tm0 {
1430  
1431 my ( $self, $tm0 ) = @_;
1432 if ( $tm0 ne $empty_string ) {
1433  
1434 $sumute->{_tm0} = $tm0;
1435 $sumute->{_note} = $sumute->{_note} . ' tm0=' . $sumute->{_tm0};
1436 $sumute->{_Step} = $sumute->{_Step} . ' tm0=' . $sumute->{_tm0};
1437  
1438 }
1439 else {
1440 print("sumute, tm0, missing tm0,\n");
1441 }
1442 }
1443  
1444 =head2 sub tmute
1445  
1446  
1447 =cut
1448  
1449 sub tmute {
1450  
1451 my ( $self, $tmute ) = @_;
1452 if ( $tmute ne $empty_string ) {
1453  
1454 $sumute->{_tmute} = $tmute;
1455 $sumute->{_note} = $sumute->{_note} . ' tmute=' . $sumute->{_tmute};
1456 $sumute->{_Step} = $sumute->{_Step} . ' tmute=' . $sumute->{_tmute};
1457  
1458 }
1459 else {
1460 print("sumute, tmute, missing tmute,\n");
1461 }
1462 }
1463  
1464 =head2 sub twindow
1465  
1466  
1467 =cut
1468  
1469 sub twindow {
1470  
1471 my ( $self, $twindow ) = @_;
1472 if ( $twindow ne $empty_string ) {
1473  
1474 $sumute->{_twindow} = $twindow;
1475 $sumute->{_note} = $sumute->{_note} . ' twindow=' . $sumute->{_twindow};
1476 $sumute->{_Step} = $sumute->{_Step} . ' twindow=' . $sumute->{_twindow};
1477  
1478 }
1479 else {
1480 print("sumute, twindow, missing twindow,\n");
1481 }
1482 }
1483  
1484 =head2 sub type
1485  
1486  
1487 =cut
1488  
1489 sub type {
1490  
1491 my ( $self, $mode ) = @_;
1492  
1493 if ( $mode ne $empty_string ) {
1494  
1495 if ( $mode eq 'top' ) {
1496 $mode = 0;
1497 $imute_par_ = $itop_mute_par_;
1498  
1499 }
1500  
1501 if ( $mode eq 'bottom' ) {
1502 $mode = 1;
1503 $imute_par_ = $ibot_mute_par_;
1504 }
1505  
1506 $sumute->{_mode} = $mode;
1507 $sumute->{_note} = $sumute->{_note} . ' mode=' . $sumute->{_mode};
1508 $sumute->{_Step} = $sumute->{_Step} . ' mode=' . $sumute->{_mode};
1509  
1510 }
1511 else {
1512 print("sumute, type, missing mode,\n");
1513 }
1514 }
1515  
1516 =head2 sub xfile
1517  
1518  
1519 =cut
1520  
1521 sub xfile {
1522  
1523 my ( $self, $xfile ) = @_;
1524 if ( $xfile ne $empty_string ) {
1525  
1526 $sumute->{_xfile} = $xfile;
1527 $sumute->{_note} = $sumute->{_note} . ' xfile=' . $sumute->{_xfile};
1528 $sumute->{_Step} = $sumute->{_Step} . ' xfile=' . $sumute->{_xfile};
1529  
1530 }
1531 else {
1532 print("sumute, xfile, missing xfile,\n");
1533 }
1534 }
1535  
1536 =head2 sub xmute
1537  
1538  
1539 =cut
1540  
1541 sub xmute {
1542  
1543 my ( $self, $xmute ) = @_;
1544 if ( $xmute ne $empty_string ) {
1545  
1546 $sumute->{_xmute} = $xmute;
1547 $sumute->{_note} = $sumute->{_note} . ' xmute=' . $sumute->{_xmute};
1548 $sumute->{_Step} = $sumute->{_Step} . ' xmute=' . $sumute->{_xmute};
1549  
1550 }
1551 else {
1552 print("sumute, xmute, missing xmute,\n");
1553 }
1554 }
1555  
1556 =head2 sub get_max_index
1557  
1558 max index = number of input variables -1
1559
1560 =cut
1561  
1562 sub get_max_index {
1563 my ($self) = @_;
1564 my $max_index = 16;
1565  
1566 return ($max_index);
1567 }
1568  
1569 1;