lib/App/SeismicUnixGui/sunix/par/unisam.pm untested

filter: Statementstmt 0.0% 0 / 146 Branchbran 0.0% 0 / 36 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 24 Podpod 0.0% 0 / 22 totaltotal 0.0% 0 / 228 CC 19 SCAR 16.9
CC
19
Cov
0%
amp
6.0
dxout
6.0
fxout
6.0
CRAP 5.4
1 package App::SeismicUnixGui::sunix::par::unisam;
2  
3  
4 =head1 DOCUMENTATION
5  
6 =head2 SYNOPSIS
7  
8 PERL PROGRAM NAME: UNISAM - UNIformly SAMple a function y(x) specified as x,y pairs
9 AUTHOR: Juan Lorenzo (Perl module only)
10 DATE:
11 DESCRIPTION:
12 Version:
13  
14 =head2 USE
15  
16 =head3 NOTES
17  
18 =head4 Examples
19  
20 =head3 SEISMIC UNIX NOTES
21  
22 UNISAM - UNIformly SAMple a function y(x) specified as x,y pairs
23  
24 unisam xin= yin= nout= [optional parameters] >binaryfile
25 ... or ...
26 unisam xfile= yfile= npairs= nout= [optional parameters] >binaryfile
27 ... or ...
28 unisam xyfile= npairs= nout= [optional parameters] >binaryfile
29  
30 Required Parameters:
31 xin=,,, array of x values (number of xin = number of yin)
32 yin=,,, array of y values (number of yin = number of xin)
33 ... or
34 xfile= binary file of x values
35 yfile= binary file of y values
36 ... or
37 xyfile= binary file of x,y pairs
38 npairs= number of pairs input (active only if xfile= and yfile=
39 or xyfile= are set)
40  
41 nout= number of y values output to binary file
42  
43 Optional Parameters:
44 dxout=1.0 output x sampling interval
45 fxout=0.0 output first x
46 method=linear =linear for linear interpolation (continuous y)
47 =mono for monotonic cubic interpolation (continuous y')
48 =akima for Akima's cubic interpolation (continuous y')
49 =spline for cubic spline interpolation (continuous y'')
50 isint=,,, where these sine interpolations to apply
51 amp=,,, amplitude of sine interpolations
52 phase0=,,, starting phase (defaults: 0,0,0,...,0)
53 totalphase=,,, total phase (default pi,pi,pi,...,pi.)
54 nwidth=0 apply window smoothing if nwidth>0
55 sloth=0 apply interpolation in input (velocities)
56 =1 apply interpolation to 1/input (slowness),
57 =2 apply interpolation to 1/input (sloth), and write
58 out velocities in each case.
59 smooth=0 apply damped least squares smoothing to output
60 r=10 ... damping coefficient, only active when smooth=1
61  
62  
63 Author: Dave Hale, Colorado School of Mines, 07/07/89
64 Zhaobo Meng, Colorado School of Mines,
65 added sine interpolation and window smoothing, 09/16/96
66 CWP: John Stockwell, added file input options, 24 Nov 1997
67  
68 Remarks: In interpolation, suppose you need 2 pieces of
69 sine interpolation before index 3 to 4, and index 20 to 21
70 then set: isint=3,20. The sine interpolations use a sine
71 function with starting phase being phase0, total phase
72 being totalphase (i.e. ending phase being phase0+totalphase
73 for each interpolation).
74
75  
76 =head2 CHANGES and their DATES
77  
78 =cut
79 use Moose;
80 our $VERSION = '0.0.1';
81 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
82  
83 my $get = L_SU_global_constants->new();
84  
85 my $var = $get->var();
86 my $empty_string = $var->{_empty_string};
87  
88  
89 my $unisam = {
90 _amp => '',
91 _dxout => '',
92 _fxout => '',
93 _isint => '',
94 _method => '',
95 _nout => '',
96 _npairs => '',
97 _nwidth => '',
98 _phase0 => '',
99 _r => '',
100 _sloth => '',
101 _smooth => '',
102 _totalphase => '',
103 _xfile => '',
104 _xin => '',
105 _xyfile => '',
106 _yfile => '',
107 _yin => '',
108 _Step => '',
109 _note => '',
110 };
111  
112  
113 =head2 sub Step
114  
115 collects switches and assembles bash instructions
116 by adding the program name
117  
118 =cut
119  
120 sub Step {
121  
122 $unisam->{_Step} = 'unisam'.$unisam->{_Step};
123 return ( $unisam->{_Step} );
124  
125 }
126  
127  
128 =head2 sub note
129  
130 collects switches and assembles bash instructions
131 by adding the program name
132  
133 =cut
134  
135 sub note {
136  
137 $unisam->{_note} = 'unisam'.$unisam->{_note};
138 return ( $unisam->{_note} );
139  
140 }
141  
142  
143 =head2 sub clear
144  
145 =cut
146  
147 sub clear {
148  
149 $unisam->{_amp} = '';
150 $unisam->{_dxout} = '';
151 $unisam->{_fxout} = '';
152 $unisam->{_isint} = '';
153 $unisam->{_method} = '';
154 $unisam->{_nout} = '';
155 $unisam->{_npairs} = '';
156 $unisam->{_nwidth} = '';
157 $unisam->{_phase0} = '';
158 $unisam->{_r} = '';
159 $unisam->{_sloth} = '';
160 $unisam->{_smooth} = '';
161 $unisam->{_totalphase} = '';
162 $unisam->{_xfile} = '';
163 $unisam->{_xin} = '';
164 $unisam->{_xyfile} = '';
165 $unisam->{_yfile} = '';
166 $unisam->{_yin} = '';
167 $unisam->{_Step} = '';
168 $unisam->{_note} = '';
169 }
170  
171  
172 =head2 sub amp
173  
174  
175 =cut
176  
177 sub amp {
178  
179 my ( $self,$amp ) = @_;
180 if ( $amp ne $empty_string ) {
181  
182 $unisam->{_amp} = $amp;
183 $unisam->{_note} = $unisam->{_note}.' amp='.$unisam->{_amp};
184 $unisam->{_Step} = $unisam->{_Step}.' amp='.$unisam->{_amp};
185  
186 } else {
187 print("unisam, amp, missing amp,\n");
188 }
189 }
190  
191  
192 =head2 sub dxout
193  
194  
195 =cut
196  
197 sub dxout {
198  
199 my ( $self,$dxout ) = @_;
200 if ( $dxout ne $empty_string ) {
201  
202 $unisam->{_dxout} = $dxout;
203 $unisam->{_note} = $unisam->{_note}.' dxout='.$unisam->{_dxout};
204 $unisam->{_Step} = $unisam->{_Step}.' dxout='.$unisam->{_dxout};
205  
206 } else {
207 print("unisam, dxout, missing dxout,\n");
208 }
209 }
210  
211  
212 =head2 sub fxout
213  
214  
215 =cut
216  
217 sub fxout {
218  
219 my ( $self,$fxout ) = @_;
220 if ( $fxout ne $empty_string ) {
221  
222 $unisam->{_fxout} = $fxout;
223 $unisam->{_note} = $unisam->{_note}.' fxout='.$unisam->{_fxout};
224 $unisam->{_Step} = $unisam->{_Step}.' fxout='.$unisam->{_fxout};
225  
226 } else {
227 print("unisam, fxout, missing fxout,\n");
228 }
229 }
230  
231  
232 =head2 sub isint
233  
234  
235 =cut
236  
237 sub isint {
238  
239 my ( $self,$isint ) = @_;
240 if ( $isint ne $empty_string ) {
241  
242 $unisam->{_isint} = $isint;
243 $unisam->{_note} = $unisam->{_note}.' isint='.$unisam->{_isint};
244 $unisam->{_Step} = $unisam->{_Step}.' isint='.$unisam->{_isint};
245  
246 } else {
247 print("unisam, isint, missing isint,\n");
248 }
249 }
250  
251  
252 =head2 sub method
253  
254  
255 =cut
256  
257 sub method {
258  
259 my ( $self,$method ) = @_;
260 if ( $method ne $empty_string ) {
261  
262 $unisam->{_method} = $method;
263 $unisam->{_note} = $unisam->{_note}.' method='.$unisam->{_method};
264 $unisam->{_Step} = $unisam->{_Step}.' method='.$unisam->{_method};
265  
266 } else {
267 print("unisam, method, missing method,\n");
268 }
269 }
270  
271  
272 =head2 sub nout
273  
274  
275 =cut
276  
277 sub nout {
278  
279 my ( $self,$nout ) = @_;
280 if ( $nout ne $empty_string ) {
281  
282 $unisam->{_nout} = $nout;
283 $unisam->{_note} = $unisam->{_note}.' nout='.$unisam->{_nout};
284 $unisam->{_Step} = $unisam->{_Step}.' nout='.$unisam->{_nout};
285  
286 } else {
287 print("unisam, nout, missing nout,\n");
288 }
289 }
290  
291  
292 =head2 sub npairs
293  
294  
295 =cut
296  
297 sub npairs {
298  
299 my ( $self,$npairs ) = @_;
300 if ( $npairs ne $empty_string ) {
301  
302 $unisam->{_npairs} = $npairs;
303 $unisam->{_note} = $unisam->{_note}.' npairs='.$unisam->{_npairs};
304 $unisam->{_Step} = $unisam->{_Step}.' npairs='.$unisam->{_npairs};
305  
306 } else {
307 print("unisam, npairs, missing npairs,\n");
308 }
309 }
310  
311  
312 =head2 sub nwidth
313  
314  
315 =cut
316  
317 sub nwidth {
318  
319 my ( $self,$nwidth ) = @_;
320 if ( $nwidth ne $empty_string ) {
321  
322 $unisam->{_nwidth} = $nwidth;
323 $unisam->{_note} = $unisam->{_note}.' nwidth='.$unisam->{_nwidth};
324 $unisam->{_Step} = $unisam->{_Step}.' nwidth='.$unisam->{_nwidth};
325  
326 } else {
327 print("unisam, nwidth, missing nwidth,\n");
328 }
329 }
330  
331  
332 =head2 sub phase0
333  
334  
335 =cut
336  
337 sub phase0 {
338  
339 my ( $self,$phase0 ) = @_;
340 if ( $phase0 ne $empty_string ) {
341  
342 $unisam->{_phase0} = $phase0;
343 $unisam->{_note} = $unisam->{_note}.' phase0='.$unisam->{_phase0};
344 $unisam->{_Step} = $unisam->{_Step}.' phase0='.$unisam->{_phase0};
345  
346 } else {
347 print("unisam, phase0, missing phase0,\n");
348 }
349 }
350  
351  
352 =head2 sub r
353  
354  
355 =cut
356  
357 sub r {
358  
359 my ( $self,$r ) = @_;
360 if ( $r ne $empty_string ) {
361  
362 $unisam->{_r} = $r;
363 $unisam->{_note} = $unisam->{_note}.' r='.$unisam->{_r};
364 $unisam->{_Step} = $unisam->{_Step}.' r='.$unisam->{_r};
365  
366 } else {
367 print("unisam, r, missing r,\n");
368 }
369 }
370  
371  
372 =head2 sub sloth
373  
374  
375 =cut
376  
377 sub sloth {
378  
379 my ( $self,$sloth ) = @_;
380 if ( $sloth ne $empty_string ) {
381  
382 $unisam->{_sloth} = $sloth;
383 $unisam->{_note} = $unisam->{_note}.' sloth='.$unisam->{_sloth};
384 $unisam->{_Step} = $unisam->{_Step}.' sloth='.$unisam->{_sloth};
385  
386 } else {
387 print("unisam, sloth, missing sloth,\n");
388 }
389 }
390  
391  
392 =head2 sub smooth
393  
394  
395 =cut
396  
397 sub smooth {
398  
399 my ( $self,$smooth ) = @_;
400 if ( $smooth ne $empty_string ) {
401  
402 $unisam->{_smooth} = $smooth;
403 $unisam->{_note} = $unisam->{_note}.' smooth='.$unisam->{_smooth};
404 $unisam->{_Step} = $unisam->{_Step}.' smooth='.$unisam->{_smooth};
405  
406 } else {
407 print("unisam, smooth, missing smooth,\n");
408 }
409 }
410  
411  
412 =head2 sub totalphase
413  
414  
415 =cut
416  
417 sub totalphase {
418  
419 my ( $self,$totalphase ) = @_;
420 if ( $totalphase ne $empty_string ) {
421  
422 $unisam->{_totalphase} = $totalphase;
423 $unisam->{_note} = $unisam->{_note}.' totalphase='.$unisam->{_totalphase};
424 $unisam->{_Step} = $unisam->{_Step}.' totalphase='.$unisam->{_totalphase};
425  
426 } else {
427 print("unisam, totalphase, missing totalphase,\n");
428 }
429 }
430  
431  
432 =head2 sub xfile
433  
434  
435 =cut
436  
437 sub xfile {
438  
439 my ( $self,$xfile ) = @_;
440 if ( $xfile ne $empty_string ) {
441  
442 $unisam->{_xfile} = $xfile;
443 $unisam->{_note} = $unisam->{_note}.' xfile='.$unisam->{_xfile};
444 $unisam->{_Step} = $unisam->{_Step}.' xfile='.$unisam->{_xfile};
445  
446 } else {
447 print("unisam, xfile, missing xfile,\n");
448 }
449 }
450  
451  
452 =head2 sub xin
453  
454  
455 =cut
456  
457 sub xin {
458  
459 my ( $self,$xin ) = @_;
460 if ( $xin ne $empty_string ) {
461  
462 $unisam->{_xin} = $xin;
463 $unisam->{_note} = $unisam->{_note}.' xin='.$unisam->{_xin};
464 $unisam->{_Step} = $unisam->{_Step}.' xin='.$unisam->{_xin};
465  
466 } else {
467 print("unisam, xin, missing xin,\n");
468 }
469 }
470  
471  
472 =head2 sub xyfile
473  
474  
475 =cut
476  
477 sub xyfile {
478  
479 my ( $self,$xyfile ) = @_;
480 if ( $xyfile ne $empty_string ) {
481  
482 $unisam->{_xyfile} = $xyfile;
483 $unisam->{_note} = $unisam->{_note}.' xyfile='.$unisam->{_xyfile};
484 $unisam->{_Step} = $unisam->{_Step}.' xyfile='.$unisam->{_xyfile};
485  
486 } else {
487 print("unisam, xyfile, missing xyfile,\n");
488 }
489 }
490  
491  
492 =head2 sub yfile
493  
494  
495 =cut
496  
497 sub yfile {
498  
499 my ( $self,$yfile ) = @_;
500 if ( $yfile ne $empty_string ) {
501  
502 $unisam->{_yfile} = $yfile;
503 $unisam->{_note} = $unisam->{_note}.' yfile='.$unisam->{_yfile};
504 $unisam->{_Step} = $unisam->{_Step}.' yfile='.$unisam->{_yfile};
505  
506 } else {
507 print("unisam, yfile, missing yfile,\n");
508 }
509 }
510  
511  
512 =head2 sub yin
513  
514  
515 =cut
516  
517 sub yin {
518  
519 my ( $self,$yin ) = @_;
520 if ( $yin ne $empty_string ) {
521  
522 $unisam->{_yin} = $yin;
523 $unisam->{_note} = $unisam->{_note}.' yin='.$unisam->{_yin};
524 $unisam->{_Step} = $unisam->{_Step}.' yin='.$unisam->{_yin};
525  
526 } else {
527 print("unisam, yin, missing yin,\n");
528 }
529 }
530  
531  
532 =head2 sub get_max_index
533
534 max index = number of input variables -1
535
536 =cut
537
538 sub get_max_index {
539 my ($self) = @_;
540
541 my $max_index = 17;
542
543 return($max_index);
544 }
545
546
547 1;