Petrel Connection#

This section offers an overview of the different functions and properties available for connecting to Petrel. To start with, we assign the PetrelConnection to the Python variable ‘petrel’ and can now use the properties of ‘petrel’ to return a Python dictionary of domain objects. A full list of available properties can be found in the Python API of the class PetrelConnection.

[1]:
from cegalprizm.pythontool import PetrelConnection
petrel = PetrelConnection()

The following parameters can be passed in the PetrelConnection():

  • petrel_ctx – A context or handle to a Cegal Hub Petrel Connector (check the Hub documentation for more information about the Cegal Hub Petrel Connector)

  • allow_experimental – Enable experimental methods to be called. Defaults to False. To check which domain objects have available experimental methods please consult the API documentation

  • enable_history – Petrel data object history is updated when changed from Python Tool Pro. Defaults to True.

To verify if a Petrel project is active on the server you can use the .a_project_is_active() function:

[2]:
petrel.a_project_is_active()
[2]:
True

We can verify the connection to the server using the .ping() function which returns an int (1-connection is working, 0-connection is not working):

[8]:
petrel.ping()
[8]:
1

The .get_current_project_name() function returns the name of the Petrel project of the established connection:

[3]:
petrel.get_current_project_name()
[3]:
'Gullfaks_dataset2.pet'

The .get_petrel_project_units() function returns the Petrel project units of the established connection:

[4]:
petrel.get_petrel_project_units()
[4]:
{'XY unit': 'm',
 'Z unit': 'm',
 'Area unit': 'm2',
 'Volume unit': 'm3',
 'Seismic time': 'ms',
 'Seismic velocity': 'm/s'}

You can retrieve Petrel objects using the GUID of the object and the .get_petrelobjects_by_guids() function:

[7]:
petrel.get_petrelobjects_by_guids(['dbae9e2e-3eea-4f7f-a357-b2d8141eaf3e'])
[7]:
[Well(petrel_name="C3")]

To close the Petrel project use the .close() function:

[34]:
petrel.close()

You can retrieve Petrel objects from Python Tool Pro using the various properties of the class PetrelConnection. All domain objects will be returned as a Python dictionary using the Petrel path as keys. If multiple objects have the same path, a list of them is returned. The image bellow summarizes the petrel objects supported by Python Tool Pro alongside the python property used to retrieve the data objects. All these domain objects will be returned as a Python dictionary using the Petrel path as keys. If multiple objects have the same path, a list of them is returned.

domainobj.png