lib/App/SeismicUnixGui/big_streams/iBottomMute.pl untested

filter: Statementstmt 0.0% 0 / 133 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 158 CC 3 SCAR 11.5
CC
3
Cov
0%
set_next
6.0
set_exit
6.0
set_pick
2.0
CRAP 3.1
1  
2 =head1 DOCUMENTATION
3  
4 =head2 SYNOPSIS
5  
6 PROGRAM NAME: iBottomMute (interactive Bottom Mute)
7 AUTHOR: Juan Lorenzo
8  
9 =head2 CHANGES and their DATES
10  
11 DATE: April 2 2009
12 September 2015 :
13 updated to oop
14 introduced Tk widgets
15 Made all event-driven
16 July 27 2016
17 June 12 2017 adapted iTopMute and its programs
18 to create this iBottom Mute
19
20 NEW: read iBottom_Mute3.config text file
21 OLD: import perl variables from
22 *.pm configuration file xi
23 within a local libAll
24 subdirectory
25 binheader is used for everything serious
26 gather is to be used to texting
27 correct offset is essential for applying the mute
28  
29 =head2 DESCRIPTION
30  
31 Interactively pick muting parameters
32  
33 =head2 USE
34  
35 =head2 Examples
36  
37 =head2 SEISMIC UNIX NOTES
38  
39 =head2 STEPS
40  
41 1. use the local library of the user
42 1.1 bring is user variables from a local file
43 2. create instances of the needed subroutines
44  
45 =head2 NOTES
46  
47 We are using Moose.
48 Moose already declares that you need debuggers turned on
49 so you don't need a line like the following:
50 use warnings;
51
52 Parameters
53
54 base_file_name su file without "su" suffix
55
56 gather_type used only to determine user messages,
57 e.g., SP, CDP
58
59 binheader_type type of gathers used for muting,
60 e.g., ep,cdp
61
62 offset_type horizontal component,
63 e.g., tracr, offset
64  
65 =cut
66  
67 use Moose;
68 our $VERSION = '1.0.4';
69 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
70 use aliased 'App::SeismicUnixGui::big_streams::iBottomMute';
71 use aliased 'App::SeismicUnixGui::configs::big_streams::iBottomMute_config';
72 #use aliased 'App::SeismicUnixGui::misc::readfiles';
73 use Tk;
74 use App::SeismicUnixGui::misc::SeismicUnix qw($true $false );
75 use aliased 'App::SeismicUnixGui::sunix::shell::xk';
76  
77 my $iBM_Tk = {_prompt => ''};
78  
79  
80 =head2 Instantiate classes:
81  
82 Create a new version of the package
83 with a unique name
84  
85 =cut
86  
87 my $iBM = iBottomMute->new();
88 my $iBottomMute_config = iBottomMute_config->new();
89 #my $read = readfiles->new();
90 my $get = L_SU_global_constants->new();
91 my $var = $get->var();
92 my $xk = xk->new();
93  
94 =head2 Get configuration information
95  
96 =cut
97  
98 my ( $CFG_h, $CFG_aref ) = $iBottomMute_config->get_values();
99  
100 my $gather_header = $CFG_h->{sumute}{1}{gather_header};
101 my $offset_type = $CFG_h->{sumute}{1}{offset_type};
102 my $base_file_name = $CFG_h->{base_file_name};
103 my $first_gather = $CFG_h->{sumute}{1}{first_gather};
104 my $last_gather = $CFG_h->{sumute}{1}{last_gather};
105 my $gather_inc = $CFG_h->{sumute}{1}{gather_inc};
106 my $freq = $CFG_h->{sugain}{1}{freq};
107 my $gather_type = $CFG_h->{sumute}{1}{gather_type};
108 my $min_amplitude = $CFG_h->{sumute}{1}{min_amplitude};
109 my $max_amplitude = $CFG_h->{sumute}{1}{max_amplitude};
110  
111 =head2 Declare variables
112  
113 in local memory space
114  
115 =cut
116  
117 my ( $calc_rb, $exit_rb, $pick_rb, $next_rb, $saveNcont_rb );
118 my $rb_value = "red";
119 my $gather = $first_gather;
120 my $next_step = 'stop';
121 my $number_of_tries = 0;
122 my $there_is_old_data;
123 our $mw;
124  
125 $iBM->number_of_tries($number_of_tries);
126 $iBM->file_in($base_file_name);
127 $iBM->gather_type($gather_type);
128 $iBM->gather_header($gather_header);
129 $iBM->offset_type($offset_type);
130 $iBM->freq($freq);
131 $iBM->min_amplitude($min_amplitude);
132 $iBM->max_amplitude($max_amplitude);
133 $iBM->gather_num($gather);
134 $iBM->set_message('iBottomMute');
135  
136  
137 =head2
138  
139 Check for old data
140 check to see if prior mute parameter files exist for this project
141  
142 =cut
143  
144 $there_is_old_data = $iBM->type('BottomMute');
145  
146 if ($there_is_old_data) {
147
148 print("Old picks already exist.\n");
149 print(
150 "Delete \(\"rm \*old\*\"\)or Save old picks, and then restart\n\n"
151 );
152 exit;
153 }
154  
155 =head2 Create Main Window
156  
157 Sstart event-driven loop
158 Interaction with user
159 initialize values
160 If picks are new, show
161 message on how to pick data
162  
163 =cut
164  
165 if ( !$there_is_old_data ) {
166  
167 print("NEW PICKS\n");
168 $iBM->iBM_message('first_bottom_mute');
169 $iBM->number_of_tries($false);
170 $iBM->gather_num($gather);
171  
172 =head2 Display
173  
174 data first time
175  
176 =cut
177  
178 $iBM->iBM_Select_tr_Sumute_bottom();
179  
180 =head2 Decide whether to
181  
182 PICK or move on to NEXT CDP
183 Place window near the upper left corner
184 of the screen
185 Changing geometry of the toplevel window
186 my $h = $mw->screenheight();
187 my $w = $mw->screenwidth();
188 print("width and height of screen are $w,$h\n\n");
189 print("geometry of screen is $geom\n\n");
190  
191 =cut
192  
193 $mw = MainWindow->new;
194 $mw->geometry("400x50+40+0");
195 $mw->title("Interactive Bottom Mute");
196 $mw->configure( -background => $var->{_my_purple} );
197  
198 $calc_rb = $mw->Radiobutton(
199 -text => 'CALC',
200 -background => $var->{_my_yellow},
201 -value => 'calc',
202 -variable => \$rb_value,
203 -command => [ \&set_calc ]
204 )->pack( -side => 'left' );
205  
206 $next_rb = $mw->Radiobutton(
207 -text => 'NEXT',
208 -background => $var->{_my_yellow},
209 -value => 'next',
210 -variable => \$rb_value,
211 -command => [ \&set_next ]
212 )->pack( -side => 'left' );
213  
214 $pick_rb = $mw->Radiobutton(
215 -text => 'PICK',
216 -background => $var->{_my_yellow},
217 -value => 'pick',
218 -variable => \$rb_value,
219 -command => [ \&set_pick ]
220 )->pack( -side => 'left' );
221 $saveNcont_rb = $mw->Radiobutton(
222 -text => 'Save and Continue',
223 -background => $var->{_my_yellow},
224 -value => 'saveNcont',
225 -variable => \$rb_value,
226 -command => [ \&set_saveNcont ]
227 )->pack( -side => 'left' );
228  
229 $exit_rb = $mw->Radiobutton(
230 -text => 'EXIT',
231 -background => $var->{_my_yellow},
232 -value => 'exit',
233 -variable => \$rb_value,
234 -command => [ \&set_exit ]
235 )->pack( -side => 'left' );
236  
237 MainLoop; # for Tk widgets
238 } # for new data
239  
240  
241 =head2 Set the prompt
242  
243 value according
244 to which button is pressed
245 then exit the MainLoop
246 destroy the main window after the prompt
247 is properly set
248  
249 =cut
250  
251 =head2 sub set_pick
252  
253 callbacks
254  
255 send gather number to $iBM
256 delete output of previous semblance
257 plus more callbacks following...
258  
259  
260 =cut
261  
262 sub set_pick {
263 my $pick = 'pick';
264 $pick_rb->configure( -state => 'normal' );
265 $iBM_Tk->{_prompt} = $pick;
266  
267 print("Picking...\n");
268  
269 $iBM->gather_num($gather);
270  
271 =head2 Delete output
272  
273 of previous muting
274  
275 =cut
276  
277 $xk->kill_this('suximage');
278 $xk->kill_this('suxwigb');
279  
280 =head2
281  
282 -replot 1st data
283 -PICK X-T pairs
284 -Increment number of tries to make
285 data display interact with user
286 (number_of_tries = 1)
287  
288 =cut
289  
290 $iBM->iBM_message('pre_pick_mute');
291 $number_of_tries++;
292 $iBM->number_of_tries($number_of_tries);
293 $iBM->iBM_Select_tr_Sumute_bottom();
294 }
295  
296 =head2 sub set_calc
297  
298 -PRESS the CALC button
299 -Increment number of tries to make
300 display and show old picks
301 (if number_of_tries >1)
302  
303 =cut
304  
305 sub set_calc {
306 my $calc = 'calc';
307 $calc_rb->configure( -state => 'normal' );
308 $iBM_Tk->{_prompt} = $calc;
309 print("Calculating...\n");
310  
311 =head2 Delete
312  
313 the previous display
314  
315 =cut
316  
317 $xk->kill_this('suximage');
318 $xk->kill_this('suxwigb');
319  
320 $iBM->iPicks2par();
321 $iBM->iBM_Save_bottom_mute_picks();
322 $iBM->iBM_Apply_bottom_mute();
323 $number_of_tries++;
324 $iBM->number_of_tries($number_of_tries);
325  
326 =head2 Message
327  
328 to halts flow
329 when number_of_tries >0
330  
331 =cut
332  
333 $iBM->iBM_message('post_pick_mute');
334 }
335  
336  
337 =head2 sub set_saveNcont
338  
339 same as next
340  
341 =cut
342  
343 sub set_saveNcont {
344 my $saveNcont = 'saveNcont';
345 $saveNcont_rb->configure( -state => 'normal' );
346 $iBM_Tk->{_prompt} = $saveNcont;
347 print("Saving and Continuing...\n");
348  
349 #$iBM->icp_sorted2oldpicks();
350 &set_next();
351  
352 }
353  
354  
355 =head2 sub set_next
356  
357 In this case the $variable is empty
358 1. increment gather
359 Exit if beyond last gather
360 2. reset prompt
361 3. Otherwise display the first semblance
362 4 ... see following callbacks
363  
364 =cut
365  
366 sub set_next {
367 print("Next...\n");
368 $next_rb->configure( -state => 'normal' );
369 my $next = '';
370 $iBM_Tk->{_prompt} = $next;
371 $gather = $gather + $gather_inc;
372  
373 #print("new gather is $gather \n\n");
374  
375 =head2 Delete output
376  
377 of previous top mute
378  
379 =cut
380  
381 $xk->kill_this('suximage');
382 $xk->kill_this('suxwigb');
383 $xk->kill_this('xgraph');
384  
385 if ( $gather > $last_gather ) {
386 set_exit();
387 }
388  
389 =head2 Display
390  
391 update gather number in memory
392 first top mute
393 Show user message
394 Select the mute values
395 =cut
396  
397 $iBM->gather_num($gather);
398 $iBM->iBM_message('first_bottom_mute');
399 $iBM->iBM_Select_tr_Sumute_bottom();
400  
401 }
402  
403 =head2 sub set_exit
404  
405 saying goodbye
406 clear old images
407 kill window
408 stop script
409  
410 =cut
411  
412 sub set_exit {
413 my $exit = 'exit';
414 $exit_rb->configure( -state => 'normal' );
415 $iBM_Tk->{_prompt} = $exit;
416 print("Good bye.\n");
417 print("Not continuing to next gather\n");
418 $xk->kill_this('suximage');
419 $xk->kill_this('suxwigb');
420 $xk->kill_this('xgraph');
421 $mw->destroy() if Tk::Exists($mw);
422 exit 1;
423 }
424  
425 # print ("Old top mute parameters MAY NOT exist\n\n") ;
426 # while ($response eq 'n') {
427 # print ("Select new top mute parameters \n\n") ;
428 # iBM->iBM_Select_tr_Sumute_bottom2");
429 # iBM->iBottomMutepicks2par2");
430 # iBM->itemp_Sumute_bottom2");
431 # print ("4. Are picks OK y/n or q-quit?\n");
432 # $response = <>;
433 ## chomp($response);