OMF IO API

OMF Writer

Batch export multiple different object types from a geological modeling software package.

../_images/ProjectExport.png
class omf.fileio.OMFWriter(project, fname)[source]

OMFWriter serializes a OMF project to a file

proj = omf.project()
...
omf.OMFWriter(proj, 'outfile.omf')

The output file starts with a 60 byte header:

  • 4 byte magic number: b'\x81\x82\x83\x84'
  • 32 byte version string: 'OMF-v0.9.0' (other bytes empty)
  • 16 byte project uid (in little-endian bytes)
  • 8 byte unsigned long long (little-endian): JSON start location in file

Following the header is a binary data blob.

Following the binary is a UTF-8 encoded JSON dictionary containing all elements of the project keyed by UID string. Objects can reference each other by UID, and arrays and images contain pointers to their data in the binary blob.

OMF Reader

Select which objects from the file are to be imported into a 3D visualization software.

../_images/ProjectImport.png
class omf.fileio.OMFReader(fopen)[source]

OMFReader deserializes an OMF file.

# Read all elements
reader = omf.OMFReader('infile.omf')
project = reader.get_project()

# Read all PointSets:
reader = omf.OMFReader('infile.omf')
project = reader.get_project_overview()
uids_to_import = [element.uid for element in project.elements
                  if isinstance(element, omf.PointSetElement)]
filtered_project = reader.get_project(uids_to_import)