测井数据可视化:绘制岩性颜色图例
-- coding: utf-8 --
import pandas as pd import numpy as np import seaborn as sns import numpy as np import pandas as pd import matplotlib.pyplot as plt import torch #import torch.optim as optim import warnings warnings.filterwarnings('ignore')
import matplotlib as mpl import matplotlib.pyplot as plt import matplotlib.colors as colors from mpl_toolkits.axes_grid1 import make_axes_locatable from pandas import set_option
pd.options.mode.chained_assignment = None
######################1.测试数据加载###########################################
filename = 'D:\工作簿1.csv' training_data = pd.read_csv(filename) print('原始数据是') print(training_data)
Before plotting, define a color map so the lithologies have consistent color.
Also creating abbreviated facies labels, and add those to the facies_vectors dataframe.
1=sandstone 2=c_siltstone 3=f_siltstone
4=marine_silt_shale 5=mudstone 6=wackestone 7=dolomite
8=packstone 9=bafflestone
facies_colors = ['#F4D03F', '#F5B041', '#DC7633', '#6E2C00', '#1B4F72','#A569BD']
facies_labels = ['泥岩', '粉砂质泥岩', '泥质粉砂岩', '粉砂岩', '细砂岩', '中砂岩']
facies_color_map is a dictionary that maps facies labels
to their respective colors
facies_color_map = {} for ind, label in enumerate(facies_labels): facies_color_map[label] = facies_colors[ind]
training_data['Facies']=training_data['Facies'].astype(int)
def label_facies(row, labels):
return labels[int(row['Facies'] -2000)]
training_data.loc[:, 'FaciesLabels'] = training_data.apply(lambda row: label_facies(row, facies_labels), axis=1) print('training_data') print(training_data)
###################### 2.调整数据集###########################################
sub-setting the features we need for training:
def make_facies_log_plot(logs, facies_colors): logs = logs.sort_values(by='Depth') cmap_facies = colors.ListedColormap( facies_colors[0:len(facies_colors)], 'indexed')
print(logs)
cols = ['CALI','DTC','POR','GR','RHOB']
line_colors = ['green', 'blue', 'gray', 'red', 'black']
ztop = logs.Depth.min()
zbot = logs.Depth.max()
# cluster is a reprensentation for a color-filled lithology, to be used by imshow
cluster = np.repeat(np.expand_dims(logs['Facies'].values, 1), 100, 1)
print(cluster)
f, ax = plt.subplots(nrows=1, ncols=6, figsize=(8, 12))
for i, col in enumerate(cols):
ax[i].plot(logs[col], logs.Depth, '-', color=line_colors[i])
im = ax[5].imshow(cluster, interpolation='none', aspect='auto', cmap=cmap_facies, vmin=1, vmax=9)
divider = make_axes_locatable(ax[5])
cax = divider.append_axes("right", size="20%", pad=0.05)
cbar = plt.colorbar(im, cax=cax)
cbar.set_label((17 * ' ').join(['泥岩', '粉砂质泥岩', '泥质粉砂岩', '粉砂岩', '细砂岩',
'中砂岩']))
cbar.set_ticks(range(0, 1));
cbar.set_ticklabels('')
for i, col in enumerate(cols):
ax[i].set_ylim(ztop, zbot)
ax[i].invert_yaxis()
ax[i].grid()
ax[i].locator_params(axis='x', nbins=3)
ax[i].set_xlabel(col)
ax[i].set_xlim(logs[col].min(), logs[col].max())
ax[i].set_yticklabels([])
ax[5].set_xlabel('Facies')
ax[5].set_yticklabels([])
ax[5].set_xticklabels([])
f.suptitle('Well: %s' % logs.iloc[0]['Well Name'], fontsize=14, y=0.94)
################## 绘制测井曲线(即特征)的单独测井数据 make_facies_log_plot( training_data[training_data['Well Name'] == 'LD10_1_5'], facies_colors) plt.show()
原文地址: https://www.cveoy.top/t/topic/n1SC 著作权归作者所有。请勿转载和采集!