equinor / segyio

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

Question: fastest way to read headers into pandas dataframe #488

Closed ghost closed 3 years ago

ghost commented 3 years ago

I would like to read a few (about 10) trace headers offsets of all traces in a sgy file into a pandas dataframe. In my attempts this step always takes longer than reading all the trace data using segyio.collect(f.trace), which is unexpected for me. What is the or is there a known fastest way to do this using segyio?

jokva commented 3 years ago

When you use segyio range features, the library rewrites some loops to faster versions that do less work in python, and more work in C, which is why more work can sometimes be faster than less work.

There fastest way to read 10 header from each header would probably be:

for h in f.header[:]:
    words.append(h[word1, word2, ...])