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

filter: Statementstmt 0.0% 0 / 90 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 16 Podpod 0.0% 0 / 12 totaltotal 0.0% 0 / 134 CC 9 SCAR 15.4
CC
9
Cov
0%
A
6.0
a
6.0
b
6.0
CRAP 4.7
1 package App::SeismicUnixGui::sunix::statsMath::suacorfrac;
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 SUACORFRAC -- general FRACtional Auto-CORrelation/convolution
25  
26  
27  
28 suacorfrac power= [optional parameters] <indata >outdata
29  
30  
31  
32 Optional parameters:
33  
34 a=0 exponent of complex amplitude
35  
36 b=0 multiplier of complex phase
37  
38 dt=(from header) time sample interval (in seconds)
39  
40 verbose=0 =1 for advisory messages
41  
42 ntout=tr.ns number of time samples output
43  
44 sym=0 if non-zero, produce a symmetric output from
45  
46 lag -(ntout-1)/2 to lag +(ntout-1)/2
47  
48 Notes:
49  
50 The calculation is performed in the frequency domain.
51  
52 The fractional autocorrelation/convolution is obtained by raising
53  
54 Fourier coefficients to separate real powers
55  
56 (a,b) for amp and phase:
57  
58 Aout exp[-i Pout] = Ain Ain^a exp[-i (1+b) Pin]
59  
60 where A=amplitude P=phase.
61  
62 Some special cases:
63  
64 (a,b)=(1,1) --> auto-correlation
65  
66 (a,b)=(0.5,0.5) --> half-auto-correlation
67  
68 (a,b)=(0,0) --> no change to data
69  
70 (a,b)=(0.5,-0.5)--> half-auto-convolution
71  
72 (a,b)=(1,-1) --> auto-convolution
73  
74  
75  
76  
77  
78 Credits:
79  
80 UHouston: Chris Liner, Sept 2009
81  
82 CWP: Based on Hale's crpow
83  
84  
85  
86 Trace header fields accessed: ns, dt, trid, d1
87  
88 /
89  
90 =head2 User's notes (Juan Lorenzo)
91 untested
92  
93 =cut
94  
95  
96 =head2 CHANGES and their DATES
97  
98 =cut
99  
100 use Moose;
101 our $VERSION = '0.0.1';
102  
103  
104 =head2 Import packages
105  
106 =cut
107  
108 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
109  
110 use App::SeismicUnixGui::misc::SeismicUnix qw($in $out $on $go $to $suffix_ascii $off $suffix_su $suffix_bin);
111 use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config';
112  
113  
114 =head2 instantiation of packages
115  
116 =cut
117  
118 my $get = L_SU_global_constants->new();
119 my $Project = Project_config->new();
120 my $DATA_SEISMIC_SU = $Project->DATA_SEISMIC_SU();
121 my $DATA_SEISMIC_BIN = $Project->DATA_SEISMIC_BIN();
122 my $DATA_SEISMIC_TXT = $Project->DATA_SEISMIC_TXT();
123  
124 my $var = $get->var();
125 my $on = $var->{_on};
126 my $off = $var->{_off};
127 my $true = $var->{_true};
128 my $false = $var->{_false};
129 my $empty_string = $var->{_empty_string};
130  
131 =head2 Encapsulated
132 hash of private variables
133  
134 =cut
135  
136 my $suacorfrac = {
137 _A => '',
138 _a => '',
139 _b => '',
140 _dt => '',
141 _ntout => '',
142 _power => '',
143 _sym => '',
144 _verbose => '',
145 _Step => '',
146 _note => '',
147  
148 };
149  
150 =head2 sub Step
151  
152 collects switches and assembles bash instructions
153 by adding the program name
154  
155 =cut
156  
157 sub Step {
158  
159 $suacorfrac->{_Step} = 'suacorfrac'.$suacorfrac->{_Step};
160 return ( $suacorfrac->{_Step} );
161  
162 }
163  
164  
165 =head2 sub note
166  
167 collects switches and assembles bash instructions
168 by adding the program name
169  
170 =cut
171  
172 sub note {
173  
174 $suacorfrac->{_note} = 'suacorfrac'.$suacorfrac->{_note};
175 return ( $suacorfrac->{_note} );
176  
177 }
178  
179  
180  
181 =head2 sub clear
182  
183 =cut
184  
185 sub clear {
186  
187 $suacorfrac->{_A} = '';
188 $suacorfrac->{_a} = '';
189 $suacorfrac->{_b} = '';
190 $suacorfrac->{_dt} = '';
191 $suacorfrac->{_ntout} = '';
192 $suacorfrac->{_power} = '';
193 $suacorfrac->{_sym} = '';
194 $suacorfrac->{_verbose} = '';
195 $suacorfrac->{_Step} = '';
196 $suacorfrac->{_note} = '';
197 }
198  
199  
200 =head2 sub A
201  
202  
203 =cut
204  
205 sub A {
206  
207 my ( $self,$A ) = @_;
208 if ( $A ne $empty_string ) {
209  
210 $suacorfrac->{_A} = $A;
211 $suacorfrac->{_note} = $suacorfrac->{_note}.' A='.$suacorfrac->{_A};
212 $suacorfrac->{_Step} = $suacorfrac->{_Step}.' A='.$suacorfrac->{_A};
213  
214 } else {
215 print("suacorfrac, A, missing A,\n");
216 }
217 }
218  
219  
220 =head2 sub a
221  
222  
223 =cut
224  
225 sub a {
226  
227 my ( $self,$a ) = @_;
228 if ( $a ne $empty_string ) {
229  
230 $suacorfrac->{_a} = $a;
231 $suacorfrac->{_note} = $suacorfrac->{_note}.' a='.$suacorfrac->{_a};
232 $suacorfrac->{_Step} = $suacorfrac->{_Step}.' a='.$suacorfrac->{_a};
233  
234 } else {
235 print("suacorfrac, a, missing a,\n");
236 }
237 }
238  
239  
240 =head2 sub b
241  
242  
243 =cut
244  
245 sub b {
246  
247 my ( $self,$b ) = @_;
248 if ( $b ne $empty_string ) {
249  
250 $suacorfrac->{_b} = $b;
251 $suacorfrac->{_note} = $suacorfrac->{_note}.' b='.$suacorfrac->{_b};
252 $suacorfrac->{_Step} = $suacorfrac->{_Step}.' b='.$suacorfrac->{_b};
253  
254 } else {
255 print("suacorfrac, b, missing b,\n");
256 }
257 }
258  
259  
260 =head2 sub dt
261  
262  
263 =cut
264  
265 sub dt {
266  
267 my ( $self,$dt ) = @_;
268 if ( $dt ne $empty_string ) {
269  
270 $suacorfrac->{_dt} = $dt;
271 $suacorfrac->{_note} = $suacorfrac->{_note}.' dt='.$suacorfrac->{_dt};
272 $suacorfrac->{_Step} = $suacorfrac->{_Step}.' dt='.$suacorfrac->{_dt};
273  
274 } else {
275 print("suacorfrac, dt, missing dt,\n");
276 }
277 }
278  
279  
280 =head2 sub ntout
281  
282  
283 =cut
284  
285 sub ntout {
286  
287 my ( $self,$ntout ) = @_;
288 if ( $ntout ne $empty_string ) {
289  
290 $suacorfrac->{_ntout} = $ntout;
291 $suacorfrac->{_note} = $suacorfrac->{_note}.' ntout='.$suacorfrac->{_ntout};
292 $suacorfrac->{_Step} = $suacorfrac->{_Step}.' ntout='.$suacorfrac->{_ntout};
293  
294 } else {
295 print("suacorfrac, ntout, missing ntout,\n");
296 }
297 }
298  
299  
300 =head2 sub power
301  
302  
303 =cut
304  
305 sub power {
306  
307 my ( $self,$power ) = @_;
308 if ( $power ne $empty_string ) {
309  
310 $suacorfrac->{_power} = $power;
311 $suacorfrac->{_note} = $suacorfrac->{_note}.' power='.$suacorfrac->{_power};
312 $suacorfrac->{_Step} = $suacorfrac->{_Step}.' power='.$suacorfrac->{_power};
313  
314 } else {
315 print("suacorfrac, power, missing power,\n");
316 }
317 }
318  
319  
320 =head2 sub sym
321  
322  
323 =cut
324  
325 sub sym {
326  
327 my ( $self,$sym ) = @_;
328 if ( $sym ne $empty_string ) {
329  
330 $suacorfrac->{_sym} = $sym;
331 $suacorfrac->{_note} = $suacorfrac->{_note}.' sym='.$suacorfrac->{_sym};
332 $suacorfrac->{_Step} = $suacorfrac->{_Step}.' sym='.$suacorfrac->{_sym};
333  
334 } else {
335 print("suacorfrac, sym, missing sym,\n");
336 }
337 }
338  
339  
340 =head2 sub verbose
341  
342  
343 =cut
344  
345 sub verbose {
346  
347 my ( $self,$verbose ) = @_;
348 if ( $verbose ne $empty_string ) {
349  
350 $suacorfrac->{_verbose} = $verbose;
351 $suacorfrac->{_note} = $suacorfrac->{_note}.' verbose='.$suacorfrac->{_verbose};
352 $suacorfrac->{_Step} = $suacorfrac->{_Step}.' verbose='.$suacorfrac->{_verbose};
353  
354 } else {
355 print("suacorfrac, verbose, missing verbose,\n");
356 }
357 }
358  
359  
360 =head2 sub get_max_index
361  
362 max index = number of input variables -1
363
364 =cut
365
366 sub get_max_index {
367 my ($self) = @_;
368 my $max_index = 6;
369  
370 return($max_index);
371 }
372
373
374 1;