lib/App/SeismicUnixGui/sunix/header/suhtmath.pm untested

filter: Statementstmt 0.0% 0 / 63 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 / 91 CC 5 SCAR 13.9
CC
5
Cov
0%
const
6.0
key
6.0
op
6.0
CRAP 4.0
1 package App::SeismicUnixGui::sunix::header::suhtmath;
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 SUHTMATH - do unary arithmetic operation on segy traces with
25  
26 headers values
27  
28  
29  
30 suhtmath <stdin >stdout
31  
32  
33  
34 Required parameters:
35  
36 none
37  
38  
39  
40 Optional parameter:
41  
42 key=tracl header word to use
43  
44 op=nop operation flag
45  
46 nop : no operation
47  
48 add : add header to trace
49  
50 mult : multiply trace with header
51  
52 div : divide trace by header
53  
54  
55  
56 scale=1.0 scalar multiplier for header value
57  
58 const=0.0 additive constant for header value
59  
60  
61  
62 Operation order: ",
63  
64  
65  
66 op=add: out(t) = in(t) + (scale * key + const)
67  
68 op=mult: out(t) = in(t) * (scale * key + const)
69  
70 op=div: out(t) = in(t) / (scale * key + const)
71  
72  
73  
74 Credits:
75  
76 Matthias Imhof, Virginia Tech, Fri Dec 27 09:17:29 EST 2002
77  
78  
79  
80 =head2 User's notes (Juan Lorenzo)
81 untested
82  
83 =cut
84  
85  
86 =head2 CHANGES and their DATES
87  
88 =cut
89  
90 use Moose;
91 our $VERSION = '0.0.1';
92  
93  
94 =head2 Import packages
95  
96 =cut
97  
98 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
99  
100 use App::SeismicUnixGui::misc::SeismicUnix qw($go $in $off $on $out $ps $to $suffix_ascii $suffix_bin $suffix_ps $suffix_segy $suffix_su);
101 use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config';
102  
103  
104 =head2 instantiation of packages
105  
106 =cut
107  
108 my $get = L_SU_global_constants->new();
109 my $Project = Project_config->new();
110 my $DATA_SEISMIC_SU = $Project->DATA_SEISMIC_SU();
111 my $DATA_SEISMIC_BIN = $Project->DATA_SEISMIC_BIN();
112 my $DATA_SEISMIC_TXT = $Project->DATA_SEISMIC_TXT();
113  
114 my $PS_SEISMIC = $Project->PS_SEISMIC();
115  
116 my $var = $get->var();
117 my $on = $var->{_on};
118 my $off = $var->{_off};
119 my $true = $var->{_true};
120 my $false = $var->{_false};
121 my $empty_string = $var->{_empty_string};
122  
123 =head2 Encapsulated
124 hash of private variables
125  
126 =cut
127  
128 my $suhtmath = {
129 _const => '',
130 _key => '',
131 _op => '',
132 _scale => '',
133 _Step => '',
134 _note => '',
135  
136 };
137  
138 =head2 sub Step
139  
140 collects switches and assembles bash instructions
141 by adding the program name
142  
143 =cut
144  
145 sub Step {
146  
147 $suhtmath->{_Step} = 'suhtmath'.$suhtmath->{_Step};
148 return ( $suhtmath->{_Step} );
149  
150 }
151  
152  
153 =head2 sub note
154  
155 collects switches and assembles bash instructions
156 by adding the program name
157  
158 =cut
159  
160 sub note {
161  
162 $suhtmath->{_note} = 'suhtmath'.$suhtmath->{_note};
163 return ( $suhtmath->{_note} );
164  
165 }
166  
167  
168  
169 =head2 sub clear
170  
171 =cut
172  
173 sub clear {
174  
175 $suhtmath->{_const} = '';
176 $suhtmath->{_key} = '';
177 $suhtmath->{_op} = '';
178 $suhtmath->{_scale} = '';
179 $suhtmath->{_Step} = '';
180 $suhtmath->{_note} = '';
181 }
182  
183  
184 =head2 sub const
185  
186  
187 =cut
188  
189 sub const {
190  
191 my ( $self,$const ) = @_;
192 if ( $const ne $empty_string ) {
193  
194 $suhtmath->{_const} = $const;
195 $suhtmath->{_note} = $suhtmath->{_note}.' const='.$suhtmath->{_const};
196 $suhtmath->{_Step} = $suhtmath->{_Step}.' const='.$suhtmath->{_const};
197  
198 } else {
199 print("suhtmath, const, missing const,\n");
200 }
201 }
202  
203  
204 =head2 sub key
205  
206  
207 =cut
208  
209 sub key {
210  
211 my ( $self,$key ) = @_;
212 if ( $key ne $empty_string ) {
213  
214 $suhtmath->{_key} = $key;
215 $suhtmath->{_note} = $suhtmath->{_note}.' key='.$suhtmath->{_key};
216 $suhtmath->{_Step} = $suhtmath->{_Step}.' key='.$suhtmath->{_key};
217  
218 } else {
219 print("suhtmath, key, missing key,\n");
220 }
221 }
222  
223  
224 =head2 sub op
225  
226  
227 =cut
228  
229 sub op {
230  
231 my ( $self,$op ) = @_;
232 if ( $op ne $empty_string ) {
233  
234 $suhtmath->{_op} = $op;
235 $suhtmath->{_note} = $suhtmath->{_note}.' op='.$suhtmath->{_op};
236 $suhtmath->{_Step} = $suhtmath->{_Step}.' op='.$suhtmath->{_op};
237  
238 } else {
239 print("suhtmath, op, missing op,\n");
240 }
241 }
242  
243  
244 =head2 sub scale
245  
246  
247 =cut
248  
249 sub scale {
250  
251 my ( $self,$scale ) = @_;
252 if ( $scale ne $empty_string ) {
253  
254 $suhtmath->{_scale} = $scale;
255 $suhtmath->{_note} = $suhtmath->{_note}.' scale='.$suhtmath->{_scale};
256 $suhtmath->{_Step} = $suhtmath->{_Step}.' scale='.$suhtmath->{_scale};
257  
258 } else {
259 print("suhtmath, scale, missing scale,\n");
260 }
261 }
262  
263  
264 =head2 sub get_max_index
265  
266 max index = number of input variables -1
267
268 =cut
269
270 sub get_max_index {
271 my ($self) = @_;
272 my $max_index = 3;
273  
274 return($max_index);
275 }
276
277
278 1;