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

filter: Statementstmt 0.0% 0 / 62 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 90 CC 5 SCAR 13.9
CC
5
Cov
0%
abs
6.0
outpar
6.0
power
6.0
CRAP 4.0
1 package App::SeismicUnixGui::sunix::statsMath::sumean;
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 SUMEAN - get the mean values of data traces ",
25  
26  
27  
28 sumean < stdin > stdout [optional parameters]
29  
30  
31  
32 Required parameters:
33  
34 power = 2.0 mean to the power
35  
36 (e.g. = 1.0 mean amplitude, = 2.0 mean energy)
37  
38  
39  
40 Optional parameters:
41  
42 verbose = 0 writes mean value of section to outpar
43  
44 = 1 writes mean value of each trace / section to
45  
46 outpar
47  
48 outpar=/dev/tty output parameter file
49  
50 abs = 1 average absolute value
51  
52 = 0 preserve sign if power=1.0
53  
54  
55  
56 Notes:
57  
58 Each sample is raised to the requested power, and the sum of all those
59  
60 values is averaged for each trace (verbose=1) and the section.
61  
62 The values power=1.0 and power=2.0 are physical, however other powers
63  
64 represent other mathematical L-p norms and may be of use, as well.
65  
66  
67  
68  
69  
70 Credits:
71  
72 Bjoern E. Rommel, IKU, Petroleumsforskning / October 1997
73  
74 bjorn.rommel@iku.sintef.no
75  
76  
77 =head2 User's notes (Juan Lorenzo)
78  
79  
80 =cut
81  
82  
83 =head2 CHANGES and their DATES
84  
85 =cut
86  
87 use Moose;
88 our $VERSION = '0.0.1';
89  
90  
91 =head2 Import packages
92  
93 =cut
94  
95 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
96  
97 use App::SeismicUnixGui::misc::SeismicUnix qw($in $out $on $go $to $suffix_ascii $off $suffix_su $suffix_bin);
98 use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config';
99  
100  
101 =head2 instantiation of packages
102  
103 =cut
104  
105 my $get = L_SU_global_constants->new();
106 my $Project = Project_config->new();
107 my $DATA_SEISMIC_SU = $Project->DATA_SEISMIC_SU();
108 my $DATA_SEISMIC_BIN = $Project->DATA_SEISMIC_BIN();
109 my $DATA_SEISMIC_TXT = $Project->DATA_SEISMIC_TXT();
110  
111 my $var = $get->var();
112 my $on = $var->{_on};
113 my $off = $var->{_off};
114 my $true = $var->{_true};
115 my $false = $var->{_false};
116 my $empty_string = $var->{_empty_string};
117  
118 =head2 Encapsulated
119 hash of private variables
120  
121 =cut
122  
123 my $sumean = {
124 _abs => '',
125 _outpar => '',
126 _power => '',
127 _verbose => '',
128 _Step => '',
129 _note => '',
130  
131 };
132  
133 =head2 sub Step
134  
135 collects switches and assembles bash instructions
136 by adding the program name
137  
138 =cut
139  
140 sub Step {
141  
142 $sumean->{_Step} = 'sumean'.$sumean->{_Step};
143 return ( $sumean->{_Step} );
144  
145 }
146  
147  
148 =head2 sub note
149  
150 collects switches and assembles bash instructions
151 by adding the program name
152  
153 =cut
154  
155 sub note {
156  
157 $sumean->{_note} = 'sumean'.$sumean->{_note};
158 return ( $sumean->{_note} );
159  
160 }
161  
162  
163  
164 =head2 sub clear
165  
166 =cut
167  
168 sub clear {
169  
170 $sumean->{_abs} = '';
171 $sumean->{_outpar} = '';
172 $sumean->{_power} = '';
173 $sumean->{_verbose} = '';
174 $sumean->{_Step} = '';
175 $sumean->{_note} = '';
176 }
177  
178  
179 =head2 sub abs
180  
181  
182 =cut
183  
184 sub abs {
185  
186 my ( $self,$abs ) = @_;
187 if ( $abs ne $empty_string ) {
188  
189 $sumean->{_abs} = $abs;
190 $sumean->{_note} = $sumean->{_note}.' abs='.$sumean->{_abs};
191 $sumean->{_Step} = $sumean->{_Step}.' abs='.$sumean->{_abs};
192  
193 } else {
194 print("sumean, abs, missing abs,\n");
195 }
196 }
197  
198  
199 =head2 sub outpar
200  
201  
202 =cut
203  
204 sub outpar {
205  
206 my ( $self,$outpar ) = @_;
207 if ( $outpar ne $empty_string ) {
208  
209 $sumean->{_outpar} = $outpar;
210 $sumean->{_note} = $sumean->{_note}.' outpar='.$sumean->{_outpar};
211 $sumean->{_Step} = $sumean->{_Step}.' outpar='.$sumean->{_outpar};
212  
213 } else {
214 print("sumean, outpar, missing outpar,\n");
215 }
216 }
217  
218  
219 =head2 sub power
220  
221  
222 =cut
223  
224 sub power {
225  
226 my ( $self,$power ) = @_;
227 if ( $power ne $empty_string ) {
228  
229 $sumean->{_power} = $power;
230 $sumean->{_note} = $sumean->{_note}.' power='.$sumean->{_power};
231 $sumean->{_Step} = $sumean->{_Step}.' power='.$sumean->{_power};
232  
233 } else {
234 print("sumean, power, missing power,\n");
235 }
236 }
237  
238  
239 =head2 sub verbose
240  
241  
242 =cut
243  
244 sub verbose {
245  
246 my ( $self,$verbose ) = @_;
247 if ( $verbose ne $empty_string ) {
248  
249 $sumean->{_verbose} = $verbose;
250 $sumean->{_note} = $sumean->{_note}.' verbose='.$sumean->{_verbose};
251 $sumean->{_Step} = $sumean->{_Step}.' verbose='.$sumean->{_verbose};
252  
253 } else {
254 print("sumean, verbose, missing verbose,\n");
255 }
256 }
257  
258  
259 =head2 sub get_max_index
260  
261 max index = number of input variables -1
262
263 =cut
264
265 sub get_max_index {
266 my ($self) = @_;
267 my $max_index = 3;
268  
269 return($max_index);
270 }
271
272
273 1;