Note
Go to the end to download the full example code.
OMF Block Model to DataFrame
An omf TensorGridBlockModel represents a Block Model, and can be converted to a Pandas DataFrame.
from pathlib import Path
import pandas as pd
from omfpandas import OMFPandasReader
Instantiate
Create the object OMFPandas with the path to the OMF file.
test_omf_path: Path = Path('../assets/v2/test_file.omf')
omfp: OMFPandasReader = OMFPandasReader(filepath=test_omf_path)
We’ll inspect the elements in the omf file, and determine what volume element to convert.
omfp.elements
{'Random Points': 'PointSet', 'Random Line': 'LineSet', 'trisurf': 'Surface', 'gridsurf': 'TensorGridSurface', 'vol': 'TensorGridBlockModel'}
Read
We can see by inspection that we have one volume element in the omf file called vol, so we will convert that to a Pandas DataFrame.
blocks: pd.DataFrame = omfp.read_blockmodel(blockmodel_name='vol', attributes=None)
print(f"DataFrame shape: {blocks.shape}")
blocks.head()
DataFrame shape: (3000, 1)
The index contains the centroid coordinates and the dimensions of the block. The columns contain the cell variables in the block model. Data assigned as points (at the grid vertices) are not included in the DataFrame.
Filter
Standard pandas query expressions can be used to filter the returned data.
blocks_filtered: pd.DataFrame = omfp.read_blockmodel(blockmodel_name='vol', attributes=None, query='`random attr`>0.5')
print(f"DataFrame shape: {blocks_filtered.shape}")
blocks_filtered.head()
DataFrame shape: (1449, 1)
Total running time of the script: (0 minutes 0.036 seconds)