Building a LAS file from scratch¶
When you create a lasio.LASFile
from scratch, it comes with some
default metadata:
>>> import lasio
>>> las = lasio.LASFile()
>>> las.header
{'Version': [HeaderItem(mnemonic="VERS", unit="", value="2.0", descr="CWLS log ASCII Standa"),
HeaderItem(mnemonic="WRAP", unit="", value="NO", descr="One line per depth ste"),
HeaderItem(mnemonic="DLM", unit="", value="SPACE", descr="Column Data Section ")],
'Well': [HeaderItem(mnemonic="STRT", unit="m", value="nan", descr="START DEPTH"),
HeaderItem(mnemonic="STOP", unit="m", value="nan", descr="STOP DEPTH"),
HeaderItem(mnemonic="STEP", unit="m", value="nan", descr="STEP"),
HeaderItem(mnemonic="NULL", unit="", value="-9999.25", descr="NULL VALUE"),
HeaderItem(mnemonic="COMP", unit="", value="", descr="COMPANY"),
HeaderItem(mnemonic="WELL", unit="", value="", descr="WELL"),
HeaderItem(mnemonic="FLD", unit="", value="", descr="FIELD"),
HeaderItem(mnemonic="LOC", unit="", value="", descr="LOCATION"),
HeaderItem(mnemonic="PROV", unit="", value="", descr="PROVINCE"),
HeaderItem(mnemonic="CNTY", unit="", value="", descr="COUNTY"),
HeaderItem(mnemonic="STAT", unit="", value="", descr="STATE"),
HeaderItem(mnemonic="CTRY", unit="", value="", descr="COUNTRY"),
HeaderItem(mnemonic="SRVC", unit="", value="", descr="SERVICE COMPANY"),
HeaderItem(mnemonic="DATE", unit="", value="", descr="DATE"),
HeaderItem(mnemonic="UWI", unit="", value="", descr="UNIQUE WELL ID"),
HeaderItem(mnemonic="API", unit="", value="", descr="API NUMBER")],
'Curves': [],
'Parameter': [],
'Other': ''}
In our case, let’s set the correct date:
>>> from datetime import datetime
>>> las.well.DATE = datetime.today().strftime('%Y-%m-%d %H:%M:%S')
And add some new header fields:
>>> las.params['ENG'] = lasio.HeaderItem('ENG', value='Kent Inverarity')
>>> las.params['LMF'] = lasio.HeaderItem('LMF', value='GL')
>>> las.other = 'Example of how to create a LAS file from scratch using lasio'
We will invent some data for a curve:
>>> import numpy as np
>>> depths = np.arange(10, 50, 0.5)
>>> synth = np.log10(depths)*5+np.random.random(len(depths))
>>> synth[:8] = np.nan
…add these to the LASFile object:
>>> las.add_curve('DEPT', depths, unit='m')
>>> las.add_curve('SYNTH', synth, descr='fake data')
And write the result to files:
>>> las.write('scratch_v1.2.las', version=1.2)
>>> las.write('scratch_v2.las', version=2)
Here is the resulting scratch_v1.2.las:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | ~Version --------------------------------------------------- VERS. 1.2 : CWLS LOG ASCII STANDARD - VERSION 1.2 WRAP. NO : One line per depth step DLM . SPACE : Column Data Section Delimiter ~Well ------------------------------------------------------ STRT.m 10.0 : START DEPTH STOP.m 49.5 : STOP DEPTH STEP.m 0.5 : STEP NULL. -9999.25 : NULL VALUE COMP. COMPANY : WELL. WELL : FLD . FIELD : LOC . LOCATION : PROV. PROVINCE : CNTY. COUNTY : STAT. STATE : CTRY. COUNTRY : SRVC. SERVICE COMPANY : DATE. DATE : 2017-11-04 15:33:20.963287 UWI . UNIQUE WELL ID : API . API NUMBER : ~Curves ---------------------------------------------------- DEPT .m : SYNTH. : fake data ~Params ---------------------------------------------------- ENG. Kent Inverarity : LMF. GL : ~Other ----------------------------------------------------- Example of how to create a LAS file from scratch using lasio ~ASCII ----------------------------------------------------- 10 -9999.25 10.5 -9999.25 11 -9999.25 11.5 -9999.25 12 -9999.25 12.5 -9999.25 13 -9999.25 13.5 -9999.25 14 5.799 14.5 6.3938 15 6.4122 15.5 6.4605 16 6.9518 16.5 6.567 17 6.3816 17.5 6.2872 18 6.4336 18.5 7.0252 19 6.7988 19.5 6.7172 20 6.6929 20.5 7.0971 21 7.145 21.5 6.7192 22 7.6034 22.5 7.3078 23 7.2213 23.5 7.668 24 7.853 24.5 7.4073 25 7.4238 25.5 7.9173 26 7.1282 26.5 7.4131 27 7.8014 27.5 7.348 28 7.9 28.5 7.6294 29 8.1244 29.5 7.9835 30 7.4759 30.5 8.3766 31 7.4717 31.5 7.6432 32 8.2327 32.5 7.6541 33 8.4481 33.5 7.8811 34 8.2332 34.5 8.4302 35 7.7218 35.5 8.71 36 8.3965 36.5 8.4355 37 8.6836 37.5 8.2236 38 8.4997 38.5 8.6656 39 8.8295 39.5 8.1707 40 8.9034 40.5 8.681 41 8.1698 41.5 8.3001 42 9.0266 42.5 8.4398 43 8.7562 43.5 8.2673 44 8.4682 44.5 8.5801 45 8.9065 45.5 8.8392 46 8.661 46.5 9.2355 47 9.0468 47.5 8.8249 48 9.0298 48.5 8.6864 49 8.5745 49.5 8.6143 |
and scratch_v2.las:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | ~Version --------------------------------------------------- VERS. 2.0 : CWLS log ASCII Standard -VERSION 2.0 WRAP. NO : One line per depth step DLM . SPACE : Column Data Section Delimiter ~Well ------------------------------------------------------ STRT.m 10.0 : START DEPTH STOP.m 49.5 : STOP DEPTH STEP.m 0.5 : STEP NULL. -9999.25 : NULL VALUE COMP. : COMPANY WELL. : WELL FLD . : FIELD LOC . : LOCATION PROV. : PROVINCE CNTY. : COUNTY STAT. : STATE CTRY. : COUNTRY SRVC. : SERVICE COMPANY DATE. 2017-11-04 15:33:20.963287 : DATE UWI . : UNIQUE WELL ID API . : API NUMBER ~Curves ---------------------------------------------------- DEPT .m : SYNTH. : fake data ~Params ---------------------------------------------------- ENG. Kent Inverarity : LMF. GL : ~Other ----------------------------------------------------- Example of how to create a LAS file from scratch using lasio ~ASCII ----------------------------------------------------- 10 -9999.25 10.5 -9999.25 11 -9999.25 11.5 -9999.25 12 -9999.25 12.5 -9999.25 13 -9999.25 13.5 -9999.25 14 5.799 14.5 6.3938 15 6.4122 15.5 6.4605 16 6.9518 16.5 6.567 17 6.3816 17.5 6.2872 18 6.4336 18.5 7.0252 19 6.7988 19.5 6.7172 20 6.6929 20.5 7.0971 21 7.145 21.5 6.7192 22 7.6034 22.5 7.3078 23 7.2213 23.5 7.668 24 7.853 24.5 7.4073 25 7.4238 25.5 7.9173 26 7.1282 26.5 7.4131 27 7.8014 27.5 7.348 28 7.9 28.5 7.6294 29 8.1244 29.5 7.9835 30 7.4759 30.5 8.3766 31 7.4717 31.5 7.6432 32 8.2327 32.5 7.6541 33 8.4481 33.5 7.8811 34 8.2332 34.5 8.4302 35 7.7218 35.5 8.71 36 8.3965 36.5 8.4355 37 8.6836 37.5 8.2236 38 8.4997 38.5 8.6656 39 8.8295 39.5 8.1707 40 8.9034 40.5 8.681 41 8.1698 41.5 8.3001 42 9.0266 42.5 8.4398 43 8.7562 43.5 8.2673 44 8.4682 44.5 8.5801 45 8.9065 45.5 8.8392 46 8.661 46.5 9.2355 47 9.0468 47.5 8.8249 48 9.0298 48.5 8.6864 49 8.5745 49.5 8.6143 |