Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning generated on empty ~Parameter section #226

Closed
bcnuttall opened this issue Mar 2, 2018 · 7 comments
Closed

Warning generated on empty ~Parameter section #226

bcnuttall opened this issue Mar 2, 2018 · 7 comments

Comments

@bcnuttall
Copy link

A warning is generated concerning an empty ~Parameter section: "Header section Parameter regexp=~P was not found." The LAS files in question pass the current version of LAS Certify. There is a ~Parameter section, but there are no parameter lines, only some comment lines. I imagine this issue is related to the regular expression for recognizing the ~Parameter section. I have attached a zipped archive version of an LAS file that illustrates this.

UT311012308500.zip

@dagrha
Copy link
Collaborator

dagrha commented Mar 2, 2018

I think this specific error has to do with how sections are read rather than a regex error.

It appears that lasio looks for lines that start with a ~ and adds any subsequent non-commented lines to the sect_lines list of the read_file_contents OrderedDict (see line 289 of reader.py).

In the case of your LAS file, sect_lines remains empty though for the ~P section because lasio doesn't find any lines to add before it hits the next ~, so if sect_lines: (line 290) evaluates to False. Thus the ~P section is never added to the OrderedDict.

@bcnuttall
Copy link
Author

bcnuttall commented Mar 3, 2018 via email

kinverarity1 added a commit that referenced this issue Mar 3, 2018
@kinverarity1
Copy link
Owner

Thanks for the issue! Thanks also Dan, I'll work out a way to distinguish between empty and missing sections. The latter certainly needs a warning, the former probably not as it's pretty common.

@dagrha
Copy link
Collaborator

dagrha commented Mar 5, 2018

something along these lines could at least ensure empty sections are added to the OrderedDict (based loosely on lashead):

line = file_obj.readline().strip()
line_number = 0

while not line.upper().startswith('~A'):
    if line.startswith('~'):
        sect_title_line = line
        sect_lines = []
        sect_line_nos = []
        sect_title_line = None
        while True:
            line = file_obj.readline().strip()
            line_number += 1
            if line.startswith('~'):
                sections[sect_title_line] = {
                    "section_type": "header",
                    "title": sect_title_line,
                    "lines": sect_lines,
                    "line_nos": sect_line_nos,
                }
                break
            elif not line.startswith("#"):
                sect_lines.append(line)
                sect_line_nos.append(line_number)

if line.upper().startswith('~A'):
    # use existing code

This assumes ~A is the final section encountered though, which I'm not sure is always the case.

@bcnuttall
Copy link
Author

bcnuttall commented Mar 6, 2018 via email

kinverarity1 added a commit that referenced this issue Mar 18, 2018
@kinverarity1
Copy link
Owner

Yep I want to avoid wherever possible assuming that only data follow ~A.. otherwise LAS 3 support will never happen!

I've fixed this by only raising the warning when the ~ line of a section is actually missing, instead of also when it is empty.

@bcnuttall
Copy link
Author

bcnuttall commented Mar 18, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants