equinor / segyio

Fast Python library for SEGY files.
Other
476 stars 214 forks source link

make_new_header() in doc not to be found #440

Closed GGDRriedel closed 4 years ago

GGDRriedel commented 4 years ago

I would like to add an extended text header, however just assigning it by

with segyio.open(outfile, "r+",ignore_geometry=True) as out:
    out.text[1]="foobar" 

I get an error. I have the standard text header (text[0])

I tried finding something in the doc, however this is the only part I can find and the function is not documented:

https://segyio.readthedocs.io/en/1.8.8/segyio.html#segyio.SegyFile.header

jokva commented 4 years ago

Hi,

What do you mean when you say "adding and extended text header"? Was it not there from before?

If so, actually adding it is slightly more involved, as it means shifting the whole file 3200 bytes, and incrementing the right header field. There is no direct support for that in segyio, as it does violate one of the design principles behind it.

Now, textual header support is really segyio's most immature and under-designed component, but there are some legacy issues there too.

Onto your problem.

Getting another textual header into the file involves creating a new file, but with more textual headers. There is a 'ext_headers' property you can set on spec, which reserves the space. Copy your file components into that, like in the create-copy examples, and remember to f.bin.update(exth = 1).

GGDRriedel commented 4 years ago

what I originally was planning was to add an extended header since the one I am dealing with is "full" and I need some more documentation.

I didn't think this through, mainly regarding the need to shift stuff, my current way of doing things is copying whole files through the OS and writing updated stuff to them. Since it's huge 3D seismics this was more convenient.

Thank you so much for your reply!

jokva commented 4 years ago

Happy to help!