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

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