Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def mklines(fname):
spec = segyio.spec()
spec.format = 5
spec.sorting = 2
spec.samples = 10
spec.ilines = range(1, 11)
spec.xlines = range(1, 6)
# create a file with 10 inlines, with values on the form l.0tv where
# l = line no
# t = trace number (within line)
# v = trace value
# i.e. 2.043 is the value at inline 2's fourth trace's third value
with segyio.create(fname, spec) as dst:
ln = np.arange(start = 0,
stop = 0.001 * (5 * 10),
step = 0.001,
dtype = np.single).reshape(5, 10)
def test_create_from_naught_prestack(self):
fname = "test-data/mk-ps.sgy"
spec = segyio.spec()
spec.format = 5
spec.sorting = 2
spec.samples = 7
spec.ilines = range(1, 4)
spec.xlines = range(1, 3)
spec.offsets = range(1, 6)
cube_size = len(spec.ilines) * len(spec.xlines)
with segyio.create(fname, spec) as dst:
arr = np.arange( start = 0.000,
stop = 0.007,
step = 0.001,
dtype = np.single)
arr = np.concatenate([[arr + 0.01], [arr + 0.02]], axis = 0)
def main():
if len(sys.argv) < 9:
sys.exit(" ".join(["Usage: {} [file] [samples]",
"[first iline] [last iline]",
"[first xline] [last xline]",
"[first offset] [last offset]"]
).format(sys.argv[0]))
spec = segyio.spec()
filename = sys.argv[1]
# to create a file from nothing, we need to tell segyio about the structure of
# the file, i.e. its inline numbers, crossline numbers, etc. You can also add
# more structural information, This is the absolute minimal specification for a
# N-by-M volume with K offsets volume
spec.sorting = 2
spec.format = 1
spec.samples = range(int(sys.argv[2]))
spec.ilines = range(*map(int, sys.argv[3:5]))
spec.xlines = range(*map(int, sys.argv[5:7]))
spec.offsets = range(*map(int, sys.argv[7:9]))
if len(spec.offsets) == 0: spec.offsets = [1]
with segyio.create(filename, spec) as f:
# one inline consists of 50 traces
def main():
if len(sys.argv) < 7:
sys.exit("Usage: {} [file] [samples] [first iline] [last iline] [first xline] [last xline]".format(sys.argv[0]))
spec = segyio.spec()
filename = sys.argv[1]
# to create a file from nothing, we need to tell segyio about the structure of
# the file, i.e. its inline numbers, crossline numbers, etc. You can also add
# more structural information, but offsets etc. have sensible defautls. This is
# the absolute minimal specification for a N-by-M volume
spec.sorting = 2
spec.format = 1
spec.samples = range(int(sys.argv[2]))
spec.ilines = range(*map(int, sys.argv[3:5]))
spec.xlines = range(*map(int, sys.argv[5:7]))
with segyio.create(filename, spec) as f:
# one inline consists of 50 traces
# which in turn consists of 2000 samples
start = 0.0
def main():
if len(sys.argv) < 3:
sys.exit("Usage: {} [source-file] [destination-file]".format(sys.argv[0]))
sourcefile = sys.argv[1]
destfile = sys.argv[2]
with segyio.open(sourcefile) as src:
spec = segyio.spec()
spec.sorting = int(src.sorting)
spec.format = int(src.format)
spec.samples = range(50)
spec.ilines = src.ilines[:5]
spec.xlines = src.xlines[:5]
with segyio.create(destfile, spec) as dst:
# Copy all textual headers, including possible extended
for i in range(1 + src.ext_headers):
dst.text[i] = src.text[i]
# copy the binary header, then insert the modifications needed for
# the new shape
dst.bin = src.bin
dst.bin = { segyio.BinField.Samples: 50,
segyio.BinField.Traces: 5 * 5
else:
logger.info("iline sorting")
ixv, jyv, kzv = cvalues.shape
for ill, iline in enumerate(segyfile.ilines):
if ixv != jyv != kzv or ixv != kzv != jyv:
segyfile.iline[iline] = cvalues[ill] # broadcasting
else:
# safer but a bit slower than broadcasting
segyfile.iline[iline] = cvalues[ill, :, :]
else:
# NOT FINISHED!
logger.debug("Input segy file from scratch ...")
# sintv = int(self.zinc * 1000)
spec = segyio.spec()
spec.sorting = 2
spec.format = 1
spec.samples = np.arange(self.nlay)
spec.ilines = np.arange(self.ncol)
spec.xlines = np.arange(self.nrow)
with segyio.create(sfile, spec) as fseg:
# write the line itself to the file and the inline number
# in all this line's headers
for ill, ilno in enumerate(spec.ilines):
fseg.iline[ilno] = cvalues[ill]
# f.header.iline[ilno] = {
Returns
-------
spec : segyio.spec
Notes
-----
.. versionadded:: 1.4
"""
if not isinstance(f, segyio.SegyFile):
with segyio.open(f) as fl:
return metadata(fl)
spec = segyio.spec()
spec.iline = f._il
spec.xline = f._xl
spec.samples = f.samples
spec.format = f.format
spec.ilines = f.ilines
spec.xlines = f.xlines
spec.offsets = f.offsets
spec.sorting = f.sorting
spec.tracecount = f.tracecount
spec.ext_headers = f.ext_headers
spec.endian = f.endian