Thursday, April 27, 2017

Python, wells, LAS and info

Those of you who deal with wireline well log data know that the standard format is call LAS. A nice site from the Canadian Well Logging Society that explains the format can be found here. In the old days, a well would be logged for gamma ray, density and maybe a couple of electric logs. In today's world, a full logging assault can yield a vast collection of data types (called curves). Not only that, but these might be split across many LAS files. One well in our data base has 17 LAS files! Each individual curve has a short abbreviation (a mnemonic) such as GR (gamma ray), RHOB (bulk density) and DT (compressional sonic). The mnemonics are somewhat standardized, but in fact there is broad variability between logging companies. Each curve also has units and a description field in the LAS file.

How do you figure out what curves are contained in such a collection of LAS files? Well, one approach is to convert each LAS to an excel file, but that gets messy and brings in the data as well as the curve information. The Agile Geoscience folks have discussed this topic and python in detail; here we have a less ambitious goal that allows a simple solution.

To deal with this problem, I wrote a code in python that I call info.py - here it is

import lasio
import os

n = 1
for file in os.listdir("."):
    if file.endswith(".las") or file.endswith(".LAS"):
        var = lasio.read(file)
        print "\n las"+str(n), file
        print var.well
        print var.other
        for curve in var.curves:
            print("%s\t[%s]\t%s\t%s" % (curve.mnemonic, curve.unit, curve.value, curve.descr))
        n += 1

This little code is magic, mainly because it draws on lasio, a library for reading and writing LAS files. Stepping through the code line-by-line goes like this
  1. import the lasio library
  2. import the operating system library
  3. set counter n to 1
  4. for each file in the current directory...
  5. if the file name ends in las or LAS...
  6. read the file
  7. print 'las' with n appended, then the file name
  8. print the 'well' data section of the file
  9. print the 'other' data section of the file
  10. for each curve in the file print mnemonic, units, value and description
  11. increase n by 1 and continue till all files are read
My early versions of this code required the file names to be pasted into the code, which was ok for a few LAS files. But that got very clunky with more than four files.

I work on a mac which has a command line terminal and python build in. Python has lots of default libraries, but others are always needed. I install them with pip, but first you must install pip itself

sudo easy_install pip

Then this command line installs lasio

sudo pip install lasio

Now you are ready to go. The code above can be copied into a text editor and saved as info.py (or another name you like better). Now go to a directory full of LAS files from a well and copy info.py into that folder. On the mac, open a terminal window and cd to the LAS directory, then type

python info.py

or, if you want to capture the output into a file

python info.py > info_jones1a.txt

The result will look something like the listing at the end of this post. The beauty of this little code fragment is the amount of information it makes readily available in complex well situations with many, or redundant, or overlapping LAS files. 

Hope you enjoy the code and it helps you organize a few tough LAS situations.

las1 Jones_1A_run1.las

Mnemonic  Unit  Value                       Description      
--------  ----  -----                       -----------      
STRT      F      437.0                      START DEPTH      
STOP      F     4000.5                      STOP DEPTH       
STEP      F     0.5                         STEP             
NULL            -999.25                     NULL VALUE       
COMP            Jones                       COMPANY          
WELL            1A                          WELL             
FLD             WILDCAT                     FIELD            
LOC             SHL: 1320' FNL & 2210' FWL  LOCATION         
CNTY                                        COUNTY           
STAT                                        STATE            
CTRY                                        COUNTRY          
SRVC                                        SERVICE COMPANY  
API                                         API NUMBER       
DATE            8-Jun-2012                  LOG DATE         
UWI                                         UNIQUE WELL ID   

DEPT [F] DEPTH (BOREHOLE) {F12.4}
C1 [IN] Caliper 1 {F11.4}
C2 [IN] Caliper 2 {F11.4}
CDF [LBF] Calibrated Downhole Force {F11.4}
CTEM [DEGF] Cartridge Temperature {F11.4}
DCAL [IN] Differential Caliper {F11.4}
DEVI [DEG] Hole Deviation {F11.4}
GR_EDTC [GAPI] EDTC Gamma Ray {F11.4}
GTEM [DEGF] Generalized Borehole Temperature {F11.4}
HAZI [DEG] Hole Azimuth {F11.4}
HAZIM [DEG] Hole Azimuth {F11.4}
P1AZ [DEG] Pad 1 Azimuth {F11.4}
RB [DEG] Relative Bearing {F11.4}
SDEV [DEG] Sonde Deviation {F11.4}
SDEVM [DEG] Sonde Deviation {F11.4}
STIT [F] Stuck Tool Indicator, Total {F11.4}
TENS [LBF] Cable Tension {F11.4}

las2 Jones_1A_run2.las

Mnemonic  Unit  Value                       Description      
--------  ----  -----                       -----------      
STRT      F      437.0                      START DEPTH      
STOP      F     4000.5                      STOP DEPTH       
STEP      F     0.5                         STEP             
NULL            -999.25                     NULL VALUE       
COMP            Jones                       COMPANY          
WELL            1A                          WELL             
FLD             WILDCAT                     FIELD            
LOC             SHL: 1320' FNL & 2210' FWL  LOCATION         
CNTY                                        COUNTY           
STAT                                        STATE            
CTRY                                        COUNTRY          
SRVC                                        SERVICE COMPANY  
API                                         API NUMBER       
DATE            8-Jun-2012                  LOG DATE         
UWI                                         UNIQUE WELL ID   

DEPT [F] DEPTH (BOREHOLE) {F12.4}
AF10 [OHMM] Array Induction Four Foot Resistivity A10 {F11.4}
AF20 [OHMM] Array Induction Four Foot Resistivity A20 {F11.4}
AF30 [OHMM] Array Induction Four Foot Resistivity A30 {F11.4}
AF60 [OHMM] Array Induction Four Foot Resistivity A60 {F11.4}
AF90 [OHMM] Array Induction Four Foot Resistivity A90 {F11.4}
AO10 [OHMM] Array Induction One Foot Resistivity A10 {F11.4}
AO20 [OHMM] Array Induction One Foot Resistivity A20 {F11.4}
AO30 [OHMM] Array Induction One Foot Resistivity A30 {F11.4}
AO60 [OHMM] Array Induction One Foot Resistivity A60 {F11.4}
AO90 [OHMM] Array Induction One Foot Resistivity A90 {F11.4}
AT10 [OHMM] Array Induction Two Foot Resistivity A10 {F11.4}
AT20 [OHMM] Array Induction Two Foot Resistivity A20 {F11.4}
AT30 [OHMM] Array Induction Two Foot Resistivity A30 {F11.4}
AT60 [OHMM] Array Induction Two Foot Resistivity A60 {F11.4}
AT90 [OHMM] Array Induction Two Foot Resistivity A90 {F11.4}
AHFCO60 [MM/M] Array Induction Four Foot Conductivity A60 {F11.4}
AHMF [OHMM] Array Induction Mud Resistivity Fully Calibrated {F11.4}
AHORT [OHMM] Array Induction One Foot Rt {F11.4}
AHORX [OHMM] Array Induction One Foot Rxo {F11.4}
AHSCA [MV] Array Induction SPA Calibrated {F11.4}
AHTCO10 [MM/M] Array Induction Two Foot Conductivity A10 {F11.4}
AHTCO20 [MM/M] Array Induction Two Foot Conductivity A20 {F11.4}
AHTCO30 [MM/M] Array Induction Two Foot Conductivity A30 {F11.4}
AHTCO60 [MM/M] Array Induction Two Foot Conductivity A60 {F11.4}
AHTCO90 [MM/M] Array Induction Two Foot Conductivity A90 {F11.4}
AHTD1 [IN] Array Induction Two Foot Inner Diameter of Invasion(D1) 
AHTD2 [IN] Array Induction Two Foot Outer Diameter of Invasion (D2) 
AHTRT [OHMM] Array Induction Two Foot Rt {F11.4}
AHTRX [OHMM] Array Induction Two Foot Rxo {F11.4}
CDF [LBF] Calibrated Downhole Force {F11.4}
CFTC [HZ] Corrected Far Thermal Counting Rate {F11.4}
CNTC [HZ] Corrected Near Thermal Counting Rate {F11.4}
CTEM [DEGF] Cartridge Temperature {F11.4}
DCAL [IN] Differential Caliper {F11.4}
DNPH [CFCF] Delta Thermal Neutron Porosity {F11.4}
DPHZ [CFCF] HRDD Standard Resolution Density Porosity {F11.4}
DSOZ [IN] HRDD Standard Resolution Density Standoff {F11.4}
ECGR [GAPI] Environmentally Corrected Gamma-Ray {F11.4}
GDEV [DEG] HGNS Deviation {F11.4}
GR [GAPI] Gamma-Ray {F11.4}
GTEM [DEGF] Generalized Borehole Temperature {F11.4}
HCAL [IN] HRCC Cal. Caliper {F11.4}
HDRA [G/C3] HRDD Density Correction {F11.4}
HDRB [G/C3] HRDD Backscatter Delta Rho {F11.4}
HGR [GAPI] HiRes Gamma-Ray {F11.4}
HMIN [OHMM] MCFL Micro Inverse Resistivity {F11.4}
HMNO [OHMM] MCFL Micro Normal Resistivity {F11.4}
HNPO [CFCF] HiRes Enhanced Thermal Neutron Porosity {F11.4}
HPRA [] HRDD Photoelectric Factor Correction {F11.4}
HTNP [CFCF] HiRes Thermal Neutron Porosity {F11.4}
NPHI [CFCF] Thermal Neutron Porosity (Ratio Method) {F11.4}
NPOR [CFCF] Enhanced Thermal Neutron Porosity {F11.4}
PEFZ [] HRDD Standard Resolution Formation Photoelectric Factor 
PXND_HILT[CFCF] HILT Porosity CrossPlot {F11.4}
RHOZ [G/C3] HRDD Standard Resolution Formation Density {F11.4}
RSOZ [IN] MCFL Standard Resolution Resistivity Standoff {F11.4}
RWA_HILT[OHMM] HILT Apparent water resistivity {F11.4}
RXO8 [OHMM] MCFL High Resolution Invaded Zone Resistivity {F11.4}
RXOZ [OHMM] MCFL Standard Resolution Invaded Zone Resistivity {F11.4}
SP [MV] Spontaneous Potential {F11.4}
SPAR [MV] SP Armor Return {F11.4}
STIT [F] Stuck Tool Indicator, Total {F11.4}
TENS [LBF] Cable Tension {F11.4}
TNPH [CFCF] Thermal Neutron Porosity {F11.4}

Tuesday, April 25, 2017

Carbonate Essentials Webinar - Day 1

Had a very good session with several questions. We had 28 attendees, but some of them were group logins. Total registration is 50. Tomorrow is part 2!

Screen shot of the webinar in progress. Attendee names redacted to protect the innocent. 
You can always depend on Mike Graul for a good dose of humor.