equinor / segyio

Fast Python library for SEGY files.
Other
476 stars 214 forks source link

I can not read the headers of the tracks #450

Closed aleran84 closed 4 years ago

aleran84 commented 4 years ago

RGV19D0001039_postm.zip

can not read the headers of the tracks : HourOfDay / Minute Of Hour / CDPX / CDPY in the attached segy file Script: import segyio import numpy as np import sys import os np.set_printoptions(threshold=sys.maxsize)

def get_sgy(files): res = [] for i in files: if i.endswith('.sgy'): res.append(i) return res

def main():

directory = '.'
files = get_sgy(os.listdir(directory))

print(files)

for file in files:
    with segyio.open(file, 'r') as f:
        CDP_X = f.attributes(segyio.TraceField.CDP_X)[:]
        CDP_Y = f.attributes(segyio.TraceField.CDP_Y)[:]
        HourOfDay = f.attributes(segyio.TraceField.HourOfDay)[:]
        MinuteOfHour = f.attributes(segyio.TraceField.MinuteOfHour)[:]
        rez = zip(CDP_X, CDP_Y, HourOfDay, MinuteOfHour)
        with open('rez2.txt', 'a', encoding='utf-8') as f:
            f.write("-------------------\n")
            f.write(file + "\n")
            f.write("-------------------\n")
            for i, j, q, z in rez:
                f.write(str(i) +' '+str(j)+' '+str(q)+' '+str(z)+ ' '+ '\n')

if name == 'main': main()

jokva commented 4 years ago

While your program is a lot slower than it needs to be (do a single pass where you extract the fields from the headers just once, instead of four passes one-word-at-the-time), what exactly do you mean you can't read them? What goes wrong?

aleran84 commented 4 years ago

When processing a list of files, the script displays the following error: Traceback (most recent call last): File "A:\SGY-файлы_ВЧНСАП-ГЛБО_все площадки\RGV\sgy (4).py", line 37, in main() File "A:\RGV\sgy (4).py", line 22, in main with segyio.open(file, 'r') as f: File "C:\Python38-32\lib\site-packages\segyio\open.py", line 187, in open return infer_geometry(f, metrics, iline, xline, strict) File "C:\Python38-32\lib\site-packages\segyio\open.py", line 7, in infer_geometry cube_metrics = f.xfd.cube_metrics(iline, xline) RuntimeError: unable to find sorting.

jokva commented 4 years ago

They're probably not (strict) cubes, or use non-standard in/crossline words.

https://github.com/equinor/segyio/#runtimeerror-unable-to-find-sorting https://segyio.readthedocs.io/en/latest/segyio.html#segyio.open

Use open(file, ignore_geometry = True)

jokva commented 4 years ago

Considering this solved.