<jupyter_start><jupyter_text>Crossplots<jupyter_code>import pandas as pd
import matplotlib.pyplot as plt
import lasio
import numpy as np
#plt.style.use(['science','grid', 'no-latex'])<jupyter_output><empty_output><jupyter_text>Lectura del archivo LAS<jupyter_code>las = lasio.read("W19.las")
well = las.df()<jupyter_output><empty_output><jupyter_text>Visualizacion del pozo fig, ax = plt.subplots(figsize=(15,10))

ax1 = plt.subplot2grid((1,6), (0,0), rowspan=1, colspan = 1)
ax2 = plt.subplot2grid((1,6), (0,1), rowspan=1, colspan = 1, sharey = ax1)
ax3 = plt.subplot2grid((1,6), (0,2), rowspan=1, colspan = 1, sharey = ax1)
ax4 = plt.subplot2grid((1,6), (0,3), rowspan=1, colspan = 1, sharey = ax1)
ax5 = ax3.twiny()
ax6 = plt.subplot2grid((1,6), (0,4), rowspan=1, colspan = 1, sharey = ax1)
ax7 = ax2.twiny()

ax10 = ax1.twiny()
ax10.xaxis.set_visible(False)
ax11 = ax2.twiny()
ax11.xaxis.set_visible(False)
ax12 = ax3.twiny()
ax12.xaxis.set_visible(False)
ax13 = ax4.twiny()
ax13.xaxis.set_visible(False)
ax14 = ax6.twiny()
ax14.xaxis.set_visible(False)

 Rayos gamma
ax1.plot(well["GR"], well.index, color = "green", linewidth = 1.5)
ax1.set_xlabel("Gamma")
ax1.xaxis.label.set_color("green")
ax1.set_xlim(0, 200)
ax1.set_ylabel("Depth (m)")
ax1.tick_params(axis='x', colors="green")
ax1.spines["top"].set_edgecolor("green")
ax1.title.set_color('green')
ax1.set_xticks([0, 50, 100, 150, 200])

 Resistividad
ax2.plot(well["LLD"], well.index, color = "red", linewidth = 1.5)
ax2.set_xlabel("Resistivity - D")
ax2.set_xlim(0.2, 200)
ax2.xaxis.label.set_color("red")
ax2.tick_params(axis='x', colors="red")
ax2.spines["top"].set_edgecolor("red")
ax2.set_xticks([0.1, 1, 10, 100])
ax2.semilogx()

 Densidad 
ax3.plot(well["RHOB"], well.index, color = "red", linewidth = 1.5)
ax3.set_xlabel("Density")
ax3.set_xlim(1.95, 2.95)
ax3.xaxis.label.set_color("red")
ax3.tick_params(axis='x', colors="red")
ax3.spines["top"].set_edgecolor("red")
ax3.set_xticks([1.95, 2.45, 2.95])

 Sonico
ax4.plot(well["DTCO"], well.index, color = "purple", linewidth = 1.5)
ax4.set_xlabel("Sonic")
ax4.set_xlim(140, 40)
ax4.xaxis.label.set_color("purple")
ax4.tick_params(axis='x', colors="purple")
ax4.spines["top"].set_edgecolor("purple")

 Neutron 
ax5.plot(well["NPHI"], well.index, color = "blue", linewidth = 1.5)
ax5.set_xlabel('Neutron')
ax5.xaxis.label.set_color("blue")
ax5.set_xlim(0.45, -0.15)
ax5.set_ylim(4122, 4028)
ax5.tick_params(axis='x', colors="blue")
ax5.spines["top"].set_position(("axes", 1.08))
ax5.spines["top"].set_visible(True)
ax5.spines["top"].set_edgecolor("blue")
ax5.set_xticks([0.45, 0.3, 0.15,0, -0.15])

 Caliper
ax6.plot(well["CALI"], well.index, color = "black", linewidth = 1.5)
ax6.set_xlabel("Caliper")
ax6.set_xlim(6, 16)
ax6.xaxis.label.set_color("black")
ax6.tick_params(axis='x', colors="black")
ax6.spines["top"].set_edgecolor("black")
ax6.fill_betweenx(well.index, 8.5, well["CALI"], facecolor='yellow')
ax6.set_xticks([6,  11, 16])

 Resistividad somera
ax7.plot(well["LLS"], well.index, color = "green", linewidth = 1.5)
ax7.set_xlabel("Resistivity - S")
ax7.set_xlim(0.2, 200)
ax7.xaxis.label.set_color("green")
ax7.spines["top"].set_position(("axes", 1.08))
ax7.spines["top"].set_visible(True)
ax7.tick_params(axis='x', colors="green")
ax7.spines["top"].set_edgecolor("green")
ax7.set_xticks([0.1, 1, 10, 100])
ax7.semilogx()

for ax in [ax1, ax2, ax3, ax4, ax6]:
    ax.set_ylim(4122, 4028)
    ax.grid(which='major', color='lightgrey', linestyle='-')
    ax.xaxis.set_ticks_position("top")
    ax.xaxis.set_label_position("top")
    ax.spines["top"].set_position(("axes", 1.02))

for ax in [ax2, ax3, ax4, ax6]:
    plt.setp(ax.get_yticklabels(), visible = False)

fig.set_dpi(300)

plt.tight_layout()
fig.subplots_adjust(wspace = 0.15) Seleccion de la zona 4  >[4103.9795 - 4105.8083]<jupyter_code>pozo=well.reset_index()
zona=pozo[['DEPTH','GR','NPHI','RHOB', 'DTCO']].loc[(pozo['DEPTH']>=4103.9795) & (pozo['DEPTH']<4105.8083)]
# Se seleccionan las 4 columnas, donde la profundidad se encuentre en el rango de la zona que nos corresponde
zona=zona.reset_index(drop=True)
zona.tail();<jupyter_output><empty_output><jupyter_text>crossplot<jupyter_code>fig, ax = plt.subplots(figsize=(5,3))

plt.scatter(zona.NPHI, zona.RHOB, c=zona.GR, cmap='gist_rainbow')
cbar = plt.colorbar(ticks=np.linspace(0,100,11))
cbar.set_label('Rayos Gamma', size=16)
plt.clim(0,100)

ax.set_ylim(3.0, 1.9)
ax.set_xlim(-0.05, 0.45)
ax.set_yticks(np.linspace(1.9,3.0,12))
ax.set_xticks(np.linspace(-0.05,0.45,11))
ax.set_ylabel('Densidad (Registro)', fontsize=16)
ax.set_xlabel('Porosidad Neutron (Registro)', fontsize=16)
plt.title('Densidad vs Porosidad Neutron')

#fig.set_dpi(300)
#plt.savefig("cph", transparent=True)
plt.show()<jupyter_output><empty_output><jupyter_text>Matriz<jupyter_code>matriz=pd.DataFrame({
    'substancia':['Cuarzo', 'Calcita', 'Dolomita', 'Agua'],
    'rho':[2.65, 2.71, 2.87, 1.00],
    'np':[-0.02, 0, 0.02, 1.00],
    'dt':[180, 156, 143, 620]
})
matriz<jupyter_output><empty_output><jupyter_text>Matriz A<jupyter_code>A = np.empty((0,len(matriz)))

for a in range(1, matriz.shape[1]):
    A = np.append(A, [matriz.iloc[:,a].to_numpy()], axis=0)
    
A = np.append(A, [np.ones(matriz.shape[1])], axis=0)<jupyter_output><empty_output><jupyter_text>Matriz B<jupyter_code>B = np.empty((0,len(matriz)-1))

for a in range(0, zona.shape[0]):
    B = np.append(B, [zona.loc[a,['RHOB', 'NPHI', 'DTCO']].to_numpy()], axis=0)

B = B.T
B = np.append(B, [np.ones(zona.shape[0])], axis=0)<jupyter_output><empty_output><jupyter_text>Matriz X<jupyter_code>x = np.empty((0,len(matriz)))
for a in range(0,B.shape[1]):
    x = np.append(x,[np.linalg.solve(A,B[:,a].T)], axis=0)

Solucion=pd.DataFrame(x,columns=['Cuarzo', 'Calcita', 'Dolomita', 'Porosidad'], index=zona['DEPTH'])
Solucion
# 'Cuarzo', 'Calcita', 'Dolomita', 'Porosidad'
print(np.linalg.solve(A,np.array([2.485, 0.158, 225, 1]).T))
print(np.sum(np.linalg.solve(A,np.array([2.485, 0.158, 225, 1]).T)))<jupyter_output>[0.03877457 0.55602401 0.25145502 0.15374639]
1.0
{'fraction_non_alphanumeric': 0.20989677207930527, 'fraction_numerical': 0.07750286744224152, 'mean_word_length': 6.122520420070011, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '564923', 'license': 'Apache-2.0', 'n_tokens_mistral': 2948, 'n_tokens_neox': 2789, 'n_words': 403, 'path': '4. crossplot.ipynb', 'repo_name': 'esia0120/fisicarocas', 'size': '6103'}