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

filter: Statementstmt 0.0% 0 / 154 Branchbran 0.0% 0 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 14 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 187 CC 6 SCAR 17.2
CC
6
Cov
0%
set_pick
12.0
set_next
12.0
set_exit
6.0
CRAP 5.6
1  
2 =head1 DOCUMENTATION
3  
4 =head2 SYNOPSIS
5  
6 PROGRAM NAME: iPick (interactive Picking)
7 AUTHOR: Juan Lorenzo
8  
9 =head2 CHANGES and their DATES
10  
11 DATE: June 15 2019
12  
13 =head2 DESCRIPTION
14  
15 Interactively pick points
16  
17 =head2 USE
18  
19 When "purpose" is 'geopsy', the processing
20 is slightly different and
21 the output directories and files have a unique format
22
23 ep is an appropriated gather header.
24 If you do not want to have ep defined as a gather header
25 variable, then the following is allowed:
26 ep = 0
27 ep max=0
28 ep min=0
29
30 ??JML TODO
31  
32  
33 Examples:
34  
35 base_file_name = 30Hz_All_geom_geom;
36 gather_header = fldr; (single gather type for picking)
37 offset_type = tracl;
38 first_gather = 1;
39 gather_inc = 1;
40 last_gather = 100;
41 freq = 0,3,100,200; (Hz; can be left empty without any values as well)
42 **gather_type = fldr;
43 min_amplitude = .0;
44 max_amplitude = .75;
45 min_x1 = 15.873015 (Hz, for geopsy)
46 max_x1 = 999.999 (Hz, for geopsy)
47 purpose = geopsy
48  
49 In geopsy plotting is in 'normal' and not 'seismic' mode,
50 The x1 axis is frequency and the y axis is phase velocity
51  
52 * Label displayed in the plot
53 header parameter value to digitize and use as Y-axis values for picking
54 If you want to digitize as a function of offset,
55 modify the d2 and f2 values prior to picking.
56
57 ** Used only to define family of interactive user messages to use
58 and can be either = SP or CDP
59  
60 =head2 Examples
61  
62 =head2 SEISMIC UNIX NOTES
63  
64 =head2 STEPS
65  
66 =head2 Perl NOTES
67  
68 We are using Moose
69 Moose already declares that you need debuggers turned on
70 so you don't need a line like the following:
71 use warnings;
72
73 For the iPick tool and in order to prevent redefining subroutines
74 we implement new modulesB,C,D ...
75
76 Both of the following instantiate iPick_spec.pm
77 --iPick_config
78 calls
79 config_superflows
80 calls
81 big_streams_param
82 which requires and instantiates iPick_spec
83 --iPick.pm
84 uses and instantiates iPick_specB.pm
85 uses iShowNselect_picks
86 which instantiates iPick_specC
87 uses iSelect_xt
88 which instantiates iPick_specD
89  
90 =cut
91  
92 use Moose;
93 our $VERSION = '0.0.1';
94  
95 use Tk;
96 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
97 use aliased 'App::SeismicUnixGui::misc::readfiles';
98  
99 use aliased 'App::SeismicUnixGui::configs::big_streams::iPick_config';
100 use aliased 'App::SeismicUnixGui::big_streams::iPick';
101 use App::SeismicUnixGui::misc::SeismicUnix qw($true $false);
102 use aliased 'App::SeismicUnixGui::messages::SuMessages';
103 use aliased 'App::SeismicUnixGui::sunix::shell::xk';
104  
105 my $iPick_Tk = {_prompt => ''};
106  
107 =head2 Instantiate classes:
108  
109 Create a new version of the package
110 with a unique name
111  
112 =cut set defaults
113  
114 my $iPick_config = iPick_config->new();
115 my $iPick = iPick->new();
116 my $get = L_SU_global_constants->new();
117 my $message = SuMessages->new();
118 my $var = $get->var();
119 my $xk = xk->new();
120  
121 =head2 Get configuration information
122  
123 =cut
124  
125 my ( $CFG_h, $CFG_aref ) = $iPick_config->get_values();
126  
127 my $gather_header = $CFG_h->{suximage}{1}{gather_header};
128 my $offset_type = $CFG_h->{suximage}{1}{offset_type};
129 my $base_file_name = $CFG_h->{base_file_name};
130 my $first_gather = $CFG_h->{suximage}{1}{first_gather};
131 my $last_gather = $CFG_h->{suximage}{1}{last_gather};
132 my $gather_inc = $CFG_h->{suximage}{1}{gather_inc};
133 my $freq = $CFG_h->{sugain}{1}{freq};
134 my $gather_type = $CFG_h->{suximage}{1}{gather_type};
135 my $min_amplitude = $CFG_h->{suximage}{1}{min_amplitude};
136 my $max_amplitude = $CFG_h->{suximage}{1}{max_amplitude};
137 my $min_x1 = $CFG_h->{suximage}{1}{min_x1};
138 my $max_x1 = $CFG_h->{suximage}{1}{max_x1};
139 my $purpose = $CFG_h->{suximage}{1}{purpose};
140  
141  
142 =head2 Declare variables
143  
144 in local memory space
145  
146 =cut
147  
148 my ( $calc_rb, $exit_rb, $pick_rb, $next_rb, $saveNcont_rb );
149 my $rb_value = "red";
150 my $gather = $first_gather;
151 my $next_step = 'stop';
152 my $number_of_tries = 0;
153 my $there_is_old_data = 0;
154 our $mw;
155  
156 $iPick->number_of_tries($number_of_tries);
157 $iPick->file_in($base_file_name);
158 $iPick->gather_type($gather_type);
159 $iPick->gather_header($gather_header);
160 $iPick->offset_type($offset_type);
161 $iPick->freq($freq);
162 $iPick->min_amplitude($min_amplitude);
163 $iPick->max_amplitude($max_amplitude);
164 $iPick->min_x1($min_x1);
165 $iPick->max_x1($max_x1);
166 $iPick->gather_num($gather);
167 $iPick->set_purpose($purpose);
168 $iPick->set_message_type('iPick_xt');
169  
170  
171 =head2
172  
173 Check for old data
174  
175 =cut
176  
177 $iPick->set_data_type('Pick_xt');
178 $there_is_old_data = $iPick->get4data_type();
179  
180 if ($there_is_old_data) {
181 print("Old picks already exist.\n");
182 print(
183 "Delete \(\"rm \*old\*\"\)or Save old picks, and then restart\n\n"
184 );
185 exit;
186 }
187  
188  
189 =head2 Display
190  
191 data first time
192  
193 =cut
194  
195 if ( !$there_is_old_data ) {
196  
197 print("NEW PICKS\n");
198  
199 $message->set('iPick_xt');
200 $message->gather_num($gather);
201 $message->instructions('first_pick_xt');
202  
203 $iPick->number_of_tries($false);
204 $iPick->gather_num($gather);
205  
206 $iPick->iSelect_xt();
207  
208 =head2 Create Main Window
209  
210 Start event-driven loop
211 Interaction with user
212 initialize values
213 If picks are new, show
214 message on how to pick data
215  
216 =cut
217  
218 =head2 Decide whether to
219  
220 PICK or move on to NEXT GATHER
221 Place windows (2) near the left side
222 of the screen
223
224 Changing geometry of the toplevel window
225 my $h = $mw->screenheight();
226 my $w = $mw->screenwidth();
227 print("width and height of screen are $w,$h\n\n");
228 print("geometry of screen is $geom\n\n");
229  
230 =cut
231  
232 $mw = MainWindow->new;
233 $mw->geometry("400x50+40+0");
234 $mw->title("Interactive Picking");
235  
236 $mw->configure( -background => $var->{_my_purple} );
237  
238 $calc_rb = $mw->Radiobutton(
239 -text => 'CALC',
240 -background => $var->{_my_yellow},
241 -value => 'calc',
242 -variable => \$rb_value,
243 -command => [ \&set_calc ]
244 )->pack( -side => 'left' );
245  
246 $next_rb = $mw->Radiobutton(
247 -text => 'NEXT',
248 -background => $var->{_my_yellow},
249 -value => 'next',
250 -variable => \$rb_value,
251 -command => [ \&set_next ]
252 )->pack( -side => 'left' );
253  
254 $pick_rb = $mw->Radiobutton(
255 -text => 'PICK',
256 -background => $var->{_my_yellow},
257 -value => 'pick',
258 -variable => \$rb_value,
259 -command => [ \&set_pick ]
260 )->pack( -side => 'left' );
261 $saveNcont_rb = $mw->Radiobutton(
262 -text => 'Save and Continue',
263 -background => $var->{_my_yellow},
264 -value => 'saveNcont',
265 -variable => \$rb_value,
266 -command => [ \&set_saveNcont ]
267 )->pack( -side => 'left' );
268  
269 $exit_rb = $mw->Radiobutton(
270 -text => 'EXIT',
271 -background => $var->{_my_yellow},
272 -value => 'exit',
273 -variable => \$rb_value,
274 -command => [ \&set_exit ]
275 )->pack( -side => 'left' );
276  
277 MainLoop; # for Tk widgets
278 } # for new data
279  
280  
281 =head2 Set the prompt
282  
283 value according
284 to which button is pressed
285 then exit the MainLoop
286 destroy the main window after the prompt
287 is properly set
288  
289 =cut
290  
291 =head2 sub set_pick
292  
293 callbacks
294
295 send gather number to $iPick
296 delete output of previous displays
297  
298 =cut
299  
300 sub set_pick {
301  
302 my ($self) = @_;
303 my $pick = 'pick';
304 $pick_rb->configure( -state => 'normal' );
305 $iPick_Tk->{_prompt} = $pick;
306  
307 print("Picking...\n");
308  
309 $iPick->gather_num($gather);
310  
311 =item Delete output
312  
313 of previous muting
314  
315 =cut
316  
317 # $xk->kill_this('suximage');
318 # $xk->kill_this('suxwigb');
319  
320 =head2
321 number_of_tries
322 -replot 1st data
323 -PICK X-T pairs
324 -Increment number of tries to make
325 data display interact with user
326 (number_of_tries = 1)
327  
328 =cut
329  
330 $message->set('iPick_xt');
331 $message->gather_num($gather);
332 $message->instructions('pre_pick_xt');
333 $number_of_tries++;
334 $iPick->number_of_tries($number_of_tries);
335  
336 # print("1. iPick.pl,set_pick,number_of_tries: $number_of_tries\n");
337  
338 if ( $number_of_tries >= 2 ) {
339  
340 # print("2. iPick.pl,set_pick,number_of_tries: $number_of_tries\n");
341 $iPick->iPicks_shownNselect();
342  
343 }
344 elsif ( $number_of_tries == 1 ) {
345  
346 # print("3. iPick.pl,set_pick,number_of_tries: $number_of_tries\n");
347 $iPick->iPicks_select_xt();
348  
349 }
350 else {
351 print("iPick.pl,bad number of tries\n");
352 }
353  
354 }
355  
356 =head2 sub set_calc
357  
358 -PRESS the CALC button
359 -Increment number of tries to make
360 display and show old picks
361 (if number_of_tries >1)
362  
363 =cut
364  
365 sub set_calc {
366  
367 my ($self) = @_;
368 my $calc = 'calc';
369 $calc_rb->configure( -state => 'normal' );
370 $iPick_Tk->{_prompt} = $calc;
371 print("Calculating...\n");
372  
373 =head2 Delete
374  
375 the previous display
376  
377 =cut
378  
379 # $xk->kill_this('suximage');
380 # $xk->kill_this('suxwigb');
381  
382 $iPick->iPicks_par();
383 $iPick->iPicks_sort();
384 $number_of_tries++;
385 $iPick->number_of_tries($number_of_tries);
386 $iPick->iPicks_shownNselect();
387 $iPick->iPicks_save();
388  
389 =head2 Message
390  
391 to halt flow
392 when number_of_tries >0
393  
394 =cut
395  
396 $message->set('iPick_xt');
397 $message->gather_num($gather);
398 $message->instructions('post_pick_xt');
399  
400 }
401  
402  
403 =head2 sub set_saveNcont
404  
405 same as next
406  
407 =cut
408  
409 sub set_saveNcont {
410  
411 my ($self) = @_;
412 my $saveNcont = 'saveNcont';
413 $saveNcont_rb->configure( -state => 'normal' );
414 $iPick_Tk->{_prompt} = $saveNcont;
415 print("Saving and Continuing...\n");
416  
417 &set_next();
418  
419 }
420  
421  
422 =head2 sub set_next
423  
424 In this case $self is empty
425 1. increment gather
426 Exit if beyond last gather
427 2. reset prompt
428 3. Otherwise display the first semblance
429 4 ... see following callbacks
430  
431 =cut
432  
433 sub set_next {
434  
435 my ($self) = @_;
436 print("Next...\n");
437 $next_rb->configure( -state => 'normal' );
438 my $next = '';
439 $iPick_Tk->{_prompt} = $next;
440 $gather = $gather + $gather_inc;
441  
442 print("new gather is $gather \n\n");
443  
444 =head2 Delete output
445  
446 of previous top mute
447  
448 =cut
449  
450 # $xk->kill_this('suximage');
451 # $xk->kill_this('suxwigb');
452 # $xk->kill_this('xgraph');
453  
454 if ( $gather > $last_gather ) {
455 set_exit();
456  
457 }
458 elsif ( $gather <= $last_gather ) {
459  
460 =head2 Display
461  
462 update gather number in memory
463 first x,t again
464 Show user message
465 Select the xt values
466 =cut
467  
468 $iPick->gather_num($gather);
469 $iPick->iPicks_message('first_pick_xt');
470 $iPick->iPicks_select_xt();
471  
472 }
473 else {
474 print("iPick.pl, unexpected gather number\n");
475 }
476  
477 }
478  
479 =head2 sub set_exit
480  
481 say goodbye
482 clear old images
483 kill window
484 stop script
485  
486 =cut
487  
488 sub set_exit {
489  
490 my ($self) = @_;
491 my $exit = 'exit';
492 $exit_rb->configure( -state => 'normal' );
493 $iPick_Tk->{_prompt} = $exit;
494  
495 print("Good bye.\n");
496 print("Not continuing to next gather\n");
497  
498 # $xk->kill_this('suximage');
499 # $xk->kill_this('suxwigb');
500 # $xk->kill_this('xgraph');
501  
502 $mw->destroy() if Tk::Exists($mw);
503 exit 1;
504  
505 }