lib/App/SeismicUnixGui/big_streams/iTopMute.pm untested

filter: Statementstmt 0.0% 0 / 151 Branchbran 0.0% 0 / 26 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 31 Podpod 0.0% 0 / 19 totaltotal 0.0% 0 / 227 CC 14 SCAR 14.7
CC
14
Cov
0%
gather_header
6.0
offset_type
6.0
gather_type
6.0
CRAP 4.4
1 package App::SeismicUnixGui::big_streams::iTopMute;
2  
3 =head1 DOCUMENTATION
4  
5 =head2 SYNOPSIS
6  
7 PERL PROGRAM NAME: iTopMute.pm
8 AUTHOR: Juan Lorenzo
9 DATE: Sept. 14 2015
10
11  
12 DESCRIPTION:
13 Version: 1.1
14 Package used for interactive top mute
15  
16 =head2 USE
17  
18 =head3 NOTES
19  
20 =head4
21 Examples
22  
23 =head3 SEISMIC UNIX NOTES
24  
25 =head4 CHANGES and their DATES
26  
27  
28 =cut
29  
30 =head2 STEPS
31  
32 1. define the types of variables you are using
33 these would be the values you enter into
34 each of the Seismic Unix programs each of the
35 Seismic Unix programs
36  
37 2. build a list or hash with all the possible variable
38 names you may use and you can even change them
39  
40 set defaults
41  
42 VELAN DATA
43 m/s
44  
45 =cut
46  
47 =head2 Import
48  
49 packages
50 directory definitions
51  
52 =cut
53  
54 use Moose;
55 our $VERSION = '1.0.3';
56 use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config';
57 use aliased 'App::SeismicUnixGui::misc::message';
58 use aliased 'App::SeismicUnixGui::sunix::shell::cp';
59 use aliased 'App::SeismicUnixGui::misc::flow';
60 use aliased 'App::SeismicUnixGui::big_streams::iApply_top_mute';
61 use aliased 'App::SeismicUnixGui::big_streams::iSelect_tr_Sumute_top';
62 use aliased 'App::SeismicUnixGui::big_streams::iTopMutePicks2par';
63 use aliased 'App::SeismicUnixGui::misc::old_data';
64 use aliased 'App::SeismicUnixGui::big_streams::iSave_top_mute_picks';
65 use aliased 'App::SeismicUnixGui::messages::SuMessages';
66 use App::SeismicUnixGui::misc::SeismicUnix
67 qw($on $off $in $to $go $itop_mute_par_ $itop_mute_check_pickfile_ $false $true );
68
69 my $Project = Project_config->new();
70 my ($DATA_SEISMIC_TXT)= $Project->DATA_SEISMIC_TXT();
71 my ($DATA_SEISMIC_SU) = $Project->DATA_SEISMIC_SU();
72 my ($date) = $Project->date();
73  
74 =head2 instantiate
75  
76 programs
77  
78 =cut
79  
80 my $cp = cp->new();
81 my $log = message->new();
82 my $run = flow->new();
83 my $iApply_top_mute = iApply_top_mute->new();
84 my $iSelect_tr_Sumute_top = iSelect_tr_Sumute_top->new();
85 my $iPicks2par = iTopMutePicks2par->new();
86 my $check4old_data = old_data->new();
87 my $iSave_top_mute_picks = iSave_top_mute_picks->new();
88 my $SuMessages = SuMessages->new();
89  
90 =head2 private hash
91
92 =cut
93  
94 my $iTopMute = {
95 _gather_header => '',
96 _offset_type => '',
97 _gather_num => '',
98 _gather_num_suffix => '',
99 _exists => '',
100 _file_in => '',
101 _freq => '',
102 _gather_type => '',
103 _min_amplitude => '',
104 _max_amplitude => '',
105 _next_step => '',
106 _number_of_tries => '',
107 _TX_inbound => '',
108 _TX_outbound => '',
109 _textfile_in => '',
110 _textfile_out => ''
111 };
112  
113 =head2
114
115 declare variables types
116 establish just the locally scoped variables
117  
118 =cut
119  
120 my ( @flow, @cp, @items );
121  
122 =head2 subroutine clear
123  
124 sets all variable strings to ''
125  
126 =cut
127  
128 sub clear {
129 $iTopMute->{_gather_num} = '';
130 $iTopMute->{_gather_type} = '';
131 $iTopMute->{_gather_header} = '';
132 $iTopMute->{_offset_type} = '';
133 $iTopMute->{_gather_num_suffix} = '';
134 $iTopMute->{_exists} = '';
135 $iTopMute->{_file_in} = '';
136 $iTopMute->{_freq} = '';
137 $iTopMute->{_min_amplitude} = '';
138 $iTopMute->{_max_amplitude} = '';
139 $iTopMute->{_next_step} = '';
140 $iTopMute->{_number_of_tries} = '';
141 $iTopMute->{_textfile_in} = '';
142 $iTopMute->{_textfile_out} = '';
143 $iTopMute->{_TX_inbound} = '';
144 $iTopMute->{_TX_outbound} = '';
145 }
146  
147 =head2 subroutine gather_header
148  
149 define which values to use in the xaxis
150  
151 =cut
152  
153 sub gather_header {
154 my ( $variable, $gather_header ) = @_;
155 $iTopMute->{_gather_header} = $gather_header if defined($gather_header);
156 }
157  
158 =head2 sub offset_type
159  
160 define which values to use in the xaxis
161  
162 =cut
163  
164 sub offset_type {
165 my ( $variable, $offset_type ) = @_;
166 $iTopMute->{_offset_type} = $offset_type if defined($offset_type);
167  
168 #print("offset type -2 $offset_type\n\n");
169 }
170  
171 =head2 sub gather_type
172  
173 define which family of messages to use
174  
175 =cut
176  
177 sub gather_type {
178 my ( $variable, $gather_type ) = @_;
179 $iTopMute->{_gather_type} = $gather_type if defined($gather_type);
180 }
181  
182 =head2 sub iTM_Select_tr_Sumute_top
183  
184 Select mute points in traces
185 provide file name
186
187 =cut
188  
189 sub iTM_Select_tr_Sumute_top {
190
191 my ($self) = @_;
192
193 $iSelect_tr_Sumute_top->gather_type( $iTopMute->{_gather_type} );
194 $iSelect_tr_Sumute_top->offset_type( $iTopMute->{_offset_type} );
195 $iSelect_tr_Sumute_top->gather_header( $iTopMute->{_gather_header} );
196 $iSelect_tr_Sumute_top->file_in( $iTopMute->{_file_in} );
197 $iSelect_tr_Sumute_top->freq( $iTopMute->{_freq} );
198 $iSelect_tr_Sumute_top->gather_num( $iTopMute->{_gather_num} );
199 $iSelect_tr_Sumute_top->min_amplitude( $iTopMute->{_min_amplitude} );
200 $iSelect_tr_Sumute_top->max_amplitude( $iTopMute->{_max_amplitude} );
201 $iSelect_tr_Sumute_top->number_of_tries( $iTopMute->{_number_of_tries} );
202 $iSelect_tr_Sumute_top->calcNdisplay();
203
204 }
205  
206 =head2 sub iTM_Apply_top_mute
207  
208 Mute the data using selected parameters
209
210 =cut
211  
212 sub iTM_Apply_top_mute {
213 $iApply_top_mute->file_in( $iTopMute->{_file_in} );
214 $iApply_top_mute->gather_header( $iTopMute->{_gather_header} );
215 $iApply_top_mute->offset_type( $iTopMute->{_offset_type} );
216 $iApply_top_mute->freq( $iTopMute->{_freq} );
217 $iApply_top_mute->gather_num( $iTopMute->{_gather_num} );
218 $iApply_top_mute->min_amplitude( $iTopMute->{_min_amplitude} );
219 $iApply_top_mute->max_amplitude( $iTopMute->{_max_amplitude} );
220 $iApply_top_mute->calcNdisplay();
221 }
222  
223 =head2 subroutine iPicks2par
224  
225 convert format of pick files for use later
226 into "par" format
227
228 =cut
229  
230 sub iPicks2par {
231 $iPicks2par->file_in( $iTopMute->{_file_in} );
232 $iPicks2par->calc();
233 }
234  
235 =head2 subroutine iTM_Save_top_mute_picks
236  
237 save pick files for later use
238
239 =cut
240  
241 sub iTM_Save_top_mute_picks {
242 $iSave_top_mute_picks->gather_num( $iTopMute->{_gather_num} );
243 $iSave_top_mute_picks->gather_header( $iTopMute->{_gather_header} );
244 $iSave_top_mute_picks->gather_type( $iTopMute->{_gather_type} );
245 $iSave_top_mute_picks->file_in( $iTopMute->{_file_in} );
246 $iSave_top_mute_picks->calc();
247 }
248  
249 =head2 sub set_message
250  
251 define the message family (type) to use
252 also set the gather nuimber (TODO: move option elsewhere)
253  
254 =cut
255  
256 sub set_message {
257 my ( $variable, $type ) = @_;
258 $iTopMute->{_message_type} = $type if defined($type);
259 $SuMessages->set( $iTopMute->{_message_type} );
260  
261 =head2
262  
263 update gather number for messages
264  
265 =cut
266  
267 $SuMessages->gather_num( $iTopMute->{_gather_num} );
268 $SuMessages->gather_header( $iTopMute->{_gather_header} );
269 $SuMessages->gather_type( $iTopMute->{_gather_type} );
270 }
271  
272 =head2 sub iTM_message
273  
274 instructions
275  
276 =cut
277  
278 sub iTM_message {
279 my ( $variable, $instructions ) = @_;
280 $iTopMute->{_instructions} = $instructions if defined($instructions);
281  
282 =head2
283 update gather number for messages
284 =cut
285  
286 $SuMessages->gather_num( $iTopMute->{_gather_num} );
287 $SuMessages->instructions( $iTopMute->{_instructions} );
288 $SuMessages->gather_header( $iTopMute->{_gather_header} );
289 $SuMessages->gather_type( $iTopMute->{_gather_type} );
290 }
291  
292 =head2 sub type
293  
294 look for old data
295  
296 Are there old picks to read?
297 These old picks are of a type e.g. velan or gather
298
299  
300 =cut
301  
302 sub type {
303  
304 my ( $variable, $type ) = @_;
305 $iTopMute->{_type} = $type if defined($type);
306 $check4old_data->gather_num( $iTopMute->{_gather_num} );
307 $check4old_data->file_in( $iTopMute->{_file_in} );
308 $iTopMute->{_exists} = $check4old_data->type( $iTopMute->{_type} );
309  
310 return $iTopMute->{_exists};
311 }
312  
313 =head2 subroutine gather_num
314  
315 sets gather number to consider
316  
317 =cut
318  
319 sub gather_num {
320 my ( $variable, $gather_num ) = @_;
321 $iTopMute->{_gather_num} = $gather_num if defined($gather_num);
322 $iTopMute->{_gather_num_suffix} = '_gather' . $iTopMute->{_gather_num}
323  
324 }
325  
326 =head2 subroutine file_in
327  
328 Required file name
329 on which to pick top mute values
330  
331 =cut
332  
333 sub file_in {
334 my ( $variable, $file_in ) = @_;
335 $iTopMute->{_file_in} = $file_in if defined($file_in);
336  
337 #print("file name is $iTopMute->{_file_in} \n\n");
338 }
339  
340 =head2 subroutine data_scale
341  
342 Required data plotting scale
343  
344 =cut
345  
346 sub data_scale {
347 my ( $variable, $data_scale ) = @_;
348 $iTopMute->{_data_scale} = $data_scale if defined($data_scale);
349  
350 #print("ds=$iTopMute->{_data_scale}\n\n");
351 }
352  
353 =head2 subroutine freq
354  
355 creates the bandpass frequencies to filter data before
356 conducting amplitude analysis
357 e.g., "3,6,40,50"
358
359 =cut
360  
361 sub freq {
362 my ( $variable, $freq ) = @_;
363 $iTopMute->{_freq} = $freq if defined($freq);
364  
365 #print("freq is $iTopMute->{_freq}\n\n");
366 }
367  
368 =head2
369  
370 subroutine maximum amplitude to plot
371  
372 =cut
373  
374 sub max_amplitude {
375 my ( $variable, $max_amplitude ) = @_;
376 $iTopMute->{_max_amplitude} = $max_amplitude if defined($max_amplitude);
377  
378 #print("max_amplitude is $iTopMute->{_max_amplitude}\n\n");
379 }
380  
381 =head2
382  
383 subroutine minumum amplitude to plot
384  
385 =cut
386  
387 sub min_amplitude {
388 my ( $variable, $min_amplitude ) = @_;
389 $iTopMute->{_min_amplitude} = $min_amplitude if defined($min_amplitude);
390  
391 #print("min_amplitude is $iTopMute->{_min_amplitude}\n\n");
392 }
393  
394 =head2
395  
396 subroutine number_of_tries
397 required count of the number of attempts
398 at estimating the velocity
399  
400 =cut
401  
402 sub number_of_tries {
403 my ( $variable, $number_of_tries ) = @_;
404 $iTopMute->{_number_of_tries} = $number_of_tries
405 if defined($number_of_tries);
406  
407 #print("number_of_tries is $iTopMute->{_number_of_tries} \n\n");
408 }
409  
410 =head2 subroutine icp_sorted_2_old_picks
411  
412 When user wants to recheck the data
413 this subroutine will allow the user to
414 recheck using an old sorted file
415 Juan M. Lorenzo
416 Jan 10 2010
417  
418 input file is ivpicks_sorted
419 output pick file
420 text file out: ivpicks_old
421  
422  
423 =cut
424  
425 sub icp_sorted2oldpicks {
426  
427 my ( $inbound, $outbound );
428 my ($writefile_out);
429 my ($flow);
430 my ( $suffix, $sortfile_in, $sorted_suffix, $XTpicks_out, $XTpicks_in );
431  
432 # suffixes
433 $sorted_suffix = '_sorted';
434 $suffix = '_gather' . $iTopMute->{_gather_num};
435  
436 #XT file names
437 $XTpicks_in = 'XTpicks_old' . $sorted_suffix;
438 $XTpicks_out = 'XTpicks_old';
439  
440 # sort file names
441 $sortfile_in = $XTpicks_in;
442 $inbound =
443 $DATA_SEISMIC_TXT . '/'
444 . $sortfile_in . '_'
445 . $iTopMute->{_file_in} . '_'
446 . $iTopMute->{_gather_num_suffix};
447  
448 # TX write file names
449 $writefile_out = $XTpicks_out;
450 $outbound =
451 $DATA_SEISMIC_TXT . '/'
452 . $writefile_out . '_'
453 . $iTopMute->{_file_in} . '_'
454 . $iTopMute->{_gather_num_suffix};
455  
456 $cp->from($inbound);
457 $cp->to($outbound);
458 $cp[1] = $cp->Step();
459  
460 =head2
461  
462 DEFINE FLOW(S)
463  
464 =cut
465  
466 @items = ( $cp[1] );
467 $flow[1] = $run->modules( \@items );
468  
469 =head2
470  
471 RUN FLOW(S)
472  
473 =cut
474  
475 $run->flow( \$flow[1] );
476  
477 =head2
478  
479 LOG FLOW(S)TO SCREEN AND FILE
480  
481 =cut
482  
483 #print "$flow[1]\n";
484 #$log->file($flow[1]);
485  
486 #end of copy of XT old picks sorted to iXTpicks_old
487 }
488  
489 1;