Skip to content

Instantly share code, notes, and snippets.

@ravi9
Last active September 16, 2020 16:34
Show Gist options
  • Save ravi9/30c2035e285b1d3baebdcb7640e93f13 to your computer and use it in GitHub Desktop.
Save ravi9/30c2035e285b1d3baebdcb7640e93f13 to your computer and use it in GitHub Desktop.
segyio-playground
import segyio
filename = 'f3.segy'
src_data = segyio.tools.cube(filename)
k1,k2,k3 = 300, 500, 400
factor = 125
il_s = k1 - factor
il_e = k1 + factor
xl_s = k2 - factor
xl_e = k2 + factor
sm_s = 462 - 100
sm_e = 462
f3_short = src_data[il_s:il_e, xl_s:xl_e, sm_s:sm_e]
data_small_fn = 'f3-small.npy'
np.save(data_small_fn,f3_short)
data_small = np.load(data_small_fn)
dstpath = "f3-short.segy"
segyio.tools.from_array3D(dstpath, data_small)
def get_data_info(segy_file):
segyfile = segyio.open(filename, "r")
data_info = {}
data_info['crossline_start'] = segyfile.xlines[0]
data_info['inline_start'] = segyfile.ilines[0]
data_info['timeslice_start'] = 1 #Todo: read this from segy
data_info['samples'] = len(segyfile.samples)
data_info['xlines'] = len(segyfile.xlines)
data_info['ilines'] = len(segyfile.ilines)
return data_info
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment