petrelpy.gslib

Work with gslib geomodel format.

Functions

load_from_petrel(→ dask.dataframe.DataFrame)

Load GSLIB geomodel file.

get_midpoint_cell_columns(geomodel, dir_out)

Find cell columns where UWI-index exists in the geomodel.

load_petrel_tops_file(tops_file)

Load in petrel tops file and return pandas dataframe.

match_well_to_cell(→ pandas.DataFrame)

Give each well in df_wells the i,j,k index of the nearest cell in df_cells.

match_ijz_petrel(geomodel, uwi_to_index, wdir[, zdmax])

Merge geomodel with wells to assign properties to wells.

aggregate_well_properties(→ pandas.DataFrame)

Find average geocellular properties about well midpoint.

get_facies_stats(df[, zonename, faciesname, attrs])

Get aggregated statistics for different facies and zones.

get_facies_histograms(→ tuple[pandas.DataFrame, ...)

Calculate histogram of original oil in place for geomodel by zone, facies, properties.

Module Contents

petrelpy.gslib.load_from_petrel(fin: pathlib.Path | str, npartitions=60) dask.dataframe.DataFrame

Load GSLIB geomodel file.

Parameters:
  • fin (Path | str) – gslib Petrel output

  • npartitions (int, optional) – number of partitions for dask dataframe. Defaults to 60.

Returns:

lazy-evaluated dataframe with geomodel properties

Return type:

dd.DataFrame

petrelpy.gslib.get_midpoint_cell_columns(geomodel: dask.dataframe.DataFrame, dir_out: str)

Find cell columns where UWI-index exists in the geomodel.

Parameters:
  • geomodel (dd.DataFrame) – geocellular model extracted from gslib file

  • dir_out (str) – folder to store the parquet file in

Returns:

vertical column of cells around the well’s midpoint

Return type:

pd.DataFrame

petrelpy.gslib.load_petrel_tops_file(tops_file: pathlib.Path | str)

Load in petrel tops file and return pandas dataframe.

petrelpy.gslib.match_well_to_cell(midpoints: pandas.DataFrame, geomodel: pandas.DataFrame, distance_upper_bound: float = 2000) pandas.DataFrame

Give each well in df_wells the i,j,k index of the nearest cell in df_cells.

Parameters:
  • midpoints (pd.DataFrame) – well midpoint locations. Columns include Well,X,Y,Z

  • geomodel (pd.DataFrame) – geocellular model. Columns include x_coord,y_coord,z_coord

  • distance_upper_bound (float, optional) – max distance between well and center of cell. Defaults to 2000.

Returns:

geomodel cells nearest to each well midpoint

Return type:

pd.DataFrame

petrelpy.gslib.match_ijz_petrel(geomodel: dask.dataframe.DataFrame, uwi_to_index: pandas.DataFrame, wdir: str, zdmax: float = 1000)

Merge geomodel with wells to assign properties to wells.

Parameters:
  • geomodel (dask.DataFrame) – dask dataframe of the geomodel, must include a column called ‘UWI-index’, ijk indices, and z coordinate

  • uwi_to_index (pd.DataFrame) – pandas dataframe with UWI-Index column and UWI column to do merging

  • wdir (str) – string pointing to the working directory for behind-the-scenes parquet file creation

  • zdmax (float) – maximum z variation from cells in ij column to point including a UWI-index

Returns:

merged dataframe that has all your favorite attributes in an ij column with less than zdmax vertical separation from midpoint at UWI-index.

Return type:

pd.DataFrame

petrelpy.gslib.aggregate_well_properties(geomodel_ijmatched: pandas.DataFrame, well_midponts: pandas.DataFrame | None = None, zdmax: float = 200, agg_arg='mean', uwi_col='UWI-Index') pandas.DataFrame

Find average geocellular properties about well midpoint.

Parameters:
  • geomodel_ijmatched (pd.DataFrame) – geomodel after paring down to nearby cells

  • well_midponts (pd.DataFrame | None, optional) – geocells nearest each well midpoint. Defaults to None. If none, cuts geomodel_ijmatched down to those with a valid uwi_col

  • zdmax (float, optional) – Max vertical distance between well and geocell. Defaults to 200.

  • agg_arg (str, optional) – method for aggregating. Defaults to “mean”.

  • uwi_col (str, optional) – geocellular column with well identifier. Defaults to “UWI-Index”.

Returns:

average properties for each well index

Return type:

pd.DataFrame

petrelpy.gslib.get_facies_stats(df, zonename='Mainzones', faciesname='Facies', attrs=None)

Get aggregated statistics for different facies and zones.

petrelpy.gslib.get_facies_histograms(geomodel: dask.dataframe.DataFrame, zone_name: str = 'Mainzones', facies_name: str = 'Facies', properties: list[str] | None = None, ooip_name: str = 'OOIP') tuple[pandas.DataFrame, pandas.DataFrame, pandas.DataFrame]

Calculate histogram of original oil in place for geomodel by zone, facies, properties.

Parameters:
  • geomodel (dd.DataFrame) – geocellular model with zone, facies, properties

  • zone_name (str, optional) – column naming the zone. Defaults to “Mainzones”.

  • facies_name (str, optional) – column naming the facies. Defaults to “Facies”.

  • properties (list[str], optional) – columns holding properties to compute histogram over. Defaults to [“Phi”, “Sw”].

  • ooip_name (str, optional) – Property to calculate the histogram over. Defaults to “OOIP”.

Returns:

ooip_splits, index_conversion, and

max property values

Return type:

tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame]