equinor / segyio

Fast Python library for SEGY files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

conversion from float32 to int16 issue

ivan-marroquin opened this issue · comments

Hi

Thanks a lot for such great package! I am using Python 3.10.0 with numpy 1.23.3 and segyio 1.9.11

I get the following warning message when I initialize a volume with 0s: C:\Temp\Python 3.10.0\lib\site-packages\segyio\utils.py:23: RuntimeWarning: Implicit conversion from float32 to int16 (narrowing)
warnings.warn(msg.format(x.dtype, dtype), RuntimeWarning)

Here is the code to show this issue:

input_file= 'amplitude.segy'
stack= segyio.open(working_dir + input_file, 'r')
stack.mmap()

attr_1= 'amplitude_square.segy'
copyfile(stack, working_dir + attr_1)

attr_1= segyio.open(attr_1, 'r+', iline= 9, xline= 13)
avo_attr_1.mmap()

crosslines= len(avo_attr_1.xlines)
samples= len(avo_attr_1.trace[0])

zero_out= np.zeros((crosslines, samples), dtype= np.float32)

for kline in avo_attr_1.ilines:
attr_1.iline[kline]= zero_out.copy()

Any suggestions?

Ivan

Yes, your segy may not be filled with floats.

Get the format code from by running attr_1.bin[segyio.BinField.Format]

Then check Table 2 on page 6 here: https://library.seg.org/pb-assets/technical-standards/seg_y_rev1-1686080991247.pdf