LASReader

petrophys.io.LASReader

class LASReader(filepath, encoding=None)[source]

Reader for LAS (Log ASCII Standard) files.

Examples

>>> reader = LASReader("well_data.las")
>>> well = reader.to_well()

Attributes

curves

Return list of curve mnemonics.

las

Return underlying lasio object.

well_name

Return well name from header.

Methods

get_curve_data

Get data for a specific curve.

get_curve_unit

Get unit for a specific curve.

get_header_unit

Get unit text from LAS well or parameter header.

get_header_value

Get value from LAS header.

to_well

Convert LAS data to Well object.

Parameters:
__init__(filepath, encoding=None)[source]

Initialize LAS reader.

Parameters:
  • filepath (str or Path) – Path to LAS file

  • encoding (str, optional) – Text encoding of the file. By default UTF-8 is tried first and lasio’s encoding detection is used if the file is not UTF-8.

Raises:
  • FileNotFoundError – If the file does not exist.

  • ValueError – If the file cannot be parsed as LAS, has no ~Curve curves or no ~A section. Comma-delimited ~A rows and lower-case section titles are read.

property las

Return underlying lasio object.

property curves: List[str]

Return list of curve mnemonics.

property well_name: str

Return well name from header.

get_header_value(key, default=None)[source]

Get value from LAS header.

Parameters:
Return type:

Any

get_header_unit(key, default='')[source]

Get unit text from LAS well or parameter header.

Parameters:
Return type:

str

get_curve_data(mnemonic)[source]

Get data for a specific curve.

Parameters:

mnemonic (str)

Return type:

ndarray | None

get_curve_unit(mnemonic)[source]

Get unit for a specific curve.

Parameters:

mnemonic (str)

Return type:

str

to_well()[source]

Convert LAS data to Well object.

The first ~Curve curve is the depth index (DEPT, TDEP, INDEX, …), as LAS 2.0 defines; a later TVD or DEPTH curve is an ordinary curve. Data rows whose index is null (the header NULL, -999.25 or NaN) are left out with a warning, and an unreadable index value raises ValueError naming its data row. In the curves, unreadable tokens (-1.#IND, ****) are read as NaN with a warning, Fortran D exponents are read, and values of COMMON_LAS_NULLS that differ from the header NULL are read as NaN with a warning.

Header values with units are stored as:

  • header.td: total depth in the well’s depth unit (well.depth_unit), converted from the TD unit; header.td_source_unit is the TD unit as written.

  • header.bit_size: bit size in inches, converted from mm, cm or m; header.bit_size_source_unit is the BS unit as written. Without a BS item, numbered bit runs (BS1, BS2, … with the depths BSD1, BSD2, … they drilled) give header.bit_size_intervals.

A TD or BS whose unit is not recognised is left unset (None) with a warning; one without a unit is taken to be in the depth unit or in inches. Other ~Well items are kept in header.las_well_items and the ~Other text in the LAS_OTHER parameter, which petrophys.io.export_las() writes back. Numeric-looking header values written with leading zeros (LIC . 00123) are kept as text.

Returns:

Well object with loaded data

Return type:

Well