Closed nitishkannan23 closed 4 years ago
Your offsets look inconsistent, why do you set them to int(xlno)
? Try setting them to 0.
It worked! Thanks a lot but the only problem that I face now is the sample values have been reset.
spec = segyio.spec()
file = 'segy_attribute_classifications_run2.segy'
spec.format = 1
spec.xline = 193
spec.iline = 189
spec.offsets = [0]
spec.samples = np.unique(final_values[:,2])
spec.ilines = np.unique(final_values[:,0])
spec.xlines = np.unique(final_values[:,1])
with segyio.create(file, spec) as f:
ix = len_ilines*len_xlines
f.trace[:ix] = final_clusters[: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+')
spec.samples
array([ 1800., 1804., 1808., 1812., 1816., 1820., 1824., 1828.,
1832., 1836., 1840., 1844., 1848., 1852., 1856., 1860.,
1864., 1868., 1872., 1876., 1880., 1884., 1888., 1892.,
1896., 1900., 1904., 1908., 1912., 1916., 1920., 1924.,
1928., 1932., 1936., 1940., 1944., 1948., 1952., 1956.,
1960., 1964., 1968., 1972., 1976., 1980., 1984., 1988.,
1992., 1996., 2000., 2004., 2008., 2012., 2016., 2020.,
2024., 2028., 2032., 2036., 2040., 2044., 2048., 2052.,
2056., 2060., 2064., 2068., 2072., 2076., 2080., 2084.,
2088., 2092., 2096., 2100., 2104., 2108., 2112., 2116.,
2120., 2124., 2128., 2132., 2136., 2140., 2144., 2148.,
2152., 2156., 2160., 2164., 2168., 2172., 2176., 2180.,
2184., 2188., 2192., 2196., 2200.])
c.samples
array([ 0., 4., 8., 12., 16., 20., 24., 28., 32.,
36., 40., 44., 48., 52., 56., 60., 64., 68.,
72., 76., 80., 84., 88., 92., 96., 100., 104.,
108., 112., 116., 120., 124., 128., 132., 136., 140.,
144., 148., 152., 156., 160., 164., 168., 172., 176.,
180., 184., 188., 192., 196., 200., 204., 208., 212.,
216., 220., 224., 228., 232., 236., 240., 244., 248.,
252., 256., 260., 264., 268., 272., 276., 280., 284.,
288., 292., 296., 300., 304., 308., 312., 316., 320.,
324., 328., 332., 336., 340., 344., 348., 352., 356.,
360., 364., 368., 372., 376., 380., 384., 388., 392.,
396., 400.])
You know why is this happening?
Yes, create() apparently does not write to the delay-recording-time field (which is a bug). To work around it: f.bin[segyio.su.delrt] = spec.samples[0]
Sorry, I'm not quite familiar with this package more importantly this function. Now I'm getting this error. It would be great if you'd help me with this.
f.bin[segyio.su.delrt] = int(spec.samples[0])
KeyError: 'No such field 109'
My apologies - delrt is a trace header word, which is why it's not written to the file in the first place.
Replace this:
f.header[hdx] = {segyio.TraceField.INLINE_3D: int(ilno),
segyio.TraceField.CROSSLINE_3D: int(xlno),
segyio.TraceField.offset:0}
with
f.header[hdx] = {segyio.TraceField.INLINE_3D: int(ilno),
segyio.TraceField.CROSSLINE_3D: int(xlno),
segyio.TraceField.offset:0,
segyio.TraceField.DelayRecordingTime: spec.samples[0]}
I created a Segy file after some process and wrote the file using following code:
When I read the file:
or When i use this:
But when I use ignore_geometry=True, it is working:
But c.ilines, c.xlines does not display anything. c.iline, c.xline displays
c.samples has resetted the values from 0 to 400. However c.header[i][189,193] and c.trace[i][:] are working fine.
Please note the ilines, xlines and samples of the file: