equinor / segyio

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

Error: when I copy a file with ignore_geometry=True, but shorten all traces #527

Closed ReHekat closed 2 years ago

ReHekat commented 2 years ago

After copy a file, there is some errors when I open the new file: trace count inconsistent with file size, trace lengths possibly of non-uniform My code:

with segyio.open(srcpath, , ignore_geometry=True) as src: ... spec = segyio.tools.metadata(src) ... spec.samples = spec.samples[:len(spec.samples) - 50] ... with segyio.create(dstpath, spec) as dst: ... dst.text[0] = src.text[0] ... dst.bin = src.bin ... dst.header = src.header ... dst.trace = src.trace file = segyio.open(dstpath, ignore_geometry=True)

ErlendHaa commented 2 years ago

Hi,

You have update the bin/trace headers when you reduce the number of slices. Have a look here: https://github.com/equinor/segyio/blob/master/python/examples/copy-sub-cube.py

ReHekat commented 2 years ago

Hi,

You have update the bin/trace headers when you reduce the number of slices. Have a look here: https://github.com/equinor/segyio/blob/master/python/examples/copy-sub-cube.py

Thanks for your help. It works well,when I insert: dst.bin = { segyio.BinField.Samples: len(spec.samples) - 50, segyio.BinField.Traces: src.tracecount } Maybe the documentation should be modified? https://segyio.readthedocs.io/en/latest/segyio.html#segyio.create