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

filter: Statementstmt 0.0% 0 / 224 Branchbran 0.0% 0 / 34 Conditioncond 0.0% 0 / 12 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 0.0% 0 / 29 Podpod 0.0% 0 / 13 totaltotal 0.0% 0 / 318 CC 18 SCAR 22.6
CC
18
Cov
0%
calcNdisplay
42.0
file_in
12.0
_inbound_curve_file
6.0
CRAP 9.6
1 package App::SeismicUnixGui::big_streams::iShow_picks;
2  
3 =head1 DOCUMENTATION
4  
5 =head2 SYNOPSIS
6  
7 PERL PROGRAM NAME: iShow_picks.pm
8 AUTHOR: Juan Lorenzo
9  
10 DESCRIPTION:
11 Purpose: display seelcted picks ontop of data
12 June 16 2019
13  
14 =head2 USE
15  
16 =head2 NOTES
17  
18  
19 =cut
20  
21 =head2
22  
23 needed packages
24  
25 =cut
26  
27 use Moose;
28 our $VERSION = '0.0.1';
29 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
30 use App::SeismicUnixGui::misc::control '0.0.3';
31 use aliased 'App::SeismicUnixGui::misc::control';
32 use aliased 'App::SeismicUnixGui::specs::big_streams::iPick_spec';
33 use aliased 'App::SeismicUnixGui::misc::manage_files_by';
34 use aliased 'App::SeismicUnixGui::misc::message';
35 use aliased 'App::SeismicUnixGui::misc::flow';
36 use aliased 'App::SeismicUnixGui::sunix::filter::sufilter';
37 use aliased 'App::SeismicUnixGui::sunix::shapeNcut::sugain';
38 use aliased 'App::SeismicUnixGui::sunix::shapeNcut::suwind';
39 use aliased 'App::SeismicUnixGui::sunix::plot::suxwigb';
40 use aliased 'App::SeismicUnixGui::sunix::plot::suximage';
41 use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config';
42 use aliased 'App::SeismicUnixGui::messages::SuMessages';
43  
44 use App::SeismicUnixGui::misc::SeismicUnix qw($go $in $on $off $ipicks
45 $itemp_picks_ $itemp_num_points
46 $itemp_picks_sorted_par_ $ipicks_par_ $suffix_su $suffix_hyphen $to
47 $itemp_picks_sorted_par_);
48  
49 my $iPick_spec = iPick_spec->new();
50  
51 my $get = L_SU_global_constants->new();
52 my $control = control->new();
53 my $manage_files_by = manage_files_by->new();
54 my $variables = $iPick_spec->variables();
55 my $DATA_DIR_IN = $variables->{_DATA_DIR_IN};
56 my $DATA_DIR_OUT = $variables->{_DATA_DIR_OUT};
57 my $data_suffix_in = $variables->{_data_suffix_in};
58 my $data_suffix_out = $variables->{_data_suffix_out};
59 my $var = $get->var();
60 my $empty_string = $var->{_empty_string};
61  
62 =head2
63  
64 inherit other packages
65 1. Instantiate classes
66 Create a new version of the package
67 Personalize to give it a new name if you wish
68 Use the following classes:
69  
70 =cut
71  
72 my $log = message->new();
73 my $run = flow->new();
74 my $sufilter = sufilter->new();
75 my $sugain = sugain->new();
76 my $suwind = suwind->new();
77 my $suxwigb = suxwigb->new();
78 my $suximage = suximage->new();
79 my $Project = Project_config->new();
80 my $SuMessages = SuMessages->new();
81 my $purpose = $get->purpose();
82  
83 =head2
84  
85 Import file-name and directory definitions
86  
87 =cut
88  
89 my ($PL_SEISMIC) = $Project->PL_SEISMIC();
90 my ($DATA_SEISMIC_SU) = $Project->DATA_SEISMIC_SU();
91 my ($DATA_SEISMIC_TXT) = $Project->DATA_SEISMIC_TXT();
92  
93 =head2
94
95 establish just the locally scoped variables
96  
97 =cut
98  
99 my ( @items, @flow, @sugain, @sufilter, @suwind );
100 my ( @suximage, @suxwigb );
101 my @windowtitle;
102 my @base_caption;
103  
104 =head2
105  
106 hash array of important variables used within
107 this package
108 Assume that the parameter file already exists
109 Assume that the name of this parameter file is:
110 $itemp__picks_sorted_par_.$iShow_picks->{_file_in}
111  
112 =cut
113  
114 my $iShow_picks = {
115 _gather_header => '',
116 _offset_type => '',
117 _file_in => '',
118 _freq => '',
119 _gather_num => '',
120 _inbound => '',
121 _inbound_curve_file => '',
122 _message_type => '',
123 _max_amplitude => '',
124 _max_x1 => '',
125 _min_amplitude => '',
126 _min_x1 => '',
127 _ntaper => '',
128 _number_of_tries => '',
129 _offset_type => '',
130 _parfile_in => '',
131 _textfile_in => '',
132 };
133  
134 =head2
135  
136 subroutine clear
137 to blank out hash array values
138  
139 =cut
140  
141 sub clear {
142 $iShow_picks->{_gather_header} = '';
143 $iShow_picks->{_file_in} = '';
144 $iShow_picks->{_file_in} = '';
145 $iShow_picks->{_freq} = '';
146 $iShow_picks->{_gather_num} = '';
147 $iShow_picks->{_inbound} = '';
148 $iShow_picks->{_inbound_curve_file} = '',
149 $iShow_picks->{_message_type} = '';
150 $iShow_picks->{_max_amplitude} = '';
151 $iShow_picks->{_max_x1} = '';
152 $iShow_picks->{_min_amplitude} = '';
153 $iShow_picks->{_min_x1} = '';
154 $iShow_picks->{_ntaper} = '';
155 $iShow_picks->{_number_of_tries} = '';
156 $iShow_picks->{_offset_type} = '';
157 $iShow_picks->{_parfile_in} = '';
158 $iShow_picks->{_textfile_in} = '';
159 }
160  
161 =head2 sub _inbound_curve_file
162  
163 Required text file with x,t pairs
164
165 =cut
166  
167 sub _inbound_curve_file {
168  
169 my ($self) = @_;
170  
171 if ( defined $iShow_picks->{_file_in} ) {
172  
173 my $file_in = $iShow_picks->{_file_in};
174  
175 $iShow_picks->{_inbound_curve_file} =
176 $DATA_DIR_OUT . '/' . $itemp_picks_ . $file_in;
177  
178 # print("iShow_picks, file_in: $iShow_picks->{_file_in} \n\n");
179 }
180 else {
181 print("iShow_picks, file_in: unexpected file_in \n\n");
182 }
183 }
184  
185 =head2 subroutine gather_header
186  
187 define the header for the x values
188 binheader type value helps define the x values
189 e.g. if gather_header = 'gather'
190 the x values are 'offset'
191  
192 =cut
193  
194 sub gather_header {
195 my ( $self, $gather_header ) = @_;
196 $iShow_picks->{_gather_header} = $gather_header
197 if defined($gather_header);
198  
199 #print(" header type is $iShow_picks->{_gather_header}\n\n");
200 }
201  
202 =head2 subroutine calcNdisplay
203  
204 main processing flow
205 display picks on top of results
206  
207 =cut
208  
209 sub calcNdisplay {
210  
211 =head2
212  
213 Assume that the parameter file already exists
214 Assume that the name of this parameter file is:
215 $itemp_picks_sorted_par_.$iShow_picks->{_file_in}
216  
217 =cut
218  
219 $iShow_picks->{_parfile_in} =
220 $itemp_picks_sorted_par_ . $iShow_picks->{_file_in};
221  
222 # SORT a TEXT FILE
223 # my @sort;
224 # $sort[1] = (" sort \\
225 # -n \\
226 # ");
227  
228 # print("iShow_picks, pick file is $iShow_picks->{_parfile_in}\n\n");
229  
230 =head2
231  
232 WINDOW DATA
233  
234 =cut
235  
236 $suwind->clear();
237 $suwind->setheaderword( $iShow_picks->{_gather_header} );
238 $suwind->min( $iShow_picks->{_gather_num} );
239 $suwind->max( $iShow_picks->{_gather_num} );
240  
241 # print("gather num is $iShow_picks->{_gather_num}\n\n");
242 $suwind[1] = $suwind->Step();
243  
244 $suwind->clear();
245 $suwind->tmin( $iShow_picks->{_min_x1} );
246 $suwind->tmax( $iShow_picks->{_max_x1} );
247 $suwind[2] = $suwind->Step();
248  
249 =head2
250  
251 set filtering parameters
252  
253 =cut
254  
255 $sufilter->clear();
256 $sufilter->freq( $iShow_picks->{_freq} );
257 $sufilter[1] = $sufilter->Step();
258  
259 =head2
260  
261 GAIN DATA
262  
263 =cut
264  
265 $sugain->clear();
266 $sugain->pbal($on);
267 $sugain[1] = $sugain->Step();
268  
269 $sugain->clear();
270 $sugain->agc($on);
271  
272 # nominal agc width
273 my $wagc =
274 ( $iShow_picks->{_max_x1} - $iShow_picks->{_min_x1} ) / 10;
275  
276 # print("iShow_picks,calcNdisplay,wagc=$wagc\n");
277 $sugain->width($wagc);
278 $sugain[2] = $sugain->Step();
279  
280 $sugain->clear();
281 $sugain->tpower(1.8);
282 $sugain[3] = $sugain->Step();
283  
284 =head2
285  
286 DISPLAY DATA (SUXIMAGE)
287  
288 =cut
289  
290 $base_caption[1] =
291 $iShow_picks->{_file_in}
292 . quotemeta(' ')
293 . quotemeta(' f=')
294 . $iShow_picks->{_freq};
295 $windowtitle[1] =
296 $iShow_picks->{_gather_header}
297 . quotemeta(' = ')
298 . $iShow_picks->{_gather_num};
299  
300 $suximage->clear();
301 $suximage->box_width(400);
302 $suximage->box_height(600);
303 $suximage->box_X0(200);
304 $suximage->box_Y0(150);
305 $suximage->title( $base_caption[1] );
306 $suximage->windowtitle( $windowtitle[1] );
307 $suximage->ylabel( quotemeta('TWTTs') );
308 $suximage->xlabel( $iShow_picks->{_offset_type} );
309 $suximage->legend($on);
310 $suximage->cmap('rgb0');
311 $suximage->loclip( $iShow_picks->{_min_amplitude} );
312 $suximage->hiclip( $iShow_picks->{_max_amplitude} );
313
314 # geopsy plot preference for JML
315 if ( length $iShow_picks->{_purpose}
316 and $iShow_picks->{_purpose} eq $purpose->{_geopsy}
317 and $iShow_picks->{_max_x1} > $iShow_picks->{_min_x1} ) {
318  
319 # print("iShow_picks, suximage with \'geopsy\' purpose\n");
320 # frequency is hzntl and velocity is vertical in geopsy,
321 # so the x axis is reversed compared to a normal seismic plot.
322 $suximage->orientation('normal');
323 $suximage->box_width(800);
324 $suximage->box_height(400);
325 $suximage->ylabel( quotemeta('frequency Hz') );
326 $suximage->cmap('hsv2');
327
328 } else {
329 $suxwigb->x1beg( $iShow_picks->{_min_x1} );
330 $suxwigb->x1end( $iShow_picks->{_max_x1} );
331 }
332
333  
334 $suximage->verbose($off);
335  
336 _inbound_curve_file();
337  
338 print("iShow_picks,calc, using a curve file:\n");
339 print("\t$iShow_picks->{_inbound_curve_file}\n\n");
340  
341 $suximage->curve( quotemeta( $iShow_picks->{_inbound_curve_file} ) );
342 my ( $ref_T, $ref_X, $num_tx_pairs ) =
343 $manage_files_by->read_2cols( \$iShow_picks->{_inbound_curve_file} );
344 $suximage->npair( quotemeta($num_tx_pairs) );
345 $suximage->curvecolor( quotemeta(2) );
346  
347 =item choose to save picks
348
349 =cut
350  
351 if ( $iShow_picks->{_number_of_tries} > 0 ) {
352  
353 $iShow_picks->{_TX_outbound} = $itemp_picks_ . $iShow_picks->{_file_in};
354 $suximage->picks( $DATA_DIR_OUT . '/' . $iShow_picks->{_TX_outbound} );
355  
356 print(
357 "iShow_picks, suximage, writing picks to $itemp_picks_$iShow_picks->{_file_in} \n"
358 );
359  
360 # print("iShow_picks, suximage, PATH: $DATA_DIR_OUT \n\n");
361 # print("number of tries is $iShow_picks->{_number_of_tries} \n\n");
362 }
363  
364 $suximage[1] = $suximage->Step();
365  
366 =head2
367  
368 DISPLAY DATA (SUXWIGB)
369  
370 =cut
371  
372 $base_caption[2] =
373 $iShow_picks->{_file_in} . quotemeta(' f=') . $iShow_picks->{_freq};
374 $windowtitle[2] =
375 $iShow_picks->{_gather_header}
376 . quotemeta(' = ')
377 . $iShow_picks->{_gather_num};
378  
379 $suxwigb->clear();
380 $suxwigb->box_width(400);
381 $suxwigb->box_height(600);
382 $suxwigb->box_X0(750);
383 $suxwigb->box_Y0(150);
384 $suxwigb->title( $base_caption[2] );
385 $suxwigb->windowtitle( $windowtitle[2] );
386 $suxwigb->ylabel( quotemeta('TWTTs') );
387 $suxwigb->xlabel( $iShow_picks->{_offset_type} );
388 $suxwigb->loclip( $iShow_picks->{_min_amplitude} );
389 $suxwigb->hiclip( $iShow_picks->{_max_amplitude} );
390
391 # geopsy plot preference for JML
392 if ( length $iShow_picks->{_purpose}
393
394 and $iShow_picks->{_purpose} eq $purpose->{_geopsy}
395 and $iShow_picks->{_max_x1} > $iShow_picks->{_min_x1} ) {
396  
397 # print("iShow_picks, suxwigb with \'geopsy\' purpose\n");
398
399 } else {
400 $suxwigb->x1beg( $iShow_picks->{_min_x1} );
401 $suxwigb->x1end( $iShow_picks->{_max_x1} );
402 }
403
404 $suxwigb->verbose($off);
405  
406 =head2 conditions
407
408 when number_of_tries is >=2
409 there should be a pre-exisiting digitized
410 overlay curve to plot as well
411  
412 =cut
413  
414 _inbound_curve_file();
415  
416 # print("iShow_picks,calc, using a curve file:\n");
417 # print("\t$iShow_picks->{_inbound_curve_file}\n\n");
418  
419 $suxwigb->curve( quotemeta( $iShow_picks->{_inbound_curve_file} ) );
420 ( $ref_T, $ref_X, $num_tx_pairs ) =
421 $manage_files_by->read_2cols( \$iShow_picks->{_inbound_curve_file} );
422 $suxwigb->npair( quotemeta($num_tx_pairs) );
423 $suxwigb->curvecolor( quotemeta(2) );
424  
425 =item choose to save picks
426
427 =cut
428  
429 if ( $iShow_picks->{_number_of_tries} > 0 ) {
430  
431 $iShow_picks->{_TX_outbound} = $itemp_picks_ . $iShow_picks->{_file_in};
432 $suxwigb->picks( $DATA_DIR_OUT . '/' . $iShow_picks->{_TX_outbound} );
433  
434 # print("iShow_picks, suxwigb, writing picks to $itemp_picks_$iShow_picks->{_file_in} \n");
435 # print("iShow_picks, suxwigb, PATH: $DATA_DIR_OUT \n\n");
436 # print("number of tries is $iShow_picks->{_number_of_tries} \n\n");
437 }
438  
439 $suxwigb[1] = $suxwigb->Step();
440  
441 =head2
442
443 DEFINE FLOW(S) - for both suximage AND suxwigb
444  
445 =cut
446  
447 @items = (
448 $suwind[1], $in, $iShow_picks->{_inbound}, $to,
449 $suwind[2], $to, $sufilter[1], $to,
450 $sugain[1], $to, $suxwigb[1], $go
451 );
452 $flow[1] = $run->modules( \@items );
453  
454 @items = (
455 $suwind[1], $in, $iShow_picks->{_inbound}, $to,
456 $suwind[2], $to, $sufilter[1], $to,
457 $sugain[1], $to, $suximage[1], $go
458 );
459 $flow[2] = $run->modules( \@items );
460  
461 =head2
462  
463 RUN FLOW(S)
464
465 output copy of picked data points
466 only occurs after the number of tries
467 is updated
468  
469 =cut
470  
471 if ($iShow_picks->{_purpose} eq $purpose->{_geopsy}) {
472  
473 # for suximage
474 $run->flow( \$flow[2] );
475  
476 }else {
477 # for suxwigb
478 $run->flow( \$flow[1] );
479  
480 # for suximage
481 $run->flow( \$flow[2] );
482 }
483 =head2
484  
485 LOG FLOW(S)TO SCREEN AND FILE
486  
487 =cut
488  
489 # for suxwigb
490 # print "$flow[1]\n";
491 #$log->file($flow[1]);
492  
493 #for suximage
494 # print "$flow[2]\n";
495  
496 } # end calcNdisplay subroutine
497  
498 =head2 sub file_in
499  
500 Required sunix file name
501 on which to pick mute values
502 print("$iShow_picks->{_inbound}\n\n");
503
504 =cut
505  
506 sub file_in {
507  
508 my ( $self, $file_in ) = @_;
509  
510 if ( defined $file_in ) {
511  
512 # e.g. 'sp1' becomes sp1
513 $control->set_infection($file_in);
514 $file_in = control->get_ticksBgone();
515 $iShow_picks->{_file_in} = $file_in if defined($file_in);
516 $iShow_picks->{_inbound} =
517 $DATA_DIR_IN . '/' . $file_in . $data_suffix_in;
518  
519 # print("iShow_picks, file_in: $iShow_picks->{_file_in} \n\n");
520 }
521 else {
522 print("iShow_picks, file_in: unexpected file_in \n\n");
523 }
524 }
525  
526 =head2
527  
528 subroutine freq
529 creates the bandpass frequencies to filter data
530 e.g., "3,6,40,50"
531
532 =cut
533  
534 sub freq {
535 my ( $self, $freq ) = @_;
536 $iShow_picks->{_freq} = $freq if defined($freq);
537  
538 # print("freq is $iShow_picks->{_freq}\n\n");
539 }
540  
541 =head2 subroutine gather
542  
543 sets gather number to consider
544  
545 =cut
546  
547 sub gather_num {
548 my ( $self, $gather_num ) = @_;
549 $iShow_picks->{_gather_num} = $gather_num if defined($gather_num);
550 }
551  
552 =head2
553  
554 subroutine maximum amplitude to plot
555  
556 =cut
557  
558 sub max_amplitude {
559 my ( $self, $max_amplitude ) = @_;
560 $iShow_picks->{_max_amplitude} = $max_amplitude
561 if defined($max_amplitude);
562  
563 # print("max_amplitude is $iShow_picks->{_max_amplitude}\n\n");
564 }
565  
566 =head2
567  
568 subroutine minumum amplitude to plot
569  
570 =cut
571  
572 sub min_amplitude {
573 my ( $self, $min_amplitude ) = @_;
574 $iShow_picks->{_min_amplitude} = $min_amplitude
575 if defined($min_amplitude);
576  
577 # print("min_amplitude is $iShow_picks->{_min_amplitude}\n\n");
578  
579 }
580  
581 =head2 sub max_x1
582  
583 maximum time/Hz to plot
584  
585 =cut
586  
587 sub max_x1 {
588 my ( $self, $max_x1 ) = @_;
589  
590 if ( length $max_x1 ) {
591  
592 $iShow_picks->{_max_x1} = $max_x1;
593  
594 # print("max_x1 is $iShow_picks->{_max_x1}\n\n");
595  
596 } else {
597 print("iShow_picks, max_x1, value missing\n");
598 }
599 return ();
600 }
601  
602 =head3 sub min_x1
603  
604 minumum time/Hz to plot
605  
606 =cut
607  
608 sub min_x1 {
609 my ( $self, $min_x1 ) = @_;
610  
611 if ( length $min_x1 ) {
612  
613 $iShow_picks->{_min_x1} = $min_x1;
614  
615 # print("min_x1 is $iShow_picks->{_min_x1}\n\n");
616  
617 } else {
618 print("iShow_picks,min_x1, unexpected min time-s\n");
619 }
620 }
621  
622 =head2 sub number_of_tries
623  
624 keep track of the number of attempts
625 at picking top mute
626  
627 =cut
628  
629 sub number_of_tries {
630 my ( $self, $number_of_tries ) = @_;
631 $iShow_picks->{_number_of_tries} = $number_of_tries
632 if defined($number_of_tries);
633  
634 # print("num of tries is $iShow_picks->{_number_of_tries}\n\n");
635 }
636  
637 =head2 subroutine offset_type
638  
639 define the header for the x values
640 offset type value helps define the x values
641 e.g. if offset_type = 'gather'
642 the x values are 'offset'
643  
644 =cut
645  
646 sub offset_type {
647 my ( $self, $offset_type ) = @_;
648
649 $iShow_picks->{_offset_type} = $offset_type if defined($offset_type);
650  
651 print(" header type is $iShow_picks->{_offset_type}\n\n");
652 }
653  
654 1;