lasio
lasio copied to clipboard
Reading only single section from LAS
Sometimes it is required to only read ~version section or ~well section from a given las. With ignore_data flag, lasio reads all sections other than '~A' section.
Has it been considered before to read only the specified section using lasio?
example:
To read complete file
las = lasio.read('tests/examples/sample.las')
To read only version section
las = lasio.read('tests/examples/sample.las', section='~v')
or
las = lasio.read('tests/examples/sample.las', section='version')
I haven't really thought about it... logically in my mind specifying section='~version'
would imply the function returns a section - not a complete LAS file. So it should be a new function.
PR #327 (soon to be merged) contains a function lasio.reader.parse_header_items_section
which is a bit lower level, but essentially serves that purpose: it reads a chunk out of a file-like object and returns a SectionItems (i.e. LAS file section). You however first also need to know the version of the LAS file, which is why this is all hidden in lasio.read
, which also handles the LAS-version-parsing.
You could write a function which is halfway in-between the two above...
Yes, new function would make sense. I'll take a stab at trying out this.
FYI #327 has now been merged to master, and could provide a basis for this functionality.