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

filter: Statementstmt 0.0% 0 / 56 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 11 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 80 CC 4 SCAR 13.1
CC
4
Cov
0%
cf
6.0
key
6.0
mc
6.0
CRAP 3.7
1 package App::SeismicUnixGui::sunix::header::sulhead;
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 SULHEAD - Load information from an ascii column file into HEADERS based
25  
26 on the value of the user specified header field
27  
28 sulhead < inflie > outfile cf=Column_file key=.. [ optional parameters]
29  
30  
31  
32 Required parameters:
33  
34 cf=Name of column file
35  
36 key=key1,key2,...Number of column entires
37  
38 Optional parameters:
39  
40 mc=1 Column number to use to match rows to traces
41  
42  
43  
44 Notes:
45  
46 Caveat: This is not simple trace header setting, but conditional
47  
48 setting.
49  
50  
51  
52 This utility reads the column file and loads the values into the
53  
54 specified header locations. Each column represents one set of header
55  
56 words, one of them (#mc) is used to match the rows to the traces
57  
58 using header tr.key[mc].
59  
60  
61  
62 Example:
63  
64 key=cdp,ep,sx mc=1 cf=file
65  
66 file contains:
67  
68 1 2 3
69  
70 2 3 4
71  
72  
73  
74 if tr.cdp equals 1 then tr.ep and tr.sx will be set to 2 and 3
75  
76 if tr.cdp equals 2 then tr.ep and tr.sx will be set to 3 and 4
77  
78 if tr.cdp equals other than tr.trid equals 3
79  
80  
81  
82 Caveat: the user has to make it sure that number of entires in key=
83  
84 is equal the number of columns stored in the file.
85  
86  
87  
88 For simple mass setting of header words, see selfdoc of: sushw
89  
90  
91  
92  
93  
94  
95  
96 Credits: Balasz Nemeth, Potash Corporation, Saskatoon Saskatchewan
97  
98 Given to CWP in 2008
99  
100  
101  
102  
103  
104 =head2 User's notes (Juan Lorenzo)
105 untested
106  
107 =cut
108  
109  
110 =head2 CHANGES and their DATES
111  
112 =cut
113  
114 use Moose;
115 our $VERSION = '0.0.1';
116  
117  
118 =head2 Import packages
119  
120 =cut
121  
122 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
123  
124 use App::SeismicUnixGui::misc::SeismicUnix qw($go $in $off $on $out $ps $to $suffix_ascii $suffix_bin $suffix_ps $suffix_segy $suffix_su);
125 use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config';
126  
127  
128 =head2 instantiation of packages
129  
130 =cut
131  
132 my $get = L_SU_global_constants->new();
133 my $Project = Project_config->new();
134 my $DATA_SEISMIC_SU = $Project->DATA_SEISMIC_SU();
135 my $DATA_SEISMIC_BIN = $Project->DATA_SEISMIC_BIN();
136 my $DATA_SEISMIC_TXT = $Project->DATA_SEISMIC_TXT();
137  
138 my $PS_SEISMIC = $Project->PS_SEISMIC();
139  
140 my $var = $get->var();
141 my $on = $var->{_on};
142 my $off = $var->{_off};
143 my $true = $var->{_true};
144 my $false = $var->{_false};
145 my $empty_string = $var->{_empty_string};
146  
147 =head2 Encapsulated
148 hash of private variables
149  
150 =cut
151  
152 my $sulhead = {
153 _cf => '',
154 _key => '',
155 _mc => '',
156 _Step => '',
157 _note => '',
158  
159 };
160  
161 =head2 sub Step
162  
163 collects switches and assembles bash instructions
164 by adding the program name
165  
166 =cut
167  
168 sub Step {
169  
170 $sulhead->{_Step} = 'sulhead'.$sulhead->{_Step};
171 return ( $sulhead->{_Step} );
172  
173 }
174  
175  
176 =head2 sub note
177  
178 collects switches and assembles bash instructions
179 by adding the program name
180  
181 =cut
182  
183 sub note {
184  
185 $sulhead->{_note} = 'sulhead'.$sulhead->{_note};
186 return ( $sulhead->{_note} );
187  
188 }
189  
190  
191  
192 =head2 sub clear
193  
194 =cut
195  
196 sub clear {
197  
198 $sulhead->{_cf} = '';
199 $sulhead->{_key} = '';
200 $sulhead->{_mc} = '';
201 $sulhead->{_Step} = '';
202 $sulhead->{_note} = '';
203 }
204  
205  
206 =head2 sub cf
207  
208  
209 =cut
210  
211 sub cf {
212  
213 my ( $self,$cf ) = @_;
214 if ( $cf ne $empty_string ) {
215  
216 $sulhead->{_cf} = $cf;
217 $sulhead->{_note} = $sulhead->{_note}.' cf='.$sulhead->{_cf};
218 $sulhead->{_Step} = $sulhead->{_Step}.' cf='.$sulhead->{_cf};
219  
220 } else {
221 print("sulhead, cf, missing cf,\n");
222 }
223 }
224  
225  
226 =head2 sub key
227  
228  
229 =cut
230  
231 sub key {
232  
233 my ( $self,$key ) = @_;
234 if ( $key ne $empty_string ) {
235  
236 $sulhead->{_key} = $key;
237 $sulhead->{_note} = $sulhead->{_note}.' key='.$sulhead->{_key};
238 $sulhead->{_Step} = $sulhead->{_Step}.' key='.$sulhead->{_key};
239  
240 } else {
241 print("sulhead, key, missing key,\n");
242 }
243 }
244  
245  
246 =head2 sub mc
247  
248  
249 =cut
250  
251 sub mc {
252  
253 my ( $self,$mc ) = @_;
254 if ( $mc ne $empty_string ) {
255  
256 $sulhead->{_mc} = $mc;
257 $sulhead->{_note} = $sulhead->{_note}.' mc='.$sulhead->{_mc};
258 $sulhead->{_Step} = $sulhead->{_Step}.' mc='.$sulhead->{_mc};
259  
260 } else {
261 print("sulhead, mc, missing mc,\n");
262 }
263 }
264  
265  
266 =head2 sub get_max_index
267  
268 max index = number of input variables -1
269
270 =cut
271
272 sub get_max_index {
273 my ($self) = @_;
274 my $max_index = 2;
275  
276 return($max_index);
277 }
278
279
280 1;