equinor / segyio-notebooks

Notebooks with examples and demos of segyio
GNU Lesser General Public License v3.0
122 stars 79 forks source link

Create base segy faster.. #10

Open alpapapo opened 4 years ago

alpapapo commented 4 years ago

According to segyio-notebooks/03_basic_segy_editing.ipynb -> Cut all traces, I am creating a minimum size empty segy from a "source" segy file with spec.samples = spec.samples[:1].

def create_initial_segy_from_same_survey_segy(segy, initial_segy_filename):
    spec = segyio.tools.metadata(segy)
    spec.samples = spec.samples[:1]
    logger.info("creating initial segy..")
    with segyio.create(initial_segy_filename, spec) as dst:
        dst.text[0] = segy.text[0]
        dst.bin = segy.bin
        dst.bin.update(hns=len(spec.samples))
        dst.header = segy.header
        dst.trace = segy.trace
    logger.info("Initial segy created!")

The thing is that copying dst.header = src.header takes too long as the "source" segy is huge. Is there any way to create faster the minimal base segy?

mrava87 commented 4 years ago

Hi, what are you planning to cut? Time axis or also restrict IL and XL?

doiko commented 4 years ago

Hi Matteo, only time axis. We need the header for each trace though.

mrava87 commented 4 years ago

Hi Dimitrios, then I don't think you can't do anything better than what this notebooks suggests. Make an empty file and fill all header words. As the length of your traces is changed you can't copy the original file and work on a copy, but since you don't want to shrink IL or XL you can't be smarter and try to just to copy a subset of ILs/XLs.

@jokva do you see any other way to make the process faster?

doiko commented 4 years ago

Thanks Matteo, Is it possible to loop over the headers and copy them faster one by one? What we see is that segyio when executing dst.header = segy.header tries to read the complete segy and since the segy is huge the process fails by trying to create a huge swap file. @alpapapo do you agree on the behavior we notice?

mrava87 commented 4 years ago

Hi, have you tried dst.header.iline = segy.header.iline as in https://github.com/equinor/segyio/blob/master/python/examples/copy-sub-cube.py

If the behavior you notice is real (@jokva ?) this may do the copy line by line. Another way is to do it trace by trace

for i in range(segy.tracecount):    
        dst.header[i] = segy.header[i] 
        dst.trace[i]  = segy.trace[i]

but this one is much slower than dst.header= segy.header.

doiko commented 4 years ago

Hi Matteo, Thanks for the suggestion, we will check it tomorrow. Can this be related to issue https://github.com/equinor/segyio/issues/423