Working with Petrel workflows#

Accessing Petrel workflows from Python Tool Pro is one of the new experimental methods. These methods have to be explicitly enabled in the PetrelConnection to be used. Check out the API documentation to view a detailed description of all the functions and methods available for Workflows.

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

Using the .workflow property, we can retrieve all the workflows from the the project in a dictionary where the keys represent the path of the workflow within the Petrel input tree and the values represent the name of the workflow:

[2]:
petrel.workflows
[2]:
Workflows({'Workflows/Unflatten cube on horizon': Workflow(petrel_name="Unflatten cube on horizon"), 'Workflows/Workflow 1': Workflow(petrel_name="Workflow 1"), 'Workflows/Flatten cube on horizon': Workflow(petrel_name="Flatten cube on horizon")})

Using the .path and .petrel_name attributes, we can also create a list of tuples that contain both the path and the name of the workflow:

[3]:
listofworkflows=[(i.petrel_name,i.path) for i in petrel.workflows]
listofworkflows
[3]:
[('Unflatten cube on horizon', 'Workflows/Unflatten cube on horizon'),
 ('Workflow 1', 'Workflows/Workflow 1'),
 ('Flatten cube on horizon', 'Workflows/Flatten cube on horizon')]

To assign a workflow to a variable, we can use the Petrel path of the data objects:

[11]:
Flatten_workflow=petrel.workflows['Workflows/Flatten cube on horizon']
Flatten_workflow.petrel_name
[11]:
'Flatten cube on horizon'

Alternatively, we can use list comprehension on the ‘listofworkflows’ variable created earlier, and assign one of workflows in the list to a variable. To do this, we select the third tuple in the list of workflows [2], and then the second value in the tuple [1], which is the path to that workflow:

[12]:
Flatten_workflow=petrel.workflows[listofworkflows[2][1]]
Flatten_workflow
[12]:
Workflow(petrel_name="Flatten cube on horizon")

The image below shows the Petrel Workflow tree and the Flatten cube on horizon workflow definition. In this example, the workflow is used to flatten a seismic cube using a specific horizon. The seismic cube and horizon are assigned to two reference variables. Next, the name of the seismic cube is also saved as a variable. The Flatten cube process takes the seismic_cube and seismic_horizon variables as inputs, flattens the cube, saves the output under a new name (the seismc cube name variable + “_flattened suffix”) and then assigns it to the seismic_cube_flattened variable.