Wavelets , Point sets and Polylines sets#

This Notebook provides examples on how to use Python Tool Pro to access Wavelets, Point sets and Polylines sets.

Wavelets#

Check out the API documentation to view a detailed description of all the functions and properties available for working with wavelets.

[2]:
#connect to local petrel project

from cegalprizm.pythontool import PetrelConnection
petrel = PetrelConnection()

Using the .wavelets property, we can save all the wavelets to a dictionary where the keys represent the path of the wavelet within the Petrel input tree (i.e, Input/Extended White 1) and the value represents the name of the wavelet (Wavelet(petrel_name=“Extended White 1”)). We can then save all the wavelet paths to a list :

[2]:
#Save all the wavelets within the Petrel project in a dictionary
all_wavelets_dict = petrel.wavelets
#Save the keys(paths) of the wavelets to a dictionary
all_wavelets_paths = petrel.wavelets.keys()
#Save all the paths to a list
wav_paths = list(all_wavelets_paths)
print(wav_paths)
['Input/Extended White 1', 'Input/Ricker 1', 'Input/ISIS (frequency) 1']

Using slicing, we can then assign the Extended White 1 wavelet to the mywavelet variable:

[3]:
#Assign the first wavelet from the list to a variable and print it
mywavelet = petrel.wavelets[wav_paths[0]]
print(mywavelet)
Wavelet(petrel_name="Extended White 1")

Using the .as_dataframe() function, we can create a DataFrame that contains all the time[s] and the amplitude values:

[4]:
mywaveletamplitudes=mywavelet.as_dataframe()
mywaveletamplitudes
[4]:
position amplitude
0 -0.256205 -2.695632e+06
1 -0.252202 2.442226e+06
2 -0.248199 6.953573e+06
3 -0.244195 1.001910e+07
4 -0.240192 1.111934e+07
... ... ...
124 0.240192 -1.161922e+07
125 0.244195 -1.247116e+07
126 0.248199 -1.097986e+07
127 0.252202 -7.483216e+06
128 0.256205 9.881313e-324

129 rows × 2 columns

This DataFrame can also be visualised in Petrel by accessing the settings of the wavelet and viewing the values. Note that the .as_dataframe() function returns the time in seconds while in Petrel the time is measured in milliseconds:

wavelet_df.png

The .sample_count property retruns the number of samples (rows in the DataFrame) in the wavelet object:

[5]:
mywavelet.sample_count
[5]:
129

The .sampling_start property returns the first time value of the wavelet object as a float:

[6]:
mywavelet.sampling_start
[6]:
-0.256204963971177

The .sample_points property returns the time values of the wavelet object as a NumPy array:

[7]:
mywavelet.sample_points
[7]:
array([-0.25620496, -0.25220176, -0.24819856, -0.24419536, -0.24019215,
       -0.23618895, -0.23218575, -0.22818255, -0.22417934, -0.22017614,
       -0.21617294, -0.21216974, -0.20816653, -0.20416333, -0.20016013,
       -0.19615693, -0.19215372, -0.18815052, -0.18414732, -0.18014412,
       -0.17614091, -0.17213771, -0.16813451, -0.16413131, -0.1601281 ,
       -0.1561249 , -0.1521217 , -0.14811849, -0.14411529, -0.14011209,
       -0.13610889, -0.13210568, -0.12810248, -0.12409928, -0.12009608,
       -0.11609287, -0.11208967, -0.10808647, -0.10408327, -0.10008006,
       -0.09607686, -0.09207366, -0.08807046, -0.08406725, -0.08006405,
       -0.07606085, -0.07205765, -0.06805444, -0.06405124, -0.06004804,
       -0.05604484, -0.05204163, -0.04803843, -0.04403523, -0.04003203,
       -0.03602882, -0.03202562, -0.02802242, -0.02401922, -0.02001601,
       -0.01601281, -0.01200961, -0.00800641, -0.0040032 ,  0.        ,
        0.0040032 ,  0.00800641,  0.01200961,  0.01601281,  0.02001601,
        0.02401922,  0.02802242,  0.03202562,  0.03602882,  0.04003203,
        0.04403523,  0.04803843,  0.05204163,  0.05604484,  0.06004804,
        0.06405124,  0.06805444,  0.07205765,  0.07606085,  0.08006405,
        0.08406725,  0.08807046,  0.09207366,  0.09607686,  0.10008006,
        0.10408327,  0.10808647,  0.11208967,  0.11609287,  0.12009608,
        0.12409928,  0.12810248,  0.13210568,  0.13610889,  0.14011209,
        0.14411529,  0.14811849,  0.1521217 ,  0.1561249 ,  0.1601281 ,
        0.16413131,  0.16813451,  0.17213771,  0.17614091,  0.18014412,
        0.18414732,  0.18815052,  0.19215372,  0.19615693,  0.20016013,
        0.20416333,  0.20816653,  0.21216974,  0.21617294,  0.22017614,
        0.22417934,  0.22818255,  0.23218575,  0.23618895,  0.24019215,
        0.24419536,  0.24819856,  0.25220176,  0.25620496])

The .amplitudes property returns the amplitudes of the wavelet object as a NumPy array:

[8]:
mywavelet.amplitudes
[8]:
array([-2.69563225e+006,  2.44222575e+006,  6.95357300e+006,
        1.00190960e+007,  1.11193390e+007,  1.01189890e+007,
        7.27118200e+006,  3.15744600e+006, -1.43888762e+006,
       -5.68180400e+006, -8.83133400e+006, -1.03502890e+007,
       -9.97684800e+006, -7.75744750e+006, -4.05475125e+006,
        4.84268906e+005,  5.01084150e+006,  8.63480300e+006,
        1.06175260e+007,  1.05407210e+007,  8.40013900e+006,
        4.61626300e+006, -5.71333984e+004, -4.70334100e+006,
       -8.45611600e+006, -1.06716890e+007, -1.10269390e+007,
       -9.50034400e+006, -6.30550000e+006, -1.82157688e+006,
        3.39220850e+006,  8.54345900e+006,  1.26186050e+007,
        1.44315200e+007,  1.30999270e+007,  8.64707300e+006,
        2.02258925e+006, -5.29143800e+006, -1.16017170e+007,
       -1.54225710e+007, -1.59338740e+007, -1.31894360e+007,
       -8.14957650e+006, -2.10678650e+006,  3.61419225e+006,
        8.63690600e+006,  1.29264750e+007,  1.69567340e+007,
        1.95280560e+007,  1.93947040e+007,  1.38430890e+007,
        1.48904484e+005, -1.66528050e+007, -2.87431580e+007,
       -3.28885300e+007, -2.88266300e+007, -1.66175710e+007,
       -1.07081650e+006,  1.41530510e+007,  2.39930880e+007,
        2.61842680e+007,  2.13336920e+007,  1.12546320e+007,
        8.23888800e+006,  9.44449200e+006,  2.27242860e+007,
        1.18747000e+007,  1.64100930e+007, -5.01091240e+007,
       -1.12076408e+008, -1.07246552e+008, -2.00442080e+007,
        2.08681600e+007,  6.01144440e+007,  6.33681560e+007,
        5.66976480e+007,  4.78777760e+007,  4.28773400e+007,
        3.04244520e+007, -9.46607750e+005, -4.21667240e+007,
       -6.21549600e+007, -5.47965720e+007, -3.60720880e+007,
       -1.83542440e+007, -7.34339400e+006,  1.00109731e+006,
        1.38459110e+007,  3.00202820e+007,  3.87916440e+007,
        3.71177240e+007,  2.74863100e+007,  1.27986410e+007,
       -2.43754800e+006, -1.55570350e+007, -2.49390000e+007,
       -2.98311960e+007, -2.90835840e+007, -2.21139300e+007,
       -1.05596850e+007,  2.00879625e+006,  1.24494330e+007,
        1.91409820e+007,  2.18668800e+007,  2.10226160e+007,
        1.69213800e+007,  9.94510500e+006,  1.21564688e+006,
       -7.45230550e+006, -1.42837490e+007, -1.79814820e+007,
       -1.80125760e+007, -1.46482670e+007, -8.76160600e+006,
       -1.58132775e+006,  5.52186500e+006,  1.12120630e+007,
        1.44482710e+007,  1.47479700e+007,  1.22751910e+007,
        7.71207250e+006,  2.03384938e+006, -3.70737125e+006,
       -8.52732300e+006, -1.16192200e+007, -1.24711620e+007,
       -1.09798630e+007, -7.48321650e+006,  9.88131292e-324])

The .time_unit_symbol property returns the measurement that describes the wavelet datatype. This measurement is defined in the unit system in Petrel.

[9]:
mywavelet.time_unit_symbol
[9]:
'Short_Time'

In Petrel, the measurement type can be accessed and changed by navigating to the wavelet settings->global settings->Customize:

wavelet_unit.png

Working with pointsets#

Check out the API documentation to view a detailed description of all the functions and properties available for working with pointsets.

The .pointsets property returns a dictionary where the keys represent the path of the pointset within the Petrel input tree and the value represents the name of the pointset.

[10]:
petrel.pointsets
[10]:
PointSets({'Input/Edited points for modeling/Base Cretaceous (Used in Make horizon)': PointSet(petrel_name="Base Cretaceous (Used in Make horizon)"), 'Input/Edited points for modeling/Top Tarbert (Used in Make horizon)': PointSet(petrel_name="Top Tarbert (Used in Make horizon)"), 'Input/Edited points for modeling/Top Ness (Used in Make horizon)': PointSet(petrel_name="Top Ness (Used in Make horizon)"), 'Input/Edited points for modeling/Top Etive (Used in Make horizon)': PointSet(petrel_name="Top Etive (Used in Make horizon)"), 'Input/Seismic/Work shop Interpretation/Faults for autom Poly/Base Cretaceous [Not converted]': PointSet(petrel_name="Base Cretaceous [Not converted]")})

We can save all the pointsets paths to a list and then use slicing to retrieve a specific pointset, which is then assigned to the mypointset variable:

[11]:
all_pointsets_dict = petrel.pointsets
all_pointsets_paths = petrel.pointsets.keys()
paths = list(all_pointsets_paths)
mypointset = petrel.pointsets[paths[0]]
print(mypointset)
PointSet(petrel_name="Base Cretaceous (Used in Make horizon)")

The .as_dataframe() function returns a DataFrame of the selected pointset where each column of the DataFrame represents an attribute or point coordinate. The column names are the names of the attributes. If there are attributes with equal names, these attribute names are given a suffix with a number to make the column names unique.

[12]:
mypointsetdf=mypointset.as_dataframe()
mypointsetdf
[12]:
x y z
0 453430.0 6780300.0 -1983.498535
1 453470.0 6780300.0 -1987.880859
2 453510.0 6780300.0 -1993.047363
3 453550.0 6780300.0 -1995.788086
4 453470.0 6780340.0 -1987.541626
... ... ... ...
32558 458070.0 6790100.0 -1981.137085
32559 458110.0 6790060.0 -1978.318115
32560 458150.0 6790060.0 -1978.329468
32561 458110.0 6790100.0 -1978.200073
32562 458150.0 6790100.0 -1977.441284

32563 rows × 3 columns

The .add_point() function adds a single point in displayed world coordinates to the pointset. The Point class can be imported from the cegalprizm.pythontool.primitives module. The point class parameters represent a point in space, according to the coordinate system in use. Then, we need to set the readonly status of the pointset to False so we can modify it:

[16]:
from cegalprizm.pythontool.primitives import Point
mypointset.readonly=False
mypointset.add_point(Point(450000.0, 6780301.0, -1982.50))

Results are written back to Petrel in real time and can be checked by accessing the point spreadsheet for the selected pointset:

pointsetspreads.png

The .set_values() function allows us to create new attribute values which are written to Petrel. The data parameter must be a Pandas DataFrame with a format as returned by the as_dataframe() function. To create new attributes, a list of attribute names can be passed to the optional parameter create. The names listed in create must be existing columns in the input DataFrame.

[ ]:
mypointsetdf['z adjusted'] = 0.95 * mypointsetdf['z']
mypointset.set_values(mypointsetdf, create = ['z adjusted'])