omfpandas.writer.OMFPandasWriter

class omfpandas.writer.OMFPandasWriter(filepath)[source]

A class to write pandas dataframes to an OMF file.

filepath

Path to the OMF file.

Type:

Path

__init__(filepath)[source]

Instantiate the OMFPandasWriter object.

Parameters:

filepath (Path) – Path to the OMF file.

Methods

__init__(filepath)

Instantiate the OMFPandasWriter object.

delete_blockmodel_attribute(blockmodel_name, ...)

Delete an attribute from a BlockModel.

get_element_attribute_names(element_name)

Get the attribute names of an element.

get_element_by_name(element_name)

Get an element by its name.

profile_blockmodel(blockmodel_name[, query])

Profile a BlockModel.

view_block_model_profile(blockmodel_name[, ...])

View the profile of a BlockModel in the default web browser.

write_block_model_schema(blockmodel_name, ...)

Write a Pandera schema to the OMF file.

write_blockmodel(blocks, blockmodel_name[, ...])

Write a dataframe to a BlockModel.

write_blockmodel_attribute(blockmodel_name, ...)

Write data to a specific attribute of a BlockModel.

write_to_changelog(element, action, description)

Write a change message to the OMF file.

Attributes

changelog

Return the change log as a DataFrame.

delete_blockmodel_attribute(blockmodel_name, attribute_name)[source]

Delete an attribute from a BlockModel.

Parameters:
  • blockmodel_name (str) – The name of the BlockModel.

  • attribute_name (str) – The name of the attribute.

profile_blockmodel(blockmodel_name, query=None)[source]

Profile a BlockModel.

Profiling will be skipped if the data has not changed.

Parameters:
  • blockmodel_name (str) – The name of the BlockModel to profile.

  • query (Optional[str]) – A query to filter the data before profiling.

Returns:

The profiled data.

Return type:

pd.DataFrame

write_block_model_schema(blockmodel_name, pd_schema_filepath)[source]

Write a Pandera schema to the OMF file.

Parameters:
  • blockmodel_name (str) – The name of the BlockModel.

  • pd_schema_filepath (Path) – The path to the Pandera schema yaml file.

write_blockmodel(blocks, blockmodel_name, pd_schema_filepath=None, allow_overwrite=False)[source]

Write a dataframe to a BlockModel.

Only dataframes with centroid (x, y, z) and block dims (dx, dy, dz) indexes are supported.

Parameters:
  • blocks (pd.DataFrame) – The dataframe to write to the BlockModel.

  • blockmodel_name (str) – The name of the BlockModel to write to.

  • pd_schema_filepath (Optional[Path]) – The path to the Pandera schema file. Default is None. If provided, the schema will be used to validate the dataframe before writing.

  • allow_overwrite (bool) – If True, overwrite the existing BlockModel. Default is False.

Raises:

ValueError – If the element retrieved is not a BlockModel.

write_blockmodel_attribute(blockmodel_name, series, allow_overwrite=False)[source]

Write data to a specific attribute of a BlockModel.

Parameters:
  • blockmodel_name (str) – The name of the BlockModel.

  • series (pd.Series) – The data to write to the attribute.

  • allow_overwrite (bool) – If True, overwrite the existing attribute. Default is False.

write_to_changelog(element, action, description)[source]

Write a change message to the OMF file.

Parameters:
  • element (str) – The name of the element that was changed

  • action (Literal['create', 'update', 'delete']) – The action taken on the object

  • description (str) – Description of the change

Returns: