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

filter: Statementstmt 0.0% 0 / 93 Branchbran 0.0% 0 / 24 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 17 Podpod 0.0% 0 / 16 totaltotal 0.0% 0 / 150 CC 13 SCAR 16.7
CC
13
Cov
0%
AminusB
6.0
AplusB
6.0
file1
6.0
CRAP 5.3
1 package App::SeismicUnixGui::sunix::statsMath::suop2;
2  
3 =head1 DOCUMENTATION
4  
5 =head2 SYNOPSIS
6  
7 PERL PROGRAM NAME: SUOP2 - do a binary operation on two data sets
8 AUTHOR: Juan Lorenzo (Perl module only)
9 DATE: Feb. 19 2015,
10 DESCRIPTION:
11 Version: 0.0.1
12  
13 =head2 USE
14
15 =head3 NOTES
16  
17 =head4 Examples
18  
19 =head3 SEISMIC UNIX NOTES
20  
21 SUOP2 - do a binary operation on two data sets
22  
23 suop2 data1 data2 op=diff [trid=111] >stdout
24  
25 Required parameters:
26 none
27  
28 Optional parameter:
29 op=diff difference of two panels of seismic data
30 =sum sum of two panels of seismic data
31 =prod product of two panels of seismic data
32 =quo quotient of two panels of seismic data
33 =ptdiff differences of a panel and single trace
34 =ptsum sum of a panel and single trace
35 =ptprod product of a panel and single trace
36 =ptquo quotient of a panel and single trace
37 =zipper do "zipper" merge of two panels
38  
39 trid=FUNPACKNYQ output trace identification code. (This option
40 is active only for op=zipper)
41 For SU version 39-43 FUNPACNYQ=111
42 (See: sukeyword trid for current value)
43  
44  
45 Note1: Output = data1 "op" data2 with the header of data1
46  
47 Note2: For convenience and backward compatibility, this
48 program may be called without an op code as:
49  
50 For: panel "op" panel operations:
51 susum file1 file2 == suop2 file1 file2 op=sum
52 sudiff file1 file2 == suop2 file1 file2 op=diff
53 suprod file1 file2 == suop2 file1 file2 op=prod
54 suquo file1 file2 == suop2 file1 file2 op=quo
55  
56 For: panel "op" trace operations:
57 suptsum file1 file2 == suop2 file1 file2 op=ptsum
58 suptdiff file1 file2 == suop2 file1 file2 op=ptdiff
59 suptprod file1 file2 == suop2 file1 file2 op=ptprod
60 suptquo file1 file2 == suop2 file1 file2 op=ptquo
61  
62 Note3: If an explicit op code is used it must FOLLOW the
63 filenames.
64  
65 Note4: With op=quo and op=ptquo, divide by 0 is trapped and 0 is returned.
66  
67 Note5: Weighted operations can be specified by setting weighting
68 coefficients for the two datasets:
69 w1=1.0
70 w2=1.0
71  
72 Note6: With op=zipper, it is possible to set the output trace id code
73 (See: sukeyword trid)
74 This option processes the traces from two files interleaving its samples.
75 Both files must have the same trace length and must not longer than
76 SU_NFLTS/2 (as in SU 39-42 SU_NFLTS=32768).
77  
78 Being "tr1" a trace of data1 and "tr2" the corresponding trace of
79 data2, The merged trace will be :
80  
81 tr[2*i]= tr1[i]
82 tr[2*i+1] = tr2[i]
83  
84 The default value of output tr.trid is that used by sufft and suifft,
85 which is the trace id reserved for the complex traces obtained through
86 the application of sufft. See also, suamp.
87  
88 For operations on non-SU binary files use:farith
89  
90 Credits:
91 SEP: Shuki Ronen
92 CWP: Jack K. Cohen
93 CWP: John Stockwell, 1995, added panel op trace options.
94 : Fernando M. Roxo da Motta <petro@roxo.org> - added zipper op
95  
96 Notes:
97 If efficiency becomes important consider inverting main loop
98 and repeating operation code within the branches of the switch.
99
100 =head2 User's notes (Juan Lorenzo)
101  
102 (old)
103 $file[1] = fileA
104 $file[2]= fileB
105 suop2->clear();
106 suop2->AminusB();
107 suop2->fileA(\$file[1]);
108 suop2->fileB(\$file[2]);
109 $suop[1] = suop2->Step();
110
111 V 0.0.3 May 2023
112 You can include a list of file names
113  
114 =cut
115  
116 =head2 CHANGES and their DATES
117  
118 V 0.0.2 Oct 4 2018
119 V 0.0.3 May 2023
120
121 =cut
122  
123 use Moose;
124 our $VERSION = '0.0.1';
125  
126 my $suop2 = {
127 _file1 => '',
128 _file2 => '',
129 _file_list1 => '',
130 _file_list2 => '',
131 _op => '',
132 _trid => '',
133 _w1 => '',
134 _w2 => '',
135 _Step => '',
136 _note => '',
137 };
138  
139 =head2 sub Step
140  
141 collects switches and assembles bash instructions
142 by adding the program name
143  
144 =cut
145  
146 sub Step {
147  
148 $suop2->{_Step} = 'suop2' . $suop2->{_Step} . ' op=' . $suop2->{_op};
149 return ( $suop2->{_Step} );
150  
151 }
152  
153 =head2 sub note
154  
155 collects switches and assembles bash instructions
156 by adding the program name
157  
158 =cut
159  
160 sub note {
161  
162 $suop2->{_note} = 'suop2' . $suop2->{_note} . $suop2->{_op};
163 return ( $suop2->{_note} );
164  
165 }
166  
167 =head2 sub clear
168  
169 =cut
170  
171 sub clear {
172  
173 $suop2->{_Output} = '';
174 $suop2->{_file1} = '';
175 $suop2->{_file2} = '';
176 $suop2->{_file_list1} = '';
177 $suop2->{_file_list2} = '';
178 $suop2->{_op} = '';
179 $suop2->{_trid} = '';
180 $suop2->{_w1} = '';
181 $suop2->{_w2} = '';
182 $suop2->{_Step} = '';
183 $suop2->{_note} = '';
184 }
185  
186 =head2 subroutine AminusB
187  
188 fis operation to be diff
189 subtract one su file from another
190 trace by trace
191  
192 =cut
193  
194 sub AminusB {
195  
196 my ($self) = @_;
197  
198 my $diff = 'diff';
199 if ($diff) {
200  
201 $suop2->{_op} = $diff;
202  
203 }
204 else {
205 print("suop2, AminusB, missing suop2,\n");
206 }
207  
208 }
209  
210 =head2 subroutine AplusB
211  
212 add one su file to another
213 trace by trace
214  
215 =cut
216  
217 sub AplusB {
218  
219 my ($self) = @_;
220  
221 my $sum = 'sum';
222 if ($sum) {
223  
224 $suop2->{_op} = $sum;
225  
226 }
227 else {
228 print("suop2, AplusB, missing suop2,\n");
229 }
230  
231 }
232  
233 =head2 subroutine file1
234  
235 subs fileA and file1, first file with which to operate
236  
237 =cut
238  
239 sub file1 {
240  
241 my ( $self, $file1 ) = @_;
242  
243 if ($file1) {
244  
245 $suop2->{_file1} = $file1;
246 $suop2->{_note} = $suop2->{_note} . ' ' . $suop2->{_file1};
247 $suop2->{_Step} = $suop2->{_Step} . ' ' . $suop2->{_file1};
248  
249 }
250 else {
251 print("suop2, file1, first file is missing,\n");
252 }
253  
254 return ();
255 }
256  
257 =head2 subroutine file2
258  
259 subs file2, fileB, second file with which to operate
260  
261 =cut
262  
263 sub file2 {
264  
265 my ( $self, $file2 ) = @_;
266  
267 if ($file2) {
268  
269 $suop2->{_file2} = $file2;
270 $suop2->{_note} = $suop2->{_note} . ' ' . $suop2->{_file2};
271 $suop2->{_Step} = $suop2->{_Step} . ' ' . $suop2->{_file2};
272  
273 }
274 else {
275 print("suop2, file2, second file is missing,\n");
276 }
277  
278 return ();
279 }
280  
281 =head2 subroutine file_list1
282  
283
284  
285 =cut
286  
287 sub file_list1 {
288  
289 my ( $self, $file_list1 ) = @_;
290  
291 if (length $file_list1) {
292  
293 $suop2->{_file_list1} = $file_list1;
294 # $suop2->{_note} = $suop2->{_note} . ' ' . $suop2->{_file1};
295 # $suop2->{_Step} = $suop2->{_Step} . ' ' . $suop2->{_file1};
296  
297 }
298 else {
299 print("suop2, file_list1, first file is missing,\n");
300 }
301  
302 return ();
303 }
304  
305 =head2 subroutine file_list2
306  
307  
308 =cut
309  
310 sub file_list2 {
311  
312 my ( $self, $file_list2 ) = @_;
313  
314 if (length $file_list2) {
315  
316 $suop2->{_file_list2} = $file_list2;
317 # $suop2->{_note} = $suop2->{_note} . ' ' . $suop2->{_file2};
318 # $suop2->{_Step} = $suop2->{_Step} . ' ' . $suop2->{_file2};
319  
320 }
321 else {
322 print("suop2, file_list2, second file is missing,\n");
323 }
324  
325 return ();
326 }
327  
328 =head2 subroutine fileA
329  
330 subs fileA and file1, first file with which to operate
331  
332 =cut
333  
334 sub fileA {
335  
336 my ( $self, $ref_fileA ) = @_;
337  
338 if ($ref_fileA) {
339  
340 $suop2->{_file1} = $$ref_fileA;
341 $suop2->{_note} = $suop2->{_note} . ' ' . $suop2->{_file1};
342 $suop2->{_Step} = $suop2->{_Step} . ' ' . $suop2->{_file1};
343  
344 }
345 else {
346 print("suop2, fileA, first file is missing,\n");
347 }
348  
349 return ();
350 }
351  
352 =head2 subroutine fileB
353  
354 subs file2, fileB, second file with which to operate
355  
356 =cut
357  
358 sub fileB {
359  
360 my ( $self, $ref_fileB ) = @_;
361  
362 if ($ref_fileB) {
363  
364 $suop2->{_file2} = $$ref_fileB;
365 $suop2->{_note} = $suop2->{_note} . ' ' . $suop2->{_file2};
366 $suop2->{_Step} = $suop2->{_Step} . ' ' . $suop2->{_file2};
367  
368 }
369 else {
370 print("suop2, fileB, second file is missing,\n");
371 }
372  
373 return ();
374 }
375  
376 =head2 sub op
377  
378  
379 =cut
380  
381 sub op {
382  
383 my ( $self, $op ) = @_;
384 if ($op) {
385  
386 $suop2->{_op} = $op;
387  
388 }
389 else {
390 print("suop2, op, missing op,\n");
391 }
392 }
393  
394 =head2 sub trid
395  
396  
397 =cut
398  
399 sub trid {
400  
401 my ( $self, $trid ) = @_;
402 if ($trid) {
403  
404 $suop2->{_trid} = $trid;
405 $suop2->{_note} = $suop2->{_note} . ' trid=' . $suop2->{_trid};
406 $suop2->{_Step} = $suop2->{_Step} . ' trid=' . $suop2->{_trid};
407  
408 }
409 else {
410 print("suop2, trid, missing trid,\n");
411 }
412 }
413  
414 =head2 sub w1
415  
416  
417 =cut
418  
419 sub w1 {
420  
421 my ( $self, $w1 ) = @_;
422 if ($w1) {
423  
424 $suop2->{_w1} = $w1;
425 $suop2->{_note} = $suop2->{_note} . ' w1=' . $suop2->{_w1};
426 $suop2->{_Step} = $suop2->{_Step} . ' w1=' . $suop2->{_w1};
427  
428 }
429 else {
430 print("suop2, w1, missing w1,\n");
431 }
432 }
433  
434 =head2 sub w2
435  
436  
437 =cut
438  
439 sub w2 {
440  
441 my ( $self, $w2 ) = @_;
442 if ($w2) {
443  
444 $suop2->{_w2} = $w2;
445 $suop2->{_note} = $suop2->{_note} . ' w2=' . $suop2->{_w2};
446 $suop2->{_Step} = $suop2->{_Step} . ' w2=' . $suop2->{_w2};
447  
448 }
449 else {
450 print("suop2, w2, missing w2,\n");
451 }
452 }
453  
454 =head2 sub get_max_index
455
456 max index = number of input variables -1
457
458 =cut
459  
460 sub get_max_index {
461 my ($self) = @_;
462  
463 my $max_index = 5;
464  
465 return ($max_index);
466 }
467  
468 1;