Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: trace too short #541

Open
SherloK1898989 opened this issue Oct 24, 2022 · 3 comments
Open

ValueError: trace too short #541

SherloK1898989 opened this issue Oct 24, 2022 · 3 comments

Comments

@SherloK1898989
Copy link

image

@ErlendHaa
Copy link
Contributor

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 :)

@SherloK1898989
Copy link
Author

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

@ErlendHaa
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants