« lib/App/SeismicUnixGui/sunix/data/data_in.pm
↑ Summary
lib/App/SeismicUnixGui/sunix/header/header_values.pm »
| 1 | package App::SeismicUnixGui::sunix::shell::sucat; | ||
| 2 | |||
| 3 | use Moose; | ||
| 4 | our $VERSION = '0.0.1'; | ||
| 5 | |||
| 6 | =head1 DOCUMENTATION | ||
| 7 | |||
| 8 | =head2 SYNOPSIS | ||
| 9 | |||
| 10 | PROGRAM NAME: sucat | ||
| 11 | AUTHOR: Juan Lorenzo (Perl module only) | ||
| 12 | DATE: May 25 2016 | ||
| 13 | DESCRIPTION concatenate a list of files | ||
| 14 | Version 1 | ||
| 15 | 1.01 June 23 2016 | ||
| 16 | Variable suffix changed to input_suffix | ||
| 17 | Notes: | ||
| 18 | Package name is the same as the file name | ||
| 19 | Moose is a package that allows an object-oriented | ||
| 20 | syntax to organizing your programs | ||
| 21 | |||
| 22 | =cut | ||
| 23 | |||
| 24 | =head2 USAGE 1 (todo) | ||
| 25 | |||
| 26 | To cat an array of trace numbers | ||
| 27 | Example | ||
| 28 | $sucat->tracl(\@array); | ||
| 29 | $sucat->Steps() | ||
| 30 | |||
| 31 | =head2 USAGE 2 | ||
| 32 | |||
| 33 | To cat a defined range of numerically-named | ||
| 34 | files | ||
| 35 | |||
| 36 | Example: | ||
| 37 | $sucat->first_file_number_in('1000'); | ||
| 38 | $sucat->last_file_number_in('1001'); | ||
| 39 | $sucat->number_of_files_in('2'); | ||
| 40 | $sucat->Step(); | ||
| 41 | =cut | ||
| 42 | |||
| 43 | =head2 import packages | ||
| 44 | |||
| 45 | =cut | ||
| 46 | |||
| 47 | use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config'; | ||
| 48 | use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants'; | ||
| 49 | use aliased 'App::SeismicUnixGui::misc::readfiles'; | ||
| 50 | use aliased 'App::SeismicUnixGui::misc::manage_files_by'; | ||
| 51 | use App::SeismicUnixGui::misc::control '0.0.3'; | ||
| 52 | use aliased 'App::SeismicUnixGui::misc::control'; | ||
| 53 | use App::SeismicUnixGui::misc::SeismicUnix | ||
| 54 | qw($itop_mute $ibot_mute $ivpicks_sorted_par_ $ep $fldr | ||
| 55 | $cdp $mute $su $suffix_su $suffix_txt $velan); | ||
| 56 | |||
| 57 | =head2 instantiate new variables | ||
| 58 | |||
| 59 | =cut | ||
| 60 | |||
| 61 | my $get = L_SU_global_constants->new(); | ||
| 62 | my $Project = Project_config->new(); | ||
| 63 | my $manage_files_by = manage_files_by->new(); | ||
| 64 | |||
| 65 | my $DATA_SEISMIC_SU = $Project->DATA_SEISMIC_SU(); # output seismic data directory | ||
| 66 | my $DATA_SEISMIC_TXT = $Project->DATA_SEISMIC_TXT(); # output list directory | ||
| 67 | |||
| 68 | =head2 declare local variables | ||
| 69 | |||
| 70 | =cut | ||
| 71 | |||
| 72 | my $var = $get->var(); | ||
| 73 | my $empty_string = $var->{_empty_string}; | ||
| 74 | |||
| 75 | =head2 newline: | ||
| 76 | |||
| 77 | is a special character | ||
| 78 | |||
| 79 | =cut | ||
| 80 | |||
| 81 | my $newline = ' | ||
| 82 | '; | ||
| 83 | |||
| 84 | =head2 list: | ||
| 85 | |||
| 86 | an empty list array | ||
| 87 | |||
| 88 | =cut | ||
| 89 | |||
| 90 | my (@list); | ||
| 91 | |||
| 92 | =head2 sucat: | ||
| 93 | is a hash of important variables | ||
| 94 | |||
| 95 | =cut | ||
| 96 | |||
| 97 | my $sucat = { | ||
| 98 | _first_file_number_in => '', | ||
| 99 | _gather_type => '', | ||
| 100 | _inbound_directory => '', | ||
| 101 | _input_suffix => '', | ||
| 102 | _input_name_extension => '', | ||
| 103 | _input_name_prefix => '', | ||
| 104 | _outbound_directory => '', | ||
| 105 | _last_file_number_in => '', | ||
| 106 | _list_aref => '', | ||
| 107 | _list_directory => '', | ||
| 108 | _number_of_files_in => '', | ||
| 109 | _input_suffix => '', | ||
| 110 | _data_type => '', | ||
| 111 | _output_base_file_name => '', | ||
| 112 | _outbound => '', | ||
| 113 | _velan_data => '', | ||
| 114 | _Step => '' | ||
| 115 | }; | ||
| 116 | |||
| 117 | =head2 sub clear: | ||
| 118 | |||
| 119 | clean hash of its values | ||
| 120 | |||
| 121 | =cut | ||
| 122 | |||
| 123 | sub clear { | ||
| 124 | my ($self) = @_; | ||
| 125 | $sucat->{_first_file_number_in} = ''; | ||
| 126 | $sucat->{_gather_type} = ''; | ||
| 127 | $sucat->{_inbound_directory} = ''; | ||
| 128 | $sucat->{_input_name_extension} = ''; | ||
| 129 | $sucat->{_input_suffix} = ''; | ||
| 130 | $sucat->{_outbound_directory} = ''; | ||
| 131 | $sucat->{_last_file_number_in} = ''; | ||
| 132 | $sucat->{_list_array} = ''; | ||
| 133 | $sucat->{_list_directory} = ''; | ||
| 134 | $sucat->{_data_type} = ''; | ||
| 135 | $sucat->{_number_of_files_in} = ''; | ||
| 136 | $sucat->{_input_suffix} = ''; | ||
| 137 | $sucat->{_output_base_file_name} = ''; | ||
| 138 | $sucat->{_outbound} = ''; | ||
| 139 | $sucat->{_Step} = ''; | ||
| 140 | } | ||
| 141 | |||
| 142 | =head2 _get_data_type | ||
| 143 | |||
| 144 | =cut | ||
| 145 | |||
| 146 | sub _get_data_type { | ||
| 147 | my ($self) = @_; | ||
| 148 | |||
| 149 | if ( $sucat->{_list_directory} ne $empty_string | ||
| 150 | and $sucat->{_list} ne $empty_string ) | ||
| 151 | |||
| 152 | { | ||
| 153 | |||
| 154 | # my $velan = $ivpicks_sorted_par_; | ||
| 155 | |||
| 156 | =head2 instantiate packages | ||
| 157 | |||
| 158 | =cut | ||
| 159 | |||
| 160 | my $read = readfiles->new(); | ||
| 161 | |||
| 162 | =head2 declare local variables | ||
| 163 | |||
| 164 | =cut | ||
| 165 | |||
| 166 | my @data_type; | ||
| 167 | my $data_type; | ||
| 168 | |||
| 169 | my $inbound_list = | ||
| 170 | $sucat->{_list_directory} . '/' . $sucat->{_list} . $suffix_txt; | ||
| 171 | |||
| 172 | my ( $array_ref, $num_gathers ) = $read->cols_1p($inbound_list); | ||
| 173 | |||
| 174 | for ( my $i = 0 ; $i < $num_gathers ; $i++ ) { | ||
| 175 | |||
| 176 | my $file_name = @$array_ref[$i]; | ||
| 177 | |||
| 178 | if ( $file_name =~ m/$itop_mute/ | ||
| 179 | or $file_name =~ m/$ibot_mute/ ) | ||
| 180 | { | ||
| 181 | |||
| 182 | #CASE 1 for mute-type files | ||
| 183 | |||
| 184 | $data_type[$i] = $mute; | ||
| 185 | |||
| 186 | # print("sucat,_get_data_type, success, matched mute\n"); | ||
| 187 | |||
| 188 | } | ||
| 189 | elsif ( $file_name =~ m/$ivpicks_sorted_par_/ ) { | ||
| 190 | |||
| 191 | #CASE 2 for velan-type files | ||
| 192 | |||
| 193 | # print("success, matched velan\n"); | ||
| 194 | $data_type[$i] = $velan; | ||
| 195 | |||
| 196 | } | ||
| 197 | elsif ( $file_name =~ m/$suffix_su/ ) { | ||
| 198 | |||
| 199 | # print("success, matched $su\n"); | ||
| 200 | $data_type[$i] = $su; | ||
| 201 | |||
| 202 | } | ||
| 203 | else { | ||
| 204 | print("sucat,_get_data_type, mismatch\n"); | ||
| 205 | $data_type[$i] = $empty_string; | ||
| 206 | } | ||
| 207 | |||
| 208 | } | ||
| 209 | |||
| 210 | # all data types must be the same | ||
| 211 | $data_type = $data_type[0]; | ||
| 212 | |||
| 213 | for ( my $i = 0 ; $i < $num_gathers ; $i++ ) { | ||
| 214 | |||
| 215 | if ( $data_type[0] eq $data_type[$i] ) { | ||
| 216 | |||
| 217 | # print("sucat,_get_data_type, data_type is consistent NADA\n"); | ||
| 218 | |||
| 219 | } | ||
| 220 | elsif ( $data_type[0] ne $data_type[$i] ) { | ||
| 221 | |||
| 222 | $data_type = $empty_string; | ||
| 223 | |||
| 224 | # print("sucat,_get_data_type,failed\ test\n"); | ||
| 225 | |||
| 226 | } | ||
| 227 | else { | ||
| 228 | print("sucat,_get_data_type_unexpected result\n"); | ||
| 229 | $data_type = $empty_string; | ||
| 230 | } | ||
| 231 | } | ||
| 232 | |||
| 233 | my $result = $data_type; | ||
| 234 | return ($result); | ||
| 235 | |||
| 236 | } | ||
| 237 | else { | ||
| 238 | print("sucat,_get_data_type,missing list and its directory\n"); | ||
| 239 | } | ||
| 240 | } | ||
| 241 | |||
| 242 | =head2 _get_gather_type | ||
| 243 | |||
| 244 | =cut | ||
| 245 | |||
| 246 | sub _get_gather_type { | ||
| 247 | my ($self) = @_; | ||
| 248 | |||
| 249 | if ( | ||
| 250 | length $sucat->{_list_directory} | ||
| 251 | and length $sucat->{_list} | ||
| 252 | and ( ( $sucat->{_data_type} eq $velan ) | ||
| 253 | or $sucat->{_data_type} eq $mute ) | ||
| 254 | ) | ||
| 255 | { | ||
| 256 | |||
| 257 | =head2 instantiate packages | ||
| 258 | |||
| 259 | =cut | ||
| 260 | |||
| 261 | my $read = readfiles->new(); | ||
| 262 | |||
| 263 | =head2 declare local variables | ||
| 264 | |||
| 265 | =cut | ||
| 266 | |||
| 267 | my @gather_type; | ||
| 268 | my $gather_type; | ||
| 269 | |||
| 270 | my $inbound_list = | ||
| 271 | $sucat->{_list_directory} . '/' . $sucat->{_list} . $suffix_txt; | ||
| 272 | |||
| 273 | my ( $array_ref, $num_gathers ) = $read->cols_1p($inbound_list); | ||
| 274 | |||
| 275 | for ( my $i = 0 ; $i < $num_gathers ; $i++ ) { | ||
| 276 | |||
| 277 | my $file_name = @$array_ref[$i]; | ||
| 278 | |||
| 279 | if ( $file_name =~ m/$fldr/ | ||
| 280 | or $file_name =~ m/$cdp/ ) | ||
| 281 | { | ||
| 282 | |||
| 283 | #CASE 1 for field record gathers | ||
| 284 | |||
| 285 | $gather_type[$i] = 'fldr'; | ||
| 286 | |||
| 287 | print("sucat,_get_gather_type, success, matched fldr\n"); | ||
| 288 | |||
| 289 | } | ||
| 290 | elsif ( $file_name =~ m/$ep/ ) { | ||
| 291 | |||
| 292 | #CASE 2 for velan-type files | ||
| 293 | |||
| 294 | # print("success, matched velan\n"); | ||
| 295 | $gather_type[$i] = $ep; | ||
| 296 | |||
| 297 | } | ||
| 298 | else { | ||
| 299 | print("sucat,_get_gather_type, mismatch\n"); | ||
| 300 | } | ||
| 301 | } | ||
| 302 | |||
| 303 | # all gather types must be the same | ||
| 304 | $gather_type = $gather_type[0]; | ||
| 305 | |||
| 306 | for ( my $i = 0 ; $i < $num_gathers ; $i++ ) { | ||
| 307 | |||
| 308 | if ( $gather_type[0] eq $gather_type[$i] ) { | ||
| 309 | |||
| 310 | # print("sucat,_get_gather_type, gather_type is consistent NADA\n"); | ||
| 311 | |||
| 312 | } | ||
| 313 | elsif ( $gather_type[0] ne $gather_type[$i] ) { | ||
| 314 | |||
| 315 | $gather_type = $empty_string; | ||
| 316 | |||
| 317 | # print("sucat,_get_gather_type,failed\ test\n"); | ||
| 318 | |||
| 319 | } | ||
| 320 | else { | ||
| 321 | print("sucat,_get_gather_type_unexpected result\n"); | ||
| 322 | $gather_type = $empty_string; | ||
| 323 | } | ||
| 324 | } | ||
| 325 | |||
| 326 | my $result = $gather_type; | ||
| 327 | return ($result); | ||
| 328 | |||
| 329 | } | ||
| 330 | else { | ||
| 331 | # print("sucat,_get_gather_type, missing list and its directory NADA\n"); | ||
| 332 | } | ||
| 333 | } | ||
| 334 | |||
| 335 | =head2 sub _set_data_type | ||
| 336 | |||
| 337 | set_data_type can be velan,su,txt, cat | ||
| 338 | |||
| 339 | =cut | ||
| 340 | |||
| 341 | sub _set_data_type { | ||
| 342 | my ($data_type) = @_; | ||
| 343 | |||
| 344 | if ( $data_type ne $empty_string ) { | ||
| 345 | |||
| 346 | $sucat->{_data_type} = $data_type; | ||
| 347 | |||
| 348 | # print("sucat, _set_data_type, data_type = $sucat->{_data_type}\n"); | ||
| 349 | |||
| 350 | } | ||
| 351 | else { | ||
| 352 | print("sucat, _set_data_type, missing data_type\n"); | ||
| 353 | } | ||
| 354 | |||
| 355 | } | ||
| 356 | |||
| 357 | =head2 sub _set_gather_type | ||
| 358 | |||
| 359 | set_gather_type can be cdp,ep,fldr | ||
| 360 | |||
| 361 | =cut | ||
| 362 | |||
| 363 | sub _set_gather_type { | ||
| 364 | |||
| 365 | my ($gather_type) = @_; | ||
| 366 | |||
| 367 | if ( $gather_type ne $empty_string ) { | ||
| 368 | |||
| 369 | $sucat->{_gather_type} = $gather_type; | ||
| 370 | |||
| 371 | # print("sucat, _set_gather_type, gather_type = $sucat->{_gather_type}\n"); | ||
| 372 | |||
| 373 | } | ||
| 374 | else { | ||
| 375 | print("sucat, _set_gather_type, missing data_type\n"); | ||
| 376 | } | ||
| 377 | |||
| 378 | } | ||
| 379 | |||
| 380 | =head2 sub data_type | ||
| 381 | |||
| 382 | data_type can be velan,su,txt,mute | ||
| 383 | |||
| 384 | =cut | ||
| 385 | |||
| 386 | sub data_type { | ||
| 387 | my ($self) = @_; | ||
| 388 | |||
| 389 | if ( $sucat->{_list_directory} ne $empty_string | ||
| 390 | and $sucat->{_list} ne $empty_string ) | ||
| 391 | { | ||
| 392 | |||
| 393 | =head2 bring in packages | ||
| 394 | |||
| 395 | =cut | ||
| 396 | |||
| 397 | =head2 instantiate packages | ||
| 398 | |||
| 399 | =cut | ||
| 400 | |||
| 401 | my $read = readfiles->new(); | ||
| 402 | my $control = control->new(); | ||
| 403 | |||
| 404 | =head2 Declare local variables | ||
| 405 | |||
| 406 | =cut | ||
| 407 | |||
| 408 | my $par_file; | ||
| 409 | my ( @result_t, @result_v ); | ||
| 410 | my @gather_number; | ||
| 411 | my ( $values_aref, $ValuesPerRow_aref ); | ||
| 412 | my $rows; | ||
| 413 | |||
| 414 | my $data_type = _get_data_type(); | ||
| 415 | _set_data_type($data_type); | ||
| 416 | my $gather_type = _get_gather_type(); | ||
| 417 | |||
| 418 | # print("sucat, data_type, data_type=---$data_type---\n\n"); | ||
| 419 | |||
| 420 | if ( | ||
| 421 | $data_type ne $empty_string | ||
| 422 | && ( $data_type eq $velan | ||
| 423 | or $data_type eq $mute ) | ||
| 424 | ) | ||
| 425 | { | ||
| 426 | |||
| 427 | my $inbound_list = | ||
| 428 | $sucat->{_list_directory} . '/' . $sucat->{_list}. $suffix_txt; | ||
| 429 | my ( $ref_array, $num_gathers ) = $read->cols_1p($inbound_list); | ||
| 430 | |||
| 431 | my $DIR_OUT = $sucat->{_list_directory}; | ||
| 432 | |||
| 433 | # print("sucat,data_type,num_gathers: $num_gathers\n"); | ||
| 434 | |||
| 435 | =head2 | ||
| 436 | |||
| 437 | 1.Read a list of file names | ||
| 438 | 2.Read contents of each file in the list | ||
| 439 | into arrays. | ||
| 440 | |||
| 441 | 3. Each line of the list uses a file name that indicates | ||
| 442 | gather number and the other file name in which to find | ||
| 443 | velocity picks. | ||
| 444 | |||
| 445 | 4. Sort the cdp or gather number into monotonically increasing | ||
| 446 | values and rearrange the pick pairs accordingly. | ||
| 447 | |||
| 448 | =cut | ||
| 449 | |||
| 450 | for ( | ||
| 451 | my $file_number = 0, my $line = 0 ; | ||
| 452 | $file_number < $num_gathers ; | ||
| 453 | $file_number++, $line++ | ||
| 454 | ) | ||
| 455 | { | ||
| 456 | |||
| 457 | my $file_name_complete = @$ref_array[$file_number]; | ||
| 458 | my $inbound = | ||
| 459 | $sucat->{_list_directory} . '/' . $file_name_complete; | ||
| 460 | |||
| 461 | my $gather_name = @$ref_array[$file_number]; | ||
| 462 | |||
| 463 | print("sucat,reading gather: $gather_name\n"); | ||
| 464 | |||
| 465 | # read number only after last underscore | ||
| 466 | my @splits = split( /_/, $gather_name ); | ||
| 467 | |||
| 468 | print("sucat, splits are:: @splits\n"); | ||
| 469 | my $last_split_index = $#splits; | ||
| 470 | |||
| 471 | my $last_split = $splits[$last_split_index]; | ||
| 472 | |||
| 473 | # print("sucat, last split is:: $last_split\n"); | ||
| 474 | $last_split =~ s/[^0-9]*//g; | ||
| 475 | $gather_number[$file_number] = $last_split; | ||
| 476 | |||
| 477 | # read values for each gather, one at a time | ||
| 478 | ( $values_aref, $ValuesPerRow_aref ) = | ||
| 479 | $manage_files_by->read_par( \$inbound ); | ||
| 480 | |||
| 481 | # print("sucat,data_type,reading gather_number: $gather_number[$file_number]\n"); | ||
| 482 | # print("sucat,data_type,ValuesPerRow : @$ValuesPerRow_aref\n"); | ||
| 483 | |||
| 484 | =head2 Place contents | ||
| 485 | |||
| 486 | of each file in the list | ||
| 487 | into an array. | ||
| 488 | |||
| 489 | =cut | ||
| 490 | |||
| 491 | $result_t[$line] = @$values_aref[0]; | ||
| 492 | $result_v[$line] = @$values_aref[1]; | ||
| 493 | |||
| 494 | # print("sucat,data_type,t: $result_t[$line]\n"); | ||
| 495 | # print("sucat,data_type,v/x: $result_v[$line]\n"); | ||
| 496 | |||
| 497 | } # end repeat over all mute- or velan-type files | ||
| 498 | |||
| 499 | =head2 sort by gather number | ||
| 500 | |||
| 501 | =cut | ||
| 502 | |||
| 503 | my @sorted_indices = | ||
| 504 | sort { $gather_number[$a] <=> $gather_number[$b] } | ||
| 505 | 0 .. $#gather_number; | ||
| 506 | my @sorted_gather_number = sort { $a <=> $b } @gather_number; | ||
| 507 | |||
| 508 | # print("sucat, data_type, sorted indices: @sorted_indices \n"); | ||
| 509 | # print("sucat, data_type, unsorted indices: 0 .. $#gather_number\n"); | ||
| 510 | |||
| 511 | my ( @sorted_result_v, @sorted_result_t ); | ||
| 512 | my $number_of_gathers = scalar @sorted_gather_number; | ||
| 513 | |||
| 514 | for ( my $i = 0 ; $i < $number_of_gathers ; $i++ ) { | ||
| 515 | |||
| 516 | $sorted_result_v[$i] = $result_v[ $sorted_indices[$i] ]; | ||
| 517 | $sorted_result_t[$i] = $result_t[ $sorted_indices[$i] ]; | ||
| 518 | |||
| 519 | # print("sucat, data_type, sorted_gather_number: $sorted_gather_number[$i]\n"); | ||
| 520 | # print("sucat, data_type, unsorted_gather_number: $gather_number[$i]\n"); | ||
| 521 | |||
| 522 | } | ||
| 523 | |||
| 524 | if ( $data_type eq $velan ) { | ||
| 525 | |||
| 526 | $manage_files_by->write_cdp( \@sorted_gather_number, $DIR_OUT ); | ||
| 527 | $manage_files_by->write_tnmo_vnmo( \@sorted_gather_number, | ||
| 528 | \@sorted_result_t, \@sorted_result_v, $DIR_OUT ); | ||
| 529 | |||
| 530 | } | ||
| 531 | elsif ( $data_type eq $mute ) { | ||
| 532 | |||
| 533 | # print("sucat,data_type. Data types are mute.\n\n"); | ||
| 534 | $manage_files_by->write_gather( \@sorted_gather_number, | ||
| 535 | $DIR_OUT, $gather_type ); | ||
| 536 | $manage_files_by->write_tmute_xmute( \@sorted_gather_number, | ||
| 537 | \@sorted_result_t, \@sorted_result_v, $DIR_OUT ); | ||
| 538 | |||
| 539 | } | ||
| 540 | |||
| 541 | else { | ||
| 542 | print("sucat, data_type, unrecognized data_type\n"); | ||
| 543 | } | ||
| 544 | |||
| 545 | } | ||
| 546 | else { | ||
| 547 | # print( | ||
| 548 | # "sucat,data_type. Data types are not: mute or velan. | ||
| 549 | #Ignore special formats. Using simple cat. NADA\n\n" | ||
| 550 | # ); | ||
| 551 | } | ||
| 552 | } | ||
| 553 | } | ||
| 554 | |||
| 555 | =head2 sub get_outbound | ||
| 556 | |||
| 557 | =cut | ||
| 558 | |||
| 559 | sub get_outbound { | ||
| 560 | |||
| 561 | my ($variable) = @_; | ||
| 562 | |||
| 563 | if ( length $sucat->{_outbound} | ||
| 564 | and length $sucat->{_data_type} | ||
| 565 | and length $sucat->{_output_base_file_name}) | ||
| 566 | |||
| 567 | { | ||
| 568 | # CASE of list | ||
| 569 | if ( $sucat->{_data_type} eq $su ) { | ||
| 570 | |||
| 571 | my $result = $sucat->{_outbound} . $suffix_su; | ||
| 572 | return ($result); | ||
| 573 | |||
| 574 | }elsif( $sucat->{_data_type} eq $mute ) { | ||
| 575 | |||
| 576 | my $result = $DATA_SEISMIC_TXT . '/'. $sucat->{_output_base_file_name}. $suffix_txt; | ||
| 577 | return ($result); | ||
| 578 | } | ||
| 579 | else { | ||
| 580 | my $result = $sucat->{_outbound}; # no change | ||
| 581 | return ($result); | ||
| 582 | } | ||
| 583 | |||
| 584 | }elsif ( length $sucat->{_outbound} | ||
| 585 | and not length $sucat->{_data_type} | ||
| 586 | and length $sucat->{_output_base_file_name}){ | ||
| 587 | |||
| 588 | # CASE of no list | ||
| 589 | my $result = $sucat->{_outbound}; # no change | ||
| 590 | return ($result); | ||
| 591 | } | ||
| 592 | else { | ||
| 593 | print("sucat,get_outbound: missing parameter\n"); | ||
| 594 | print("outbound=$sucat->{_outbound}\n"); | ||
| 595 | print("data_type=$sucat->{_data_type}\n"); | ||
| 596 | print("output_base_file_name=$sucat->{_output_base_file_name}\n"); | ||
| 597 | } | ||
| 598 | |||
| 599 | } | ||
| 600 | |||
| 601 | =head2 sub first_file_number_in: | ||
| 602 | |||
| 603 | for first_file_number_in numerical file name | ||
| 604 | |||
| 605 | =cut | ||
| 606 | |||
| 607 | sub first_file_number_in { | ||
| 608 | my ( $variable, $first_file_number_in ) = @_; | ||
| 609 | if ( $first_file_number_in ne $empty_string ) { | ||
| 610 | $sucat->{_first_file_number_in} = $first_file_number_in; | ||
| 611 | } | ||
| 612 | else { | ||
| 613 | |||
| 614 | # print("sucat,first_file_number_in: NADA\n"); | ||
| 615 | } | ||
| 616 | |||
| 617 | # print( | ||
| 618 | # "sucat, first_file_number_in, first_file_number_in=---$sucat->{_first_file_number_in}---\n\n" | ||
| 619 | # ); | ||
| 620 | } | ||
| 621 | |||
| 622 | =head2 sub inbound_directory: | ||
| 623 | |||
| 624 | for inbound directory name | ||
| 625 | |||
| 626 | =cut | ||
| 627 | |||
| 628 | sub inbound_directory { | ||
| 629 | my ( $variable, $inbound_directory ) = @_; | ||
| 630 | |||
| 631 | if ( $inbound_directory ne $empty_string ) { | ||
| 632 | $sucat->{_inbound_directory} = $inbound_directory; | ||
| 633 | } | ||
| 634 | else { | ||
| 635 | # print("sucat,inbound_directory: NADA\n"); | ||
| 636 | } | ||
| 637 | |||
| 638 | } | ||
| 639 | |||
| 640 | =head2 sub input_name_extension | ||
| 641 | |||
| 642 | use after names and numbers | ||
| 643 | |||
| 644 | e.g., gather_100_input_name_extension.su | ||
| 645 | |||
| 646 | =cut | ||
| 647 | |||
| 648 | sub input_name_extension { | ||
| 649 | my ( $variable, $input_name_extension ) = @_; | ||
| 650 | |||
| 651 | if ( $input_name_extension ne $empty_string ) { | ||
| 652 | |||
| 653 | $sucat->{_input_name_extension} = $input_name_extension; | ||
| 654 | |||
| 655 | } | ||
| 656 | else { | ||
| 657 | |||
| 658 | # print("sucat,input_name_extension: NADA\n"); | ||
| 659 | } | ||
| 660 | } | ||
| 661 | |||
| 662 | =head2 sub input_name_prefix | ||
| 663 | |||
| 664 | use before names and numbers | ||
| 665 | input_prefix_100.su | ||
| 666 | |||
| 667 | =cut | ||
| 668 | |||
| 669 | sub input_name_prefix { | ||
| 670 | my ( $variable, $input_name_prefix ) = @_; | ||
| 671 | |||
| 672 | if ( $input_name_prefix ne $empty_string ) { | ||
| 673 | $sucat->{_input_name_prefix} = $input_name_prefix; | ||
| 674 | } | ||
| 675 | else { | ||
| 676 | |||
| 677 | # print("sucat,input_input_name_prefix: NADA\n"); | ||
| 678 | } | ||
| 679 | } | ||
| 680 | |||
| 681 | =head2 sub input_suffix | ||
| 682 | |||
| 683 | use after dot for all names | ||
| 684 | e.g., .su | ||
| 685 | |||
| 686 | =cut | ||
| 687 | |||
| 688 | sub input_suffix { | ||
| 689 | my ( $variable, $input_suffix ) = @_; | ||
| 690 | |||
| 691 | if ( $input_suffix ne $empty_string ) { | ||
| 692 | $sucat->{_input_suffix} = $input_suffix; | ||
| 693 | } | ||
| 694 | else { | ||
| 695 | |||
| 696 | # print("sucat,input_suffix: NADA\n"); | ||
| 697 | } | ||
| 698 | |||
| 699 | } | ||
| 700 | |||
| 701 | =head2 sub last_file_number_in: | ||
| 702 | |||
| 703 | for last_file_number_in numerical file name | ||
| 704 | |||
| 705 | =cut | ||
| 706 | |||
| 707 | sub last_file_number_in { | ||
| 708 | my ( $variable, $last_file_number_in ) = @_; | ||
| 709 | |||
| 710 | if ( $last_file_number_in ne $empty_string ) { | ||
| 711 | $sucat->{_last_file_number_in} = $last_file_number_in; | ||
| 712 | } | ||
| 713 | else { | ||
| 714 | |||
| 715 | # print("sucat,last_file_number_in: NADA\n"); | ||
| 716 | } | ||
| 717 | |||
| 718 | # print( | ||
| 719 | # "sucat,last_file_number_in, last_file_number_in: $sucat->{_last_file_number_in} \n\n" | ||
| 720 | # ); | ||
| 721 | } | ||
| 722 | |||
| 723 | =head2 sub list: | ||
| 724 | |||
| 725 | for list directory name | ||
| 726 | |||
| 727 | =cut | ||
| 728 | |||
| 729 | sub list { | ||
| 730 | my ( $variable, $list ) = @_; | ||
| 731 | |||
| 732 | if ( $list ne $empty_string ) { | ||
| 733 | $sucat->{_list} = $list; | ||
| 734 | |||
| 735 | # print("sucat,list is $sucat->{_list}\n"); | ||
| 736 | } | ||
| 737 | else { | ||
| 738 | |||
| 739 | # print("sucat,list is empty NADA\n"); | ||
| 740 | } | ||
| 741 | |||
| 742 | } | ||
| 743 | |||
| 744 | =head2 sub list_directory: | ||
| 745 | |||
| 746 | for list directory name | ||
| 747 | |||
| 748 | =cut | ||
| 749 | |||
| 750 | sub list_directory { | ||
| 751 | my ( $variable, $list_directory ) = @_; | ||
| 752 | |||
| 753 | if ( $list_directory ne $empty_string ) { | ||
| 754 | |||
| 755 | $sucat->{_list_directory} = $list_directory; | ||
| 756 | |||
| 757 | } | ||
| 758 | |||
| 759 | else { | ||
| 760 | # print("sucat,list_directory: NADA\n"); | ||
| 761 | } | ||
| 762 | |||
| 763 | } | ||
| 764 | |||
| 765 | =head2 sub number_of_files_in: | ||
| 766 | |||
| 767 | for number_of_files_in | ||
| 768 | |||
| 769 | =cut | ||
| 770 | |||
| 771 | =head2 sub number_of_files_in: | ||
| 772 | |||
| 773 | for number of files to concatenate | ||
| 774 | |||
| 775 | =cut | ||
| 776 | |||
| 777 | sub number_of_files_in { | ||
| 778 | my ( $variable, $number_of_files_in ) = @_; | ||
| 779 | |||
| 780 | if ( $number_of_files_in ne $empty_string ) { | ||
| 781 | $sucat->{_number_of_files_in} = $number_of_files_in; | ||
| 782 | } | ||
| 783 | else { | ||
| 784 | |||
| 785 | # print("sucat,number_of_files_in: NADA\n"); | ||
| 786 | } | ||
| 787 | |||
| 788 | } | ||
| 789 | |||
| 790 | =head2 sub outbound_directory: | ||
| 791 | |||
| 792 | for outbound directory name | ||
| 793 | |||
| 794 | =cut | ||
| 795 | |||
| 796 | sub outbound_directory { | ||
| 797 | my ( $variable, $outbound_directory ) = @_; | ||
| 798 | |||
| 799 | if ( $outbound_directory ne $empty_string ) { | ||
| 800 | |||
| 801 | $sucat->{_outbound_directory} = $outbound_directory; | ||
| 802 | |||
| 803 | } | ||
| 804 | else { | ||
| 805 | # print("sucat,outbound_directory: NADA\n"); | ||
| 806 | } | ||
| 807 | |||
| 808 | } | ||
| 809 | |||
| 810 | =head2 sub output_base_file_name: | ||
| 811 | |||
| 812 | for number of files to concatenate | ||
| 813 | |||
| 814 | =cut | ||
| 815 | |||
| 816 | sub output_base_file_name { | ||
| 817 | my ( $variable, $output_base_file_name ) = @_; | ||
| 818 | |||
| 819 | if ( $output_base_file_name ne $empty_string ) { | ||
| 820 | |||
| 821 | $sucat->{_output_base_file_name} = $output_base_file_name; | ||
| 822 | |||
| 823 | } | ||
| 824 | else { | ||
| 825 | # print("sucat,output_base_file_name: NADA\n"); | ||
| 826 | } | ||
| 827 | |||
| 828 | } | ||
| 829 | |||
| 830 | =head2 sub set_ist_aref | ||
| 831 | |||
| 832 | list array | ||
| 833 | |||
| 834 | =cut | ||
| 835 | |||
| 836 | sub set_list_aref { | ||
| 837 | my ( $variable, $list_aref ) = @_; | ||
| 838 | |||
| 839 | if ( $list_aref ne $empty_string ) { | ||
| 840 | |||
| 841 | $sucat->{_list_aref} = $list_aref; | ||
| 842 | |||
| 843 | } | ||
| 844 | else { | ||
| 845 | # print("sucat,set_list_aref: NADA\n"); | ||
| 846 | } | ||
| 847 | |||
| 848 | # print("sucat, list_aref, list=---@$list_aref--\n"); | ||
| 849 | $sucat->{_number_of_files_in} = scalar @$list_aref; | ||
| 850 | |||
| 851 | #print( | ||
| 852 | # "sucat, set_list_aref, number_of_files_in=$sucat->{_number_of_files_in}\n\n" | ||
| 853 | #); | ||
| 854 | } | ||
| 855 | |||
| 856 | =head2 sub set_outbound | ||
| 857 | |||
| 858 | =cut | ||
| 859 | |||
| 860 | sub set_outbound { | ||
| 861 | my ( $variable, $outbound ) = @_; | ||
| 862 | |||
| 863 | if ( length $outbound ) { | ||
| 864 | |||
| 865 | $sucat->{_outbound} = $outbound; | ||
| 866 | } | ||
| 867 | else { | ||
| 868 | print("sucat,set_outbound: missing parameter\n"); | ||
| 869 | } | ||
| 870 | |||
| 871 | } | ||
| 872 | |||
| 873 | =head2 subroutine Step | ||
| 874 | |||
| 875 | builds array to concatenate | ||
| 876 | first_file_number_in line , | ||
| 877 | output contacts program name, | ||
| 878 | successive lines | ||
| 879 | final output name is provided by user name | ||
| 880 | add new file names | ||
| 881 | |||
| 882 | =cut | ||
| 883 | |||
| 884 | sub Step { | ||
| 885 | |||
| 886 | my $file; | ||
| 887 | |||
| 888 | # CASE 1: there is a list | ||
| 889 | if ( $sucat->{_list_aref} ne $empty_string ) { | ||
| 890 | |||
| 891 | $sucat->{_Step} = ' cat '; | ||
| 892 | |||
| 893 | # CASE 1A- without data type | ||
| 894 | if ( $sucat->{_data_type} eq $empty_string ) { | ||
| 895 | |||
| 896 | print(" sucat, Step, no list with data_type: $sucat->{_Step}\n\n"); | ||
| 897 | |||
| 898 | for ( my $i = 0 ; $i < $sucat->{_number_of_files_in} ; $i++ ) { | ||
| 899 | |||
| 900 | # CASE 1A-1 : there is an input suffix specified by user | ||
| 901 | if ( $sucat->{_input_suffix} ne $empty_string ) { | ||
| 902 | print( | ||
| 903 | "Warning: Incorrect settings. Either \n | ||
| 904 | \t 1) Use a list and output without file name. But, exclude values for first 6 parameters. \n | ||
| 905 | \t (The alternative directories are optional).\n | ||
| 906 | \t That is, when you use a list, the values of the prior\n | ||
| 907 | \t 6 parameters remain blank.\n | ||
| 908 | \t 2) Do NOT use a list. Include values for at least the first 3 \n | ||
| 909 | \t parameters. The output file name is allowed. Suffix,prefix and file name extensions | ||
| 910 | \t are optional. But do not use a \n | ||
| 911 | \t the list. See help for examples. (sucat, Step Case 1A-1)\n" | ||
| 912 | ); | ||
| 913 | } | ||
| 914 | |||
| 915 | # CASE 1A-2 : there is no input sufffix specified by user | ||
| 916 | elsif ( $sucat->{_input_suffix} eq $empty_string ) { | ||
| 917 | $sucat->{_Step} = | ||
| 918 | $sucat->{_Step} | ||
| 919 | . $sucat->{_inbound_directory} . '/' | ||
| 920 | . @{ $sucat->{_list_aref} }[$i] . ' \\' | ||
| 921 | . $newline; | ||
| 922 | |||
| 923 | } | ||
| 924 | else { | ||
| 925 | print("sucat,Step, unexpected input_suffix \n"); | ||
| 926 | } | ||
| 927 | |||
| 928 | # print("i=$i\n\n"); | ||
| 929 | # print(" list_directory is $sucat->{_list_directory}\n\n"); | ||
| 930 | # print(" 1. list is $sucat->{_Step}\n"); | ||
| 931 | } | ||
| 932 | } # end CASE 1A no data type | ||
| 933 | |||
| 934 | # CASE 1B: data_type does exist | ||
| 935 | elsif ( $sucat->{_data_type} ne $empty_string ) { | ||
| 936 | |||
| 937 | if ( $sucat->{_data_type} eq $velan ) { | ||
| 938 | |||
| 939 | $sucat->{_Step} = | ||
| 940 | $sucat->{_Step} | ||
| 941 | . $sucat->{_list_directory} . '/' . '.cdp ' | ||
| 942 | . $sucat->{_list_directory} . '/' . '.tv' . '\\' | ||
| 943 | . $newline; | ||
| 944 | |||
| 945 | print( | ||
| 946 | "sucat,Step, case of velan,sucat->{_Step}=$sucat->{_Step}\n" | ||
| 947 | ); | ||
| 948 | |||
| 949 | } | ||
| 950 | elsif ( $sucat->{_data_type} eq $mute ) { | ||
| 951 | |||
| 952 | $sucat->{_Step} = | ||
| 953 | $sucat->{_Step} | ||
| 954 | . $sucat->{_list_directory} . '/' | ||
| 955 | . '.gather ' | ||
| 956 | . $sucat->{_list_directory} . '/' . '.tx ' . '\\' | ||
| 957 | . $newline; | ||
| 958 | |||
| 959 | } | ||
| 960 | elsif ( $sucat->{_data_type} eq $su ) { | ||
| 961 | |||
| 962 | for ( my $i = 0 ; $i < $sucat->{_number_of_files_in} ; $i++ ) { | ||
| 963 | |||
| 964 | $sucat->{_Step} = | ||
| 965 | $sucat->{_Step} | ||
| 966 | . $DATA_SEISMIC_SU . '/' | ||
| 967 | . @{ $sucat->{_list_aref} }[$i] . ' \\' | ||
| 968 | . $newline; | ||
| 969 | |||
| 970 | } | ||
| 971 | |||
| 972 | } | ||
| 973 | |||
| 974 | else { | ||
| 975 | print(" sucat,Step,unexpected data_type\n\n"); | ||
| 976 | } | ||
| 977 | } | ||
| 978 | else { | ||
| 979 | print(" list sucat,Step,unexpected situation \n\n"); | ||
| 980 | } | ||
| 981 | } #END CASE 1: with list | ||
| 982 | |||
| 983 | # CASE 2: there is no list | ||
| 984 | elsif ( $sucat->{_list_aref} eq $empty_string ) { | ||
| 985 | $sucat->{_Step} = ' cat '; | ||
| 986 | |||
| 987 | # print(" 2. sucat,Step, list is $sucat->{_Step}\n\n"); | ||
| 988 | |||
| 989 | # CASE 2A: the nos. increase monotonically | ||
| 990 | if ( $sucat->{_first_file_number_in} <= $sucat->{_last_file_number_in} ) | ||
| 991 | { | ||
| 992 | for ( | ||
| 993 | my $file = $sucat->{_first_file_number_in} ; | ||
| 994 | $file <= $sucat->{_last_file_number_in} ; | ||
| 995 | $file++ | ||
| 996 | ) | ||
| 997 | { | ||
| 998 | |||
| 999 | # CASE 2A-1 there is an input suffix specified by user | ||
| 1000 | if ( $sucat->{_input_suffix} ne $empty_string ) { | ||
| 1001 | |||
| 1002 | $sucat->{_Step} = | ||
| 1003 | $sucat->{_Step} . ' ' | ||
| 1004 | . $sucat->{_inbound_directory} . '/' | ||
| 1005 | . $sucat->{_input_name_prefix} | ||
| 1006 | . $file | ||
| 1007 | . $sucat->{_input_name_extension} . '.' | ||
| 1008 | . $sucat->{_input_suffix}; | ||
| 1009 | } | ||
| 1010 | |||
| 1011 | # CASE 2A-2 there is no input suffix specified by user | ||
| 1012 | elsif ( $sucat->{_input_suffix} eq $empty_string ) { | ||
| 1013 | |||
| 1014 | $sucat->{_Step} = | ||
| 1015 | $sucat->{_Step} . ' ' | ||
| 1016 | . $sucat->{_inbound_directory} . '/' | ||
| 1017 | . $sucat->{_input_name_prefix} | ||
| 1018 | . $file | ||
| 1019 | . $sucat->{_input_name_extension}; | ||
| 1020 | |||
| 1021 | } | ||
| 1022 | else { | ||
| 1023 | print(" sucat,Step, unexpected input, growing numbers\n"); | ||
| 1024 | } | ||
| 1025 | |||
| 1026 | } # end for loop | ||
| 1027 | } | ||
| 1028 | |||
| 1029 | # CASE 2B: nos. decrease monotonically | ||
| 1030 | elsif ( | ||
| 1031 | $sucat->{_first_file_number_in} > $sucat->{_last_file_number_in} ) | ||
| 1032 | { | ||
| 1033 | print("2. sucat, Step, reverse order assumed\n"); | ||
| 1034 | |||
| 1035 | for ( | ||
| 1036 | my $file = $sucat->{_first_file_number_in} ; | ||
| 1037 | $file >= $sucat->{_last_file_number_in} ; | ||
| 1038 | $file = ( $file - 1 ) | ||
| 1039 | ) | ||
| 1040 | { | ||
| 1041 | |||
| 1042 | # CASE 2B-1 there is an input suffix specified by user | ||
| 1043 | if ( $sucat->{_input_suffix} ne $empty_string ) { | ||
| 1044 | |||
| 1045 | $sucat->{_Step} = | ||
| 1046 | $sucat->{_Step} . ' ' | ||
| 1047 | . $sucat->{_inbound_directory} . '/' | ||
| 1048 | . $sucat->{_input_name_prefix} | ||
| 1049 | . $file | ||
| 1050 | . $sucat->{_input_name_extension} . '.' | ||
| 1051 | . $sucat->{_input_suffix}; | ||
| 1052 | print("2A-1 sucat,Step,file=$file\n"); | ||
| 1053 | } | ||
| 1054 | |||
| 1055 | # CASE 2A-2 there is no input suffix specified by user | ||
| 1056 | elsif ( $sucat->{_input_suffix} eq $empty_string ) { | ||
| 1057 | |||
| 1058 | $sucat->{_Step} = | ||
| 1059 | $sucat->{_Step} . ' ' | ||
| 1060 | . $sucat->{_inbound_directory} . '/' | ||
| 1061 | . $sucat->{_input_name_prefix} | ||
| 1062 | . $file | ||
| 1063 | . $sucat->{_input_name_extension}; | ||
| 1064 | print("2A-2 sucat,Step,file=$file\n"); | ||
| 1065 | |||
| 1066 | } | ||
| 1067 | else { | ||
| 1068 | print( | ||
| 1069 | "sucat,Step, unexpected input suffix, decreasing number, case 2A\n" | ||
| 1070 | ); | ||
| 1071 | } | ||
| 1072 | |||
| 1073 | } # end for loop | ||
| 1074 | |||
| 1075 | } | ||
| 1076 | else { | ||
| 1077 | print( | ||
| 1078 | "sucat,Step,case 2B nos. neither increase nor decrease monotnically\n" | ||
| 1079 | ); | ||
| 1080 | } | ||
| 1081 | } | ||
| 1082 | else { | ||
| 1083 | print("sucat,Step, unexpected list CASES 1 and 2\n"); | ||
| 1084 | } | ||
| 1085 | |||
| 1086 | return $sucat->{_Step}; | ||
| 1087 | } | ||
| 1088 | |||
| 1089 | 1; |