kinverarity1 / lasio

Python library for reading and writing well data using Log ASCII Standard (LAS) files
https://lasio.readthedocs.io/en/latest/
MIT License
340 stars 153 forks source link

lasio incorrectly determines the number of columns in a multiline LAS file when the number of curves is a multiple of the number of columns. #583

Open Aycon3296 opened 7 months ago

Aycon3296 commented 7 months ago

Describe the bug lasio incorrectly determines the number of columns in a multiline LAS file when the count of curves is a multiple of the number of columns. reader.inspect_data_section returns of "8" (number of columns in first line of pure data) istead of "-1" on my LAS File with 56 curves. I was only able to fix this by using the monkey patch by adding a check that:

# file lasio.las.LASFile
# in function read()

# How many curves should the reader attempt to find?
reader_n_columns = n_columns
len_curves = len(self.curves)
if reader_n_columns == -1 or (len_curves > reader_n_columns and len_curves % reader_n_columns == 0):
    reader_n_columns = len(self.curves)

To Reproduce Try open (or read) multiline LAS file where a count of columns data is a multiple of headers (mnemonics in '~C' sector).

Current behavior Console write many warnings as is:

WARNING:lasio.reader:Curve #8 'DC' is defined in the ~C section but there is no data in ~A
WARNING:lasio.reader:Curve #9 'DGK' is defined in the ~C section but there is no data in ~A
WARNING:lasio.reader:Curve #10 'DN' is defined in the ~C section but there is no data in ~A
...

The number of data lines read is 7 times less than actual lines (56 // 8 = 7).

Expected behavior LAS file readed correctly.

kinverarity1 commented 7 months ago

Thanks for reporting - can you provide an example file? Also is the data section wrapped onto multiple lines and if so what is the value of the line with WRAP in the ~V section?

Aycon3296 commented 7 months ago

Certainly! Here's my example. It is truncated and the extension is changed to "txt". 321-02.txt

kinverarity1 commented 7 months ago

Thank you, the sample is very helpful