lib/App/SeismicUnixGui/sunix/model/sufdmod1.pm untested

filter: Statementstmt 0.0% 0 / 218 Branchbran 0.0% 0 / 58 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 32 Podpod 0.0% 0 / 29 totaltotal 0.0% 0 / 337 CC 30 SCAR 19.1
CC
30
Cov
0%
density_file_bin
12.0
dfile
12.0
velocity_file_bin
12.0
CRAP 6.7
1 package App::SeismicUnixGui::sunix::model::sufdmod1;
2  
3 =head1 DOCUMENTATION
4  
5 =head2 SYNOPSIS
6  
7 PERL PROGRAM NAME: SUFDMOD1 - Finite difference modelling (1-D first order) for the
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 SUFDMOD1 - Finite difference modelling (1-D 1rst order) for the
22 acoustic wave equation "
23  
24 sufdmod1 <vfile >sfile nz= tmax= sz= [optional parameters]
25  
26 Required parameters :
27 L_SU checks to make sure only <vfile and >sfile=is used
28 <vfile binary file containing velocities[nz]
29 >sfile SU file containing seimogram[nt]
30 nz= number of z samples
31 tmax= maximum propagation time
32 sz= z coordinate of source
33  
34 Optional parameters :
35 dz=1 z sampling interval
36 fz=0.0 first depth sample
37 rz=1 coordinate of receiver
38 sz=1 coordinate of source
39 dfile= binary input file containing density[nz]
40 wfile= output file for wave field (snapshots in a SU trace panel)
41 abs=0,1 absorbing conditions on top and bottom
42 styp=0 source type (0: gauss, 1: ricker 1, 2: ricker 2)
43 freq=15.0 approximate source center frequency (Hz)
44 nt=1+tmax/dt number od time samples (dt determined for numerical
45 stability)
46 zt=1 trace undersampling factor for trace and snapshots
47 zd=1 depth undersampling factor for snapshots
48 press=1 to record the pressure field; 0 records the particle
49 velocity
50 verbose=0 =1 for diagnostic messages
51  
52 Notes :
53 This program uses a first order explicit velocity/pressure finite
54 difference equation.
55 The source function is applied on the pressure component.
56 If no density file is given, constant density is assumed
57 Wavefield can be easily viewed with suximage, user must provide f2=0
58 to the ximage program in order to get correct time labelling
59 Seismic trace is shifted in order to get a zero phase source
60 Source begins and stop when it's amplitude is 10^-4 its maximum
61 Time and depth undersampling only modify the output trace and snapshots.
62 These parameters are useful for keeping snapshot file small and
63 the number of samples under SU_NFLTS.
64  
65  
66 =head2 CHANGES and their DATES
67  
68 =cut
69  
70 use Moose;
71 our $VERSION = '0.0.1';
72 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
73 use aliased 'App::SeismicUnixGui::specs::model::sufdmod1_spec';
74  
75 my $get = L_SU_global_constants->new();
76 my $sufdmod1_spec = sufdmod1_spec->new();
77  
78 my $specs = $sufdmod1_spec->variables();
79  
80 my $var = $get->var();
81 my $empty_string = $var->{_empty_string};
82  
83 my $sufdmod1 = {
84 _abs => '',
85 _dfile => '',
86 _dz => '',
87 _freq => '',
88 _fz => '',
89 _nt => '',
90 _nz => '',
91 _press => '',
92 _rz => '',
93 _sfile => '',
94 _styp => '',
95 _sz => '',
96 _tmax => '',
97 _verbose => '',
98 _vfile => '',
99 _wfile => '',
100 _zd => '',
101 _zt => '',
102 _Step => '',
103 _note => '',
104 };
105  
106 =head2 sub Step
107  
108 collects switches and assembles bash instructions
109 by adding the program name
110  
111 =cut
112  
113 sub Step {
114  
115 $sufdmod1->{_Step} = 'sufdmod1' . $sufdmod1->{_Step};
116 return ( $sufdmod1->{_Step} );
117  
118 }
119  
120 =head2 sub note
121  
122 collects switches and assembles bash instructions
123 by adding the program name
124  
125 =cut
126  
127 sub note {
128  
129 $sufdmod1->{_note} = 'sufdmod1' . $sufdmod1->{_note};
130 return ( $sufdmod1->{_note} );
131  
132 }
133  
134 =head2 sub clear
135  
136 =cut
137  
138 sub clear {
139  
140 $sufdmod1->{_abs} = '';
141 $sufdmod1->{_dfile} = '';
142 $sufdmod1->{_dz} = '';
143 $sufdmod1->{_freq} = '';
144 $sufdmod1->{_fz} = '';
145 $sufdmod1->{_nt} = '';
146 $sufdmod1->{_nz} = '';
147 $sufdmod1->{_press} = '';
148 $sufdmod1->{_rz} = '';
149 $sufdmod1->{_sfile} = '';
150 $sufdmod1->{_styp} = '';
151 $sufdmod1->{_sz} = '';
152 $sufdmod1->{_tmax} = '';
153 $sufdmod1->{_verbose} = '';
154 $sufdmod1->{_vfile} = '';
155 $sufdmod1->{_wfile} = '';
156 $sufdmod1->{_zd} = '';
157 $sufdmod1->{_zt} = '';
158 $sufdmod1->{_Step} = '';
159 $sufdmod1->{_note} = '';
160 }
161  
162 =head2 sub abs
163  
164 boundary conditions
165  
166 =cut
167  
168 sub abs {
169  
170 my ( $self, $abs ) = @_;
171 if ( $abs ne $empty_string ) {
172  
173 $sufdmod1->{_abs} = $abs;
174 $sufdmod1->{_note} = $sufdmod1->{_note} . ' abs=' . $sufdmod1->{_abs};
175 $sufdmod1->{_Step} = $sufdmod1->{_Step} . ' abs=' . $sufdmod1->{_abs};
176  
177 }
178 else {
179 print("sufdmod1, abs, missing abs,\n");
180 }
181 }
182  
183 =head2 sub boundary_conditions
184  
185 boundary conditions
186  
187 =cut
188  
189 sub boundary_conditions {
190  
191 my ( $self, $abs ) = @_;
192 if ( $abs ne $empty_string ) {
193  
194 $sufdmod1->{_abs} = $abs;
195 $sufdmod1->{_note} = $sufdmod1->{_note} . ' abs=' . $sufdmod1->{_abs};
196 $sufdmod1->{_Step} = $sufdmod1->{_Step} . ' abs=' . $sufdmod1->{_abs};
197  
198 }
199 else {
200 print("sufdmod1, abs, missing abs,\n");
201 }
202 }
203  
204 =head2 sub density_file_bin
205  
206  
207 =cut
208  
209 sub density_file_bin {
210  
211 my ( $self, $dfile ) = @_;
212 if ( $dfile ne $empty_string ) {
213  
214 my $data_suffix_in = $specs->{_data_suffix_in};
215  
216 if ( $dfile =~ /$data_suffix_in/ ) { # check extension '.bin'
217  
218 $sufdmod1->{_dfile} = $dfile;
219 $sufdmod1->{_note} =
220 $sufdmod1->{_note} . ' dfile=' . $sufdmod1->{_dfile};
221 $sufdmod1->{_Step} =
222 $sufdmod1->{_Step} . ' dfile=' . $sufdmod1->{_dfile};
223  
224 }
225 else {
226 $dfile = $dfile . $data_suffix_in;
227 $sufdmod1->{_dfile} = $dfile;
228 $sufdmod1->{_note} =
229 $sufdmod1->{_note} . ' dfile=' . $sufdmod1->{_dfile};
230 $sufdmod1->{_Step} =
231 $sufdmod1->{_Step} . ' dfile=' . $sufdmod1->{_dfile};
232 }
233 }
234 else {
235 print("sufdmod1, dfile, missing dfile,\n");
236 }
237 }
238  
239 =head2 sub dfile
240  
241  
242 =cut
243  
244 sub dfile {
245  
246 my ( $self, $dfile ) = @_;
247 if ( $dfile ne $empty_string ) {
248  
249 my $data_suffix_in = $specs->{_data_suffix_in};
250  
251 if ( $dfile =~ /$data_suffix_in/ ) { # check extension '.bin'
252  
253 $sufdmod1->{_dfile} = $dfile;
254 $sufdmod1->{_note} =
255 $sufdmod1->{_note} . ' dfile=' . $sufdmod1->{_dfile};
256 $sufdmod1->{_Step} =
257 $sufdmod1->{_Step} . ' dfile=' . $sufdmod1->{_dfile};
258  
259 }
260 else {
261 $dfile = $dfile . $data_suffix_in;
262 $sufdmod1->{_dfile} = $dfile;
263 $sufdmod1->{_note} =
264 $sufdmod1->{_note} . ' dfile=' . $sufdmod1->{_dfile};
265 $sufdmod1->{_Step} =
266 $sufdmod1->{_Step} . ' dfile=' . $sufdmod1->{_dfile};
267 }
268 }
269 else {
270 print("sufdmod1, dfile, missing dfile,\n");
271 }
272 }
273  
274 =head2 sub dz
275  
276  
277 =cut
278  
279 sub dz {
280  
281 my ( $self, $dz ) = @_;
282 if ( $dz ne $empty_string ) {
283  
284 $sufdmod1->{_dz} = $dz;
285 $sufdmod1->{_note} = $sufdmod1->{_note} . ' dz=' . $sufdmod1->{_dz};
286 $sufdmod1->{_Step} = $sufdmod1->{_Step} . ' dz=' . $sufdmod1->{_dz};
287  
288 }
289 else {
290 print("sufdmod1, dz, missing dz,\n");
291 }
292 }
293  
294 =head2 sub freq
295  
296  
297 =cut
298  
299 sub freq {
300  
301 my ( $self, $freq ) = @_;
302 if ( $freq ne $empty_string ) {
303  
304 $sufdmod1->{_freq} = $freq;
305 $sufdmod1->{_note} = $sufdmod1->{_note} . ' freq=' . $sufdmod1->{_freq};
306 $sufdmod1->{_Step} = $sufdmod1->{_Step} . ' freq=' . $sufdmod1->{_freq};
307  
308 }
309 else {
310 print("sufdmod1, freq, missing freq,\n");
311 }
312 }
313  
314 =head2 sub fz
315  
316  
317 =cut
318  
319 sub fz {
320  
321 my ( $self, $fz ) = @_;
322 if ( $fz ne $empty_string ) {
323  
324 $sufdmod1->{_fz} = $fz;
325 $sufdmod1->{_note} = $sufdmod1->{_note} . ' fz=' . $sufdmod1->{_fz};
326 $sufdmod1->{_Step} = $sufdmod1->{_Step} . ' fz=' . $sufdmod1->{_fz};
327  
328 }
329 else {
330 print("sufdmod1, fz, missing fz,\n");
331 }
332 }
333  
334 =head2 sub nt
335  
336  
337 =cut
338  
339 sub nt {
340  
341 my ( $self, $nt ) = @_;
342 if ( $nt ne $empty_string ) {
343  
344 $sufdmod1->{_nt} = $nt;
345 $sufdmod1->{_note} = $sufdmod1->{_note} . ' nt=' . $sufdmod1->{_nt};
346 $sufdmod1->{_Step} = $sufdmod1->{_Step} . ' nt=' . $sufdmod1->{_nt};
347  
348 }
349 else {
350 print("sufdmod1, nt, missing nt,\n");
351 }
352 }
353  
354 =head2 sub nz
355  
356  
357 =cut
358  
359 sub nz {
360  
361 my ( $self, $nz ) = @_;
362 if ( $nz ne $empty_string ) {
363  
364 $sufdmod1->{_nz} = $nz;
365 $sufdmod1->{_note} = $sufdmod1->{_note} . ' nz=' . $sufdmod1->{_nz};
366 $sufdmod1->{_Step} = $sufdmod1->{_Step} . ' nz=' . $sufdmod1->{_nz};
367  
368 }
369 else {
370 print("sufdmod1, nz, missing nz,\n");
371 }
372 }
373  
374 =head2 sub press
375  
376  
377 =cut
378  
379 sub press {
380  
381 my ( $self, $press ) = @_;
382 if ( $press ne $empty_string ) {
383  
384 $sufdmod1->{_press} = $press;
385 $sufdmod1->{_note} =
386 $sufdmod1->{_note} . ' press=' . $sufdmod1->{_press};
387 $sufdmod1->{_Step} =
388 $sufdmod1->{_Step} . ' press=' . $sufdmod1->{_press};
389  
390 }
391 else {
392 print("sufdmod1, press, missing press,\n");
393 }
394 }
395  
396 =head2 sub receiver_depth
397  
398  
399 =cut
400  
401 sub receiver_depth {
402  
403 my ( $self, $rz ) = @_;
404 if ( $rz ne $empty_string ) {
405  
406 $sufdmod1->{_rz} = $rz;
407 $sufdmod1->{_note} = $sufdmod1->{_note} . ' rz=' . $sufdmod1->{_rz};
408 $sufdmod1->{_Step} = $sufdmod1->{_Step} . ' rz=' . $sufdmod1->{_rz};
409  
410 }
411 else {
412 print("sufdmod1, rz, missing rz,\n");
413 }
414 }
415  
416 =head2 sub rz
417  
418  
419 =cut
420  
421 sub rz {
422  
423 my ( $self, $rz ) = @_;
424 if ( $rz ne $empty_string ) {
425  
426 $sufdmod1->{_rz} = $rz;
427 $sufdmod1->{_note} = $sufdmod1->{_note} . ' rz=' . $sufdmod1->{_rz};
428 $sufdmod1->{_Step} = $sufdmod1->{_Step} . ' rz=' . $sufdmod1->{_rz};
429  
430 }
431 else {
432 print("sufdmod1, rz, missing rz,\n");
433 }
434 }
435  
436 =head2 sub source_depth
437  
438  
439 =cut
440  
441 sub source_depth {
442  
443 my ( $self, $sz ) = @_;
444 if ( $sz ne $empty_string ) {
445  
446 $sufdmod1->{_sz} = $sz;
447 $sufdmod1->{_note} = $sufdmod1->{_note} . ' sz=' . $sufdmod1->{_sz};
448 $sufdmod1->{_Step} = $sufdmod1->{_Step} . ' sz=' . $sufdmod1->{_sz};
449  
450 }
451 else {
452 print("sufdmod1, sz, missing sz,\n");
453 }
454 }
455  
456 =head2 sub seismogram_out
457  
458  
459 =cut
460  
461 sub seismogram_out {
462  
463 my ( $self, $sfile ) = @_;
464 if ( $sfile ne $empty_string ) {
465  
466 $sufdmod1->{_sfile} = $sfile;
467 $sufdmod1->{_note} =
468 $sufdmod1->{_note} . ' sfile=' . $sufdmod1->{_sfile};
469 $sufdmod1->{_Step} =
470 $sufdmod1->{_Step} . ' sfile=' . $sufdmod1->{_sfile};
471  
472 }
473 else {
474 print("sufdmod1, sfile, missing sfile,\n");
475 }
476 }
477  
478 =head2 sub sfile
479  
480  
481 =cut
482  
483 sub sfile {
484  
485 my ( $self, $sfile ) = @_;
486 if ( $sfile ne $empty_string ) {
487  
488 $sufdmod1->{_sfile} = $sfile;
489 $sufdmod1->{_note} =
490 $sufdmod1->{_note} . ' sfile=' . $sufdmod1->{_sfile};
491 $sufdmod1->{_Step} =
492 $sufdmod1->{_Step} . ' sfile=' . $sufdmod1->{_sfile};
493  
494 }
495 else {
496 print("sufdmod1, sfile, missing sfile,\n");
497 }
498 }
499  
500 =head2 sub source_type
501  
502  
503 =cut
504  
505 sub source_type {
506  
507 my ( $self, $styp ) = @_;
508 if ( $styp ne $empty_string ) {
509  
510 $sufdmod1->{_styp} = $styp;
511 $sufdmod1->{_note} = $sufdmod1->{_note} . ' styp=' . $sufdmod1->{_styp};
512 $sufdmod1->{_Step} = $sufdmod1->{_Step} . ' styp=' . $sufdmod1->{_styp};
513  
514 }
515 else {
516 print("sufdmod1, styp, missing styp,\n");
517 }
518 }
519  
520 =head2 sub styp
521  
522  
523 =cut
524  
525 sub styp {
526  
527 my ( $self, $styp ) = @_;
528 if ( $styp ne $empty_string ) {
529  
530 $sufdmod1->{_styp} = $styp;
531 $sufdmod1->{_note} = $sufdmod1->{_note} . ' styp=' . $sufdmod1->{_styp};
532 $sufdmod1->{_Step} = $sufdmod1->{_Step} . ' styp=' . $sufdmod1->{_styp};
533  
534 }
535 else {
536 print("sufdmod1, styp, missing styp,\n");
537 }
538 }
539  
540 =head2 sub sz
541  
542  
543 =cut
544  
545 sub sz {
546  
547 my ( $self, $sz ) = @_;
548 if ( $sz ne $empty_string ) {
549  
550 $sufdmod1->{_sz} = $sz;
551 $sufdmod1->{_note} = $sufdmod1->{_note} . ' sz=' . $sufdmod1->{_sz};
552 $sufdmod1->{_Step} = $sufdmod1->{_Step} . ' sz=' . $sufdmod1->{_sz};
553  
554 }
555 else {
556 print("sufdmod1, sz, missing sz,\n");
557 }
558 }
559  
560 =head2 sub tmax
561  
562  
563 =cut
564  
565 sub tmax {
566  
567 my ( $self, $tmax ) = @_;
568 if ( $tmax ne $empty_string ) {
569  
570 $sufdmod1->{_tmax} = $tmax;
571 $sufdmod1->{_note} = $sufdmod1->{_note} . ' tmax=' . $sufdmod1->{_tmax};
572 $sufdmod1->{_Step} = $sufdmod1->{_Step} . ' tmax=' . $sufdmod1->{_tmax};
573  
574 }
575 else {
576 print("sufdmod1, tmax, missing tmax,\n");
577 }
578 }
579  
580 =head2 sub velocity_file_bin
581  
582  
583 =cut
584  
585 sub velocity_file_bin {
586  
587 my ( $self, $vfile ) = @_;
588 if ( $vfile ne $empty_string ) {
589  
590 my $data_suffix_in = $specs->{_data_suffix_in};
591 print("velocity_file_bin, mad it sufdmod1\n");
592  
593 if ( $vfile =~ /$data_suffix_in/ ) { # check extension '.bin'
594  
595 $sufdmod1->{_vfile} = $vfile;
596 $sufdmod1->{_note} =
597 $sufdmod1->{_note} . ' vfile<' . $sufdmod1->{_vfile};
598 $sufdmod1->{_Step} =
599 $sufdmod1->{_Step} . ' vfile<' . $sufdmod1->{_vfile};
600  
601 }
602 else {
603 $vfile = $vfile . $data_suffix_in;
604 $sufdmod1->{_vfile} = $vfile;
605 $sufdmod1->{_note} =
606 $sufdmod1->{_note} . ' vfile<' . $sufdmod1->{_vfile};
607 $sufdmod1->{_Step} =
608 $sufdmod1->{_Step} . ' vfile<' . $sufdmod1->{_vfile};
609 }
610 }
611 else {
612 print("sufdmod1, vfile, missing vfile,\n");
613 }
614 }
615  
616 =head2 sub verbose
617  
618  
619 =cut
620  
621 sub verbose {
622  
623 my ( $self, $verbose ) = @_;
624 if ( $verbose ne $empty_string ) {
625  
626 $sufdmod1->{_verbose} = $verbose;
627 $sufdmod1->{_note} =
628 $sufdmod1->{_note} . ' verbose=' . $sufdmod1->{_verbose};
629 $sufdmod1->{_Step} =
630 $sufdmod1->{_Step} . ' verbose=' . $sufdmod1->{_verbose};
631  
632 }
633 else {
634 print("sufdmod1, verbose, missing verbose,\n");
635 }
636 }
637  
638 =head2 sub vfile
639  
640  
641 =cut
642  
643 =head2 sub vfile
644  
645  
646 =cut
647  
648 sub vfile {
649  
650 my ( $self, $vfile ) = @_;
651 if ( $vfile ne $empty_string ) {
652  
653 my $data_suffix_in = $specs->{_data_suffix_in};
654  
655 if ( $vfile =~ /$data_suffix_in/ ) { # check extension '.bin'
656  
657 $sufdmod1->{_vfile} = $vfile;
658 $sufdmod1->{_note} =
659 $sufdmod1->{_note} . ' vfile<' . $sufdmod1->{_vfile};
660 $sufdmod1->{_Step} =
661 $sufdmod1->{_Step} . ' vfile<' . $sufdmod1->{_vfile};
662  
663 }
664 else {
665 $vfile = $vfile . $data_suffix_in;
666 $sufdmod1->{_vfile} = $vfile;
667 $sufdmod1->{_note} =
668 $sufdmod1->{_note} . ' vfile<' . $sufdmod1->{_vfile};
669 $sufdmod1->{_Step} =
670 $sufdmod1->{_Step} . ' vfile<' . $sufdmod1->{_vfile};
671 }
672 }
673 else {
674 print("sufdmod1, vfile, missing vfile,\n");
675 }
676 }
677  
678 =head2 sub wfile
679  
680  
681 =cut
682  
683 sub wfile {
684  
685 my ( $self, $wfile ) = @_;
686 if ( $wfile ne $empty_string ) {
687  
688 $sufdmod1->{_wfile} = $wfile;
689 $sufdmod1->{_note} =
690 $sufdmod1->{_note} . ' wfile=' . $sufdmod1->{_wfile};
691 $sufdmod1->{_Step} =
692 $sufdmod1->{_Step} . ' wfile=' . $sufdmod1->{_wfile};
693  
694 }
695 else {
696 print("sufdmod1, wfile, missing wfile,\n");
697 }
698 }
699  
700 =head2 sub zd
701  
702  
703 =cut
704  
705 sub zd {
706  
707 my ( $self, $zd ) = @_;
708 if ( $zd ne $empty_string ) {
709  
710 $sufdmod1->{_zd} = $zd;
711 $sufdmod1->{_note} = $sufdmod1->{_note} . ' zd=' . $sufdmod1->{_zd};
712 $sufdmod1->{_Step} = $sufdmod1->{_Step} . ' zd=' . $sufdmod1->{_zd};
713  
714 }
715 else {
716 print("sufdmod1, zd, missing zd,\n");
717 }
718 }
719  
720 =head2 sub zt
721  
722  
723 =cut
724  
725 sub zt {
726  
727 my ( $self, $zt ) = @_;
728 if ( $zt ne $empty_string ) {
729  
730 $sufdmod1->{_zt} = $zt;
731 $sufdmod1->{_note} = $sufdmod1->{_note} . ' zt=' . $sufdmod1->{_zt};
732 $sufdmod1->{_Step} = $sufdmod1->{_Step} . ' zt=' . $sufdmod1->{_zt};
733  
734 }
735 else {
736 print("sufdmod1, zt, missing zt,\n");
737 }
738 }
739  
740 =head2 sub get_max_index
741  
742 max index = number of input variables -1
743
744 =cut
745  
746 sub get_max_index {
747 my ($self) = @_;
748 my $max_index = 17;
749  
750 return ($max_index);
751 }
752  
753 1;