Support header-only LAS files--don't lose the last header section before a missng ~A section #326
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In practice, we run into LAS files that contain header sections only--no array data section. We'd still like to extract useful information from these files (cf. Postel's Law).
For these files, with or without the ignore_data option to lasio.read, the last header section from the file is missing. This can lead to errors in which las.curves is empty, even though there is a curve section, and we get array index exceptions from las.well.STRT, for example.
This is because raw sections are only saved when the line-by-line reader in reader.py's read_file_contents runs into a ~ line, and not at the end of the line-by-line enumeration. Not a problem when there's an ~A section, since this handled specially and is the last section of the file. But when there is no ~A section, a last bit of code to save the section that was being scanned up to EOF is required.
This pull request adds the necessary bit of code, and adds a test to tests/test_read.py to verify that curves are correctly returned when there is no ~A section.