equinor / segyio

Fast Python library for SEGY files.
Other
471 stars 213 forks source link

Unable to open open Kahu 3-D SEGY file #517

Open jcfaracco opened 2 years ago

jcfaracco commented 2 years ago

There are some datasets available on SEG Wiki. One of them is Kahu 3-D.

Kahu is not opening properly using segyio.

Here is the code I`m using:

filename = "KAHU-3D-PR3177-FM.3D.Final_Migration.sgy"
with segyio.open(filename) as fl:
    data = np.ascontiguousarray(np.array(segyio.tools.cube(fl)))

But I'm getting the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/conda/envs/rapids/lib/python3.7/site-packages/segyio/open.py", line 187, in open
    return infer_geometry(f, metrics, iline, xline, strict)
  File "/opt/conda/envs/rapids/lib/python3.7/site-packages/segyio/open.py", line 7, in infer_geometry
    cube_metrics = f.xfd.cube_metrics(iline, xline)
RuntimeError: unable to find sorting.Check iline, (189) and xline (193) in case you are sure the file is a 3D sorted volume

If I pass ignore_geometry=True, I get a different error like the one below:

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/opt/conda/envs/rapids/lib/python3.7/site-packages/segyio/tools.py", line 242, in cube
    fast, slow, offs = len(fast), len(slow), len(f.offsets)
TypeError: object of type 'NoneType' has no len()

I'm still not sure if the Kahu 3-D data has any problem or it is a bug inside segyio.

da-wad commented 2 years ago

The Kahu-3D dataset has a problem. Or, actually, two.

  1. The iline and xline headers appear to be in positions 181 and 185 rather than the standard 189 and 193.
  2. The file is not regular.

    The following snippet should help you figure out what's going on...

>>> f1 = segyio.open('KAHU-3D-PR3177-FM.3D.Final_Migration.sgy', strict=False)
>>> coords = np.array([(h[181], h[185]) for h in f1.header])
>>> len(np.unique(coords[:,0]))
599
>>> len(np.unique(coords[:,1]))
1697
>>> 599*1697
1016503
>>> len(coords)
994230
TLarsen-ui commented 2 years ago

I get the same error when running the code in the attached image. The post stack cube I am reading have Undef traces/bins in it. When I use iosegy on a volume with no Undef traces it reads it without problems.

image

ErlendHaa commented 2 years ago

Hi,

By default segyio tries to infer cube geometry from the trace headers. In your case it's not regular (the dimensions doesn't add up). You would have to explicitly set ignore_geometry=True or strict=False in open in order to open it. The documentation explains these options in more detail [1]. Note that operations on ilines and xlines are not available (as these need geometry to work properly). Hence you are limited to iterating the cube trace-by-trace in this case

[1] https://segyio.readthedocs.io/en/latest/segyio.html#segyio.open