Converting segy to sac format

Hi,
I have borehole seismic data, with seg-y format.
I do not know anything about the data structure and header, I just retrieved it from IRIS.
I want to convert it to SAC, but before, I tried to read it using:

import obspy
import matplotlib.pyplot as plt
segy_file = '20.41.57.0507.1'
try:
    st = obspy.read(segy_file, format='SEGY', endian='>')
except obspy.io.segy.segy.SEGYError:
    print("Big-endian failed, trying little-endian...")
    st = obspy.read(segy_file, format='SEGY', endian='<')
print(st)
st.plot()
st.plot(type="section", orientation="horizontal", scale=0.1, linewidth=0.5, show=True)

But I got the error:
obspy.io.segy.segy.SEGYError: Unable to determine the endianness of the file. Please specify it.
I attached an event, I would be grateful if you could help with plotting it and convert it to sac format.
R072.01.rar (88.6 KB)

Wrong name for the option, try using byteorder, see docs: obspy.io.segy.core._read_segy — ObsPy 1.4.1.post0+334.gdb0be6b1e5.obspy.master documentation

Thank you for your reply.
I change the script to:

import obspy
import matplotlib.pyplot as plt
segy_file = '20.41.57.0507.1'
try:
    st = obspy.read(segy_file, format='SEGY', byteorder='>', textual_header_encoding='EBCDIC')
except obspy.io.segy.segy.SEGYError:
    print("Big-endian failed, trying little-endian...")
    st = obspy.read(segy_file, format='SEGY', byteorder='<', textual_header_encoding='EBCDIC')
print(st)
st.plot()
st.plot(type="section", orientation="horizontal", scale=0.1, linewidth=0.5, show=True)

And I got the error:
File “/home/mpsn/.local/lib/python3.8/site-packages/obspy/io/segy/segy.py”, line 213, in _read_textual_header
textual_header.decode(‘EBCDIC-CP-BE’).encode(‘ascii’)
UnicodeEncodeError: ‘ascii’ codec can’t encode character ‘\x97’ in position 3: ordinal not in range(128)

When I tried ASCII I got:
NotImplementedError: Extended textual headers are not yet supported. Please contact the developers.
Even when I used none, it did not work.

@megies
Gently reminder ._.

Well, I’m sorry but seems like reading files with “extended textual headers” was not implemented. I did not write any of the SEGY routines, so other people would have to step up.

1 Like

@megies
I just realized that these files are reftek raw data.
Do you have a script to read and plot the data? It will be helpful

Thank you,

we can read files written by REFTEK-130 but these files don’t look like that. other formats Reftek might have we don’t have support for