Observed data#
This notebook provides examples on how to use Python Tool Pro to access observed data. With the release of Python Tool Pro version 2.2 users can now access and manipulte the Global Observerd Datasets as well.
Connect to a Petrel project#
[1]:
from cegalprizm.pythontool import PetrelConnection
petrel = PetrelConnection(allow_experimental=True)
Global observed data#
The .predefined_global_observed_data property returns a dictionary of all the predefined global observed data in the Petrel project, where the keys represent the name of the predifined global observed data and the values represent the IDs used to identify them:
[2]:
petrel.predefined_global_observed_data
[2]:
{'Gas mass injection cumulative': 'INJECTION_MASS_CUML_GAS',
'Gas mass rate': 'MASS_RATE_GAS',
'Water mass cumulative': 'MASS_CUML_WATER',
'Liquid phase PI': 'PHASE_PI_LIQUID',
'Oil injection cumulative': 'INJECTION_CUML_OIL',
'Tracer production rate': 'PRODUCTION_RATE_TRACER',
'Liquid production rate': 'PRODUCTION_RATE_LIQUID',
'Alkali production concentration': 'PRODUCTION_CONCENTRATION_ALKALI',
'Well block average pressure': 'WELL_BLOCK_AVERAGE_PRESSURE',
'Pressure average (4-point)': 'PRESSURE_4_POINT',
'Pressure average (5-point)': 'PRESSURE_5_POINT',
'Clean fluid cumulative': 'CLEAN_FLUID_CUML',
'Uptime fraction': 'UPTIME_FRACTION',
'Pressure average (9-point)': 'PRESSURE_9_POINT',
'Oil injection rate': 'INJECTION_RATE_OIL',
'Oil-liquid ratio': 'OIL_LIQUID_RATIO',
'Oil formation volume factor': 'FORMATION_VOLUME_FACTOR_OIL',
'Oil mass cumulative': 'MASS_CUML_OIL',
'Methane production cumulative': 'PRODUCTION_CUML_METHANE',
'Alkali injection concentration': 'INJECTION_CONCENTRATION_ALKALI',
'Surfactant production cumulative': 'PRODUCTION_CUML_SURFACTANT',
'Gas phase PI': 'PHASE_PI_GAS',
'Gas lift injection cumulative': 'INJECTION_CUML_LIFTGAS',
'Tracer injection rate (Solution)': 'INJECTION_RATE_TRACER_SOLUTION',
'Water phase PI': 'PHASE_PI_WATER',
'Tracer production concentration (Free)': 'PRODUCTION_CONCENTRATION_TRACER_FREE',
'Polymer injection concentration': 'INJECTION_CONCENTRATION_POLYMER',
'Gas density': 'DENSITY_GAS',
'Bottom hole pressure': 'BOTTOM_HOLE_PRESSURE',
'Surfactant production rate': 'PRODUCTION_RATE_SURFACTANT',
'Polymer injection rate': 'INJECTION_RATE_POLYMER',
'Oil viscosity compressibility': 'VISCOSITY_COMPRESSIBILITY_OIL',
'Reservoir volume production rate': 'RES_VOLUME_PRODUCTION_RATE',
'Liquid production cumulative': 'PRODUCTION_CUML_LIQUID',
'Oil mass injection cumulative': 'INJECTION_MASS_CUML_OIL',
'Pressure': 'PRESSURE',
'Liquid-gas ratio': 'LIQUID_GAS_RATIO',
'Tracer injection concentration (Solution)': 'INJECTION_CONCENTRATION_TRACER_SOLUTION',
'Tracer production concentration': 'PRODUCTION_CONCENTRATION_TRACER',
'Gas mass cumulative': 'MASS_CUML_GAS',
'Water injection rate weighting': 'INJECTION_RATE_WATER_WEIGHTING',
'Gas lift injection rate': 'INJECTION_RATE_LIFTGAS',
'Gas production rate': 'PRODUCTION_RATE_GAS',
'Oil mass production cumulative': 'PRODUCTION_MASS_CUML_OIL',
'Bottom hole proppant concentration': 'BOTTOM_HOLE_PROPPANT_CONCENTRATION',
'Tracer production rate (Free)': 'PRODUCTION_RATE_TRACER_FREE',
'Oil-water ratio': 'OIL_WATER_RATIO',
'Water cut': 'WATER_CUT',
'Oil mass injection rate': 'INJECTION_MASS_RATE_OIL',
'Oil production cumulative': 'PRODUCTION_CUML_OIL',
'Proppant concentration': 'PROPPANT_CONCENTRATION',
'Oil production rate weighting': 'PRODUCTION_RATE_OIL_WEIGHTING',
'Bottom hole pressure weighting': 'BOTTOM_HOLE_PRESSURE_WEIGHTING',
'Instantaneous water production rate': 'PRODUCTION_INSTRATE_WATER',
'Tracer injection rate (Free)': 'INJECTION_RATE_TRACER_FREE',
'Salt injection concentration': 'INJECTION_CONCENTRATION_BRINE',
'Liquid-oil ratio': 'LIQUID_OIL_RATIO',
'Oil compressibility': 'COMPRESSIBILITY_OIL',
'Tubing head pressure': 'TUBING_HEAD_PRESSURE',
'Polymer production rate': 'PRODUCTION_RATE_POLYMER',
'Gas-oil ratio': 'GAS_OIL_RATIO',
'Tracer injection rate': 'INJECTION_RATE_TRACER',
'Tracer production rate (Solution)': 'PRODUCTION_RATE_TRACER_SOLUTION',
'Reservoir volume production cumulative': 'RES_VOLUME_PRODUCTION_CUML',
'Tracer injection cumulative (Free)': 'INJECTION_CUML_TRACER_FREE',
'Instantaneous oil injection rate': 'INJECTION_INSTRATE_OIL',
'Oil injection rate weighting': 'INJECTION_RATE_OIL_WEIGHTING',
'Instantaneous gas injection rate': 'INJECTION_INSTRATE_GAS',
'Instantaneous water injection rate': 'INJECTION_INSTRATE_WATER',
'Tracer injection concentration (Free)': 'INJECTION_CONCENTRATION_TRACER_FREE',
'Instantaneous oil production rate': 'PRODUCTION_INSTRATE_OIL',
'Oil production rate': 'PRODUCTION_RATE_OIL',
'Oil density': 'DENSITY_OIL',
'Oil phase PI': 'PHASE_PI_OIL',
'Water mass rate': 'MASS_RATE_WATER',
'Slurry cumulative': 'SLURRY_CUML',
'Reservoir volume production rate weighting': 'RES_VOLUME_PRODUCTION_RATE_WEIGHTING',
'Methane injection rate': 'INJECTION_RATE_METHANE',
'Temperature': 'TEMPERATURE',
'Water formation volume factor': 'FORMATION_VOLUME_FACTOR_WATER',
'Water mass injection rate': 'INJECTION_MASS_RATE_WATER',
'Methane injection cumulative': 'INJECTION_CUML_METHANE',
'Oil-gas ratio': 'OIL_GAS_RATIO',
'Artificial lift quantity': 'ALQ_VALUE',
'Water-gas ratio': 'WATER_GAS_RATIO',
'Injected solution gas-oil ratio': 'SOLUTION_GAS_OIL_RATIO_INJ',
'Gas production cumulative': 'PRODUCTION_CUML_GAS',
'Tracer production cumulative (Solution)': 'PRODUCTION_CUML_TRACER_SOLUTION',
'Water production rate': 'PRODUCTION_RATE_WATER',
'Gas-liquid ratio': 'GAS_LIQUID_RATIO',
'Tracer production concentration (Solution)': 'PRODUCTION_CONCENTRATION_TRACER_SOLUTION',
'Gas injection rate': 'INJECTION_RATE_GAS',
'Surfactant injection cumulative': 'INJECTION_CUML_SURFACTANT',
'Salt production concentration': 'PRODUCTION_CONCENTRATION_BRINE',
'Oil injection uptime fraction': 'UPTIME_FRACTION_OIL',
'Slurry rate': 'SLURRY_RATE',
'Wet gas production rate': 'PRODUCTION_RATE_WET_GAS',
'Oil mass production rate': 'PRODUCTION_MASS_RATE_OIL',
'Tubing head temperature for producer wells': 'TUBING_HEAD_TEMPERATURE',
'Oil thermal expansivity': 'THERMAL_EXPANSIVITY_OIL',
'Bottom hole treating pressure': 'BOTTOM_HOLE_TREATMENT_PRESSURE',
'Gas mass production cumulative': 'PRODUCTION_MASS_CUML_GAS',
'Oil API gravity': 'API_GRAVITY_OIL',
'Water mass injection cumulative': 'INJECTION_MASS_CUML_WATER',
'Tracer injection concentration': 'INJECTION_CONCENTRATION_TRACER',
'Injected vaporized oil-gas ratio': 'VAPOR_OIL_GAS_RATIO_INJ',
'Gas formation volume factor': 'FORMATION_VOLUME_FACTOR_GAS',
'Gas production rate weighting': 'PRODUCTION_RATE_GAS_WEIGHTING',
'Liquid production rate weighting': 'PRODUCTION_RATE_LIQUID_WEIGHTING',
'Water injection cumulative': 'INJECTION_CUML_WATER',
'Water thermal expansivity': 'THERMAL_EXPANSIVITY_WATER',
'Water production rate weighting': 'PRODUCTION_RATE_WATER_WEIGHTING',
'Tracer injection cumulative (Solution)': 'INJECTION_CUML_TRACER_SOLUTION',
'Liquid-water ratio': 'LIQUID_WATER_RATIO',
'Polymer production cumulative': 'PRODUCTION_CUML_POLYMER',
'Surfactant injection rate': 'INJECTION_RATE_SURFACTANT',
'Water mass production cumulative': 'PRODUCTION_MASS_CUML_WATER',
'Oil mass rate': 'MASS_RATE_OIL',
'Gas injection cumulative': 'INJECTION_CUML_GAS',
'Water production cumulative': 'PRODUCTION_CUML_WATER',
'Tracer injection cumulative': 'INJECTION_CUML_TRACER',
'Water injection uptime fraction': 'UPTIME_FRACTION_WATER',
'Tracer production cumulative': 'PRODUCTION_CUML_TRACER',
'Gas-water ratio': 'GAS_WATER_RATIO',
'Clean fluid rate': 'CLEAN_FLUID_RATE',
'Water injection rate': 'INJECTION_RATE_WATER',
'Water mass production rate': 'PRODUCTION_MASS_RATE_WATER',
'Gas injection uptime fraction': 'UPTIME_FRACTION_GAS',
'Water cut in a chemical four phase system': 'WATER_CUT4',
'Methane production rate': 'PRODUCTION_RATE_METHANE',
'Polymer production concentration': 'PRODUCTION_CONCENTRATION_POLYMER',
'Instantaneous gas production rate': 'PRODUCTION_INSTRATE_GAS',
'Treating pressure': 'TREATING_PRESSURE',
'Gas injection rate weighting': 'INJECTION_RATE_GAS_WEIGHTING',
'Polymer injection cumulative': 'INJECTION_CUML_POLYMER',
'Productivity index': 'PRODUCTIVITY_INDEX',
'Proppant cumulative': 'PROPPANT_CUML',
'Bottom hole temperature': 'BOTTOM_HOLE_TEMPERATURE',
'Tracer production cumulative (Free)': 'PRODUCTION_CUML_TRACER_FREE',
'Instantaneous liquid production rate': 'PRODUCTION_INSTRATE_LIQUID'}
You can access all the Global observed data sets using the .global_observed_data_sets property which will return a dictionary where the key represents the path of the global observed data sets within the Petrel input tree and the value represents the name of the global observed data set.
[3]:
global_observed = petrel.global_observed_data_sets
global_observed
[3]:
GlobalObservedDataSets({'Input/Wells/Global observed data/Observed data sets/Production Observed data - PE': GlobalObservedDataSet(petrel_name="Production Observed data - PE"), 'Input/Wells/Global observed data/Observed data sets/PTP_ObservedData': GlobalObservedDataSet(petrel_name="PTP_ObservedData"), 'Input/Wells/Global observed data/Observed data sets/Observed 3': GlobalObservedDataSet(petrel_name="Observed 3"), 'Input/Wells/Global observed data/Observed data sets/Observed 1': GlobalObservedDataSet(petrel_name="Observed 1")})
We can access a particular Global observed data set by saving the paths of all global observed data sets to a list and then use slicing to assign it to a variable. Alternatively, you can access a particular global data set by providing it’s path as an argument.
[4]:
# Get all the global observed data sets paths from the dictionary keys and save them in a list
global_observed_path=list(global_observed.keys())
#Slice the list to get a specific global data set
global_observed_dataset=global_observed[global_observed_path[0]]
print(global_observed_dataset)
#Alternative way to access a specific global observed data set
global_observed_dataset_alternative=global_observed["Input/Wells/Global observed data/Observed data sets/Observed 1"]
print(global_observed_dataset_alternative)
GlobalObservedDataSet(petrel_name="Observed 1")
GlobalObservedDataSet(petrel_name="Observed 1")
To return the name of the selected global observed data set we can use the .petrel_name property:
[5]:
global_observed_dataset.petrel_name
[5]:
'Observed 1'
The path of the object can be accessed using the .path property:
[6]:
global_observed_dataset.path
[6]:
'Input/Wells/Global observed data/Observed data sets/Observed 1'
The .droid property returns the object id or guid which represents the Petrel filename in the project directory:
[7]:
global_observed_dataset.droid
[7]:
'e2bb0067-99a5-4c2d-8506-2d70298f9180'
The .retrieve_history() function will return the Petrel history of the object as a dataframe.
[81]:
global_observed_dataset.retrieve_history()
[81]:
Date | User | Action | Description | |
---|---|---|---|---|
0 | Jun 22 2011 16:24 | YGuilarte | Import Well observed data (ASCII) | From: C:\Users\YGuilarte\Desktop\observedhist.vol |
You can add a comment to the selected global observed data set 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 selected global observed data set is set to readonly meaning you can not modify any of its attributes. To allow modifications you can use the .readonly property and set it to false:
[18]:
global_observed_dataset.readonly=False
global_observed_dataset.add_comment(new_comment="Edited by user with Python Tool Pro",overwrite=False)
You can access the existing comments of a completion element using the .comments property which will return a string:
[19]:
global_observed_dataset.comments
[19]:
'Edited by user with Python Tool Pro'
We can create a copy of the selected global observed data set using the .clone() function and providing it a string which represents the name of the new global observed data set:
[8]:
global_observed_dataset.clone("PTP_ObservedData")
[8]:
GlobalObservedDataSet(petrel_name="PTP_ObservedData")
We can create an observed data set for a specific well and assign it to the newly created global observed data set. To that we first assign the PTP_ObservedData global observed data set to a variable and also select a specific well and assign that to a variable. Then we apply the .create_observed_data_set() function to the PTP_ObservedData variable and pass the selected well as an input parameter :
[4]:
PTP_ObservedData=global_observed["Input/Wells/Global observed data/Observed data sets/PTP_ObservedData"]
well15 = petrel.wells["Input/Wells/A Wells/A15"]
PTP_ObservedData_WellA15= PTP_ObservedData.create_observed_data_set(well15)
Observed data#
You can access all the observed data sets using the .observed_data_sets property which will return a dictionary where the key represents the path of the observed data set within the Petrel input tree and the value represents the name of the observed data set:
[5]:
observed_data=petrel.observed_data_sets
observed_data
[5]:
ObservedDataSets({'Input/Wells/A Wells/A15/PTP_ObservedData': ObservedDataSet(petrel_name="PTP_ObservedData"), 'Input/Wells/A Wells/A16/Production Observed data - PE': ObservedDataSet(petrel_name="Production Observed data - PE"), 'Input/Wells/B Wells/B8/Observed 3': ObservedDataSet(petrel_name="Observed 3"), 'Input/Wells/B Wells/B8/Production Observed data - PE': ObservedDataSet(petrel_name="Production Observed data - PE"), 'Input/Wells/B Wells/B9/Observed 3': ObservedDataSet(petrel_name="Observed 3"), 'Input/Wells/B Wells/B8/Observed 1': ObservedDataSet(petrel_name="Observed 1"), 'Input/Wells/A Wells/A15/Observed 3': ObservedDataSet(petrel_name="Observed 3"), 'Input/Wells/A Wells/A16/Observed 3': ObservedDataSet(petrel_name="Observed 3"), 'Input/Wells/A Wells/A15/Observed 1': ObservedDataSet(petrel_name="Observed 1"), 'Input/Wells/B Wells/B9/Observed 1': ObservedDataSet(petrel_name="Observed 1"), 'Input/Wells/B Wells/B9/Production Observed data - PE': ObservedDataSet(petrel_name="Production Observed data - PE"), 'Input/Wells/A Wells/A16/Observed 1': ObservedDataSet(petrel_name="Observed 1"), 'Input/Wells/A Wells/A15/Production Observed data - PE': ObservedDataSet(petrel_name="Production Observed data - PE")})
We can access a particular observed data set by saving the paths of all observed data sets to a list and then use slicing to assign it to a variable. Alternatively, you can access a particular observed data set by providing it’s path as an argument:
[11]:
# Get all the observed data sets paths from the dictionary keys and save them in a list
observed_data_path=list(observed_data.keys())
#Slice the list to get the "Observed 1" dataset from well A15
observed1_wellA15=observed_data[observed_data_path[8]]
print(observed1_wellA15)
#Alternative way to access a specific observed data set
observed1_wellA15_alternative=observed_data["Input/Wells/A Wells/A15/Observed 1"]
print(observed1_wellA15_alternative)
ObservedDataSet(petrel_name="Observed 1")
ObservedDataSet(petrel_name="Observed 1")
You can check that you selected the observed data set for the correct well using the .well property which will return the well associated to the selected observed data set.
[12]:
observed1_wellA15.well
[12]:
Well(petrel_name="A15")
To return the name of the selected observed data set we can use the .petrel_name property:
[13]:
observed1_wellA15.petrel_name
[13]:
'Observed 1'
The path of the object can be accessed using the .path property:
[30]:
observed1_wellA15.path
[30]:
'Input/Wells/A Wells/A15/Observed 1'
The .droid property returns the object id or guid which represents the Petrel filename in the project directory:
[26]:
observed1_wellA15.droid
[26]:
'://1d9a2dd1-dd1d-4676-a92e-6057e64d33c2/6b5a07a9-695c-4340-b3b3-e5f24c61da85://1d9a2dd1-dd1d-4676-a92e-6057e64d33c2/e2bb0067-99a5-4c2d-8506-2d70298f9180'
The .retrieve_history() function will return the Petrel history of the object as a dataframe.
[33]:
observed1_wellA15.retrieve_history()
[33]:
Date | User | Action | Description | |
---|---|---|---|---|
0 | Jun 22 2011 16:24 | YGuilarte | Import Well observed data (ASCII) | From: C:\Users\YGuilarte\Desktop\observedhist.vol |
1 | Aug 04 2015 08:26 | JDulibeako | Synchronized from | G:\Petrel2013_2 demo project.pet |
2 | Aug 05 2015 12:32 | JDulibeako | Synchronized from | C:\Gulfaks DEMO\Petrel 2015.1\BACKUPS\06 Geolo... |
3 | Feb 03 2020 14:43 | brucech | Synchronized from | C:\PythonToolDemoProject\Gullfaks_2018_demo\Gu... |
To access the observe data contained in the observe dataset in a dataframe we can use the .as_dataframe() function: