« lib/App/SeismicUnixGui/sunix/NMO_Vel_Stk/sustack.pm
↑ Summary
lib/App/SeismicUnixGui/sunix/filter/sudipfilt.pm »
| 1 | package App::SeismicUnixGui::sunix::data::segdread; | ||
| 2 | |||
| 3 | =head2 SYNOPSIS | ||
| 4 | |||
| 5 | PERL PROGRAM NAME: | ||
| 6 | |||
| 7 | AUTHOR: Juan Lorenzo (Perl module only) | ||
| 8 | |||
| 9 | DATE: | ||
| 10 | |||
| 11 | DESCRIPTION: | ||
| 12 | |||
| 13 | Version: | ||
| 14 | |||
| 15 | =head2 USE | ||
| 16 | |||
| 17 | =head3 NOTES | ||
| 18 | |||
| 19 | =head4 Examples | ||
| 20 | |||
| 21 | =head2 SYNOPSIS | ||
| 22 | |||
| 23 | =head3 SEISMIC UNIX NOTES | ||
| 24 | SEGDREAD - read an SEG-D tape | ||
| 25 | |||
| 26 | |||
| 27 | |||
| 28 | segdread > stdout tape= | ||
| 29 | |||
| 30 | |||
| 31 | |||
| 32 | Required parameters: | ||
| 33 | |||
| 34 | tape= input tape device | ||
| 35 | |||
| 36 | tape=- to read from stdin | ||
| 37 | |||
| 38 | |||
| 39 | |||
| 40 | Optional parameters: | ||
| 41 | |||
| 42 | use_stdio=0 for record devices (9-track reel tape drive) | ||
| 43 | |||
| 44 | =1 for pipe, disk and fixed-block 8mm drives | ||
| 45 | |||
| 46 | verbose=0 silent operation | ||
| 47 | |||
| 48 | = 1 ; echo every 'vblock' traces | ||
| 49 | |||
| 50 | = 2 ; echo information about blocks | ||
| 51 | |||
| 52 | vblock=50 echo every 'vblock' traces under verbose option | ||
| 53 | |||
| 54 | ptmin=1 first shot to read | ||
| 55 | |||
| 56 | ptmax=INT_MAX last shot to read | ||
| 57 | |||
| 58 | gain=0 no application of gain | ||
| 59 | |||
| 60 | aux=0 no recovery of auxiliary traces | ||
| 61 | |||
| 62 | errmax=0 allowable number of consecutive tape IO errors | ||
| 63 | |||
| 64 | ns=0 override of computed ns to work around SEG-D | ||
| 65 | |||
| 66 | flaws. Ignored when use_stdio=0. | ||
| 67 | |||
| 68 | pivot_year=30 Use current century for 2 digit yrs less than | ||
| 69 | |||
| 70 | pivot_year, previous century otherwise. | ||
| 71 | |||
| 72 | |||
| 73 | |||
| 74 | type: sudoc segdread for further information | ||
| 75 | |||
| 76 | |||
| 77 | |||
| 78 | Credits: | ||
| 79 | |||
| 80 | for version 1: | ||
| 81 | |||
| 82 | IPRA, Pau, France: Dominique Rousset, rousset@iprrs1.univ-pau.fr | ||
| 83 | |||
| 84 | for version 2.2: | ||
| 85 | |||
| 86 | EOST, Strasbourg, France: Celine Girard | ||
| 87 | |||
| 88 | for versions 2.3: | ||
| 89 | |||
| 90 | EOST, Strasbourg, France: Marc Schaming, mschaming@eost.u-strasbg.fr | ||
| 91 | |||
| 92 | for version 2.4: | ||
| 93 | |||
| 94 | SEP, Stanford University: Stew Levin, stew@sep.stanford.edu | ||
| 95 | |||
| 96 | a) Changed definitions of BCD_FF/BCD_FFFF | ||
| 97 | |||
| 98 | b) Corrected decoding of general_header_1 in info_gh1. | ||
| 99 | |||
| 100 | c) Changed buff=0 to use_stdio=1 to avoid confusion (stdio | ||
| 101 | |||
| 102 | IS buffered I/O). Kept old buff= internally for backwards | ||
| 103 | |||
| 104 | compatibility. | ||
| 105 | |||
| 106 | d) Changed F8015 decoding of negative mantissas to avoid | ||
| 107 | |||
| 108 | 1 part in 2^14th decoding error on 2's complement platforms. | ||
| 109 | |||
| 110 | e) Adapted F8015 to F0015 decoding routine. Unused, but now available. | ||
| 111 | |||
| 112 | f) Use AT&T sfio package for tape read. | ||
| 113 | |||
| 114 | g) Handle endian and wordsize dependencies portably (I think). | ||
| 115 | |||
| 116 | g) Allow tape=- command line argument to accept input from stdin. | ||
| 117 | |||
| 118 | h) Compute trace length explicitly from headers so that disk data | ||
| 119 | |||
| 120 | input can work. | ||
| 121 | |||
| 122 | i) Correct tape trace length calculation to account for demux | ||
| 123 | |||
| 124 | trace header extensions. | ||
| 125 | |||
| 126 | j) Fix a couple of typos in comments and selfdoc | ||
| 127 | |||
| 128 | k) Added F8022 for 1 byte quaternary exponent demux. | ||
| 129 | |||
| 130 | l) Added F8024 for 2 byte quaternary exponent demux. | ||
| 131 | |||
| 132 | m) Added F8042 for 1 byte hexadecimal exponent demux. | ||
| 133 | |||
| 134 | n) Added F8044 for 2 byte hexadecimal exponent demux. | ||
| 135 | |||
| 136 | o) Added F8048 for 4 byte hexadecimal exponent demux. | ||
| 137 | |||
| 138 | p) Added F8036 for 2 byte 2's complement integer demux. | ||
| 139 | |||
| 140 | q) Added F8038 for 4 byte 2's complement integer demux. | ||
| 141 | |||
| 142 | r) Added F8058 for 4 byte IEEE float demux. | ||
| 143 | |||
| 144 | s) Added ns= parameter to work around bad SEG-D trace | ||
| 145 | |||
| 146 | length specifications in headers. | ||
| 147 | |||
| 148 | for version 2.5: | ||
| 149 | |||
| 150 | SEP, Stanford University: Stew Levin, stew@sep.stanford.edu | ||
| 151 | |||
| 152 | a) Added pivot_year to disambiguate decoding of 2-digit yrs | ||
| 153 | |||
| 154 | b) Modified decode of 2-byte BCD to avoid endian problems | ||
| 155 | |||
| 156 | c) Modified debug printout to fix endian BCD display problems | ||
| 157 | |||
| 158 | d) Don't let dem_trace_header override ns specified on command line | ||
| 159 | |||
| 160 | e) Removed extra factor of two in decoding of general_header_1.r | ||
| 161 | |||
| 162 | f) Removed conditional disabling of sfio | ||
| 163 | |||
| 164 | for version 2.6: | ||
| 165 | |||
| 166 | SEP, Stanford University: Stew Levin, stew@sep.stanford.edu | ||
| 167 | |||
| 168 | a) tightened test for Sercel 358 | ||
| 169 | |||
| 170 | b) modified 8015 conversion to handle Sercel 358/368 misuse of | ||
| 171 | |||
| 172 | two's complement instead of one's complement. | ||
| 173 | |||
| 174 | |||
| 175 | |||
| 176 | -------------------------------------------------------------------- | ||
| 177 | |||
| 178 | SEGDREAD: Version 2.1, 10/10/94 | ||
| 179 | |||
| 180 | Version 2.2, 17/08/95 | ||
| 181 | |||
| 182 | Version 2.3, 04/1997 Thu Apr 10 11:55:45 DFT 1997 | ||
| 183 | |||
| 184 | Version 2.4, 10/03/98 Tue Mar 10 1998 | ||
| 185 | |||
| 186 | Version 2.5, Feb 4, 2001 | ||
| 187 | |||
| 188 | Version 2.6, May 26, 2009 | ||
| 189 | |||
| 190 | -------------------------------------------------------------------- | ||
| 191 | |||
| 192 | |||
| 193 | |||
| 194 | =head2 User's notes (Juan Lorenzo) | ||
| 195 | untested | ||
| 196 | |||
| 197 | Example: | ||
| 198 | $segdread->clear(); | ||
| 199 | $segdread->tape($segdread_inbound[1]); | ||
| 200 | $segdread->verbose(1); | ||
| 201 | $segdread->ptmax(1); | ||
| 202 | $segdread->aux(0); | ||
| 203 | $segdread->use_stdio(1); | ||
| 204 | $segdread[1] = $segdread->Step(); | ||
| 205 | |||
| 206 | =cut | ||
| 207 | |||
| 208 | |||
| 209 | =head2 CHANGES and their DATES | ||
| 210 | |||
| 211 | =cut | ||
| 212 | |||
| 213 | use Moose; | ||
| 214 | our $VERSION = '0.0.1'; | ||
| 215 | |||
| 216 | |||
| 217 | =head2 Import packages | ||
| 218 | |||
| 219 | =cut | ||
| 220 | |||
| 221 | use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants'; | ||
| 222 | |||
| 223 | use App::SeismicUnixGui::misc::SeismicUnix qw($in $out $on $go $to $suffix_ascii $off $suffix_su $suffix_bin); | ||
| 224 | use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config'; | ||
| 225 | |||
| 226 | |||
| 227 | =head2 instantiation of packages | ||
| 228 | |||
| 229 | =cut | ||
| 230 | |||
| 231 | my $get = L_SU_global_constants->new(); | ||
| 232 | my $Project = Project_config->new(); | ||
| 233 | my $DATA_SEISMIC_SU = $Project->DATA_SEISMIC_SU(); | ||
| 234 | my $DATA_SEISMIC_BIN = $Project->DATA_SEISMIC_BIN(); | ||
| 235 | my $DATA_SEISMIC_TXT = $Project->DATA_SEISMIC_TXT(); | ||
| 236 | |||
| 237 | my $var = $get->var(); | ||
| 238 | my $on = $var->{_on}; | ||
| 239 | my $off = $var->{_off}; | ||
| 240 | my $true = $var->{_true}; | ||
| 241 | my $false = $var->{_false}; | ||
| 242 | my $empty_string = $var->{_empty_string}; | ||
| 243 | |||
| 244 | =head2 Encapsulated | ||
| 245 | hash of private variables | ||
| 246 | |||
| 247 | =cut | ||
| 248 | |||
| 249 | my $segdread = { | ||
| 250 | _aux => '', | ||
| 251 | _buff => '', | ||
| 252 | _errmax => '', | ||
| 253 | _gain => '', | ||
| 254 | _ns => '', | ||
| 255 | _pivot_year => '', | ||
| 256 | _ptmax => '', | ||
| 257 | _ptmin => '', | ||
| 258 | _tape => '', | ||
| 259 | _use_stdio => '', | ||
| 260 | _vblock => '', | ||
| 261 | _verbose => '', | ||
| 262 | _Step => '', | ||
| 263 | _note => '', | ||
| 264 | |||
| 265 | }; | ||
| 266 | |||
| 267 | =head2 sub Step | ||
| 268 | |||
| 269 | collects switches and assembles bash instructions | ||
| 270 | by adding the program name | ||
| 271 | |||
| 272 | =cut | ||
| 273 | |||
| 274 | sub Step { | ||
| 275 | |||
| 276 | $segdread->{_Step} = 'segdread'.$segdread->{_Step}; | ||
| 277 | return ( $segdread->{_Step} ); | ||
| 278 | |||
| 279 | } | ||
| 280 | |||
| 281 | |||
| 282 | =head2 sub note | ||
| 283 | |||
| 284 | collects switches and assembles bash instructions | ||
| 285 | by adding the program name | ||
| 286 | |||
| 287 | =cut | ||
| 288 | |||
| 289 | sub note { | ||
| 290 | |||
| 291 | $segdread->{_note} = 'segdread'.$segdread->{_note}; | ||
| 292 | return ( $segdread->{_note} ); | ||
| 293 | |||
| 294 | } | ||
| 295 | |||
| 296 | |||
| 297 | |||
| 298 | =head2 sub clear | ||
| 299 | |||
| 300 | =cut | ||
| 301 | |||
| 302 | sub clear { | ||
| 303 | |||
| 304 | $segdread->{_aux} = ''; | ||
| 305 | $segdread->{_buff} = ''; | ||
| 306 | $segdread->{_errmax} = ''; | ||
| 307 | $segdread->{_gain} = ''; | ||
| 308 | $segdread->{_ns} = ''; | ||
| 309 | $segdread->{_pivot_year} = ''; | ||
| 310 | $segdread->{_ptmax} = ''; | ||
| 311 | $segdread->{_ptmin} = ''; | ||
| 312 | $segdread->{_tape} = ''; | ||
| 313 | $segdread->{_use_stdio} = ''; | ||
| 314 | $segdread->{_vblock} = ''; | ||
| 315 | $segdread->{_verbose} = ''; | ||
| 316 | $segdread->{_Step} = ''; | ||
| 317 | $segdread->{_note} = ''; | ||
| 318 | } | ||
| 319 | |||
| 320 | |||
| 321 | =head2 sub aux | ||
| 322 | |||
| 323 | |||
| 324 | =cut | ||
| 325 | |||
| 326 | sub aux { | ||
| 327 | |||
| 328 | my ( $self,$aux ) = @_; | ||
| 329 | if ( $aux ne $empty_string ) { | ||
| 330 | |||
| 331 | $segdread->{_aux} = $aux; | ||
| 332 | $segdread->{_note} = $segdread->{_note}.' aux='.$segdread->{_aux}; | ||
| 333 | $segdread->{_Step} = $segdread->{_Step}.' aux='.$segdread->{_aux}; | ||
| 334 | |||
| 335 | } else { | ||
| 336 | print("segdread, aux, missing aux,\n"); | ||
| 337 | } | ||
| 338 | } | ||
| 339 | |||
| 340 | |||
| 341 | =head2 sub buff | ||
| 342 | |||
| 343 | |||
| 344 | =cut | ||
| 345 | |||
| 346 | sub buff { | ||
| 347 | |||
| 348 | my ( $self,$buff ) = @_; | ||
| 349 | if ( $buff ne $empty_string ) { | ||
| 350 | |||
| 351 | $segdread->{_buff} = $buff; | ||
| 352 | $segdread->{_note} = $segdread->{_note}.' buff='.$segdread->{_buff}; | ||
| 353 | $segdread->{_Step} = $segdread->{_Step}.' buff='.$segdread->{_buff}; | ||
| 354 | |||
| 355 | } else { | ||
| 356 | print("segdread, buff, missing buff,\n"); | ||
| 357 | } | ||
| 358 | } | ||
| 359 | |||
| 360 | |||
| 361 | =head2 sub errmax | ||
| 362 | |||
| 363 | |||
| 364 | =cut | ||
| 365 | |||
| 366 | sub errmax { | ||
| 367 | |||
| 368 | my ( $self,$errmax ) = @_; | ||
| 369 | if ( $errmax ne $empty_string ) { | ||
| 370 | |||
| 371 | $segdread->{_errmax} = $errmax; | ||
| 372 | $segdread->{_note} = $segdread->{_note}.' errmax='.$segdread->{_errmax}; | ||
| 373 | $segdread->{_Step} = $segdread->{_Step}.' errmax='.$segdread->{_errmax}; | ||
| 374 | |||
| 375 | } else { | ||
| 376 | print("segdread, errmax, missing errmax,\n"); | ||
| 377 | } | ||
| 378 | } | ||
| 379 | |||
| 380 | |||
| 381 | =head2 sub gain | ||
| 382 | |||
| 383 | |||
| 384 | =cut | ||
| 385 | |||
| 386 | sub gain { | ||
| 387 | |||
| 388 | my ( $self,$gain ) = @_; | ||
| 389 | if ( $gain ne $empty_string ) { | ||
| 390 | |||
| 391 | $segdread->{_gain} = $gain; | ||
| 392 | $segdread->{_note} = $segdread->{_note}.' gain='.$segdread->{_gain}; | ||
| 393 | $segdread->{_Step} = $segdread->{_Step}.' gain='.$segdread->{_gain}; | ||
| 394 | |||
| 395 | } else { | ||
| 396 | print("segdread, gain, missing gain,\n"); | ||
| 397 | } | ||
| 398 | } | ||
| 399 | |||
| 400 | |||
| 401 | =head2 sub ns | ||
| 402 | |||
| 403 | |||
| 404 | =cut | ||
| 405 | |||
| 406 | sub ns { | ||
| 407 | |||
| 408 | my ( $self,$ns ) = @_; | ||
| 409 | if ( $ns ne $empty_string ) { | ||
| 410 | |||
| 411 | $segdread->{_ns} = $ns; | ||
| 412 | $segdread->{_note} = $segdread->{_note}.' ns='.$segdread->{_ns}; | ||
| 413 | $segdread->{_Step} = $segdread->{_Step}.' ns='.$segdread->{_ns}; | ||
| 414 | |||
| 415 | } else { | ||
| 416 | print("segdread, ns, missing ns,\n"); | ||
| 417 | } | ||
| 418 | } | ||
| 419 | |||
| 420 | |||
| 421 | =head2 sub pivot_year | ||
| 422 | |||
| 423 | |||
| 424 | =cut | ||
| 425 | |||
| 426 | sub pivot_year { | ||
| 427 | |||
| 428 | my ( $self,$pivot_year ) = @_; | ||
| 429 | if ( $pivot_year ne $empty_string ) { | ||
| 430 | |||
| 431 | $segdread->{_pivot_year} = $pivot_year; | ||
| 432 | $segdread->{_note} = $segdread->{_note}.' pivot_year='.$segdread->{_pivot_year}; | ||
| 433 | $segdread->{_Step} = $segdread->{_Step}.' pivot_year='.$segdread->{_pivot_year}; | ||
| 434 | |||
| 435 | } else { | ||
| 436 | print("segdread, pivot_year, missing pivot_year,\n"); | ||
| 437 | } | ||
| 438 | } | ||
| 439 | |||
| 440 | |||
| 441 | =head2 sub ptmax | ||
| 442 | |||
| 443 | |||
| 444 | =cut | ||
| 445 | |||
| 446 | sub ptmax { | ||
| 447 | |||
| 448 | my ( $self,$ptmax ) = @_; | ||
| 449 | if ( $ptmax ne $empty_string ) { | ||
| 450 | |||
| 451 | $segdread->{_ptmax} = $ptmax; | ||
| 452 | $segdread->{_note} = $segdread->{_note}.' ptmax='.$segdread->{_ptmax}; | ||
| 453 | $segdread->{_Step} = $segdread->{_Step}.' ptmax='.$segdread->{_ptmax}; | ||
| 454 | |||
| 455 | } else { | ||
| 456 | print("segdread, ptmax, missing ptmax,\n"); | ||
| 457 | } | ||
| 458 | } | ||
| 459 | |||
| 460 | |||
| 461 | =head2 sub ptmin | ||
| 462 | |||
| 463 | |||
| 464 | =cut | ||
| 465 | |||
| 466 | sub ptmin { | ||
| 467 | |||
| 468 | my ( $self,$ptmin ) = @_; | ||
| 469 | if ( $ptmin ne $empty_string ) { | ||
| 470 | |||
| 471 | $segdread->{_ptmin} = $ptmin; | ||
| 472 | $segdread->{_note} = $segdread->{_note}.' ptmin='.$segdread->{_ptmin}; | ||
| 473 | $segdread->{_Step} = $segdread->{_Step}.' ptmin='.$segdread->{_ptmin}; | ||
| 474 | |||
| 475 | } else { | ||
| 476 | print("segdread, ptmin, missing ptmin,\n"); | ||
| 477 | } | ||
| 478 | } | ||
| 479 | |||
| 480 | |||
| 481 | =head2 sub tape | ||
| 482 | |||
| 483 | |||
| 484 | =cut | ||
| 485 | |||
| 486 | sub tape { | ||
| 487 | |||
| 488 | my ( $self, $tape ) = @_; | ||
| 489 | if ( $tape ne $empty_string ) { | ||
| 490 | |||
| 491 | use App::SeismicUnixGui::misc::SeismicUnix qw($suffix_segd); | ||
| 492 | use File::Basename; | ||
| 493 | my ($DATA_SEISMIC_SEGD) = $Project->DATA_SEISMIC_SEGD(); | ||
| 494 | my $new_file_name = $tape; | ||
| 495 | |||
| 496 | # force correct suffix | ||
| 497 | $new_file_name = basename($tape) . $suffix_segd; | ||
| 498 | |||
| 499 | # print("1. segyread,tape, new_file_name= $new_file_name\n"); | ||
| 500 | |||
| 501 | $segdread->{_tape} = $DATA_SEISMIC_SEGD . '/' . $new_file_name; | ||
| 502 | |||
| 503 | $segdread->{_note} = | ||
| 504 | $segdread->{_note} . ' tape=' . $segdread->{_tape}; | ||
| 505 | $segdread->{_Step} = | ||
| 506 | $segdread->{_Step} . ' tape=' . $segdread->{_tape}; | ||
| 507 | |||
| 508 | } | ||
| 509 | else { | ||
| 510 | print("segyread, tape, missing tape,\n"); | ||
| 511 | } | ||
| 512 | } | ||
| 513 | |||
| 514 | =head2 sub use_stdio | ||
| 515 | |||
| 516 | |||
| 517 | =cut | ||
| 518 | |||
| 519 | sub use_stdio { | ||
| 520 | |||
| 521 | my ( $self,$use_stdio ) = @_; | ||
| 522 | if ( $use_stdio ne $empty_string ) { | ||
| 523 | |||
| 524 | $segdread->{_use_stdio} = $use_stdio; | ||
| 525 | $segdread->{_note} = $segdread->{_note}.' use_stdio='.$segdread->{_use_stdio}; | ||
| 526 | $segdread->{_Step} = $segdread->{_Step}.' use_stdio='.$segdread->{_use_stdio}; | ||
| 527 | |||
| 528 | } else { | ||
| 529 | print("segdread, use_stdio, missing use_stdio,\n"); | ||
| 530 | } | ||
| 531 | } | ||
| 532 | |||
| 533 | |||
| 534 | =head2 sub vblock | ||
| 535 | |||
| 536 | |||
| 537 | =cut | ||
| 538 | |||
| 539 | sub vblock { | ||
| 540 | |||
| 541 | my ( $self,$vblock ) = @_; | ||
| 542 | if ( $vblock ne $empty_string ) { | ||
| 543 | |||
| 544 | $segdread->{_vblock} = $vblock; | ||
| 545 | $segdread->{_note} = $segdread->{_note}.' vblock='.$segdread->{_vblock}; | ||
| 546 | $segdread->{_Step} = $segdread->{_Step}.' vblock='.$segdread->{_vblock}; | ||
| 547 | |||
| 548 | } else { | ||
| 549 | print("segdread, vblock, missing vblock,\n"); | ||
| 550 | } | ||
| 551 | } | ||
| 552 | |||
| 553 | |||
| 554 | =head2 sub verbose | ||
| 555 | |||
| 556 | |||
| 557 | =cut | ||
| 558 | |||
| 559 | sub verbose { | ||
| 560 | |||
| 561 | my ( $self,$verbose ) = @_; | ||
| 562 | if ( $verbose ne $empty_string ) { | ||
| 563 | |||
| 564 | $segdread->{_verbose} = $verbose; | ||
| 565 | $segdread->{_note} = $segdread->{_note}.' verbose='.$segdread->{_verbose}; | ||
| 566 | $segdread->{_Step} = $segdread->{_Step}.' verbose='.$segdread->{_verbose}; | ||
| 567 | |||
| 568 | } else { | ||
| 569 | print("segdread, verbose, missing verbose,\n"); | ||
| 570 | } | ||
| 571 | } | ||
| 572 | |||
| 573 | |||
| 574 | =head2 sub get_max_index | ||
| 575 | |||
| 576 | max index = number of input variables -1 | ||
| 577 | |||
| 578 | =cut | ||
| 579 | |||
| 580 | sub get_max_index { | ||
| 581 | my ($self) = @_; | ||
| 582 | my $max_index = 11; | ||
| 583 | |||
| 584 | return($max_index); | ||
| 585 | } | ||
| 586 | |||
| 587 | |||
| 588 | 1; |