equinor / segyio

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

Cannot Import segy. file #539

Closed yshigei closed 1 year ago

yshigei commented 1 year ago

Hello,

I am trying to import .sgy file extracted from Petrel (P-Impedance cube/Post Stack). segyio.open() successfully worked, but cannot read through inline/xline (segyfile.iline/xline/depth_slice... did not work).

How could I fix this issue??

It would be appreciated if you could help my problem.

Best Regards, yshig

da-wad commented 1 year ago

Please provide the full error message?

yshigei commented 1 year ago

Read data along first xline

data = segyfile.xline[segyfile.xlines[1]]

Read data along last iline

data = segyfile.iline[segyfile.ilines[-1]]

Read data along 100th time slice

data = segyfile.depth_slice[100]

Read data cube

data = segyio.tools.cube(filename)

Read data along last iline

data = segyfile.iline[segyfile.ilines[-1]]

[Error Message]

OSError Traceback (most recent call last)

in 1 # Read data along first xline ----> 2 data = segyfile.xline[segyfile.xlines[1]] 3 4 # Read data along last iline 5 data = segyfile.iline[segyfile.ilines[-1]] c:\Users\shigei\Anaconda3\lib\site-packages\segyio\line.py in __getitem__(self, index) 204 pass 205 else: --> 206 return self.filehandle.getline(head, 207 self.length, 208 self.stride, OSError: I/O operation on closed file
ErlendHaa commented 1 year ago

Your file handle has been closed before you reach segyfile.xline[segyfile.xlines[1]] in your code. Do you perhaps use python's with-statement with segyio.open and then left the inner scope?

yshigei commented 1 year ago

Thank you very much @ErlendHaa. After fixed my indent as your instruction, it successfully run.