Documentos de Académico
Documentos de Profesional
Documentos de Cultura
ipynb - Colaboratory
18 de Julio, 2020
DATOS
Pozo
F02-1_logs.las (https://wiki.seg.org/wiki/F3_Netherlands)
Volumen sismico
Penobscot_0-1000ms.sgy (https://terranubis.com/datainfo/Penobscot)
NOTA:
REQUERIMIENTO
TODOS los archivos deben estar cargados en su disco local (Jupyter Notebook) o GDrive.
NO nos vamos a detener porque alguien no sabe como cargar sus datos en GDrive o en
Jupyter, o no sabe como instalar una libreria.
Preguntas?
CONTENIDO
Declaraciones de ujos de control & Ciclos
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 1/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
For
While
Break
Continue
Ley de Darcy
Wavelet
Electrical logs
Seismic
Production
if some_condition:
algorithm
Mayor >
Mayor que >=
Igual ==
Menor que <=
Menor <
NO igual !=
1 porosity = 0.15
2 if porosity > 0.1:
3 print("Sand")
Sand
If-else
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 2/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
if some_condition:
algorithm
else:
algorithm
1 porosity = 0.1
2 if porosity > 0.15:
3 print("Sand")
4 else:
5 print("Shaly-Sand")
Shaly-Sand
1 porosity = 0.1
2 if porosity >= 0.1:
3 print("Sand")
4 else:
5 print("Shaly-Sand")
Sand
if-elif
if some_condition1:
algorithm
elif some_condition2:
algorithm
else:
algorithm
Loops
For
1 for i in range(5):
2 print(i)
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 4/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
0
1
In the2above example, i iterates over the 0,1,2,3,4. Every time it takes each value and executes the
algorithm
3 inside the loop. It is also possible to iterate over a nested list illustrated below.
4
1 # Definimos variables
2 wells = ['wellA', 'wellB', 'wellC']
3 mean_poro = [0.2, 0.3, 0.5]
4 mean_permeability = [500, 1500, 200]
5 number_of_wells = len(wells)
6
7 # Defino ciclo 'for'
8 for x in range(number_of_wells):
9 print('The well name is ', wells[x], ', the mean poro
10 ' and mean permeability is ', mean_permeability
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 5/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
The well name is wellA , the mean porosity is 0.2 and mean permeability is 500
The well name is wellB , the mean porosity is 0.3 and mean permeability is 1500
The well name is wellC , the mean porosity is 0.5 and mean permeability is 200
While
while some_condition:
algorithm
1 n = 5
2
3 while n > 0:
4 n -= 1 # Equivalente a n = n-1
5 # n += 1 # Equivalente a n = n+1
6 print(n)
7 print('Finished')
4
3
2
1
0
Finished
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 6/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
Rate is 248.96
Rate is 434.08
Rate is 383.7
Rate is 400.76
Rate is 322.64
Rate is 225.64
Rate is 208.29
Rate is 168.05
Rate is 145.51
Rate was below 150 m3/d in item 9 of the list
Break
As the name says. It is used to break out of a loop when a condition becomes true when executing
the loop.
1 for i in range(20):
2 print(i)
3 if i>=7:
4 break
0
1
2
3
4
5
6
7
Continue
This continues the rest of the loop. Sometimes when a condition is satis ed there are chances of
the loop getting terminated. This can be avoided using continue statement.
1 for i in range(10):
2 if i>4:
3 print("The end.")
4 continue
5 elif i<7:
6 print(i)
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 7/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
0
1
2
3
4
The end.
The end.
The end.
The end.
Ley de
The Darcy
end.
where:
Q = ow rate[m3 /s]
k = permeability [m2 ]
A = cross-sectional area [m2 ]
μ = viscosity [Pa.s]
L = length of sample [m]
ΔP = pressure difference accross the sample [Pa]
1 # 2. Escribir la funcion
2
3 Q = (s * K * dp)/ u*L
4
5 print(Q)
10.0
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 8/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
1 import numpy as np
Now, lets write the Darcy's Law function, and see the documentation we just created:
1 darcy_law?
Now, we can evaluate the function using the sample values used before
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 9/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
1 darcy_law(1, 1, 1, 1, 0)
0.0
1 k = 4.9346165e-13 # ~500 mD
2 A = 2.03e-3 # 1 inch diameter plug
3 mu = 8.9e-4 #~dynamic viscosity of water at about 25C
4 L = 0.0508 #2 inch plug
5 dP = 689476 # ~100 psi
6
7 Q = darcy_law(k, A, mu, L, dP)
8 print (f'The flow rate `Q` is: {Q:.1e} m3/s or {Q * 3600:.2f}
The flow rate `Q` is: 1.5e-05 m3/s or 0.05m3/h
Now, let's use Numpy to make a plot of the ow rate vs. plug length. For that we will need to de ne
the range of plug lengths. For that, let's use the np.arange(first, last, step)
1 import numpy as np
2
3 L = np.arange(0.05,1, 0.005)
4 L
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 10/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
1 len(Q)
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 11/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
190
1 %matplotlib inline
2 import matplotlib.pyplot as plt
3
4 plt.plot(L,Q)
5 plt.show()
1 # Mejorando grafico
2
3 plt.plot(L,Q)
4
5 plt.title('Ley de Darcy')
6 plt.xlabel('Longitud [L]')
7 lt l b l('Fl R t [Q]')
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 12/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
7 plt.ylabel('Flow Rate [Q]')
8 plt.show()
1 # Mejorando grafico
2
3 plt.plot(L,Q)
4
5 plt.title('Ley de Darcy', fontsize = 30)
6 plt.xlabel('Longitud [L]', fontsize = 20)
7 plt.ylabel('Flow Rate [Q]', fontsize = 20)
8 plt.show()
1 # Agregando grid
2
3 lt l t(L Q)
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 13/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
3 plt.plot(L,Q)
4
5 plt.title('Ley de Darcy', fontsize = 30)
6 plt.xlabel('Longitud [L]', fontsize = 20)
7 plt.ylabel('Flow Rate [Q]', fontsize = 20)
8 plt.grid()
9 plt.show()
1 # Agregando grid
2
3 plt.figure(figsize = (16,8))
4 plt.plot(L,Q)
5
6 plt.title('Ley de Darcy', fontsize = 30)
7 plt.xlabel('Longitud [L]', fontsize = 20)
8 plt.ylabel('Flow Rate [Q]', fontsize = 20)
9 plt.grid()
10 plt.show()
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 14/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
1 # Cambiando linea
2
3 plt.figure(figsize = (16,8))
4 plt.plot(L,Q, lw = 6, c = 'red')
5
6 plt.title('Ley de Darcy', fontsize = 30)
7 plt.xlabel('Longitud [L]', fontsize = 20)
8 plt.ylabel('Flow Rate [Q]', fontsize = 20)
9 plt.grid()
10 plt.show()
Matplotlib help us to edit the labels of the axis, title of the graph, etc. For it, we need to specify the
g which is the area that contains the plot, and ax is the plot itself.
WAVELET
1 # Import modules
2 import numpy as np
3 import matplotlib.pyplot as plt
4 %matplotlib inline
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 16/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
Ondicula de Ricker
2 2 2
2 2 2 −π f t
A = (1 − 2π f t )e
Revisar: https://subsurfwiki.org/wiki/Ricker_wavelet
1 # Define parameters
2 freq = 15 # Frecuencia
3 tn = 500 # Longitud de mi ondicula (en tiempo!!!)
4 dt = 4 # Tasa de muestreo
1 # Plot results
2 plt.plot(t,ricker)
3 plt.show()
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 17/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
1 # Diferentes FRECUENCIAS
2 freq_1 = 5 # Frecuencia [Hz]
3 freq_2 = 50 # Frecuencia [Hz]
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 18/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
1 # Mejorar grafico
2 freq_1 = 5 # Frecuencia [Hz]
3 freq_2 = 50 # Frecuencia [Hz]
4 tn = 500 # Longitud de mi ondicula (en tiempo!!!)
5 dt = 4 # Tasa de muestreo
6
7 # Create time array
8 t = np.arange(-tn / 2, tn / 2 + dt, dt) / 1000
9
10 # Define Ricker Wavelet
11 ricker_1 = (1 - 2 * np.pi**2 * freq_1**2 * t**2) * np.exp(-np
12 ricker_2 = (1 - 2 * np.pi**2 * freq_2**2 * t**2) * np.exp(-np
13
14 plt.plot(t,ricker_1, c = 'r')
15 lt l t(t i k 2 'b')
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 19/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
15 plt.plot(t,ricker_2, c = 'b')
16 plt.show()
1 # Mejorar grafico
2 freq_1 = 5 # Frecuencia [Hz]
3 freq_2 = 50 # Frecuencia [Hz]
4 tn = 500 # Longitud de mi ondicula (en tiempo!!!)
5 dt = 4 # Tasa de muestreo
6
7 # Create time array
8 t = np.arange(-tn / 2, tn / 2 + dt, dt) / 1000
9
10 # Define Ricker Wavelet
11 ricker_1 = (1 - 2 * np.pi**2 * freq_1**2 * t**2) * np.exp(-np
12 ricker_2 = (1 - 2 * np.pi**2 * freq_2**2 * t**2) * np.exp(-np
13
14 # Cambiar tamano de grafico
15 plt.figure(figsize=(12,4))
16 plt.plot(t,ricker_1, c = 'r')
17 plt.plot(t,ricker_2, c = 'b')
18 plt.show()
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 20/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
1 # Mejorar grafico
2 freq_1 = 5 # Frecuencia [Hz]
3 freq_2 = 50 # Frecuencia [Hz]
4 tn = 500 # Longitud de mi ondicula (en tiempo!!!)
5 dt = 4 # Tasa de muestreo
6
7 # Create time array
8 t = np.arange(-tn / 2, tn / 2 + dt, dt) / 1000
9
10 # Define Ricker Wavelet
11 ricker_1 = (1 - 2 * np.pi**2 * freq_1**2 * t**2) * np.exp(-np
12 ricker_2 = (1 - 2 * np.pi**2 * freq_2**2 * t**2) * np.exp(-np
13
14 # Cambiar tamano de grafico
15 plt.figure(figsize=(12,4))
16 plt.title("Comparacion de ondiculas de Ricker", fontsize = 30
17 plt.plot(t,ricker_1, c = 'r', label='Ondicula 1 (5 hz)')
18 plt.plot(t,ricker_2, c = 'b', label='Ondicula 2 (50 hz)')
19 plt.xlabel('Tiempo [s]', fontsize = 20)
20 plt.ylabel('Amplitud', fontsize = 20)
21 plt.grid()
22 plt.legend(fontsize = 20)
23 plt.show()
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 21/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 22/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
Utilizando los condicionales, indicar que se llene los valores de la ondicula, utilizando la funcion
.fill_between()
o
1 # Datos de entrada
2 freq = 5 # Frecuencia [Hz]
3 tn = 500 # Longitud de mi ondicula (en tiempo!!!)
4 dt = 1 # Tasa de muestreo
5
6
7 # Create time array
8 t = np.arange(-tn / 2, tn / 2 + dt, dt) / 1000
9
10 # Define Ricker Wavelet
11 ricker = (1 - 2 * np.pi**2 * freq**2 * t**2) * np.exp(-np.pi*
12
13 # Graficar
14 plt.figure(figsize=(12,4))
15 plt.plot(t,ricker, lw=2, color='black')
16
17 plt.fill_between(t, ricker, 0, ricker >= 0.0, color='blue',
18 plt.fill_between(t, ricker, 0, ricker < 0.0, color='red', alp
19
20 plt.plot(t,ricker, lw=1, color='black')
21 plt.grid()
22 plt.show()
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 23/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
1 # Datos de entrada
2 freq = 5 # Frecuencia [Hz]
3 tn = 500 # Longitud de mi ondicula (en tiempo!!!)
4 dt = 1 # Tasa de muestreo
5
6
7 # Create time array
8 t = np.arange(-tn / 2, tn / 2 + dt, dt) / 1000
9
10 # Define Ricker Wavelet
11 ricker = (1 - 2 * np.pi**2 * freq**2 * t**2) * np.exp(-np.pi*
12
13 # Graficar
14 plt.figure(figsize=(12,4))
15 plt.plot(t,ricker, lw=2, color='black')
16
17 plt.fill_between(t, ricker, 0, ricker >= 0.0, color='blue',
18 plt.fill_between(t, ricker, 0, ricker < 0.0, color='red', alp
19
20 plt.title('%d Hz Ricker wavelet' %freq, fontsize = 16 )
21 plt.xlabel( 'two-way time (s)', fontsize = 14)
22 plt.ylabel('amplitude', fontsize = 14)
23 plt.ylim((-1.1,1.1))
24 plt.xlim((min(t),max(t)))
25 plt.grid()
26 plt.show()
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 24/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
1 !ls
gdrive sample_data
1 import os
2 os.chdir("/content/gdrive/My Drive/")
1 !ls
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 25/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
1 !ls
Australia.csv demo.csv sample_data
RESUMEN
Opcion 1: "Montando" el GDrive, permite que la ruta de los archivos quede ja estatica en mi
codigo.
Option2: Es mas simple de usar, permite la interactividad con el usuario. Sin embargo, NO se
guarda en la memoria del la maquina (virtual), y no permitiria replicar los resultados de forma
automatica.
WELL LOGS
1 # Import modules
2 import matplotlib.pyplot as plt
3 import numpy as np
4 import pandas as pd
2
3 file = '/content/gdrive/My Drive/Colab Notebooks/F02-1_logs.l
Mnemonicos
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 27/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
1 data
1 data head()
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 28/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
1 data.head()
1 data.describe()
Plot
1 plt.plot(subgroup_data[:,1], subgroup_data[:,0])
[<matplotlib.lines.Line2D at 0x7f4ffc2aae48>]
1 DEPTH = subgroup_data[:,0]
2 RHOB = subgroup_data[:,1]
1 plt.plot(RHOB, DEPTH)
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 30/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
[<matplotlib.lines.Line2D at 0x7f4ffc1b74a8>]
1 plt.figure(figsize=(4,10))
2 plt.plot(RHOB, DEPTH)
[<matplotlib.lines.Line2D at 0x7f4ffd1c40b8>]
1 GR = subgroup_data[:,3]
8
9 data = pd.DataFrame(data, columns=mnemonics)
10
11 subgroup_data = data[['DEPTH', 'RHOB', 'DT', 'GR', 'PHIE']] #
12 subgroup_data = subgroup_data.values
13
14 DEPTH = subgroup_data[:,0]
15 RHOB = subgroup_data[:,1]
16 GR = subgroup_data[:,3]
17
18 plt.figure(figsize=(4,10))
19 plt.plot(RHOB, DEPTH)
[<matplotlib.lines.Line2D at 0x7f4ffc2bd470>]
1 plt.plot(GR, RHOB)
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 32/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
[<matplotlib.lines.Line2D at 0x7f4ffbba17f0>]
1 plt.scatter(GR, RHOB)
<matplotlib.collections.PathCollection at 0x7f4ffc45b0f0>
1 plt.figure(figsize = (12,8))
2 plt.scatter(GR, RHOB, c = 'r', s = 2)
3 plt.title('GR vs RHOB', fontsize = 'xx-large')
4 plt.xlabel('GR [API]', fontsize = 20)
5 plt.ylabel('RHOB [g/cc]', fontsize = 20)
6 plt.grid()
7 plt.show()
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 33/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
Subplots
las: 2
columnas: 2
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 34/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
https://drive.google.com/ le/d/1kwYFaRjCOmKXGpOHZdDgxJ4gfAMpJ195/view
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 35/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
1 rows, cols = 1, 4
2 fig, ax = plt.subplots(nrows = rows, ncols = cols, figsize =
3 ax[0].plot(RHOB, DEPTH)
4 plt.show()
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 36/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
Notice that the y-axis is backward. For that reason we need to manipulate the axis. Since we have
fours axis (columns), we need to specify the maximum and the minimum values of the axis we
would like to manipulate, in this case will be the rst (0).
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 38/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 39/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 41/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 43/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 44/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 45/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 46/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
5 DT = subgroup_data[:,2]
6 GR = subgroup_data[:,3]
7 PHIE = subgroup_data[:,4]
8
9 fix, ax = plt.subplots(nrows = rows, ncols = cols, figsize =
10 ax[0].plot(RHOB, DEPTH, c = 'red', lw = 0.5)
11 ax[0].set_ylim(max(DEPTH), min(DEPTH))
12 ax[0].set_title('Densidad [g/cc]')
13 ax[0].grid()
14
15 ax[1].plot(DT, DEPTH, c = 'green', lw = 0.5)
16 #ax[1].set_ylim(max(DEPTH), min(DEPTH))
17 ax[1].set_title('DT [1/ms]')
18 ax[1].grid()
19
20 ax[2].plot(GR, DEPTH, c = 'black', lw = 0.5)
21 #ax[2].set_ylim(max(DEPTH), min(DEPTH))
22 ax[2].set_title('Gamma Ray [API]')
23 ax[2].grid()
24
25 ax[3].plot(PHIE, DEPTH, c = 'magenta', lw = 0.5)
26 #ax[3].set_ylim(max(DEPTH), min(DEPTH))
27 ax[3].set_title('Porosidad Effect')
28 ax[3].grid()
29
30 plt.show()
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 48/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
Aplicando los conocimientos previos, podemos seleccionar un cut-off y rellenar la curva de acuerdo
a dicho cut-off:
3 DEPTH = subgroup_data[:,0]
4 RHOB = subgroup_data[:,1]
5 DT = subgroup_data[:,2]
6 GR = subgroup_data[:,3]
7 PHIE = subgroup_data[:,4]
8
9 fix, ax = plt.subplots(nrows = rows, ncols = cols, figsize =
10 ax[0].plot(RHOB, DEPTH, c = 'red', lw = 0.5)
11 ax[0].set_ylim(max(DEPTH), min(DEPTH))
12 ax[0].set_title('Densidad [g/cc]')
13 ax[0].grid()
14
15 ax[1].plot(DT, DEPTH, c = 'green', lw = 0.5)
16 #ax[1].set_ylim(max(DEPTH), min(DEPTH))
17 ax[1].set_title('DT [1/ms]')
18 ax[1].grid()
19
20 ax[2].plot(GR, DEPTH, c = 'black', lw = 0.5)
21 #ax[2].set_ylim(max(DEPTH), min(DEPTH))
22 ax[2].set_title('Gamma Ray [API]')
23
24 # Cut-off
25 cut_off = GR*0+50 # Cut-off es 50 API
26 ax[2].fill_betweenx(DEPTH, GR,cut_off, where=(GR>=cut_off), c
27 ax[2].fill_betweenx(DEPTH, GR,cut_off, where=(GR< cut_off), c
28 ax[2].grid()
29
30 ax[3].plot(PHIE, DEPTH, c = 'magenta', lw = 0.5)
31 #ax[3].set_ylim(max(DEPTH), min(DEPTH))
32 ax[3].set_title('Porosidad Effect')
33 ax[3].grid()
34
35 plt.show()
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 50/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 51/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
Now we can repeat the code in order to ll the other tracks, but replacing each index with the
corresponding column index.
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 52/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
However, this approach is not practical. Analyzing the code we see that there is pattern that we can
optimize using some of the tools reviewed previously, for example the For loop.
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 53/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 54/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
Now is time to add other things into the graph such as a grid with different colors, tick (minor), and
the title of each plot using the mnemonics.
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 55/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
An extra feature may be edit (or remove) the space between tracks (plots), using the function (out
of the loop):
plt.subplots_adjust(wspace=0)
It controls the amount of width reserved for space between subplots, expressed as a fraction of the
average axis width.
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 57/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
SEISMIC
1 # Import modules
2 import numpy as np
3 import segyio
4 import matplotlib.pyplot as plt
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 58/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
filename = 'Penobscot_0-1000ms.sgy'
1 import numpy as np
2 import segyio
3 import matplotlib.pyplot as plt
4
5 filename = '/content/gdrive/My Drive/Colab Notebooks/Penobsco
6
7 with segyio.open(filename) as s:
8 c = segyio.cube(s)
1 # Use segyio
2
3 with segyio.open(filename) as s:
4 c = segyio.cube(s)
1 type(c)
numpy.ndarray
1 c.shape
(601, 481, 251)
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 59/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
1 # Plot seismic
2 # plt.imshow(c[x, y, z])
3
4 # plt.imshow(c[inline, crossline, timeslice])
5
6 plt.imshow(c[150,:,:],)
7 plt.show()
1 # Plot seismic
2 plt.imshow(c[150,:,:].T)
3 plt.show()
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 60/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
1 # Plot seismic
2 plt.imshow(c[150,:,:].T, cmap = 'Greys')
3 plt.show()
1 ma = np.percentile(c, 98)
2 ma
4247.0
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 62/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
1 # Plot INLINE
2 plt.figure(figsize=(18,6))
3 plt.imshow(c[150,:,:].T, vmin=-ma, vmax = ma, cmap = 'Greys',
4 plt.colorbar()
5 plt.title('INLINE', fontsize=20)
6 plt.ylabel('Time (ms)')
7 plt.show()
1 # Plot XLINE
2 plt.figure(figsize=(18,6))
3 plt.imshow(c[:,240,:].T, vmin=-ma, vmax = ma, cmap = 'Greys',
4 plt.colorbar()
5 plt.title('XLINE', fontsize=20)
6 lt l b l('Ti ( )')
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 63/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
6 plt.ylabel('Time (ms)')
7 plt.show()
1 # Plot TIMESLICE
2 plt.figure(figsize=(14,10))
3 plt.imshow(c[:,:,125].T, vmin=-ma, vmax = ma, cmap = 'seismic
4 plt.colorbar()
5 plt.title('TIMESLICE', fontsize=20)
6 plt.xlabel('Inline')
7 plt.ylabel('Xline')
8 plt.show()
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 64/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
1 # Plot TIMESLICE
2 time_slice = 200
3
4 plt.figure(figsize=(14,10))
5 plt.imshow(c[:,:,time_slice].T, vmin=-ma, vmax = ma, cmap = '
6 plt.colorbar()
7 plt.title('TIME SLICE = %d ms' %time_slice, fontsize=20)
8 plt.xlabel('Inline', fontsize=16)
9 plt.ylabel('Xline', fontsize=16)
10 plt.show()
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 65/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
PRODUCCION
Importar librerias
Importar datos:
Datos de produccion
1 len(well_rate)
27
plot(x, y)
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 66/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
Datos de fecha
1 t = [1, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330,
2 360, 390, 420, 450, 480, 510, 540, 570, 600, 630, 660,
3 690, 720, 750, 780]
4 len(t)
27
O podemos realizar el analisis a traves del uso de la funcion np.arange(inicio, final, step) :
1 dias = 27 * 30
2 dias
810
1 tiempo = np.arange(1,dias,30)
2 tiempo
array([ 1, 31, 61, 91, 121, 151, 181, 211, 241, 271, 301, 331, 361,
391, 421, 451, 481, 511, 541, 571, 601, 631, 661, 691, 721, 751,
781])
1 k = 0
2 for i in tiempo:
3 tiempo[k] -= 1
4 k += 1
5
6 tiempo
array([ 0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360,
390, 420, 450, 480, 510, 540, 570, 600, 630, 660, 690, 720, 750,
780])
1 len(time)
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 67/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
27
Codigo completo (alternativo) de generar la escala de valores de tiempo:
1 dias = 27 * 30
2 tiempo = np.arange(1,dias,30)
3 k = 0
4 for i in tiempo:
5 tiempo[k] -= 1
6 k += 1
7
8 tiempo
array([ 0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360,
390, 420, 450, 480, 510, 540, 570, 600, 630, 660, 690, 720, 750,
780])
Procedemos a gra car los valores de produccion, en funcion del la lista de dias ( t ) que generamos
de forma manual:
1 plt.plot(t,well_rate,"x",color = 'black')
2 plt.show()
Luego, podemos realizar un ajuste de los datos de produccion a una curva, por ejemplo la curva de
ajuste de "Doung":
a 1−m
−3 (t −1)
q = qi t e 1−m
El método duong fue desarrollado especí camente para depósitos no convencionales con muy
baja permeabilidad. La forma de la curva es adecuada para pozos que exhiben largos períodos de
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 68/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
ujo transitorio. El método duong alcanzará un eur nito, y tiende a ser más conservador que los
descensos tradicionales de Arps con b> 1.
Referencia: https://petrowiki.org/Types_of_decline_analysis_in_production_forecasting
Primero, procedemos a seleccionar parametros iniciales de mi aproximacion:
Suposiciones:
Produccion de 90 m3 /d
1 # Ajustar ecuacion
2 f
q2 = []
3 for x in t:
4 qx = (qi * math.pow(x,-m))* math.exp((a / (1 - m)) * ((ma
5 if qx < 90:
6 qx = 0
7 q2.append(qx)
8
9 print(q2)
[248.956137704918, 438.070516922889, 365.17987542930115, 316.9576744515737, 282.53663669
1 plt.plot(t,q2,color='green')
2 plt.plot(t,well_rate,"x",color = 'black')
3 plt.show()
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 69/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
1 # Parametros iniciales
2 qi = 250.0 # Produccion inicial
3 m = 1.18
4 a = 1.8
5
6 # Ajustar ecuacion
7 q2 = []
8 for x in t:
9 qx = (qi * math.pow(x,-m))* math.exp((a / (1 - m)) * ((ma
10 if qx < 90:
11 qx = 0
12 q2.append(qx)
13
14
15 # Graficar resultados
16 plt.figure(figsize=(16,8))
17 plt.plot(t,q2,color='green', lw=4, label='$q_{i}$ %d (b/d) Do
18 plt.plot(t,well_rate,"o",color = 'red', lw=5, label='Producci
19 plt.title('Ajuste de Produccion de Pozo', fontsize = 40)
20 plt.xlabel('Tiempo (dias)', fontsize = 30)
21 plt.ylabel('Produccion (barriles/dia', fontsize = 30)
22 plt.xlim([0,900])
23 plt.xticks(fontsize = 20)
24 plt.yticks(fontsize = 20)
25 plt.grid()
26 plt.legend(fontsize = 20)
27 plt.show()
28
29 plt.savefig('productionFinal.png')
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 70/71
7/18/2020 PythonExploracionHidrocarburos.ipynb - Colaboratory
https://colab.research.google.com/drive/1NEZHKxMEB2GJf0YP5MB7PoCgp1uCHVON#scrollTo=HlXYDLlgAfIT&uniqifier=1&printMode=true 71/71