Skip to content

ahjulstad/lasio

 
 

Repository files navigation

lasio

Research software impact

This is a Python 2/3 package to read and write Log ASCII Standard (LAS) files, used for borehole data such as geophysical, geological, or petrophysical logs. It's compatible with versions 1.2 and 2.0 of the LAS file specification, published by the Canadian Well Logging Society. In principle it is designed to read as many types of LAS files as possible, including ones containing common errors or non-compliant formatting.

Depending on your particular application you may also want to check out striplog for stratigraphic/lithological data, or (still in alpha dev) welly for dealing with data at the well level. lasio is primarily for reading & writing LAS files.

Note this is not a package for reading LiDAR data (also called "LAS files").

Installation

lasio is written to be compatible with Python 2.6+, and 3.2+. To install run:

$ pip install lasio

If necessary this will download and install the requirements (numpy and a few other small ones).

There are some other packages which lasio will use to provide extra functionality if they are installed, but they are not required:

I'd recommend installing these too with:

$ pip install -r optional-packages.txt

New releases are frequently sent to PyPI, so if you want to stay updated:

$ pip install --upgrade lasio

Usage

Take a look through the example Jupyter notebooks (or if that is down try here) for detailed examples of how to use lasio

Thanks to @oliveirarodolfo you can also explore lasio tutorial notebooks live in your browser at binder: Binder

Or as a quick example:

>>> import lasio
>>> l = lasio.read("sample_big.las")

Data is accessible both directly as numpy arrays

>>> l["SFLU"]
array([ 123.45,  123.45,  123.45, ...,  123.45,  123.45,  123.45])
>>> l["DEPT"]
array([ 1670.   ,  1669.875,  1669.75 , ...,  1669.75 ,  1670.   , 1669.875])

and as Curve objects with their associated metadata:

>>> l.curves
[Curve(mnemonic=u'DEPT', unit=u'M', value=u'', descr=u'1  DEPTH', data=array([ 1670.   ,  1669.875,  1669.75 , ...,  1669.75 ,  1670.   , 1669.875])),
 Curve(mnemonic=u'DT', unit=u'US/M', value=u'', descr=u'2  SONIC TRANSIT TIME', data=array([ 123.45,  123.45,  123.45, ...,  123.45,  123.45,  123.45])),
 Curve(mnemonic=u'RHOB', unit=u'K/M3', value=u'', descr=u'3  BULK DENSITY', data=array([ 2550.,  2550.,  2550., ...,  2550.,  2550.,  2550.])),
 Curve(mnemonic=u'NPHI', unit=u'V/V', value=u'', descr=u'4   NEUTRON POROSITY', data=array([ 0.45,  0.45,  0.45, ...,  0.45,  0.45,  0.45])),
 Curve(mnemonic=u'SFLU', unit=u'OHMM', value=u'', descr=u'5  RXO RESISTIVITY', data=array([ 123.45,  123.45,  123.45, ...,  123.45,  123.45,  123.45])),
 Curve(mnemonic=u'SFLA', unit=u'OHMM', value=u'', descr=u'6  SHALLOW RESISTIVITY', data=array([ 123.45,  123.45,  123.45, ...,  123.45,  123.45,  123.45])),
 Curve(mnemonic=u'ILM', unit=u'OHMM', value=u'', descr=u'7  MEDIUM RESISTIVITY', data=array([ 110.2,  110.2,  110.2, ...,  110.2,  110.2,  110.2])),
 Curve(mnemonic=u'ILD', unit=u'OHMM', value=u'', descr=u'8  DEEP RESISTIVITY', data=array([ 105.6,  105.6,  105.6, ...,  105.6,  105.6,  105.6]))]

Header information is parsed into simple HeaderItem objects, and stored in a dictionary for each section of the header:

>>> l.version
{'VERS': HeaderItem(mnemonic=u'VERS', unit=u'', value=1.2, descr=u'CWLS LOG ASCII STANDARD -VERSION 1.2'),
 'WRAP': HeaderItem(mnemonic=u'WRAP', unit=u'', value=u'NO', descr=u'ONE LINE PER DEPTH STEP')}
>>> l.well
{'STRT': HeaderItem(mnemonic=u'STRT', unit=u'M', value=1670.0, descr=u''),
 'STOP': HeaderItem(mnemonic=u'STOP', unit=u'M', value=1660.0, descr=u''),
 'STEP': HeaderItem(mnemonic=u'STEP', unit=u'M', value=-0.125, descr=u''),
 'NULL': HeaderItem(mnemonic=u'NULL', unit=u'', value=-999.25, descr=u''),
 'COMP': HeaderItem(mnemonic=u'COMP', unit=u'', value=u'ANY OIL COMPANY LTD.', descr=u'COMPANY'),
 'WELL': HeaderItem(mnemonic=u'WELL', unit=u'', value=u'ANY ET AL OIL WELL #12', descr=u'WELL'),
 'FLD': HeaderItem(mnemonic=u'FLD', unit=u'', value=u'EDAM', descr=u'FIELD'),
 'LOC': HeaderItem(mnemonic=u'LOC', unit=u'', value=u'A9-16-49-20W3M', descr=u'LOCATION'),
 'PROV': HeaderItem(mnemonic=u'PROV', unit=u'', value=u'SASKATCHEWAN', descr=u'PROVINCE'),
 'SRVC': HeaderItem(mnemonic=u'SRVC', unit=u'', value=u'ANY LOGGING COMPANY LTD.', descr=u'SERVICE COMPANY'),
 'DATE': HeaderItem(mnemonic=u'DATE', unit=u'', value=u'25-DEC-1988', descr=u'LOG DATE'),
 'UWI': HeaderItem(mnemonic=u'UWI', unit=u'', value=u'100091604920W300', descr=u'UNIQUE WELL ID')}
>>> l.params
{'BHT': HeaderItem(mnemonic=u'BHT', unit=u'DEGC', value=35.5, descr=u'BOTTOM HOLE TEMPERATURE'),
 'BS': HeaderItem(mnemonic=u'BS', unit=u'MM', value=200.0, descr=u'BIT SIZE'),
 'FD': HeaderItem(mnemonic=u'FD', unit=u'K/M3', value=1000.0, descr=u'FLUID DENSITY'),
 'MATR': HeaderItem(mnemonic=u'MATR', unit=u'', value=0.0, descr=u'NEUTRON MATRIX(0=LIME,1=SAND,2=DOLO)'),
 'MDEN': HeaderItem(mnemonic=u'MDEN', unit=u'', value=2710.0, descr=u'LOGGING MATRIX DENSITY'),
 'RMF': HeaderItem(mnemonic=u'RMF', unit=u'OHMM', value=0.216, descr=u'MUD FILTRATE RESISTIVITY'),
 'DFD': HeaderItem(mnemonic=u'DFD', unit=u'K/M3', value=1525.0, descr=u'DRILL FLUID DENSITY')}

You can also build LAS files from scratch.

Character encodings

Three options:

  • Do nothing and hope for no errors.
  • Specify the encoding (internally lasio uses the open function from codecs which is part of the standard library):
>>> l = lasio.read("example.las", encoding="windows-1252")
  • Install a third-party package like cChardet (faster) or chardet (slower) to automatically detect the character encoding. If these packages are installed this code will use whichever is faster:
>>> l = lasio.read("example.las", autodetect_encoding=True)

Note that by default autodetect_encoding=False.

Development

Build Status Codacy Badge

See the list of changes for each released version.

To use the latest development version:

$ git clone https://github.com/kinverarity1/lasio.git
$ cd lasio
$ python setup.py develop

And to update:

$ git pull origin master

lasio should work on Python 3.2, but it isn't tested regularly at Travis CI because Miniconda is only Python 3.3+.

Contributions are very very welcome! Please fork the project on GitHub and submit a pull request (PR) containing any changes you have made. Or anything is welcome as a GitHub issue or an email to [email protected] - suggestions, criticisms, questions, example files.

Thanks to the following GitHub users for their help:

  • VelizarVESSELINOV
  • diverdude
  • tomtommahout
  • dagrha
  • oliveirarodolfo

About

Trying to read LAS 3

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Jupyter Notebook 75.5%
  • Python 24.5%