Stop reading SGY files

Hi everyone!

I’m a begginer user of ObsPy. Maybe somebody could help me solving a problem of reading SEGY files.

I’m writing a fortran code able to read SEGY files. Right now I’ve already achieved to read and translate the 3200 bytes Textual Header, I also read and translated the 400 Binary Header (BIGENDIAN to LITTLEENDIAN), and I did the same to the first 240 Trace Header (trace number one) as well.

My problem comes while reading the values of the trace. My traces (according to the TraceHeader) have 1001 samples of 4 bytes each one, but the read stops at the sample 543.

My code:

do i=1,1001
read(1,’(A)’,advance=‘no’)valtraz
float4=valtraz
call SWAP_f4(float4)
write(11,*) i, tsam, float4
tsam=tsam+0.02
enddo

The error says:

forrtl: severe (268): end of record during read, unit 1, file /home/hugo/Desktop/Cubos sismicos/Furbero_PSTM_TWT.sgy

I know that my record 1 (first line of file) is probably finished at that sample, but when I start reading the second record the supposed next samples 544-1001 don’t fit with the ones I got using ObsPy.

I run this same code using three different .sgy files, and the error is the same for all. Nevertheless, the read stops at differents samples of each file.

Could somebody help me understanding why my “I/0” instructions ends while reading de record? Why this ending-record-length is different for each .sgy file? Where could I see how ObsPy solved this?

Thanks a lot.
Hugo.

Hi Hugo,

just say 'st = read("Furbero_PSTM_TWT.sgy")' in Python. :wink:

No, seriously, I am not sure this is the right place for your question,
as this strictly speaking does not seem ObsPy related at all.

The source code doing that in ObsPy is here:
https://github.com/obspy/obspy/blob/master/obspy/segy/core.py#L114

best,
Tobias

Hi Hugo,

you may also take a look into the sources of

(1) Convseis (FORTRAN), e.g.

ftp://www.orfeus-eu.org/pub/software/conversion/CONVSEIS/SOURCES/SEGY2ASC.FOR

(2) SEGY2ASC (C)

ftp://www.orfeus-eu.org/pub/software/conversion/SEGY2ASC/

Hope it helps,
Robert

Hi Hugo,

just say 'st = read("Furbero_PSTM_TWT.sgy")' in Python. :wink:

No, seriously, I am not sure this is the right place for your
question, as this strictly speaking does not seem ObsPy related at
all.

The source code doing that in ObsPy is here:
https://github.com/obspy/obspy/blob/master/obspy/segy/core.py#L114

best, Tobias

Hi everyone!

I'm a begginer user of ObsPy. Maybe somebody could help me
solving a problem of reading SEGY files.

I'm writing a fortran code able to read SEGY files. Right now
I've already achieved to read and translate the 3200 bytes
Textual Header, I also read and translated the 400 Binary Header
(BIGENDIAN to LITTLEENDIAN), and I did the same to the first 240
Trace Header (trace number one) as well.

My problem comes while reading the values of the trace. My
traces (according to the TraceHeader) have 1001 samples of 4
bytes each one, but the read stops at the sample 543.

My code:

do i=1,1001 read(1,'(A)',advance='no')valtraz float4=valtraz call
SWAP_f4(float4) write(11,*) i, tsam, float4 tsam=tsam+0.02 enddo

The error says:

forrtl: severe (268): end of record during read, unit 1, file
/home/hugo/Desktop/Cubos sismicos/Furbero_PSTM_TWT.sgy

I know that my record 1 (first line of file) is probably finished
at that sample, but when I start reading the second record the
supposed next samples 544-1001 don't fit with the ones I got
using ObsPy.

I run this same code using three different .sgy files, and the
error is the same for all. Nevertheless, the read stops at
differents samples of each file.

Could somebody help me understanding why my "I/0" instructions
ends while reading de record? Why this ending-record-length is
different for each .sgy file? Where could I see how ObsPy solved
this?

Thanks a lot. Hugo.

_______________________________________________ obspy-users
mailing list obspy-users@lists.sevor.de
http://lists.obspy.org/cgi-bin/mailman/listinfo/obspy-users

- --
Dr. Robert Barsch

EGU Office Munich
Luisenstr. 37
80333 Munich
Germany

Phone: +49-89-21806549
Fax: +49-89-218017855
eMail: barsch@egu.eu

Hi Hugo,

it is also hard to tell what might go wrong without the file. From the way
you describe the error I guess that you reach the end of the file so I would
say your byte count got messed up somewhere along the line.

But why roll your own SEG-Y reader? Robert already pointed out some
alternatives. Furthermore as far as I know Seismic Unix is also able to
read SEG-Y files. It is written in C which you can call from Fortran with
most compilers. It also has a very liberal license.

Good luck!

Lion