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

filter: Statementstmt 0.0% 0 / 112 Branchbran 0.0% 0 / 18 Conditioncond 0.0% 0 / 15 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 0.0% 0 / 21 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 183 CC 10 SCAR 18.7
CC
10
Cov
0%
calc
20.0
set_purpose
12.0
gather_header
6.0
CRAP 6.5
1 package App::SeismicUnixGui::big_streams::iSave_picks;
2  
3 use Moose;
4 our $VERSION = '0.0.1';
5  
6 =head1 DOCUMENTATION
7  
8 =head2 SYNOPSIS
9  
10 PROGRAM NAME:iSave_picks.pm
11 AUTHOR: Juan Lorenzo
12 DATE: iSave_picks
13 Version: 1.0
14  
15 DESCRIPTION: Save final version of
16 muted picks for any type of muting
17  
18 =head2 USE
19  
20 =head4
21  
22 Examples
23  
24 =head2 SEISMIC UNIX NOTES
25  
26 =head4 CHANGES and their DATES
27  
28 Base on iTop_mute_picks3.pm V 3.0
29 Sept. 2015
30 Originally to Save final Top Mute of Data
31  
32 =head2 STEPS
33  
34 use the local library of the user
35 bring is user variables from a local file
36 create instances of the needed subroutines
37  
38 =cut
39  
40 =head2
41  
42 instantiate classes
43  
44 =cut
45  
46 use aliased 'App::SeismicUnixGui::misc::message';
47 use aliased 'App::SeismicUnixGui::misc::flow';
48 use aliased 'App::SeismicUnixGui::sunix::shell::cp';
49 use App::SeismicUnixGui::misc::SeismicUnix qw($go $in $on $to);
50 use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config';
51 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
52  
53 use App::SeismicUnixGui::misc::control '0.0.3';
54 use aliased 'App::SeismicUnixGui::misc::control';
55  
56 my $control = control->new();
57 my $get = L_SU_global_constants->new();
58 my $log = message->new();
59 my $run = flow->new();
60 my $cp = cp->new();
61 my $Project = Project_config->new();
62  
63 my $purpose = $get->purpose();
64 my $var = $get->var();
65 my $empty_string = $var->{_empty_string};
66  
67 =head2
68  
69 Import file-name and directory definitions
70  
71 =cut
72  
73 use App::SeismicUnixGui::misc::SeismicUnix qw($itemp_picks_sorted_par_ $ipicks_par_);
74 my ($DATA_SEISMIC_TXT) = $Project->DATA_SEISMIC_TXT();
75  
76 =head2
77
78 declare variables types
79 establish just the locally scoped variables
80  
81 =cut
82  
83 my ( @flow, @cp, @items );
84  
85 =head2
86  
87 create hash with important variables
88  
89 =cut
90  
91 my $iSave_picks = {
92 _gather_num => '',
93 _gather_type => '',
94 _gather_header => '',
95 _file_in => '',
96 _inbound => '',
97 _outbound => '',
98 _purpose => '',
99 };
100  
101 =head2 subroutine clear
102  
103 sets all variable strings to ''
104  
105 =cut
106  
107 sub clear {
108 $iSave_picks->{_gather_num} = '';
109 $iSave_picks->{_gather_type} = '';
110 $iSave_picks->{_gather_header} = '';
111 $iSave_picks->{_inbound} = '';
112 $iSave_picks->{_outbound} = '';
113 $iSave_picks->{_purpose} = '';
114 }
115  
116 =head2 subroutine gather_header
117  
118 sets gather_header number to consider
119  
120 =cut
121  
122 sub gather_header {
123 my ( $variable, $gather_header ) = @_;
124 $iSave_picks->{_gather_header} = $gather_header
125 if defined($gather_header);
126 }
127  
128 =head2 sub calc
129  
130 rewrite sorted picks into a permanent file
131  
132 =cut
133  
134 sub calc {
135  
136 my ($self) = @_;
137  
138 # my $suffix = '_'.$iSave_picks->{_gather_header}.
139 # $iSave_picks->{_gather_num};
140  
141 # CASE 1 - geopsy
142 if ( defined $iSave_picks->{_purpose}
143 && $iSave_picks->{_purpose} eq $purpose->{_geopsy} )
144 {
145  
146 my ($GEOPSY_PICKS_RAW) = $Project->GEOPSY_PICKS_RAW();
147  
148 if ( -d $GEOPSY_PICKS_RAW ) {
149  
150 $iSave_picks->{_inbound} =
151 $DATA_SEISMIC_TXT . '/'
152 . '.itemp'
153 . '_picks_sorted_'
154 . $iSave_picks->{_file_in};
155  
156 $iSave_picks->{_outbound} =
157 $GEOPSY_PICKS_RAW . '/' . 'xt_'
158 . $iSave_picks->{_file_in} . '_'
159 . $iSave_picks->{_gather_type}
160 . $iSave_picks->{_gather_num};
161  
162 $cp->from( $iSave_picks->{_inbound} );
163 $cp->to( $iSave_picks->{_outbound} );
164 $cp[1] = $cp->Step();
165  
166 }
167 else {
168  
169 use Tk;
170 use strict;
171 use App::SeismicUnixGui::misc::L_SU_global_constants;
172  
173 my $get = L_SU_global_constants->new();
174 my $var = $get->var();
175  
176 # Main Window
177 my $mw = MainWindow->new();
178  
179 my $arial_14 = $mw->fontCreate(
180 'arial_14',
181 -family => 'arial',
182 -weight => 'bold',
183 -size => -14
184 );
185  
186 $mw->configure( -background => $var->{_my_purple} );
187  
188 use App::SeismicUnixGui::messages::message_director;
189 my $iPick_message = message_director->new();
190 my $message = $iPick_message->iPick(0);
191  
192 $mw->messageBox(
193 -title => "iPick geopsy",
194 -font => $arial_14,
195 -message => $message,
196 -background => $var->{_my_yellow},
197 -default => 'oK',
198 );
199 print("iSave_picks,calc, $message\n");
200 }
201  
202 }
203 # CASE 2 - normal case
204 elsif ( not defined $iSave_picks->{_purpose}
205 || $iSave_picks->{_purpose} eq $empty_string )
206 {
207  
208 $iSave_picks->{_inbound} =
209 $DATA_SEISMIC_TXT . '/'
210 . '.itemp'
211 . '_picks_sorted_par_'
212 . $iSave_picks->{_file_in};
213  
214 $iSave_picks->{_outbound} =
215 $DATA_SEISMIC_TXT . '/'
216 . 'xt_par_'
217 . $iSave_picks->{_file_in} . '_'
218 . $iSave_picks->{_gather_type}
219 . $iSave_picks->{_gather_num};
220  
221 $cp->from( $iSave_picks->{_inbound} );
222 $cp->to( $iSave_picks->{_outbound} );
223 $cp[1] = $cp->Step();
224  
225 }
226 else {
227 print("1. iSave_picks, purpose:---$iSave_picks->{_purpose}---\n");
228 }
229  
230 =head2
231  
232 DEFINE FLOW(S)
233  
234 =cut
235  
236 @items = ( $cp[1], $go );
237 $flow[1] = $run->modules( \@items );
238  
239 =head2
240  
241 RUN FLOW(S)
242  
243 =cut
244  
245 $run->flow( \$flow[1] );
246  
247 =head2
248  
249 LOG FLOW(S)TO SCREEN AND FILE
250  
251 =cut
252  
253 # print "$flow[1]\n";
254 # $log->file($flow[1]);
255  
256 } # end calc subroutine
257  
258 =head2 subroutine file_in
259  
260 Required file name
261 on which to pick x,t values
262  
263 =cut
264  
265 sub file_in {
266  
267 my ( $self, $file_in ) = @_;
268  
269 if ( defined $file_in && $file_in ne $empty_string ) {
270  
271 # e.g. 'sp1' becomes sp1
272 $control->set_infection($file_in);
273 $file_in = control->get_ticksBgone();
274 $iSave_picks->{_file_in} = $file_in;
275  
276 # print("iSave_picks, file_in: $iSave_picks->{_file_in} \n");
277  
278 }
279 else {
280 print("iSave_picks, file_in: unexpected file_in \n");
281 }
282 }
283  
284 =head2 subroutine gather
285  
286 sets gather number to consider
287  
288 =cut
289  
290 sub gather_num {
291 my ( $variable, $gather_num ) = @_;
292 $iSave_picks->{_gather_num} = $gather_num if defined($gather_num);
293 }
294  
295 =head2 sub gather_type
296  
297 define which family of messages to use
298
299 e.g., SP or CDP
300  
301 =cut
302  
303 sub gather_type {
304 my ( $self, $gather_type ) = @_;
305  
306 if ( defined($gather_type)
307 || $gather_type eq $empty_string )
308 {
309  
310 control->set_infection($gather_type);
311 $gather_type = control->get_ticksBgone();
312 $iSave_picks->{_gather_type} = $gather_type;
313  
314 # print("iSave_picks,gather_type: $gather_type\n");
315  
316 }
317 else {
318 print("iSave_picks,gather_type, unexpected gather_type");
319 }
320 return ();
321 }
322  
323 #sub icp {
324 #
325 # my ($self) = @_;
326 #
327 # use Shell qw(echo);
328 #
329 # my $home_directory = ` echo \$HOME`;
330 # chomp $home_directory;
331 #
332 # my $HOME = $home_directory;
333 #
334 # use File::Copy;
335 # use App::SeismicUnixGui::misc::control '0.0.3';
336 #use aliased 'App::SeismicUnixGui::misc::control';
337 # use dirs;
338 # use App::SeismicUnixGui::misc::readfiles;
339 #
340 # my $ACTIVE_CONFIGURATION = $HOME.'/.L_SU/configuration/active';
341 # my $inbound = $ACTIVE_CONFIGURATION.'/Project.config';
342 #
343 # my $readfiles = readfiles ->new();
344 # my $dirs = dirs ->new();
345 # my $control = control ->new();
346 #
347 # my $project = {
348 # _names_aref => '',
349 # _values_aref => '',
350 # _check_buttons_aref => '',
351 # };
352 #
353 # my ($names_aref,$values_aref) = $readfiles->configs($inbound);
354 #
355 # $project->{_names_aref} = $names_aref;
356 # $project->{_values_aref} = $values_aref;
357 # my $PROJECT_NAME = @{$project->{_values_aref}}[2];
358 # # my $PROJECT_PATH = @{$project->{_values_aref}}[1];
359 # $dirs -> set_path($PROJECT_NAME);
360 # my $Project_name = $dirs-> get_last_dirInpath();
361 # $control -> set_infection($Project_name );
362 # $Project_name = $control->get_ticksBgone();
363 #
364 # # print("Project_config,update_configuration_file, PROJECT_PATH: $PROJECT_PATH\n");
365 #
366 # # print("Project_config,update_configuration_file, Project_name: $Project_name \n");
367 #
368 # my $FROM_project_config = $inbound;
369 # my $TO_project_config = $HOME.'/.L_SU/configuration/'.$Project_name.'/Project.config';
370 # # print("Project_config,update_configuration_files copying from $FROM_project_config to $TO_project_config\n");
371 # copy($FROM_project_config,$TO_project_config);
372 #
373 #
374 # }
375  
376 =head2 sub set_purpose
377  
378 define where the data will need to go
379 define the type of behavior
380
381 =cut
382  
383 sub set_purpose {
384  
385 my ( $self, $type ) = @_;
386  
387 if ( defined $type
388 && $type ne $empty_string )
389 {
390  
391 my $control = control->new();
392 $control->set_infection($type);
393 $type = control->get_ticksBgone();
394  
395 # print("iSave_picks,set_purpose: $type\n");
396 # print("iSave_picks,set_purpose: $purpose->{_geopsy}\n");
397  
398 if ( $type eq $purpose->{_geopsy} ) {
399  
400 $iSave_picks->{_purpose} = $type;
401  
402 # print("iSave_picks,set_purpose: $iSave_picks->{_purpose}\n");
403  
404 }
405 else {
406 # print("iSave_picks,set_purpose is unavailable, NADA\n");
407 }
408  
409 }
410 else {
411 # print("iSave_picks,set_purpose value is empty NADA\n");
412 }
413 }
414  
415 1;