fmu.tools package

Subpackages

Submodules

fmu.tools.extract_grid_zone_tops_etc module

Extract grid zone tops from wells.

fmu.tools.extract_grid_zone_tops_etc.extract_grid_zone_tops(project=None, well_list=None, logrun='log', trajectory='Drilled trajectory', gridzonelog=None, mdlogname=None, grid=None, zone_param=None, alias_file=None, rms_name='RMS_WELL_NAME', ecl_name='ECLIPSE_WELL_NAME')[source]

Function for extracting top and base from gridzones, both in TVD and MD. A pandas dataframe will be returned.

Users can either input a pre-generated gridzonelog or a grid and a zone parameter for computing the gridzonelog.

The function works both inside RMS and outside with file input. If input from files, and a MD log is not present in the well a quasi md log will be computed and used.

Return type:

DataFrame

fmu.tools.extract_grid_zone_tops_etc.shift_zone_values(zvals)[source]
Return type:

ndarray

fmu.tools.extract_grid_zone_tops_etc.make_alias_dict(alias_file, rms_name='RMS_WELL_NAME', ecl_name='ECLIPSE_WELL_NAME')[source]

Create a correspondance dictionary so that well_dict[ <RMS wellname> ] = <Eclipse wellname>

Return type:

Dict[str, str]

fmu.tools.version module

Module contents

Top-level package for fmu-tools

fmu.tools.extract_grid_zone_tops(project=None, well_list=None, logrun='log', trajectory='Drilled trajectory', gridzonelog=None, mdlogname=None, grid=None, zone_param=None, alias_file=None, rms_name='RMS_WELL_NAME', ecl_name='ECLIPSE_WELL_NAME')[source]

Function for extracting top and base from gridzones, both in TVD and MD. A pandas dataframe will be returned.

Users can either input a pre-generated gridzonelog or a grid and a zone parameter for computing the gridzonelog.

The function works both inside RMS and outside with file input. If input from files, and a MD log is not present in the well a quasi md log will be computed and used.

Return type:

DataFrame

fmu.tools.wellzonation_vs_grid(data, project=None)[source]

Check well zonation or perforations vs 3D grid.

Parameters:

data (dict) – This is dictonary telling where data comes from

class fmu.tools.QCProperties[source]

Bases: object

The QCProperties class consists of a set of methods for extracting property statistics from 3D Grids, Raw and Blocked wells.

Statistics can be collected from either discrete or continous properties. Dependent on the property different statistics are collected.

The methods for statistics extraction can be run individually, or a yaml-configuration file can be used to enable an automatic run of the methods. See the method ‘from_yaml’.

When several methods of statistics extraction has been run within the instance, a merged dataframe is available through the ‘dataframe’ property.

All methods can be run from either RMS python, or from files.

XTGeo is being utilized to get a dataframe from the input parameter data. XTGeo data is reused in the instance to increase performance.

property dataframe

Dataframe with statistics

get_grid_statistics(data, project=None)[source]

Extract property statistics from 3D Grid

Return type:

DataFrame

get_well_statistics(data, project=None)[source]

Extract property statistics from wells

Return type:

DataFrame

get_bwell_statistics(data, project=None)[source]

Extract property statistics from blocked wells

Return type:

DataFrame

from_yaml(cfg, project=None)[source]

Use yaml-configuration file to run the statistics extractions methods

to_csv(csvfile)[source]

Write combined dataframe to csv

class fmu.tools.DomainConversion(depth_surfaces, time_surfaces, names=None, template=None, _nlay_cropper=(0, 0))[source]

Bases: object

Domain conversion, tailored for fmu-sim2seis, but also works as standalone.

The principle is to use matching sets of time and depth surfaces to create a velocity (and slowness) model, and use that further to domain convert either seismic cubes or surfaces, time <=> depth.

Parameters:
  • depth_surfaces (list[RegularSurface]) – List of depth surfaces.

  • time_surfaces (list[RegularSurface]) – List of time surfaces.

  • names (list[str] | None) – Optional list of names for the surfaces. If not provided, the names will be inferred from the input object, or (if missing) generated as “surf_0”, “surf_1”, etc.

  • template (RegularSurface | None) – Optional template surface to use for resampling the input surfaces. If not provided, the last time surface will be used as template.

Note

The input surfaces must be in the same sorted order, and the number of depth and time surfaces must be equal. The first surface does not need to be MSL. The surfaces must extend the full area of the model, and the subsequent surfaces or cubes to be converted must be inside the area of the surfaces that define the model.

Example

>>> from xtgeo import RegularSurface, Cube
>>> from fmu.tools.domainconversion import DomainConversion
>>> # read input surfaces into lists...
>>> depth_surfaces_list = [xtgeo.surface_from_file("depth1.gri"), ...]
>>> time_surfaces_list = [xtgeo.surface_from_file("time1.gri"), ...]
>>> dc = DomainConversion(depth_surfaces_list, time_surfaces_list)
>>> # read a cube... and convert the cube from time to depth
>>> input_cube_in_time = xtgeo.cube_from_file("input_cube.segy")
>>> result_cube_in_depth = dc.depth_convert_cube(input_cube_in_time)
depth_surfaces: list[RegularSurface]
time_surfaces: list[RegularSurface]
names: list[str] | None = None
template: RegularSurface | None = None
static max_depth_for_cube(cube)[source]

Calculate the maximum depth for a cube.

Return type:

float

surface_names()[source]

Return a generator of surface names.

velocity_surfaces()[source]

Return a generator of velocity surfaces.

slowness_surfaces()[source]

Return a generator of slowness surfaces.

property average_velocity_cube_in_time: Cube | None
property average_slowness_cube_in_depth: Cube | None
depth_convert_surfaces(insurfs)[source]

Use the current average velocity model/surfaces to perform depth conversion.

Parameters:

insurfs (list[RegularSurface]) – List of xtgeo surface objects (in time domain) to depth convert.

Return type:

list[RegularSurface]

time_convert_surfaces(insurfs)[source]

Use the average slowness model/cube to perform depth to time conversion.

Parameters:

insurfs (list[RegularSurface]) – List of xtgeo surface objects to time convert.

Return type:

list[RegularSurface]

depth_convert_cube(incube, zinc=None, zmin=None, zmax=None, undefined=-999.25)[source]

Depth convert a cube (time to depth).

Parameters:
  • incube (Cube) – Input cube (in time domain) to convert.

  • zinc (float | None) – Proposed z increment for the output cube.

  • zmin (float | None) – Proposed z minimum for the output cube.

  • zmax (float | None) – Proposed z maximum for the output cube.

  • undefined (float) – Value to use for undefined values in the output cube.

Return type:

Cube

Note

The proposed zinc, zmin, zmax are optional and will be calculated from the existing input surfaces (making the velocity/slowness model) if not provided. If given, the actual values may differ from the proposed values, for technical reasons.

time_convert_cube(incube, tinc=None, tmin=None, tmax=None, undefined=-999.25)[source]

Time convert a cube (depth to time).

Parameters:
  • incube (Cube) – Input cube (in depth domain) to convert.

  • tinc (float | None) – Proposed time increment for the output cube.

  • tmin (float | None) – Proposed time minimum for the output cube.

  • tmax (float | None) – Proposed time maximum for the output cube.

  • undefined (float) – Value to use for undefined values in the output cube.

Return type:

Cube

Note

The proposed tinc, tmin, tmax are optional and will be calculated from the existing input surfaces (making the velocity/slowness model) if not provided. If given, the values may be adjusted for technical reasons.

fmu.tools.sample_attributes_for_sim2seis(grid, attribute, attribute_error=0.05, attribute_error_minimum=None, region=None, zone=None, position=('', Position.CENTER), **kwargs)[source]

Sample attributes on grid resolution as poinst sets.

This usage is for setting attributes on grid resolution, e.g. a seismic attribute (from a map) combined with a region parameter from the grid.

This is targeted to the “sim2seis” workflow in FMU.

Parameters:
  • grid (Grid) – The grid to sample the attributes on.

  • attribute (RegularSurface) – The seismic (or custom) map/surface to sample the attribute from.

  • attribute_error (RegularSurface | float) – The error to apply to the attribute (optional). Shall be absolute (positive) values. If the user wants to apply a polygons with different error values, the user can ise surface-polygons functions in xtgeo to achieve this.

  • attribute_error_minimum (float | None) – The minimum error to apply to the attribute (optional).

  • region (GridProperty | None) – The region parameter to sample from the grid (optional).

  • zone (GridProperty | None) – The zone parameter to sample from the grid (optional).

  • position (tuple[str, Position]) – The position to sample the attributes on the grid. This shall be given as a tuple, as e.g. (“MyZone”, “center”) where the first is zone name, and the second is vertical position (“top”, “center”, “base”) in that zone. Default is (“”, “center”) which will take the middle layer of the total grid. The zone name is case sensitive. If zone is not given, the full grid interval will be applied to determine the layer.

  • **kwargs (Any) – Additional keywords (developer settings).

Returns:

Points with the sampled attributes and attributes combined.

Return type:

pd.Dataframe

fmu.tools.create_nested_hybrid_grid(grid, region, target_region_id, refinement)[source]

Create a nested hybrid grid by refining one region and merging it back.

The cells belonging to target_region_id are replaced by a refined (subdivided) version of the same region. A NEST_ID discrete property is attached to the merged grid, encoding the nested hybrid structure:

  • NEST_ID == 1: coarse (mother) grid cells.

  • NEST_ID == 2: refined grid cells.

In addition, a NNC mapping table is returned that lists every mother ↔ refined cell pair that should be connected by a Non-Neighbour Connection (NNC). The table is derived from the topological knowledge available at merge time (which original cell was refined and how its sub-cells map into the merged grid).

The table columns are:

  • I1, J1, K1: mother cell indices (1-based) in the merged grid.

  • I2, J2, K2: refined cell indices (1-based) in the merged grid.

  • DIRECTION: face direction from the mother cell’s perspective (I+, I-, J+, J-, K+, K-).

This table can be passed to xtgeo.Grid.get_transmissibilities() to compute NNC transmissibilities for the specified cell pairs.

Parameters:
  • grid (Grid) – The original coarse grid.

  • region (GridProperty) – A xtgeo.GridProperty whose values identify the regions (e.g. an integer region parameter).

  • target_region_id (int) – The region value to refine.

  • refinement (tuple[int, int, int]) – (ncol, nrow, nlay) refinement factors.

Return type:

tuple[Grid, DataFrame]

Returns:

A tuple (merged_grid, nnc_table) where merged_grid is a new xtgeo.Grid with the refined region stitched back into the coarse grid and nnc_table is a pandas.DataFrame mapping mother cells to their connected refined cells.

fmu.tools.nnc_to_flowsimulator_input(nnc_df, filepath)[source]

Write NNC transmissibilities to a flow-simulator input file.

Produces a file with the NNC keyword suitable for reservoir simulators that use Eclipse-style input decks, such as Eclipse and OPM Flow. The file can be included in the deck via INCLUDE. Each row of nnc_df becomes one NNC record with the six cell indices and the transmissibility value.

Parameters:
  • nnc_df (DataFrame) – A DataFrame with at least columns I1, J1, K1, I2, J2, K2, T. Optional columns TYPE and DIRECTION are written as end-of-line comments.

  • filepath (str | PathLike[str]) – Path to the output file.

Return type:

None

fmu.tools.nnc_to_gridproperty(grid, nnc_df)[source]

Convert NNC transmissibility data to three GridProperty instances.

Takes the NNC DataFrame produced by xtgeo.Grid.get_transmissibilities() and maps transmissibility values onto grid cells, producing one property per direction (I, J, K).

For rows where DIRECTION contains "+", the transmissibility value is placed in cell (I1, J1, K1). For rows where DIRECTION contains "-", the value is placed in cell (I2, J2, K2). Index columns (I1, J1, K1, I2, J2, K2) are expected to be 1-based.

If multiple rows map to the same cell and direction, the transmissibility values are summed (parallel flow paths are additive).

Parameters:
  • grid (Grid) – The xtgeo Grid that defines the geometry.

  • nnc_df (DataFrame) – A DataFrame with at least columns I1, J1, K1, I2, J2, K2, T, DIRECTION.

Return type:

tuple[GridProperty, GridProperty, GridProperty]

Returns:

A tuple (tranx_nnc, trany_nnc, tranz_nnc) of xtgeo.GridProperty instances named "TRANX_NNC", "TRANY_NNC", and "TRANZ_NNC" respectively. Cells without an NNC value are set to -1.0.