Corresponding obspy documentation can be found at:
https://docs.obspy.org/packages/autogen/obspy.io.segy.segy._read_segy.html
Each file has a general form of T traces, where the i-th trace can be accessed in segyfile.traces[i]. Each trace has N samples that are accessed in segyfile.traces[i].data and the j-th data point is accessed in segyfile.traces[i].data[j]. N is such that $N = n\Delta_y$, where $\Delta_y$ is the is the size of the y-dimension.
In [1]:
%matplotlib inline
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
from obspy.io.segy import segy
import urllib
import numpy as np
Reading the data:
In [2]:
segyfile = segy._read_segy('/Users/mviana/Documents/IBMProjects/Seismic/SegY2TifConv/PSDM_IL1500_2600_XL_3100_6500_time.sgy')
Number of traces:
In [3]:
len(segyfile.traces)
Out[3]:
Number of samples:
In [4]:
segyfile.traces[0].data.shape[0]
Out[4]:
Number of traces and we want to explore:
In [108]:
ntraces = 3401#len(segyfile.traces)
nsamples = len(segyfile.traces[0].data)
Image creation:
In [109]:
mtraces = np.zeros((nsamples, ntraces))
mtraces.shape
Out[109]:
In [110]:
for i in range(ntraces):
mtraces[:nsamples, i] = segyfile.traces[i].data[:nsamples]
In [111]:
mtraces.shape
Out[111]:
Scalar range:
In [112]:
srange = [np.min(mtraces),np.max(mtraces)]
print(srange)
In [113]:
plt.figure(num=None, figsize=(8, 20), dpi=120, facecolor='w', edgecolor='k')
imgplot = plt.imshow(mtraces, vmin=srange[0], vmax=0*srange[1])
Determing the number of traces:
In [114]:
plt.plot(mtraces[700:720,3400])
Out[114]:
In [117]:
plt.plot(mtraces[700:720,3400])
Out[117]:
In [118]:
segyfile.binary_file_header
Out[118]:
Number of images:
In [119]:
len(segyfile.traces)/3401
Out[119]:
In [120]:
from PIL import Image
In [121]:
im = Image.fromarray(mtraces)
im.save('/Users/mviana/Documents/IBMProjects/Seismic/SegY2TifConv/temp.tif')
In [ ]: