lib/App/SeismicUnixGui/sunix/transform/suamp.pm untested

filter: Statementstmt 0.0% 0 / 64 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 11 totaltotal 0.0% 0 / 101 CC 8 SCAR 16.0
CC
8
Cov
0%
jack
6.0
mode
6.0
r
6.0
CRAP 4.9
1 package App::SeismicUnixGui::sunix::transform::suamp;
2  
3 =head1 DOCUMENTATION
4  
5 =head2 SYNOPSIS
6  
7 PERL PROGRAM NAME: SUAMP - output amp, phase, real or imag trace from
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 SUAMP - output amp, phase, real or imag trace from
22 (frequency, x) domain data
23  
24 suamp <stdin >stdout mode=amp
25  
26 Required parameters:
27 none
28 Optional parameter:
29 mode=amp output flag
30 =amp output amplitude traces
31 =logamp output log(amplitude) traces
32 =phase output phase traces
33 =ouphase output unwrapped phase traces (oppenheim)
34 =suphase output unwrapped phase traces (simple)
35 =real output real parts
36 =imag output imag parts
37 jack=0 =1 divide value at zero frequency by 2
38 (operative only for mode=amp)
39  
40 .... phase unwrapping options .....
41 unwrap=1 |dphase| > pi/unwrap constitutes a phase wrapping
42 (operative only for mode=suphase)
43 trend=1 remove linear trend from the unwrapped phase
44 zeromean=0 assume phase(0)=0.0, else assume phase is zero mean
45 smooth=0 apply damped least squares smoothing to unwrapped phase
46 r=10.0 ... damping coefficient, only active when smooth=1
47  
48 Notes:
49 The trace returned is half length from 0 to Nyquist.
50  
51 Example:
52 sufft <data | suamp >amp_traces
53 Example:
54 sufft < data > complex_traces
55 suamp < complex_traces mode=real > real_traces
56 suamp < complex_traces mode=imag > imag_traces
57  
58 Note: the inverse of the above operation is:
59 suop2 real_traces imag_traces op=zipper > complex_traces
60  
61 Note: Explanation of jack=1
62 The amplitude spectrum is the modulus of the complex output of
63 the fft. f(0) is thus the average over the range of integration
64 of the transform. For causal functions, or equivalently, half
65 transforms, f(0) is 1/2 of the average over the full range.
66 Most oscillatory functions encountered in wave applications are
67 zero mean, so this is usually not an issue.
68  
69 Note: Phase unwrapping:
70  
71 The mode=ouphase uses the phase unwrapping method of Oppenheim and
72 Schaffer, 1975.
73 The mode=suphase generates unwrapped phase assuming that jumps
74 in phase larger than pi/unwrap constitute a phase wrapping.
75  
76 Credits:
77 CWP: Shuki Ronen, Jack K. Cohen c.1986
78  
79 Notes:
80 If efficiency becomes important consider inverting main loop
81 and repeating extraction code within the branches of the switch.
82  
83 Trace header fields accessed: ns, trid
84 Trace header fields modified: ns, trid
85  
86 =head2 CHANGES and their DATES
87  
88 =cut
89  
90 use Moose;
91 our $VERSION = '0.0.1';
92  
93 my $suamp = {
94 _jack => '',
95 _mode => '',
96 _op => '',
97 _r => '',
98 _smooth => '',
99 _trend => '',
100 _unwrap => '',
101 _zeromean => '',
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 $suamp->{_Step} = 'suamp' . $suamp->{_Step};
116 return ( $suamp->{_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 $suamp->{_note} = 'suamp' . $suamp->{_note};
130 return ( $suamp->{_note} );
131  
132 }
133  
134 =head2 sub clear
135  
136 =cut
137  
138 sub clear {
139  
140 $suamp->{_jack} = '';
141 $suamp->{_mode} = '';
142 $suamp->{_op} = '';
143 $suamp->{_r} = '';
144 $suamp->{_smooth} = '';
145 $suamp->{_trend} = '';
146 $suamp->{_unwrap} = '';
147 $suamp->{_zeromean} = '';
148 $suamp->{_Step} = '';
149 $suamp->{_note} = '';
150 }
151  
152 =head2 sub jack
153  
154  
155 =cut
156  
157 sub jack {
158  
159 my ( $self, $jack ) = @_;
160 if ($jack) {
161  
162 $suamp->{_jack} = $jack;
163 $suamp->{_note} = $suamp->{_note} . ' jack=' . $suamp->{_jack};
164 $suamp->{_Step} = $suamp->{_Step} . ' jack=' . $suamp->{_jack};
165  
166 }
167 else {
168 print("suamp, jack, missing jack,\n");
169 }
170 }
171  
172 =head2 sub mode
173  
174  
175 =cut
176  
177 sub mode {
178  
179 my ( $self, $mode ) = @_;
180 if ($mode) {
181  
182 $suamp->{_mode} = $mode;
183 $suamp->{_note} = $suamp->{_note} . ' mode=' . $suamp->{_mode};
184 $suamp->{_Step} = $suamp->{_Step} . ' mode=' . $suamp->{_mode};
185  
186 }
187 else {
188 print("suamp, mode, missing mode,\n");
189 }
190 }
191  
192  
193 =head2 sub r
194  
195  
196 =cut
197  
198 sub r {
199  
200 my ( $self, $r ) = @_;
201 if ($r) {
202  
203 $suamp->{_r} = $r;
204 $suamp->{_note} = $suamp->{_note} . ' r=' . $suamp->{_r};
205 $suamp->{_Step} = $suamp->{_Step} . ' r=' . $suamp->{_r};
206  
207 }
208 else {
209 print("suamp, r, missing r,\n");
210 }
211 }
212  
213 =head2 sub smooth
214  
215  
216 =cut
217  
218 sub smooth {
219  
220 my ( $self, $smooth ) = @_;
221 if ($smooth) {
222  
223 $suamp->{_smooth} = $smooth;
224 $suamp->{_note} = $suamp->{_note} . ' smooth=' . $suamp->{_smooth};
225 $suamp->{_Step} = $suamp->{_Step} . ' smooth=' . $suamp->{_smooth};
226  
227 }
228 else {
229 print("suamp, smooth, missing smooth,\n");
230 }
231 }
232  
233 =head2 sub trend
234  
235  
236 =cut
237  
238 sub trend {
239  
240 my ( $self, $trend ) = @_;
241 if ($trend) {
242  
243 $suamp->{_trend} = $trend;
244 $suamp->{_note} = $suamp->{_note} . ' trend=' . $suamp->{_trend};
245 $suamp->{_Step} = $suamp->{_Step} . ' trend=' . $suamp->{_trend};
246  
247 }
248 else {
249 print("suamp, trend, missing trend,\n");
250 }
251 }
252  
253 =head2 sub unwrap
254  
255  
256 =cut
257  
258 sub unwrap {
259  
260 my ( $self, $unwrap ) = @_;
261 if ($unwrap) {
262  
263 $suamp->{_unwrap} = $unwrap;
264 $suamp->{_note} = $suamp->{_note} . ' unwrap=' . $suamp->{_unwrap};
265 $suamp->{_Step} = $suamp->{_Step} . ' unwrap=' . $suamp->{_unwrap};
266  
267 }
268 else {
269 print("suamp, unwrap, missing unwrap,\n");
270 }
271 }
272  
273 =head2 sub zeromean
274  
275  
276 =cut
277  
278 sub zeromean {
279  
280 my ( $self, $zeromean ) = @_;
281 if ($zeromean) {
282  
283 $suamp->{_zeromean} = $zeromean;
284 $suamp->{_note} =
285 $suamp->{_note} . ' zeromean=' . $suamp->{_zeromean};
286 $suamp->{_Step} =
287 $suamp->{_Step} . ' zeromean=' . $suamp->{_zeromean};
288  
289 }
290 else {
291 print("suamp, zeromean, missing zeromean,\n");
292 }
293 }
294  
295 =head2 sub get_max_index
296
297 max index = number of input variables -1
298
299 =cut
300  
301 sub get_max_index {
302 my ($self) = @_;
303  
304 my $max_index = 6;
305  
306 return ($max_index);
307 }
308  
309 1;