equinor / segyio

Fast Python library for SEGY files.
Other
480 stars 215 forks source link

trace too short: expected 6004 bytes, got 4 #523

Closed farooqad0 closed 1 year ago

farooqad0 commented 2 years ago

spec = segyio.spec() file = "New.sgy" spec.format = 1 spec.xline = 185 spec.iline = 181 spec.offsets = [0] spec.samples = np.unique(dataframe.iloc[:,1]) spec.ilines = np.unique(dataframe.iloc[:,0].values) spec.xlines = np.unique(dataframe.iloc[:,2].values) with segyio.create(file, spec) as f: ix = len_ilines*len_xlines f.trace[:ix] = dataframe.iloc[:,3].values[:ix]

hdx = 0
for ilno in spec.ilines:
    for xlno in spec.xlines:
        f.header[hdx] = {segyio.TraceField.INLINE_3D: int(ilno),
                         segyio.TraceField.CROSSLINE_3D: int(xlno),
                         segyio.TraceField.offset:0}
        hdx = hdx+1

c = segyio.open(file, 'r+')

ValueError Traceback (most recent call last)

in 10 with segyio.create(file, spec) as f: 11 ix = len_ilines*len_xlines ---> 12 f.trace[:ix] = dataframe.iloc[:,3].values[:ix].astype("float64") 13 14 hdx = 0 ~\Anaconda3\envs\tensorflow_low\lib\site-packages\segyio\trace.py in __setitem__(self, i, val) 280 if isinstance(i, slice): 281 for j, x in zip(range(*i.indices(len(self))), val): --> 282 self[j] = x 283 284 return ~\Anaconda3\envs\tensorflow_low\lib\site-packages\segyio\trace.py in __setitem__(self, i, val) 288 # TODO: check if len(xs) > shape, and optionally warn on truncating 289 # writes --> 290 self.filehandle.puttr(self.wrapindex(i), xs) 291 292 def __repr__(self): ValueError: trace too short: expected 6004 bytes, got 4
da-wad commented 2 years ago

You could say a little more about your dataframe object, specifically what dataframe.iloc[:,1] comes back as?

ErlendHaa commented 1 year ago

Closing due to inactivity, feel free to reopen