Reputation: 19
I'm using the python lasio.py library and I must be missing in something in the docs.
Is there a native way to add headers columns in the ~ASCII (~A) section of the output file.
I need to output something like
~A DEPTH DT RHOB NPHI SFLU SFLA ILM ILD
1670.000 123.450 2550.000 0.450 123.450 123.450 110.200 105.600
1669.875 123.450 2550.000 0.450 123.450 123.450 110.200 105.600
1669.750 123.450 2550.000 0.450 123.450 123.450 110.200 105.600
where I'm actually getting
~ASCII -----------------------------------------------------
1670 123.45 2550 0.45 123.45 123.45 110.2 105.6
1669.9 123.45 2550 0.45 123.45 123.45 110.2 105.6
1669.8 123.45 2550 0.45 123.45 123.45 110.2 105.6
written to my output file.
I feel like I'm missing something really obvious.
edit: output for file is pretty straight forward:
las.write(outfilename + '.las', fmt='%.3f', version=2)
cheers
Upvotes: 1
Views: 699
Reputation: 576
As of the current (June 2022) version of Lasio: v0.30
The Curve headers can be included in the ~ASCII data_header.
Here is the basic syntax example:
las.write(s, mnemonics_header=True, data_section_header="~ASCII")
If the curves in the las document/object are:
~Curve Information -----------------------------------------
DEPT.M : 1 DEPTH
DT .US/M 60 520 32 00 : 2 SONIC TRANSIT TIME
RHOB.K/M3 45 350 01 00 : 3 BULK DENSITY
NPHI.V/V 42 890 00 00 : 4 NEUTRON POROSITY
SFLU.OHMM 07 220 04 00 : 5 SHALLOW RESISTIVITY
SFLA.OHMM 07 222 01 00 : 6 SHALLOW RESISTIVITY
ILM .OHMM 07 120 44 00 : 7 MEDIUM RESISTIVITY
ILD .OHMM 07 120 46 00 : 8 DEEP RESISTIVITY
Then calling las.write(s, mnemonics_header=True, data_section_header="~ASCII")
will include the curve headers as the ASCII header:
~ASCII DEPT DT RHOB NPHI SFLU SFLA ILM ILD
Output:
...
~ASCII DEPT DT RHOB NPHI SFLU SFLA ILM ILD
1670.00000 123.45000 2550.00000 0.45000 123.45000 123.45000 110.20000 105.60000
1669.87500 123.45000 2550.00000 0.45000 123.45000 123.45000 110.20000 105.60000
...
Upvotes: 0
Reputation: 11
To anyone who comes across this issue, here is a workaround. You need to modify the writer.py file in the lasio package. Create a list with curve mnemonics, convert it to np array, stack said array on top of data_arr using np.vstack()
data_arr = las.data # original code
# adding curve names as headers - insert these 5 lines in writer.py
hdr_list = []
for hdr_item in las.curves:
hdr_list.append(hdr_item.mnemonic)
hdrs = np.array(hdr_list).reshape(1, -1)
data_arr = np.vstack((hdrs, data_arr))
nrows, ncols = data_arr.shape # original code
Upvotes: 1