Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to read latitude/longitude or xcoordinate/ycoordinate information?? #90

Open
SoumiC opened this issue Jan 25, 2019 · 17 comments
Open

Comments

@SoumiC
Copy link

SoumiC commented Jan 25, 2019

Hi,
I need to know how to read latitude/longitude or xcoordinate/ycoordinate information from a .sgy file instead of inline/xline? I need to know the field names for extraction.

Thank you.
Regards,
Soumi

@rob-smallshire
Copy link
Contributor

rob-smallshire commented Jan 25, 2019

for inline_xline in segy_reader.inline_xline_numbers():
    index = segy_reader.trace_index(inline_xline)
    header = segy_reader.trace_header(index)
    # Do something with the header e.g. print it to look at the field names and values
    # You'll need to identify which fields contain the coordinate you're looking for
    print(header)

@keerthigajee
Copy link

Hi,
I am trying to read x and y coordinates from seg file using given code but, it showing this error :
EOFError: Trace header truncated when reading from position 3600 with packer BijectiveHeaderPacker(TraceHeaderRev1), how to rectify this issue and I need to know the field names for trace header..

Thank you,
Regards,
keerthi.

@rob-smallshire
Copy link
Contributor

@keerthigajee It's difficult to say what the problem is unless you can share your SEG-Y file in some way. You can see the header field names in the code here

class TraceHeaderRev0(Header):

@adclose
Copy link

adclose commented Apr 10, 2019

So I'm having the same issue I believe it may have something to do with the size of the trace header.

I get this when I simply try to see the header
"segydata.trace_header(0)
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.4\helpers\pydev_pydevd_bundle\pydevd_exec2.py", line 3, in Exec
exec(exp, global_vars, local_vars)
File "", line 1, in
File "C:\Users\Aaron\AppData\Local\Programs\Python\Python36\lib\site-packages\segpy\reader.py", line 514, in trace_header
trace_header = read_trace_header(self._fh, header_packer, pos)
File "C:\Users\Aaron\AppData\Local\Programs\Python\Python36\lib\site-packages\segpy\toolkit.py", line 457, in read_trace_header
"{} with packer {!r}".format(pos, trace_header_packer)) from e
EOFError: Trace header truncated when reading from position 3600 with packer BijectiveHeaderPacker(TraceHeaderRev1)"

Mine is in a 2D data file with what looks like non standard cdp_x and cdp_y bit locations but I'm not sure that is the issue.

Also is there a way to easily override the offset for those fields so that it will read the traces correctly?

@adclose
Copy link

adclose commented Apr 10, 2019

After a lot of tracking down, I found an issue between the segy file I had and the format for the trace header, this may be related to the original problem and my not.

solution for me was to edit the trace_header.py to say

class Correlated(IntEnum):
"""Correlated: 0 = UNKNOWN,1 = no, 2 = yes."""
UNKNOWN = 0
NO = 1
YES = 2

Seems like sometimes segy files include 0 for this field

@InnoKaleid
Copy link

Hi,

I also run into the same issue: EOFError: Trace header truncated when reading from position 3600 with packer BijectiveHeaderPacker(TraceHeaderRev1).

I am trying to (1) read in a 2D seismic segy using create_reader [create_reader(segy_in_file, dimensionality=2)] and then (2) write it out into a new segy file using write_segy [write_segy(segy_out_file, seg_y_dataset, endian='>')]. The read-in step is fine while the error message occurs during the write-out step.

I zip the public segy file and attach it here.
3X_75_PR.zip. I was wondering if someone can help me with it?

Kindest regards,

John

@rob-smallshire
Copy link
Contributor

rob-smallshire commented Apr 20, 2019 via email

@InnoKaleid
Copy link

Hi rob-smallshire,

Thank you and have a great vacation.

John

@adclose
Copy link

adclose commented Apr 20, 2019

@InnoKaleid
This is my test code that should solve your problem
but you will need to need to replace the trace_header.py in the package with the attached

trace_header.zip

Best of Luck
Aaron

`
from segpy.reader import create_reader
import numpy as np

def getpoint(segydata, i, j = None):

if j is None:
    header = segydata.trace_header(segydata.trace_index(i))
else:
    header = segydata.trace_header(segydata.trace_index([i, j]))

if header.cdp_x != 0:
    x = header.cdp_x
    y = header.cdp_y
else:
    x = (header.source_x + header.group_x) / 2
    y = (header.source_y + header.group_y) / 2

point = np.array([x,y])

if (header.xy_scalar >= 0):
    scale = header.xy_scalar
else:
    scale = 1 / np.abs(header.xy_scalar)

point = point * scale

return point

filePath = "tmp/3X_75_PR.SGY"

fileHandle = open(filePath, 'rb')
segyData = create_reader(fileHandle)

imax = max(segyData.cdp_numbers())
imin = min(segyData.cdp_numbers())

for i in np.arange(imin, imax, 10):
point = getpoint(segyData, i)
if i == imin:
points = np.array([point])
else:
points = np.append(points, [point], axis=0)

print(points)

`

@InnoKaleid
Copy link

Hi Aaron,

Thank you for your help. It seems work well and have a great weekend.

John

@adclose
Copy link

adclose commented Apr 21, 2019

John
No problem hope this helps..
I could have abstracted the answer a bit better but glad it works.. I’ve been using the library a lot this week so just pulled pieces of some of my working code.

@InnoKaleid
Copy link

Hi Aaron,

Thank you very much and your answer is very helpful. Happy Easter!

John

@pktrigg
Copy link

pktrigg commented Jun 11, 2019

Hi, I too have the same error:
EOFError: Trace header truncated when reading from position 3600 with packer BijectiveHeaderPacker(TraceHeaderRev1)

any thoughts how this can be fixed in the pip distro module?

@adclose
Copy link

adclose commented Jun 11, 2019

my fork should work for this.

Aaron

@satyajitchiku
Copy link

what is the use of progress in the reader and writer module and how to use it ????

@SoumiC
Copy link
Author

SoumiC commented Apr 20, 2020

Hello @rob-smallshire,
In case of 3D files, x-coordinates and y-coordinates fields are valid?
or these are valid only for 2D seismic files?

I tried to check the field names, but the EOFError issue persists.
"EOFError: Trace header truncated when reading from position 3600 with packer BijectiveHeaderPacker(TraceHeaderRev1)".

What to do with a 3D seismic file if x, y co-ordinates are required?

Kindly help!.

Regards,
Soumi

@adclose
Copy link

adclose commented Apr 20, 2020

The EOF error is pretty common.
You might try my fork and see if that runs for you.
Aaron

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants