lib/App/SeismicUnixGui/sunix/data/segyread_old.pm untested

filter: Statementstmt 0.0% 0 / 205 Branchbran 0.0% 0 / 46 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 34 Podpod 0.0% 0 / 27 totaltotal 0.0% 0 / 312 CC 24 SCAR 16.5
CC
24
Cov
0%
bfile
6.0
buff
6.0
byte
6.0
CRAP 5.2
1 package App::SeismicUnixGui::sunix::data::segyread;
2  
3 =head1 DOCUMENTATION
4  
5 =head2 SYNOPSIS
6  
7 PERL PROGRAM NAME: SEGYREAD - read an SEG-Y tape
8 AUTHOR: Juan Lorenzo (Perl module only)
9 DATE:
10 DESCRIPTION:
11 Version:
12  
13 =head2 USE
14  
15 =head3 NOTES
16  
17 =head4 Examples
18  
19 =head3 SEISMIC UNIX NOTES
20  
21 SEGYREAD - read an SEG-Y tape
22  
23 segyread > stdout tape=
24  
25 or
26  
27 SEG-Y data stream ... | segyread tape=- > stdout
28  
29 Required parameter:
30 tape= input tape device or seg-y filename (see notes)
31  
32 Optional parameters:
33 buff=1 for buffered device (9-track reel tape drive)
34 =0 possibly useful for 8mm EXABYTE drives
35 verbose=0 silent operation
36 =1 ; echo every 'vblock' traces
37 vblock=50 echo every 'vblock' traces under verbose option
38 hfile=header file to store ebcdic block (as ascii)
39 bfile=binary file to store binary block
40 xfile=xhdrs file to store extended text block
41 over=0 quit if bhed format not equal 1, 2, 3, 5, or 8
42 = 1 ; override and attempt conversion
43 format=bh.format if over=1 try to convert assuming format value
44 conv=1 convert data to native format
45 = 0 ; assume data is in native format
46 ebcdic=1 perform ebcdic to ascii conversion on 3200 byte textural
47 header. =0 do not perform conversion
48 ns=bh.hns number of samples (use if bhed ns wrong)
49 trcwt=1 apply trace weighting factor (bytes 169-170)
50 =0, do not apply. (Default is 0 for formats 1 and 5)
51 trmin=1 first trace to read
52 trmax=INT_MAX last trace to read
53 endian=(autodetected) =1 for big-endian, =0 for little-endian byte order
54 swapbhed=endian swap binary reel header?
55 swaphdrs=endian swap trace headers?
56 swapdata=endian swap data?
57 errmax=0 allowable number of consecutive tape IO errors
58 remap=...,... remap key(s)
59 byte=...,... formats to use for header remapping
60  
61 Notes:
62 Traditionally tape=/dev/rmt0. However, in the modern world tape device
63 names are much less uniform. The magic name can often be deduced by
64 "ls /dev". Likely man pages with the names of the tape devices are:
65 "mt", "sd" "st". Also try "man -k scsi", " man mt", etc.
66 Sometimes "mt status" will tell the device name.
67  
68 For a SEG-Y diskfile use tape=filename.
69  
70 The xfile argument will only be used if the file contains extended
71 text headers.
72  
73 Remark: a SEG-Y file is not the same as an su file. A SEG-Y file
74 consists of three parts: an ebcdic header, a binary reel header, and
75 the traces. The traces are (usually) in 32 bit IBM floating point
76 format. An SU file consists only of the trace portion written in the
77 native binary floats.
78  
79 Formats supported:
80 1: IBM floating point, 4 byte (32 bits)
81 2: two's complement integer, 4 byte (32 bits)
82 3: two's complement integer, 2 byte (16 bits)
83 5: IEEE floating point, 4 byte (32 bits)
84 8: two's complement integer, 1 byte (8 bits)
85  
86 tape=- read from standard input. Caveat, under Solaris, you will
87 need to use the buff=1 option, as well.
88  
89 Header remap:
90 The value of header word remap is mapped from the values of byte
91  
92 Map a float at location 221 to sample spacing d1:
93 segyread <data >outdata remap=d1 byte=221f
94  
95 Map a long at location 225 to source location sx:
96 segyread <data >outdata remap=sx byte=225l
97  
98 Map a short at location 229 to gain constant igc:
99 segyread <data >outdata remap=igc byte=229s
100  
101 Or all combined:
102 segyread <data >outdata remap=d1,sx,igc byte=221f,225l,229s
103  
104 Segy header words are accessed as Xt where X denotes the byte number
105 starting at 1 in correspondance with the SEGY standard (1975)
106 Known types include: f float (4 bytes)
107 l long int (4 bytes)
108 s short int (2 bytes)
109 b byte (1 bytes)
110  
111 type: sudoc segyread for further information
112  
113  
114  
115 Note:
116 If you have a tape with multiple sequences of ebcdic header,
117 binary header,traces, use the device that
118 invokes the no-rewind option and issue multiple segyread
119 commands (making an appropriate shell script if you
120 want to save all the headers). Consider using >> if
121 you want a single trace file in the end. Similar
122 considerations apply for multiple reels of tapes,
123 but use the standard rewind on end of file.
124  
125 Note: For buff=1 (default) tape is accessed with 'read', for buff=0
126 tape is accessed with fread. We suggest that you try buff=1
127 even with EXABYTE tapes.
128 Caveat: may be slow on an 8mm streaming (EXABYTE) tapedrive
129 Warning: segyread or segywrite to 8mm tape is fragile. Allow sufficient
130 time between successive reads and writes.
131 Warning: may return the error message "efclose: fclose failed"
132 intermittently when segyreading/segywriting to 8mm (EXABYTE) tape
133 even if actual segyread/segywrite is successful. However, this
134 error message may be returned if your tape drive has a fixed
135 block size set.
136 Caution: When reading or writing SEG-Y tapes, the tape
137 drive should be set to be able to read variable block length
138 tape files.
139  
140  
141 Credits:
142 SEP: Einar Kjartansson
143 CWP: Jack K. Cohen, Brian Sumner, Chris Liner
144 : John Stockwell (added 8mm tape stuff)
145 conv parameter added by:
146 Tony Kocurko
147 Department of Earth Sciences
148 Memorial University of Newfoundland
149 St. John's, Newfoundland
150 read from stdin via tape=- added by Tony Kocurko
151 bhed format = 2,3 conversion by:
152 Remco Romijn (Applied Geophysics, TU Delft)
153 J.W. de Bruijn (Applied Geophysics, TU Delft)
154 bhed format = 8 conversion by: John Stockwell
155 header remap feature added by:
156 Matthias Imhof, Virginia Tech
157 --------------------------
158 Additional Notes:
159 Brian's subroutine, ibm_to_float, which converts IBM floating
160 point to IEEE floating point is NOT portable and must be
161 altered for non-IEEE machines. See the subroutine notes below.
162  
163 A direct read by dd would suck up the entire tape; hence the
164 dancing around with buffers and files.
165  
166  
167 =head2 CHANGES and their DATES
168  
169 10.06.21 V0.0.2
170 forcing correct suffix deprecated and is now handled in segyread_spec.pm
171  
172 =cut
173  
174 use Moose;
175 our $VERSION = '0.0.2';
176 use aliased 'App::SeismicUnixGui::misc::L_SU_global_constants';
177 use aliased 'App::SeismicUnixGui::configs::big_streams::Project_config';
178  
179 my $Project = Project_config->new();
180 my $get = L_SU_global_constants->new();
181  
182 my $var = $get->var();
183 my $empty_string = $var->{_empty_string};
184  
185 my $segyread = {
186 _bfile => '',
187 _buff => '',
188 _byte => '',
189 _conv => '',
190 _ebcdic => '',
191 _endian => '',
192 _errmax => '',
193 _format => '',
194 _hfile => '',
195 _ns => '',
196 _over => '',
197 _remap => '',
198 _swapbhed => '',
199 _swapdata => '',
200 _swaphdrs => '',
201 _tape => '',
202 _trcwt => '',
203 _trmax => '',
204 _trmin => '',
205 _vblock => '',
206 _verbose => '',
207 _xfile => '',
208 _Step => '',
209 _note => '',
210 };
211  
212 =head2 sub Step
213  
214 collects switches and assembles bash instructions
215 by adding the program name
216  
217 =cut
218  
219 sub Step {
220  
221 $segyread->{_Step} = 'segyread' . $segyread->{_Step};
222 return ( $segyread->{_Step} );
223  
224 }
225  
226 =head2 sub note
227  
228 collects switches and assembles bash instructions
229 by adding the program name
230  
231 =cut
232  
233 sub note {
234  
235 $segyread->{_note} = 'segyread' . $segyread->{_note};
236 return ( $segyread->{_note} );
237  
238 }
239  
240 =head2 sub clear
241  
242 =cut
243  
244 sub clear {
245  
246 $segyread->{_bfile} = '';
247 $segyread->{_buff} = '';
248 $segyread->{_byte} = '';
249 $segyread->{_conv} = '';
250 $segyread->{_ebcdic} = '';
251 $segyread->{_endian} = '';
252 $segyread->{_errmax} = '';
253 $segyread->{_format} = '';
254 $segyread->{_hfile} = '';
255 $segyread->{_ns} = '';
256 $segyread->{_over} = '';
257 $segyread->{_remap} = '';
258 $segyread->{_swapbhed} = '';
259 $segyread->{_swapdata} = '';
260 $segyread->{_swaphdrs} = '';
261 $segyread->{_tape} = '';
262 $segyread->{_trcwt} = '';
263 $segyread->{_trmax} = '';
264 $segyread->{_trmin} = '';
265 $segyread->{_vblock} = '';
266 $segyread->{_verbose} = '';
267 $segyread->{_xfile} = '';
268 $segyread->{_Step} = '';
269 $segyread->{_note} = '';
270 }
271  
272 =head2 sub bfile
273  
274  
275 =cut
276  
277 sub bfile {
278  
279 my ( $self, $bfile ) = @_;
280 if ( $bfile ne $empty_string ) {
281  
282 use File::Basename;
283 my ($DATA_SEISMIC_BIN) = $Project->DATA_SEISMIC_BIN();
284  
285 $segyread->{_bfile} = $bfile;
286  
287 my $new_file_name = basename($bfile);
288  
289 $segyread->{_bfile} =
290 $DATA_SEISMIC_BIN . '/' . "'" . $new_file_name . "'";
291  
292 $segyread->{_note} =
293 $segyread->{_note} . ' bfile=' . $segyread->{_bfile};
294 $segyread->{_Step} =
295 $segyread->{_Step} . ' bfile=' . $segyread->{_bfile};
296  
297 }
298 else {
299 print("segyread, bfile, missing bfile,\n");
300 }
301 }
302  
303 =head2 sub buff
304  
305  
306 =cut
307  
308 sub buff {
309  
310 my ( $self, $buff ) = @_;
311 if ( $buff ne $empty_string ) {
312  
313 $segyread->{_buff} = $buff;
314 $segyread->{_note} =
315 $segyread->{_note} . ' buff=' . $segyread->{_buff};
316 $segyread->{_Step} =
317 $segyread->{_Step} . ' buff=' . $segyread->{_buff};
318  
319 }
320 else {
321 print("segyread, buff, missing buff,\n");
322 }
323 }
324  
325 =head2 sub byte
326  
327  
328 =cut
329  
330 sub byte {
331  
332 my ( $self, $byte ) = @_;
333 if ( $byte ne $empty_string ) {
334  
335 $segyread->{_byte} = $byte;
336 $segyread->{_note} =
337 $segyread->{_note} . ' byte=' . $segyread->{_byte};
338 $segyread->{_Step} =
339 $segyread->{_Step} . ' byte=' . $segyread->{_byte};
340  
341 }
342 else {
343 print("segyread, byte, missing byte,\n");
344 }
345 }
346  
347 =head2 sub conv
348  
349  
350 =cut
351  
352 sub conv {
353  
354 my ( $self, $conv ) = @_;
355 if ( $conv ne $empty_string ) {
356  
357 $segyread->{_conv} = $conv;
358 $segyread->{_note} =
359 $segyread->{_note} . ' conv=' . $segyread->{_conv};
360 $segyread->{_Step} =
361 $segyread->{_Step} . ' conv=' . $segyread->{_conv};
362  
363 }
364 else {
365 print("segyread, conv, missing conv,\n");
366 }
367 }
368  
369 =head2 sub ebcdic
370  
371  
372 =cut
373  
374 sub ebcdic {
375  
376 my ( $self, $ebcdic ) = @_;
377 if ( $ebcdic ne $empty_string ) {
378  
379 $segyread->{_ebcdic} = $ebcdic;
380 $segyread->{_note} =
381 $segyread->{_note} . ' ebcdic=' . $segyread->{_ebcdic};
382 $segyread->{_Step} =
383 $segyread->{_Step} . ' ebcdic=' . $segyread->{_ebcdic};
384  
385 }
386 else {
387 print("segyread, ebcdic, missing ebcdic,\n");
388 }
389 }
390  
391 =head2 sub endian
392  
393  
394 =cut
395  
396 sub endian {
397  
398 my ( $self, $endian ) = @_;
399 if ( $endian ne $empty_string ) {
400  
401 $segyread->{_endian} = $endian;
402 $segyread->{_note} =
403 $segyread->{_note} . ' endian=' . $segyread->{_endian};
404 $segyread->{_Step} =
405 $segyread->{_Step} . ' endian=' . $segyread->{_endian};
406  
407 }
408 else {
409 print("segyread, endian, missing endian,\n");
410 }
411 }
412  
413 =head2 sub errmax
414  
415  
416 =cut
417  
418 sub errmax {
419  
420 my ( $self, $errmax ) = @_;
421 if ( $errmax ne $empty_string ) {
422  
423 $segyread->{_errmax} = $errmax;
424 $segyread->{_note} =
425 $segyread->{_note} . ' errmax=' . $segyread->{_errmax};
426 $segyread->{_Step} =
427 $segyread->{_Step} . ' errmax=' . $segyread->{_errmax};
428  
429 }
430 else {
431 print("segyread, errmax, missing errmax,\n");
432 }
433 }
434  
435 =head2 sub file
436  
437 nowadays is usually a segyfile on disk
438 same as tape
439 forcing correct suffix deprecated 10.06.21
440 parse filepaths and keep only the file name
441  
442 =cut
443  
444 sub file {
445  
446 my ( $self, $file ) = @_;
447 if ( $file ne $empty_string ) {
448  
449 use File::Basename;
450 my ($DATA_SEISMIC_SEGY) = $Project->DATA_SEISMIC_SEGY();
451  
452 # forcing correct suffix deprecated 10.06.21
453 my $new_file_name = basename($file);
454 $segyread->{_tape} =
455 $DATA_SEISMIC_SEGY . '/' . "'" . $new_file_name . "'";
456  
457 $segyread->{_note} =
458 $segyread->{_note} . ' tape=' . $segyread->{_tape};
459 $segyread->{_Step} =
460 $segyread->{_Step} . ' tape=' . $segyread->{_tape};
461  
462 }
463 else {
464 print("segyread, tape, missing tape,\n");
465 }
466 }
467  
468 =head2 sub format
469  
470  
471 =cut
472  
473 sub format {
474  
475 my ( $self, $format ) = @_;
476 if ( $format ne $empty_string ) {
477  
478 $segyread->{_format} = $format;
479 $segyread->{_note} =
480 $segyread->{_note} . ' format=' . $segyread->{_format};
481 $segyread->{_Step} =
482 $segyread->{_Step} . ' format=' . $segyread->{_format};
483  
484 }
485 else {
486 print("segyread, format, missing format,\n");
487 }
488 }
489  
490 =head2 sub hfile
491  
492  
493 =cut
494  
495 sub hfile {
496  
497 my ( $self, $hfile ) = @_;
498
499 if ( $hfile ne $empty_string ) {
500  
501 use File::Basename;
502 my ($DATA_SEISMIC_TXT) = $Project->DATA_SEISMIC_TXT();
503  
504 my $new_file_name = basename($hfile);
505
506 $segyread->{_hfile} =
507 $DATA_SEISMIC_TXT . '/' . "'" . $new_file_name . "'";
508  
509 $segyread->{_note} =
510 $segyread->{_note} . ' hfile=' . $segyread->{_hfile};
511 $segyread->{_Step} =
512 $segyread->{_Step} . ' hfile=' . $segyread->{_hfile};
513  
514 }
515 else {
516 print("segyread, hfile, missing hfile,\n");
517 }
518 }
519  
520 =head2 sub ns
521  
522  
523 =cut
524  
525 sub ns {
526  
527 my ( $self, $ns ) = @_;
528 if ( $ns ne $empty_string ) {
529  
530 $segyread->{_ns} = $ns;
531 $segyread->{_note} = $segyread->{_note} . ' ns=' . $segyread->{_ns};
532 $segyread->{_Step} = $segyread->{_Step} . ' ns=' . $segyread->{_ns};
533  
534 }
535 else {
536 print("segyread, ns, missing ns,\n");
537 }
538 }
539  
540 =head2 sub over
541  
542  
543 =cut
544  
545 sub over {
546  
547 my ( $self, $over ) = @_;
548 if ( $over ne $empty_string ) {
549  
550 $segyread->{_over} = $over;
551 $segyread->{_note} =
552 $segyread->{_note} . ' over=' . $segyread->{_over};
553 $segyread->{_Step} =
554 $segyread->{_Step} . ' over=' . $segyread->{_over};
555  
556 }
557 else {
558 print("segyread, over, missing over,\n");
559 }
560 }
561  
562 =head2 sub remap
563  
564  
565 =cut
566  
567 sub remap {
568  
569 my ( $self, $remap ) = @_;
570 if ( $remap ne $empty_string ) {
571  
572 $segyread->{_remap} = $remap;
573 $segyread->{_note} =
574 $segyread->{_note} . ' remap=' . $segyread->{_remap};
575 $segyread->{_Step} =
576 $segyread->{_Step} . ' remap=' . $segyread->{_remap};
577  
578 }
579 else {
580 print("segyread, remap, missing remap,\n");
581 }
582 }
583  
584 =head2 sub swapbhed
585  
586  
587 =cut
588  
589 sub swapbhed {
590  
591 my ( $self, $swapbhed ) = @_;
592 if ( $swapbhed ne $empty_string ) {
593  
594 $segyread->{_swapbhed} = $swapbhed;
595 $segyread->{_note} =
596 $segyread->{_note} . ' swapbhed=' . $segyread->{_swapbhed};
597 $segyread->{_Step} =
598 $segyread->{_Step} . ' swapbhed=' . $segyread->{_swapbhed};
599  
600 }
601 else {
602 print("segyread, swapbhed, missing swapbhed,\n");
603 }
604 }
605  
606 =head2 sub swapdata
607  
608  
609 =cut
610  
611 sub swapdata {
612  
613 my ( $self, $swapdata ) = @_;
614 if ( $swapdata ne $empty_string ) {
615  
616 $segyread->{_swapdata} = $swapdata;
617 $segyread->{_note} =
618 $segyread->{_note} . ' swapdata=' . $segyread->{_swapdata};
619 $segyread->{_Step} =
620 $segyread->{_Step} . ' swapdata=' . $segyread->{_swapdata};
621  
622 }
623 else {
624 print("segyread, swapdata, missing swapdata,\n");
625 }
626 }
627  
628 =head2 sub swaphdrs
629  
630  
631 =cut
632  
633 sub swaphdrs {
634  
635 my ( $self, $swaphdrs ) = @_;
636 if ( $swaphdrs ne $empty_string ) {
637  
638 $segyread->{_swaphdrs} = $swaphdrs;
639 $segyread->{_note} =
640 $segyread->{_note} . ' swaphdrs=' . $segyread->{_swaphdrs};
641 $segyread->{_Step} =
642 $segyread->{_Step} . ' swaphdrs=' . $segyread->{_swaphdrs};
643  
644 }
645 else {
646 print("segyread, swaphdrs, missing swaphdrs,\n");
647 }
648 }
649  
650 =head2 sub tape
651  
652 nowadays is usually a segyfile on disk
653  
654 =cut
655  
656 sub tape {
657  
658 my ( $self, $tape ) = @_;
659 if ( $tape ne $empty_string ) {
660  
661 use File::Basename;
662 my ($DATA_SEISMIC_SEGY) = $Project->DATA_SEISMIC_SEGY();
663  
664 # forcing correct suffix deprecated 10.06.21
665 my $new_file_name = basename($tape);
666 $segyread->{_tape} =
667 $DATA_SEISMIC_SEGY . '/' . "'" . $new_file_name . "'";
668  
669 $segyread->{_note} =
670 $segyread->{_note} . ' tape=' . $segyread->{_tape};
671 $segyread->{_Step} =
672 $segyread->{_Step} . ' tape=' . $segyread->{_tape};
673  
674 }
675 else {
676 print("segyread, tape, missing tape,\n");
677 }
678 }
679  
680 =head2 sub trcwt
681  
682  
683 =cut
684  
685 sub trcwt {
686  
687 my ( $self, $trcwt ) = @_;
688 if ( $trcwt ne $empty_string ) {
689  
690 $segyread->{_trcwt} = $trcwt;
691 $segyread->{_note} =
692 $segyread->{_note} . ' trcwt=' . $segyread->{_trcwt};
693 $segyread->{_Step} =
694 $segyread->{_Step} . ' trcwt=' . $segyread->{_trcwt};
695  
696 }
697 else {
698 print("segyread, trcwt, missing trcwt,\n");
699 }
700 }
701  
702 =head2 sub trmax
703  
704  
705 =cut
706  
707 sub trmax {
708  
709 my ( $self, $trmax ) = @_;
710 if ( $trmax ne $empty_string ) {
711  
712 $segyread->{_trmax} = $trmax;
713 $segyread->{_note} =
714 $segyread->{_note} . ' trmax=' . $segyread->{_trmax};
715 $segyread->{_Step} =
716 $segyread->{_Step} . ' trmax=' . $segyread->{_trmax};
717  
718 }
719 else {
720 print("segyread, trmax, missing trmax,\n");
721 }
722 }
723  
724 =head2 sub trmin
725  
726  
727 =cut
728  
729 sub trmin {
730  
731 my ( $self, $trmin ) = @_;
732 if ( $trmin ne $empty_string ) {
733  
734 $segyread->{_trmin} = $trmin;
735 $segyread->{_note} =
736 $segyread->{_note} . ' trmin=' . $segyread->{_trmin};
737 $segyread->{_Step} =
738 $segyread->{_Step} . ' trmin=' . $segyread->{_trmin};
739  
740 }
741 else {
742 print("segyread, trmin, missing trmin,\n");
743 }
744 }
745  
746 =head2 sub vblock
747  
748  
749 =cut
750  
751 sub vblock {
752  
753 my ( $self, $vblock ) = @_;
754 if ( $vblock ne $empty_string ) {
755  
756 $segyread->{_vblock} = $vblock;
757 $segyread->{_note} =
758 $segyread->{_note} . ' vblock=' . $segyread->{_vblock};
759 $segyread->{_Step} =
760 $segyread->{_Step} . ' vblock=' . $segyread->{_vblock};
761  
762 }
763 else {
764 print("segyread, vblock, missing vblock,\n");
765 }
766 }
767  
768 =head2 sub verbose
769  
770  
771 =cut
772  
773 sub verbose {
774  
775 my ( $self, $verbose ) = @_;
776 if ( $verbose ne $empty_string ) {
777  
778 $segyread->{_verbose} = $verbose;
779 $segyread->{_note} =
780 $segyread->{_note} . ' verbose=' . $segyread->{_verbose};
781 $segyread->{_Step} =
782 $segyread->{_Step} . ' verbose=' . $segyread->{_verbose};
783  
784 }
785 else {
786 print("segyread, verbose, missing verbose,\n");
787 }
788 }
789  
790 =head2 sub xfile
791  
792  
793 =cut
794  
795 sub xfile {
796  
797 my ( $self, $xfile ) = @_;
798 if ( $xfile ne $empty_string ) {
799  
800 $segyread->{_xfile} = $xfile;
801 $segyread->{_note} =
802 $segyread->{_note} . ' xfile=' . $segyread->{_xfile};
803 $segyread->{_Step} =
804 $segyread->{_Step} . ' xfile=' . $segyread->{_xfile};
805  
806 }
807 else {
808 print("segyread, xfile, missing xfile,\n");
809 }
810 }
811  
812 =head2 sub get_max_index
813
814 max index = number of input variables -1
815
816 =cut
817  
818 sub get_max_index {
819 my ($self) = @_;
820 my $max_index = 21;
821  
822 return ($max_index);
823 }
824  
825 1;