equinor / segyio

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

Runtime Error trace count inconsistent with file size, trace lengths possibly of non-uniform #514

Open marcoskaj opened 2 years ago

marcoskaj commented 2 years ago

Hi,

I'm getting error "Runtime Error trace count inconsistent with file size, trace lengths possibly of non-uniform" when trying to open any segy files from the Volve dataset. I've tried with a few segy files in the dataset, but I keep getting the same error.

Is there anything I need to do before I use segyio to open a file from the Volve dataset?

Thanks, Marcos

da-wad commented 2 years ago

Hi Marcos, you'd need to be more specific about which SEG-Y files you're attempting to open here. The Volve dataset includes a 2D survey (ST0299), two 3D surveys (ST0202 & ST10010) and a 4D difference between the 3D surveys, all of which have multiple SEG-Y files of varying shapes and sizes.

GGDRriedel commented 2 years ago

I have the same problem and it's because the traces are longer than what the binary header space allows as a number for samples in a trace. check if your header provides the correct info

marcoskaj commented 2 years ago

Hi Marcos, you'd need to be more specific about which SEG-Y files you're attempting to open here. The Volve dataset includes a 2D survey (ST0299), two 3D surveys (ST0202 & ST10010) and a 4D difference between the 3D surveys, all of which have multiple SEG-Y files of varying shapes and sizes.

Hi,

I've tried with a few files from "volve/Seismic/ST0202/Stacks/" folder. I suspect I may be using the wrong function to load the file. If that is the case, could you please point me to some documentation or user guide for segyio that tells me which functions to use for each seg-y file type (i.e., 2D or 3D, etc).

Here is a snapshot of the code and error message I get with one of the files from this folder.

... filename = 'volve/Seismic/ST0202/Stacks/ST0202R08-PS_PSDM_FULL_OFFSET_DEPTH.MIG_FIN.POST_STACK.3D.JS-017534.segy'

similarity = 1-segyio.tools.cube(filename)

RuntimeError Traceback (most recent call last) in ----> 1 similarity = 1-segyio.tools.cube(filename)

/opt/conda/lib/python3.7/site-packages/segyio/tools.py in cube(f) 234 235 if not isinstance(f, segyio.SegyFile): --> 236 with segyio.open(f) as fl: 237 return cube(fl) 238

/opt/conda/lib/python3.7/site-packages/segyio/open.py in open(filename, mode, iline, xline, strict, ignore_geometry, endian) 161 from . import _segyio 162 fd = _segyio.segyiofd(str(filename), mode, endians[endian]) --> 163 fd.segyopen() 164 metrics = fd.metrics() 165

RuntimeError: trace count inconsistent with file size, trace lengths possibly of non-uniform

I also tried with a few files from "volve/Seismic/ST10010/Stacks" folder. I get similar error.

... filename = 'volve/Seismic/ST10010/Stacks/ST10010ZC11_PZ_PSDM_RAW_NEAR_T.MIG_RAW.POST_STACK.3D.JS-017536.segy'

similarity = 1-segyio.tools.cube(filename)

RuntimeError Traceback (most recent call last) in ----> 1 similarity = 1-segyio.tools.cube(filename)

/opt/conda/lib/python3.7/site-packages/segyio/tools.py in cube(f) 234 235 if not isinstance(f, segyio.SegyFile): --> 236 with segyio.open(f) as fl: 237 return cube(fl) 238

/opt/conda/lib/python3.7/site-packages/segyio/open.py in open(filename, mode, iline, xline, strict, ignore_geometry, endian) 161 from . import _segyio 162 fd = _segyio.segyiofd(str(filename), mode, endians[endian]) --> 163 fd.segyopen() 164 metrics = fd.metrics() 165

RuntimeError: trace count inconsistent with file size, trace lengths possibly of non-uniform

-Thank you.

da-wad commented 2 years ago

Please check whether you actually have the same file here.

>>> filename = r'ST0202R08-PS_PSDM_FULL_OFFSET_DEPTH.MIG_FIN.POST_STACK.3D.JS-017534.segy'
>>> import os
>>> os.path.getsize(filename)
895367300
>>>
>>> import hashlib
>>> hashlib.md5(open(filename, 'rb').read()).hexdigest()
'783884f1a920831400d3d06766953503'
>>>
>>> import segyio
>>> arr = segyio.tools.cube(filename)
>>> arr.shape
(385, 605, 901)
GGDRriedel commented 2 years ago

I would still love to find a solution even for non-valid files.

I know that the _segyio.segyiofd routines check for validity of the file, however it would be incredibly useful to still somehow get the trace data regardless of that validity.

I kind of want to add it myself but the error checking and basic reading routines are in C++ and I'm mainly on Python so this is out of my scope

da-wad commented 2 years ago

@GGDRriedel are you sure you have traces which are too long for valid SEG-Y? Rev2 allows trace lengths of 2^32 ... segyio handles this here but only if the regular binary header is zeroed or the revision flag is correctly set.

GGDRriedel commented 2 years ago

Unfortunately I am not on Rev2.

As it is with most segy files, the machine creating the files uses Rev1 as a base and then just writes whatever it wants to wherever the dev felt like putting stuff.

I have the traces, I know parsed them from Binary and confirmed theird lengths through comparing file seizes and it works, however, I would love to have an agnostic reader instead of me doing bytewise surgery on a file.

marcoskaj commented 2 years ago

Hi @da-wad, I've checked the files and it looks like they are valid. Please note that I'm using files from the Volve dataset. Perhaps there is a problem with the files on the Volve dataset? I've tried with all files on that dataset, and they all seem to have the same or some other problem. Do I need to tell the library which revision to use? Rev1 vs Rev2 perhaps?

import os filename = '../data/Volve/ST10010ZDC12-PZ-PSDM-KIRCH-NEAR-MID-T.MIG_FIN.POST_STACK.3D.JS-017534.sgy' os.path.getsize(filename)

274726912

import hashlib hashlib.md5(open(filename, 'rb').read()).hexdigest()

'ce81c880804c1d483899ca30f64f77b5'

import segyio arr = segyio.tools.cube(filename) arr.shape


RuntimeError Traceback (most recent call last)

in 1 import segyio ----> 2 arr = segyio.tools.cube(filename) 3 arr.shape

/opt/conda/lib/python3.7/site-packages/segyio/tools.py in cube(f) 234 235 if not isinstance(f, segyio.SegyFile): --> 236 with segyio.open(f) as fl: 237 return cube(fl) 238

/opt/conda/lib/python3.7/site-packages/segyio/open.py in open(filename, mode, iline, xline, strict, ignore_geometry, endian) 161 from . import _segyio 162 fd = _segyio.segyiofd(str(filename), mode, endians[endian]) --> 163 fd.segyopen() 164 metrics = fd.metrics() 165

RuntimeError: trace count inconsistent with file size, trace lengths possibly of non-uniform

da-wad commented 2 years ago

Hi Marcos,

It hadn't escaped my attention that the files you are trying to use are from the Volve dataset. I'm afraid the one you are referring to now is not 274726912 bytes long though. Microsoft Azure Storage Explorer (if you are using this to obtain this data) gives a filesize of 754.5MB and to be exact, see below:

>>> filename = r'ST10010ZDC12-PZ-PSDM-KIRCH-NEAR-MID-T.MIG_FIN.POST_STACK.3D.JS-017534.segy'
>>> os.path.getsize(filename)
791121200
>>> hashlib.md5(open(filename, 'rb').read()).hexdigest()
'dacb61992d91ad18284b7f542d2adef0'

However, when you have a non-truncated version of this file you should get the correct error when trying to read the data from it using segyio.tools.cube which is ValueError: Inlines inconsistent, expect all inlines to be unique ... because this file has an irregular geometry.

ST0202R08-PS_PSDM_FULL_OFFSET_DEPTH.MIG_FIN.POST_STACK.3D.JS-017534.segy has a regular geometry, so this function should work just fine with the full 895367300 bytes :-)

marcoskaj commented 2 years ago

Hi @da-wad , You're absolutely right. For some reason all my files have not been downloaded correctly. In fact, storage explorer was still working on the files after all these days. -Very strange. I canceled the download and downloaded only one file and this time completed successfully and was able to open the file via segyio. Thank you so much for your help.