Completions#
Python Tool Pro version 2.2 added suport for Completions. This notebook offers an overview of the different functions and properites available for working with Casing and Perforation data. For a more detailed description of all the functions and properties, check out the API documentation.
Connect to a Petrel project#
[1]:
from cegalprizm.pythontool import PetrelConnection
petrel = PetrelConnection(allow_experimental=True)
print('Connected to {}'.format(petrel.get_current_project_name()))
Connected to Gullfaks_dataset3.pet
Assign the completions data to a variable#
In order to start working with completions data we first need to select a well and assign it to a variable. For more information on working with wells check out the Wells, well survey and well logs userguide.
Then using the .completions_set property we obtain an iterable collection of the available compelitions data for the selected well:
[2]:
wellA15 = petrel.wells['Input/Wells/Producers/A15']
completions = wellA15.completions_set
completions
[2]:
CompletionsSet(well_petrel_name="A15")
To access the completions data in a dataframe we can use the .as_dataframe() function:
[3]:
df = completions.as_dataframe()
df
[3]:
Well name | UWI | Category | Type | Name | Top MD | Bottom MD | Outer Diameter | Inner Diameter | Start Date | Is Valid | |
---|---|---|---|---|---|---|---|---|---|---|---|
0 | A15 | Casing | Casing string | Casing 1 | 1808.89 | 1900.0 | NaN | NaN | 1980-01-01 | True | |
1 | A15 | Casing | Casing part | Casing 1:1 | 1808.89 | 1900.0 | 9.84252 | 9.84252 | 1980-01-01 | True | |
2 | A15 | Casing | Casing string | Casing 2 | 1808.89 | 2036.0 | NaN | NaN | 1980-01-01 | True | |
3 | A15 | Casing | Casing part | Casing 2:1 | 1808.89 | 2036.0 | 8.62500 | 8.09700 | 1980-01-01 | True | |
4 | A15 | Workovers | Perforation | Perforation 1 | 1922.00 | 1992.0 | NaN | NaN | 1980-01-01 | True | |
5 | A15 | Workovers | Perforation | Perforation 2 | 1879.00 | 1906.0 | NaN | NaN | 1980-01-01 | True |
Casing data#
You can assign the casing strings to a variable using the .casing property which will return an iterable collection of the avaialbe casing strings for the selected well :
[4]:
casings = completions.casings
casings
[4]:
CasingStrings(CompletionsSet="CompletionsSet(well_petrel_name="A15")")
Using a for loop we can iterate through the casings and assign one to a variable:
[5]:
for c in casings:
print(c)
selected_casing = c
CasingString("Casing 1")
CasingString("Casing 2")
[6]:
selected_casing
[6]:
CasingString("Casing 2")
To return the name of the casing we can use the .petrel_name property:
[51]:
selected_casing.petrel_name
[51]:
'Casing 2'
The path of the object represents it’s location in the Petrel input tree and can be accessed using the .path property:
[52]:
selected_casing.path
[52]:
'Input/Wells/Producers/A15/Completions/Casing 2'
The .droid property returns the object id or guid which represents the Petrel filename in the project directory:
[53]:
selected_casing.droid
[53]:
'30a18f16-0840-458d-b7c2-0c8be5bfb32d'
We can retrieve the statistics of the casing associated to the selected well using the .retrieve_stats() function which outputs a dictionary:
[55]:
selected_casing.retrieve_stats()
[55]:
{'X Min': '456645.06',
'X Max': '456676.11',
'Y Delta': '-169.080000000075',
'Y Min': '6781579.73',
'Z Delta': '-148.39',
'Z Min': '-1808.89',
'X Delta': '31.0499999999884',
'Type of completion': 'Casing',
'Z Max': '-1957.28',
'Y Max': '6781410.65'}
The statistics are a snapshot of the information in the Statistics located in Settings panel of the object.
The .retrieve_history() function will return the Petrel history of the object as a dataframe.
[58]:
selected_casing.retrieve_history()
[58]:
Date | User | Action | Description |
---|
To acess the equipment associaed with the casings you can use the .available_equipment() function which will return a list of all the equiment IDs:
[44]:
selected_casing.available_equipment()
[44]:
['CS_EQ1', 'C-API-4.500/J-55/9.50', 'C-API-4.500/C-95/11.60', 'C-API-5.000/J-55/11.50', 'C-API-5.000/C-95/15.00', 'C-API-5.500/J-55/14.00', 'C-API-5.500/C-95/17.00', 'C-API-6.625/J-55/20.00', 'C-API-6.625/C-95/24.00', 'C-API-7.000/J-55/20.00', 'C-API-7.000/C-95/23.00', 'C-API-7.625/J-55/26.40', 'C-API-7.625/C-95/47.10', 'C-API-8.625/J-55/24.00', 'C-API-8.625/C-95/36.00', 'C-API-9.625/J-55/36.00', 'C-API-9.625/C-95/40.00', 'C-API-10.750/J-55/40.50', 'C-API-10.750/C-95/51.00', 'C-API-11.750/J-55/47.00', 'C-API-11.750/C-95/60.00', 'C-API-13.375/J-55/54.50', 'C-API-13.375/C-95/68.00', 'C-API-16.000/J-55/75.00', 'C-API-18.625/J-55/87.50', 'C-API-20.000/J-55/94.00']
In Petrel, the association between the completion and the equipment can be view in the Completion manager:
You can add a comment to the casing element using the .add_comment() function which takes in two parameters: new_comment , a string which represents the comment you want to add and overwrite , a boolean value which indicates if you want to add a new comment (overwrite=False) or overwrite the existing one (overwrite=True). The overwrite paramater defaults to False if not specified.
By default the casing object is set to readonly meaning you can not modify any of its attribute. To allow modifications you can use the .readonly property and set it to false:
[48]:
selected_casing.readonly=False
selected_casing.add_comment(new_comment="Edited by user with Python Tool Pro",overwrite=False)
The code cell above will add a new comment into the Comments section in Petrel:
You can access the existing comments of a completion element using the .comments property which will return a string:
[50]:
selected_casing.comments
[50]:
'Edited by user with Python Tool Pro'
The .start_date property will return the start date of the casing string as a datetime object:
[68]:
selected_casing.start_date
[68]:
datetime.datetime(1980, 1, 1, 0, 0)
Assuming that the .readonly value of the selected object is set to false the start date of the object can be modified by assing a new date to the variable using the datetime() function which can take in the following parameters: Year, Month, Day, Hour, Minute, Second, Microsecond.
[69]:
import datetime
selected_casing.start_date = datetime.datetime(2020,3,8,0,0)
selected_casing.start_date
[69]:
datetime.datetime(2020, 3, 8, 0, 0)
In Petrel, the start date of the completions object can be viewed in the Completions manager:
The .bottom_md property returns the measured depth value of the bottom of the casing string:
[70]:
selected_casing.bottom_md
[70]:
2036.0
The bottom_md value can be modified by assigning it a new value. After executing the cell bellow the results will also be written to Petrel:
[72]:
selected_casing.bottom_md=2000
The .parts property returns an iterable collection of the individual parts associated to the casing string:
[74]:
selected_casing.parts
[74]:
CasingStringParts(CasingString("Casing 2"))
[73]:
selected_casing.template
[73]:
''
Perforation data#
You can assign the casing strings to a variable using the .perforations property which will return an iterable collection of the avaialbe perforations for the selected well :
[3]:
perforations = completions.perforations
perforations
[3]:
Perforations(CompletionsSet="CompletionsSet(well_petrel_name="A15")")
Using a for loop we can iterate through the casings and assign one to a variable:
[4]:
for p in perforations:
print(p)
selected_perforation = p
Perforation("Perforation 1")
Perforation("Perforation 2")
[5]:
selected_perforation
[5]:
Perforation("Perforation 2")
To return the name of the perforation we can use the .petrel_name property:
[78]:
selected_perforation.petrel_name
[78]:
'Perforation 2'
The path of the object represents it’s location in the Petrel input tree and can be accessed using the .path property:
[79]:
selected_perforation.path
[79]:
'Input/Wells/Producers/A15/Completions/Perforation 2'
The .droid property returns the object id or guid which represents the Petrel filename in the project directory:
[80]:
selected_perforation.droid
[80]:
'c4bd86c7-b008-4628-9edb-30933e52978d'
We can retrieve the statistics of the perforation associated to the selected well using the .retrieve_stats() function which outputs a dictionary:
[81]:
selected_perforation.retrieve_stats()
[81]:
{'X Min': '456654.64',
'X Max': '456658.39',
'Y Delta': '-20.1299999998882',
'Y Min': '6781528.03',
'Z Delta': '-17.5899999999999',
'Z Min': '-1855.26',
'X Delta': '3.75',
'Type of completion': 'Perforation',
'Z Max': '-1872.85',
'Y Max': '6781507.9'}
The statistics are a snapshot of the information in the Statistics located in Settings panel of the object.
The .retrieve_history() function will return the Petrel history of the object as a dataframe.
[83]:
selected_perforation.retrieve_history()
[83]:
Date | User | Action | Description |
---|
You can add a comment to the perforation element using the .add_comment() function which takes in two parameters: new_comment , a string which represents the comment you want to add and overwrite , a boolean value which indicates if you want to add a new comment (overwrite=False) or overwrite the existing one (overwrite=True). The overwrite paramater defaults to False if not specified.
By default the perforation object is set to readonly meaning you can not modify any of its attribute. To allow modifications you can use the .readonly property and set it to false:
[85]:
selected_perforation.readonly=False
selected_perforation.add_comment(new_comment='Perforation modified using Python Tool Pro', overwrite=False)
The code cell above will add a new comment into the Comments section in Petrel:
You can access the existing comments of a completion element using the .comments property which will return a string:
[86]:
selected_perforation.comments
[86]:
'Perforation modified using Python Tool Pro'
The .start_date property will return the start date of the perforation as a datetime object:
[87]:
selected_perforation.start_date
[87]:
datetime.datetime(1980, 1, 1, 0, 0)
Assuming that the .readonly value of the selected object is set to false the start date of the object can be modified by assing a new date to the variable using the datetime() function which can take in the following parameters: Year, Month, Day, Hour, Minute, Second, Microsecond.
[88]:
import datetime
selected_perforation.start_date = datetime.datetime(2020,8,5,0,0)
selected_perforation.start_date
[88]:
datetime.datetime(2020, 8, 5, 0, 0)
In Petrel, the start date of the completions object can be viewed in the Completions manager:
The .skin_factor property returns skin factor of the perforation as a float value:
[91]:
selected_perforation.skin_factor
[91]:
0.0
The skin_factor value can be modified by assigning it a new value. After executing the cell bellow the results will also be written to Petrel:
[92]:
selected_perforation.skin_factor = 1
The .bottom_md property returns the measured depth value of the bottom of the perforation and it can be modified by assigning it a new value:
[ ]:
selected_perforation.bottom_md
selected_perforation.bottom_md= 2100
The .start_md property returns the measured depth value of the top of the perforation and it can be modified by assigning it a new value:
[94]:
selected_perforation.top_md
selected_perforation.top_md=1900
[94]:
1879.0
You can add a new perforation to the completions data of the selected well by using the .add_perforation function and providing 3 input parameters : the name of the new perforation and the measured depth of top and bottom and the perforation. This is an expiremental function so make sure to set the allow_experimental flag to true when defining your Petrel connection ( i.e petrel = PetrelConnection(allow_experimental=True))
[7]:
completions.add_perforation(name="New Perforation",top_md=1850,bottom_md=1870)
[7]:
Perforation("New Perforation")