equinor / segyio

Fast Python library for SEGY files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ValueError: trace too short

SherloK1898989 opened this issue · comments

Hi

From the error message I see that segyio expects each trace is 200 bytes long. I'm guessing that you are using 4 byte floats, meaning the you've set spec.samples=50 somewhere (50 x 4 = 200)? So when assigning a whole trace, like you do on line 103, you need to assign 50 floats, not a single value like it seams like you are doing?

Some friendly reminders about posting issues. It's very helpful for whomever is helping you if you provide 1) a description of the problem 2) a description about what you expected to happen 3) a minimal reproducible example illustrating you problem. It's also better to post code and tracebacks as text, as we can then copy and modify your example without having to re-type everything :)

I am trying to record data from 3 stations , each station has 4000 data on 1 channel .and I get such an error, indicating that the block should go through a cycle of length spec.samples did not help
this my fragment code :

spec.sorting = 2
spec.format = 1
spec.samples = range(int(4000))
spec.ilines = range(3)
spec.xlines = range(1, 3)
with segyio.create(filename, spec) as f:
for _i in range(3):
dat = np.array(ark[_i])
data = np.require(dat, dtype=np.single)
real_t = np.array(real_time[_i])
trace = Trace(data=data)
trace.stats.delta = 0.00001
trace.stats.starttime = (real_time[_i])
arrtrace.append(trace)
tr = 0
for il in spec.ilines:
for xl in spec.xlines:
f.header[tr] = {
segyio.su.offset : 1,
segyio.su.iline : il,
segyio.su.xline : xl
}
for value in spec.samples:
print(value)
f.trace[tr] = arrtrace[value][tr]
tr += 1
f.bin.update(
tsort=segyio.TraceSortingFormat.INLINE_SORTING
)
and error:

image

Sorry for the delayed answer. When setting a trace for you file segyio expect the data you provide to be of 16000bytes, or 4000 samples (of 32 bit floats). Which is correct (spec.samples = range(int(4000))). Can you confirmed that len(arrtrace[value][tr]) == 4000?