petrelpy.petrel

Convert between Petrel and various other formats.

Functions

write_header(df, fname[, fill_na])

Write header information to a Petrel-readable header file.

read_header(→ pandas.DataFrame)

Read headers from a file.

collect_perfs(→ pandas.DataFrame)

Group perforations by well.

export_perfs_ev(→ None)

Export perforations in ev (event file) format.

export_perfs_prn(→ None)

Export perforations in prn (fixed) format.

read_production(infile[, yearly])

Get raw data from infile (even if infile is several files).

export_vol(wells, outfile[, header])

Export production volumes to Petrel-readable .vol format file.

export_injection_vol(wells, outfile[, header])

Export injection volumes to Petrel-readable .vol format file.

convert_properties_petrel_to_arc(fin, fout, prop)

Make Midland basin Petrel gslib file Arc-readable.

read_petrel_tops(→ pandas.DataFrame)

Read Petrel tops file.

write_tops(df, fname[, comments, fill_na])

Write top picks to Petrel-readable file.

get_raw_table(→ pandas.DataFrame)

Ingest excel, prn, or csv file.

Module Contents

petrelpy.petrel.write_header(df, fname, fill_na=-999)

Write header information to a Petrel-readable header file.

Parameters:
  • df (DataFrame) – header information for wells (does not pass index)

  • fname (str) – file to write to

  • fill_na (int, optional) – value to write null values to, by default -999

petrelpy.petrel.read_header(fname: str) pandas.DataFrame

Read headers from a file.

petrelpy.petrel.collect_perfs(df_perf: pandas.DataFrame) pandas.DataFrame

Group perforations by well.

Parameters:

df_perf (pd.DataFrame) – Well completion data. Expected columns include “Date Completion”, “Date First Report”, “Depth Top”, “Depth Base” and “UWI”

Returns:

Perforations grouped by well

Return type:

pd.DataFrame

petrelpy.petrel.export_perfs_ev(perfs: pandas.DataFrame, output: pathlib.Path, header: str = 'UNITS FIELD\n') None

Export perforations in ev (event file) format.

Parameters:
  • perfs (pd.DataFrame) – contains perfs in columns for API,start_depth,stop_depth

  • output (Path) – prn file to write to

  • header (str) – first line for file, probably explaining units

petrelpy.petrel.export_perfs_prn(perfs: pandas.DataFrame, output: pathlib.Path) None

Export perforations in prn (fixed) format.

Parameters:
  • perfs (pd.DataFrame) – contains perfs in columns for API,start_depth,stop_depth

  • output (Path) – prn file to write to

petrelpy.petrel.read_production(infile: str | tuple[str], yearly=False)

Get raw data from infile (even if infile is several files).

petrelpy.petrel.export_vol(wells: pandas.DataFrame, outfile: str | pathlib.Path, header: str | None = None)

Export production volumes to Petrel-readable .vol format file.

Parameters:
  • wells (pd.DataFrame) – IHS-style wells dataframe with oil, water, and gas production. Expected columns are API,Date,Liquid,Water,Gas.

  • outfile (str | Path) – vol file to save to

  • header (str | None, optional) – Units and column names. Defaults to None.

petrelpy.petrel.export_injection_vol(wells, outfile, header=None)

Export injection volumes to Petrel-readable .vol format file.

Parameters:
  • wells (pd.DataFrame) – IHS-style wells dataframe with water, and gas injection. Expected columns are API,Date,Water,Gas.

  • outfile (str | Path) – vol file to save to

  • header (str | None, optional) – Units and column names. Defaults to None.

petrelpy.petrel.convert_properties_petrel_to_arc(fin, fout, prop)

Make Midland basin Petrel gslib file Arc-readable.

petrelpy.petrel.read_petrel_tops(fname: str) pandas.DataFrame

Read Petrel tops file.

Parameters:

fname (str) – path to file

Returns:

Tops, with Well indicating the well, then a column for each surface

Return type:

pd.DataFrame

petrelpy.petrel.write_tops(df, fname, comments='', fill_na=-999)

Write top picks to Petrel-readable file.

Parameters:
  • df (DataFrame) – tops picks. Expects “Well” to be first column, then a column per horizon

  • fname (str) – Path to write out

  • comments (str, optional) – Any comments to include at the beginning of the file, by default “”

  • fill_na (int, optional) – Value to assign nulls to, by default -999

petrelpy.petrel.get_raw_table(fname: str | pathlib.Path, sheetname: int | str = 0) pandas.DataFrame

Ingest excel, prn, or csv file.

Parameters:
  • fname (str) – file to read

  • sheetname (int | str, optional) – sheet to extract if excel. Defaults to 0.

Returns:

table

Return type:

pd.DataFrame