read

petrophys.api.read

Also available as petrophys.read

read(
path,
*,
formations=None,
lithology=None,
formation_options=None,
lithology_options=None,
depth_reference=None,
datum=None,
curve_aliases=None,
survey=None,
elevation=None,
**reader_options,
)[source]

Read a well from LAS, DLIS, CSV, TSV or Excel and optionally attach geology.

A folder, a file pattern ("logs/*.las") or a list of files reads every well into a WellList, which interpret() takes as it is. A multi-well formations or lithology table is read once and each well keeps its own rows, found by the well’s name, UWI or API, else by its file name; a well the table has no rows for is read without them and named in a warning. Each file is read with the reader options its format takes (depth_unit is for the CSV, TSV and Excel files of a folder that also holds LAS files). A file that cannot be read is named in wells.failed and in a warning.

Reading never calculates interpretation curves; use interpret() for that. Curves of LAS, CSV, TSV and Excel files keep the names and units found in the file. A DLIS file is read as petrophys.io.read_dlis() reads it: without frame_name, its frames are merged onto one depth index in metres and curve names and units are standardized (standardize=False keeps them).

Parameters:
  • path (str, Path or list) – Well file. The format is chosen from the extension (.las, .dlis, .csv, .tsv, .xlsx, .xlsm or .xls). A folder (its LAS and DLIS files, and its CSV, TSV and Excel files when depth_unit is given), a file pattern or a list of files reads several wells.

  • formations (path, DataFrame, mapping, or sequence, optional) – Formation tops or intervals (see petrophys.read_formations()). They annotate plots and calibrate core permeability per formation in interpret() when they do not overlap, apart from groups that contain their own ranked formations (the formation’s model then takes precedence). formation_options={"rank": "formation"} attaches one level only.

  • lithology (path or DataFrame, optional) – Lithology intervals with top,bottom,lithology columns (see petrophys.io.read_lithology_intervals()). They take precedence over embedded lithology for plotting and interpretation.

  • formation_options (mapping, optional) – Extra arguments for petrophys.read_formations(), e.g. {"columns": {"formation_name": "Surface", "top_depth": "MD"}}, {"well_name": "30/6-5"} for a multi-well table, {"rank": "formation"} for one stratigraphic level, or {"sheet_name": 1} for an Excel sheet.

  • lithology_options (mapping, optional) – Extra arguments for petrophys.io.read_lithology_intervals(), e.g. {"columns": {"lithology": "ROCK"}}.

  • depth_reference (str, optional) – Depth reference of the well, e.g. "MD"; geology recorded against a different reference is rejected.

  • datum (str, optional) – Depth datum of the well, e.g. "KB"; geology recorded against a different datum is rejected.

  • curve_aliases (mapping, path or DataFrame, optional) – Your names for standard curves, e.g. {"GAMMA_RAY_1": "GR", "DEEP_RES": "RDEP"} or a CSV/Excel table of curve name and standard name (see petrophys.preprocessing.standardization.user_aliases.read_curve_aliases()). It is stored on the well, so interpretation and plots use it. Entries that name no curve of the well (of any well, for several) are named in a warning with their likely fix.

  • survey (path, DataFrame or "vertical", optional) – Deviation survey (MD, inclination, azimuth; CSV, Excel or LAS) or "vertical". Adds TVD below the log depth reference and, when the header gives the reference elevation (EKB/EDF/APD), TVDSS (see petrophys.io.attach_survey()).

  • elevation (float, optional) – Elevation of the log’s depth reference above sea level, in the well’s depth unit, for TVDSS in place of the header’s; needs survey.

  • **reader_options – Options for the format reader. CSV, TSV and Excel files need depth_unit="m" or depth_unit="ft" unless the depth column header states the unit (DEPTH (m)); other options (e.g. depth_column="MD", or sheet_name="Logs" for an Excel sheet) are passed to petrophys.io.read_csv(), petrophys.io.read_excel(), petrophys.io.read_las() or petrophys.io.read_dlis(). A CSV file’s separator (comma, semicolon or tab) and decimal comma are found from the file unless sep and decimal are given.

Returns:

The well, with any attached geology stored for plot() and interpret(); several wells for a folder, pattern or list.

Return type:

Well or WellList

Raises:
  • FileNotFoundError – If path does not exist; the message names the folder searched.

  • ValueError – If the extension names an unsupported format (whether or not the file exists) or an existing file has no extension, the path holds its quotation marks or control characters (a backslash read as an escape), the depth unit of a CSV, TSV or Excel file is neither given nor in its depth column header, a folder holds no well file or a pattern matches none, attached geology is invalid for this well (a single well the formations or lithology table has no rows for; depths that fit the logged interval in the other depth unit only), elevation is given without survey, or a survey file is given for several wells.

Examples

>>> import petrophys as pp
>>> well = pp.read(pp.sample("30_6-5"))
>>> well = pp.read("my_well.csv", depth_unit="m", formations="tops.csv")
>>> wells = pp.read("logs/", formations="tops.xlsx")