{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import os\n", "\n", "import lasio" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], "source": [ "las = lasio.read(os.path.join('..', 'tests', 'examples', 'sample.las'))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "we'll use this LAS file as an example:" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "~VERSION INFORMATION\n", " VERS. 1.2: CWLS LOG ASCII STANDARD -VERSION 1.2\n", " WRAP. NO: ONE LINE PER DEPTH STEP\n", "~WELL INFORMATION BLOCK\n", "#MNEM.UNIT DATA TYPE INFORMATION\n", "#--------- ------------- ------------------------------\n", " STRT.M 1670.000000:\n", " STOP.M 1660.000000:\n", " STEP.M -0.1250:\n", " NULL. -999.2500:\n", " COMP. COMPANY: # ANY OIL COMPANY LTD.\n", " WELL. WELL: ANY ET AL OIL WELL #12\n", " FLD . FIELD: EDAM\n", " LOC . LOCATION: A9-16-49-20W3M\n", " PROV. PROVINCE: SASKATCHEWAN\n", " SRVC. SERVICE COMPANY: ANY LOGGING COMPANY LTD.\n", " DATE. LOG DATE: 25-DEC-1988\n", " UWI . UNIQUE WELL ID: 100091604920W300\n", "~CURVE INFORMATION\n", "#MNEM.UNIT API CODE CURVE DESCRIPTION\n", "#--------- ------------- ------------------------------\n", " DEPT.M : 1 DEPTH\n", " DT .US/M \t\t : 2 SONIC TRANSIT TIME\n", " RHOB.K/M3 : 3 BULK DENSITY\n", " NPHI.V/V : 4 NEUTRON POROSITY\n", " SFLU.OHMM : 5 RXO RESISTIVITY\n", " SFLA.OHMM : 6 SHALLOW RESISTIVITY\n", " ILM .OHMM : 7 MEDIUM RESISTIVITY\n", " ILD .OHMM : 8 DEEP RESISTIVITY\n", "~PARAMETER INFORMATION\n", "#MNEM.UNIT VALUE DESCRIPTION\n", "#--------- ------------- ------------------------------\n", " BHT .DEGC 35.5000: BOTTOM HOLE TEMPERATURE\n", " BS .MM 200.0000: BIT SIZE\n", " FD .K/M3 1000.0000: FLUID DENSITY\n", " MATR. 0.0000: NEUTRON MATRIX(0=LIME,1=SAND,2=DOLO)\n", " MDEN. 2710.0000: LOGGING MATRIX DENSITY\n", " RMF .OHMM 0.2160: MUD FILTRATE RESISTIVITY\n", " DFD .K/M3 1525.0000: DRILL FLUID DENSITY\n", "~Other\n", " Note: The logging tools became stuck at 625 meters causing the data\n", "\t between 625 meters and 615 meters to be invalid.\n", "~A DEPTH DT RHOB NPHI SFLU SFLA ILM ILD\n", "1670.000 123.450 2550.000 0.450 123.450 123.450 110.200 105.600\n", "1669.875 123.450 2550.000 0.450 123.450 123.450 110.200 105.600\n", "1669.750 123.450 2550.000 0.450 123.450 123.450 110.200 105.600\n", "\n" ] } ], "source": [ "print las._text" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now use the ``ExcelConverter`` object to produce an Excel spreadsheet:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "lasio.ExcelConverter(las).write('example.xlsx')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "we can import this spreadsheet back into Python directly using ``pandas``:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import pandas" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The spreadsheet has two sheets, one called \"Header\" with the header information from each section:" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": true }, "outputs": [], "source": [ "xls_header_sheet = pandas.read_excel('example.xlsx', sheetname='Header')" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
SectionMnemonicUnitValueDescription
0~VersionVERSNaN1.2CWLS LOG ASCII STANDARD -VERSION 1.2
1~VersionWRAPNaNNOONE LINE PER DEPTH STEP
2~WellSTRTM1670NaN
3~WellSTOPM1660NaN
4~WellSTEPM-0.125NaN
5~WellNaNNaN-999.25NaN
6~WellCOMPNaN# ANY OIL COMPANY LTD.COMPANY
7~WellWELLNaNANY ET AL OIL WELL #12WELL
8~WellFLDNaNEDAMFIELD
9~WellLOCNaNA9-16-49-20W3MLOCATION
10~WellPROVNaNSASKATCHEWANPROVINCE
11~WellSRVCNaNANY LOGGING COMPANY LTD.SERVICE COMPANY
12~WellDATENaN25-DEC-1988LOG DATE
13~WellUWINaN100091604920W300UNIQUE WELL ID
14~ParameterBHTDEGC35.5BOTTOM HOLE TEMPERATURE
15~ParameterBSMM200BIT SIZE
16~ParameterFDK/M31000FLUID DENSITY
17~ParameterMATRNaN0NEUTRON MATRIX(0=LIME,1=SAND,2=DOLO)
18~ParameterMDENNaN2710LOGGING MATRIX DENSITY
19~ParameterRMFOHMM0.216MUD FILTRATE RESISTIVITY
20~ParameterDFDK/M31525DRILL FLUID DENSITY
\n", "
" ], "text/plain": [ " Section Mnemonic Unit Value \\\n", "0 ~Version VERS NaN 1.2 \n", "1 ~Version WRAP NaN NO \n", "2 ~Well STRT M 1670 \n", "3 ~Well STOP M 1660 \n", "4 ~Well STEP M -0.125 \n", "5 ~Well NaN NaN -999.25 \n", "6 ~Well COMP NaN # ANY OIL COMPANY LTD. \n", "7 ~Well WELL NaN ANY ET AL OIL WELL #12 \n", "8 ~Well FLD NaN EDAM \n", "9 ~Well LOC NaN A9-16-49-20W3M \n", "10 ~Well PROV NaN SASKATCHEWAN \n", "11 ~Well SRVC NaN ANY LOGGING COMPANY LTD. \n", "12 ~Well DATE NaN 25-DEC-1988 \n", "13 ~Well UWI NaN 100091604920W300 \n", "14 ~Parameter BHT DEGC 35.5 \n", "15 ~Parameter BS MM 200 \n", "16 ~Parameter FD K/M3 1000 \n", "17 ~Parameter MATR NaN 0 \n", "18 ~Parameter MDEN NaN 2710 \n", "19 ~Parameter RMF OHMM 0.216 \n", "20 ~Parameter DFD K/M3 1525 \n", "\n", " Description \n", "0 CWLS LOG ASCII STANDARD -VERSION 1.2 \n", "1 ONE LINE PER DEPTH STEP \n", "2 NaN \n", "3 NaN \n", "4 NaN \n", "5 NaN \n", "6 COMPANY \n", "7 WELL \n", "8 FIELD \n", "9 LOCATION \n", "10 PROVINCE \n", "11 SERVICE COMPANY \n", "12 LOG DATE \n", "13 UNIQUE WELL ID \n", "14 BOTTOM HOLE TEMPERATURE \n", "15 BIT SIZE \n", "16 FLUID DENSITY \n", "17 NEUTRON MATRIX(0=LIME,1=SAND,2=DOLO) \n", "18 LOGGING MATRIX DENSITY \n", "19 MUD FILTRATE RESISTIVITY \n", "20 DRILL FLUID DENSITY " ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "xls_header_sheet" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "and another called \"Curves\" containing the data itself:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": true }, "outputs": [], "source": [ "xls_data_sheet = pandas.read_excel('example.xlsx', sheetname='Curves')" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
DEPTDTRHOBNPHISFLUSFLAILMILD
01670.000123.4525500.45123.45123.45110.2105.6
11669.875123.4525500.45123.45123.45110.2105.6
21669.750123.4525500.45123.45123.45110.2105.6
\n", "
" ], "text/plain": [ " DEPT DT RHOB NPHI SFLU SFLA ILM ILD\n", "0 1670.000 123.45 2550 0.45 123.45 123.45 110.2 105.6\n", "1 1669.875 123.45 2550 0.45 123.45 123.45 110.2 105.6\n", "2 1669.750 123.45 2550 0.45 123.45 123.45 110.2 105.6" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "xls_data_sheet" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you want to further modify the ``openpyxl.Workbook`` object, you can access it like so:" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": true }, "outputs": [], "source": [ "converter = lasio.ExcelConverter(las)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "openpyxl.workbook.workbook.Workbook" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "type(converter.workbook)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "finally take a look at some screenshots of the Excel file itself:\n", "\n", "![](example.xlsx-Header.png)\n", "\n", "![](example.xlsx-Curves.png)\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.11" } }, "nbformat": 4, "nbformat_minor": 0 }