Skip to content

Commit ffd0309

Browse files
committed
small changes to improve plotting functions
1 parent 8a88246 commit ffd0309

9 files changed

Lines changed: 194 additions & 94 deletions

File tree

.gitignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

CoreData/CoreBeta/Public.json

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
{"Lease_Name":"Public",
2-
"Lease":"Public core #1",
3-
"corenameAbrev":"PC",
4-
"API":-999,
5-
"State":"Texas",
6-
"County":"Public county",
7-
"noOfCols":5,
1+
{"Lease_Name":"Public","Lease":"Public core No. 1",
2+
"corenameAbrev":null,"API":-999,"State":"Texas","County":"Public","noOfCols":5,
83
"coretube_length":2.0,
94
"ImageType":"vis",
10-
"CoreBox_crop_points":[70,150,750,900],
5+
"CoreBox_crop_points":null,
116
"Photo_depth":"Depth_calculated",
12-
"TopOfFirstCorebox":3978,"XRF_resolution":0.17,
13-
"Attribute_plotted": ["TOC", "TON", "Quartz", "Calcite", "2_1 clay minerals"]}
7+
"TopOfFirstCorebox":null,
8+
"XRF_resolution":0.166666,
9+
"Attribute_plotted": ["TOC", "Illite/Mica", "Quartz", "Calcite", "Average_UCS_MPa"]}

CorePycodes/Attribute_merge.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
# Root_path, Run_settings, and Corebeta and the two .json core settings files with all input parameters
1919
Root_path = os.path.dirname(os.getcwd())
20+
21+
# Run_settings and Corebeta contain teh meta data and settings information to run CorePy scripts.
22+
# Corebeta: a separate .json files exists for each core and provides core-specific data
23+
# Run_settings is derived from settings.py and stores model and elemental parameter
2024
Run_settings=json.load(open(os.path.join(Root_path + '/CorePycodes/' + 'Run_settings' + '.json')))
2125
Corebeta=json.load(open(os.path.join(Root_path + '/CoreData/CoreBeta/' + Run_settings['Lease_Name'] +'.json')))
2226

@@ -48,13 +52,13 @@
4852
all_files = os.listdir(Attribute_dir)
4953
csv_files = list(filter(lambda f: f.endswith('.csv'), all_files))
5054

51-
XRF_file = coredata
55+
XRF_file = coredata # original XRF file that attribute fuiles will be added to
5256

5357
Merged_file=XRF_file
5458
# Loop over the attribute files and merge on Core-Box-Inch
5559
for i in range(len(csv_files)):
5660
Attribute_file = pd.read_csv(os.path.join(Attribute_dir + '/' + csv_files[i]))
57-
# Merging adds duplicate file names so I use these two lines to remove duplicate names
61+
# Merging adds duplicate column names so I use these two lines to remove duplicate columns. So instead of pandas using _x or _y to rename columns it uses _drop
5862
Merged_file = pd.merge(Merged_file, Attribute_file, how='left', on=['Core', 'Box', 'Inch'],suffixes=('', '_drop'))
5963
Merged_file.drop([col for col in Merged_file.columns if 'drop' in col], axis=1, inplace=True)
6064

@@ -97,7 +101,7 @@
97101
x=wirelinedata[depth_column_heading] # original wireline log depth is always called DEPT...no it is not
98102
#y=wirelinedata[Corebeta['WirelineLogs_NeuralModel'][i]] # wireline log attribute being cycled over
99103
y=wirelinedata[Corebeta['WirelineLogs'][i]] # wireline log attribute being cycled over
100-
f = interp1d(x,y, bounds_error=False, fill_value=-10, kind='linear')
104+
f = interp1d(x,y, bounds_error=False, fill_value=-999, kind='linear')
101105

102106
new_data = np.array([coredata['Wireline_Depth'] , f(coredata['Wireline_Depth'] )])
103107
new_data=np.transpose(new_data)

CorePycodes/Core_Attribute.py

Lines changed: 79 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,41 @@
5252
plt.savefig(os.path.join(dirName + '/' + Run_settings["Lease_Name"] + '_' + Formation_names + '_AttributeBoxplot' + '.eps'),format='eps',dpi = 600)
5353

5454

55+
fig, ((ax1, ax2,), (ax3, ax4), (ax5, ax6)) = plt.subplots(nrows=3, ncols=2, sharex=False, sharey=False, figsize=(10,15))
56+
57+
sns.scatterplot(x=attribute_plotted[0], y=attribute_plotted[2], hue=Run_settings["RockClassification"],data=coredata, palette=chemofacies_color,ax=ax1, edgecolor='black')
58+
ax1.legend([])
59+
60+
sns.scatterplot(x=attribute_plotted[1], y=attribute_plotted[2], hue=Run_settings["RockClassification"],data=coredata, palette=chemofacies_color,ax=ax2, edgecolor='black')
61+
ax2.legend([])
62+
63+
sns.scatterplot(x=attribute_plotted[3], y=attribute_plotted[0], hue=Run_settings["RockClassification"],data=coredata, palette=chemofacies_color,ax=ax3, edgecolor='black')
64+
ax3.legend([])
65+
ax3.set(xscale="log")
66+
ax3.grid(which = 'minor')
67+
ax3.grid(which = 'major')
68+
69+
sns.scatterplot(x=attribute_plotted[3], y=attribute_plotted[1], hue=Run_settings["RockClassification"],data=coredata, palette=chemofacies_color,ax=ax4, edgecolor='black')
70+
ax4.legend([])
71+
ax4.set(xscale="log")
72+
ax4.grid(which = 'minor')
73+
ax4.grid(which = 'major')
74+
#sns.scatterplot(x=Run_settings["Elements_plotted"][1], y=Run_settings["Elements_plotted"][7], hue=Run_settings["RockClassification"],data=coredata, palette=chemofacies_color,ax=ax5, edgecolor='black')
75+
#ax5.legend([])
76+
77+
#sns.scatterplot(x=Run_settings["Elements_plotted"][0], y=Run_settings["Elements_plotted"][9], hue=Run_settings["RockClassification"],data=coredata, palette=chemofacies_color,ax=ax6, edgecolor='black')
78+
#ax6.legend([])
79+
80+
plt.savefig(os.path.join(dirName + '/' + Run_settings["Lease_Name"] + '_' + Formation_names + '_AttributeCrossPlot_' + Run_settings["RockClassification"] + '.png'),dpi = 300)
81+
plt.savefig(os.path.join(dirName + '/' + Run_settings["Lease_Name"] + '_' + Formation_names + '_AttributeCrossPlot_' + Run_settings["RockClassification"] + '.eps'),format='eps',dpi = 600)
82+
83+
84+
85+
86+
87+
88+
89+
5590
# This section defines descriptive statistics for each chemofacies. Median, Q3, and Q1
5691
Median_calc=attributedata.groupby(Run_settings["RockClassification"]).quantile(0.50)[attribute_plotted]
5792
Q3_calc=attributedata.groupby(Run_settings["RockClassification"]).quantile(0.75)[attribute_plotted]
@@ -85,13 +120,20 @@
85120

86121
coredata = Attribute_corelog # cheating here. Should rename throughout
87122

123+
Depth_figure_top = min(Attribute_corelog[Run_settings["Depth_model"]])
124+
Depth_figure_bottom = max(Attribute_corelog[Run_settings["Depth_model"]])
125+
126+
127+
#Depth_figure_top = 10820
128+
#Depth_figure_bottom = 10892
129+
88130
plt.subplot(1, n, 1)
89131
for i in range(len(Attribute_corelog)):
90132
Q = [0, 0, coredata[Run_settings["RockClassification"]][i]+2, coredata[Run_settings["RockClassification"]][i]+2]
91133
Z = [coredata[Run_settings["Depth_model"]][i]+Corebeta["XRF_resolution"], coredata[Run_settings["Depth_model"]][i], coredata[Run_settings["Depth_model"]][i], coredata[Run_settings["Depth_model"]][i]+Corebeta["XRF_resolution"]]
92134

93135
plt.fill(Q, Z,c=chemofacies_color[coredata[Run_settings["RockClassification"]][i]], linewidth=0.0)
94-
plt.ylim((max(coredata[Run_settings["Depth_model"]]),min(coredata[Run_settings["Depth_model"]])))
136+
plt.ylim(Depth_figure_bottom,Depth_figure_top)
95137
plt.xlim((0,6))
96138
plt.xlabel("RockClass", fontsize=18)
97139
plt.ylabel(Run_settings["Depth_model"], fontsize=18)
@@ -100,110 +142,110 @@
100142

101143

102144
plt.subplot(1, n, 2)
103-
y_av = corepy.movingaverage(Attribute_corelog[Run_settings["Elements_plotted"][2]]/Attribute_corelog[Run_settings["Elements_plotted"][1]], Run_settings["moving_avg"])
145+
y_av = corepy.movingaverage(Attribute_corelog[Run_settings["Elements_plotted"][10]], Run_settings["moving_avg"])
104146
axs=plt.plot(y_av,Attribute_corelog[Run_settings["Depth_model"]], color='blue')
105147
#plt.xlim([0,10])
106-
plt.ylim((max(Attribute_corelog[Run_settings["Depth_model"]]),min(Attribute_corelog[Run_settings["Depth_model"]])))
107-
plt.yticks([])
148+
plt.ylim(Depth_figure_bottom,Depth_figure_top)
149+
#plt.yticks([])
108150
plt.xticks(fontsize=14)
109151
#plt.xscale('log')
110152
plt.xlabel(Run_settings["Elements_plotted"][3], fontsize=18)
111-
plt.xlabel('Si/Al', fontsize=18)
153+
plt.xlabel(Run_settings["Elements_plotted"][10], fontsize=18)
112154

113155
plt.subplot(1,n, 3)
114-
y_av = corepy.movingaverage(coredata[Run_settings["Elements_plotted"][6]]/coredata[Run_settings["Elements_plotted"][2]], Run_settings["moving_avg"])
156+
y_av = corepy.movingaverage(coredata[Run_settings["Elements_plotted"][7]], Run_settings["moving_avg"])
115157
axs=plt.plot(y_av,coredata[Run_settings["Depth_model"]], color='blue')
116158
#plt.xlim([0,0.02])
117-
plt.ylim((max(coredata[Run_settings["Depth_model"]]),min(coredata[Run_settings["Depth_model"]])))
118-
plt.yticks([])
159+
plt.ylim(Depth_figure_bottom,Depth_figure_top)
160+
#plt.yticks([])
119161
plt.xticks(fontsize=14)
120162
#plt.xscale('log')
121163
plt.xlabel(Run_settings["Elements_plotted"][2], fontsize=18)
122-
plt.xlabel('Mo/Al', fontsize=18)
164+
plt.xlabel(Run_settings["Elements_plotted"][7], fontsize=18)
123165

124166

125167
plt.subplot(1, n, 4)
126-
y_av = corepy.movingaverage(coredata[Run_settings["Elements_plotted"][8]]/coredata[Run_settings["Elements_plotted"][2]], Run_settings["moving_avg"])
168+
y_av = corepy.movingaverage(coredata[Run_settings["Elements_plotted"][4]], Run_settings["moving_avg"])
127169
axs=plt.plot(y_av,coredata[Run_settings["Depth_model"]], color='blue')
128-
plt.ylim((max(coredata[Run_settings["Depth_model"]]),min(coredata[Run_settings["Depth_model"]])))
170+
plt.ylim(Depth_figure_bottom,Depth_figure_top)
129171
#plt.xlim([0,10])
130-
plt.yticks([])
172+
#plt.yticks([])
131173
plt.xticks(fontsize=14)
132174
#plt.xscale('log')
133175
plt.xlabel(Run_settings["Elements_plotted"][1], fontsize=18)
134-
plt.xlabel('Ni/Al', fontsize=18)
176+
plt.xlabel(Run_settings["Elements_plotted"][4], fontsize=18)
135177

136178
plt.subplot(1,n,5)
137179
y_av = corepy.movingaverage(Attribute_corelog[(os.path.join(attribute_plotted[0] + '_median'))], Run_settings["moving_avg"])
138180
axs = sns.scatterplot(x=attribute_plotted[0] , y=Run_settings["Depth_model"], hue=Run_settings["RockClassification"],s=150, edgecolor='black',data = attributedata,palette=chemofacies_color)
139181
axs.legend([])
140-
axs=plt.plot(y_av,Attribute_corelog[Run_settings["Depth_model"]], color='blue',linewidth=1.0)
182+
#axs=plt.plot(y_av,Attribute_corelog[Run_settings["Depth_model"]], color='blue',linewidth=1.0)
141183

142184
#plt.xlim([0,30])
143-
plt.ylim((max(Attribute_corelog[Run_settings["Depth_model"]]),min(Attribute_corelog[Run_settings["Depth_model"]])))
144-
plt.yticks([])
185+
plt.ylim(Depth_figure_bottom,Depth_figure_top)
186+
#plt.yticks([])
145187
plt.xticks(fontsize=14)
146188
plt.xlabel(attribute_plotted[0], fontsize=18)
147-
plt.ylabel('')
189+
#plt.ylabel('')
148190

149191

150192
plt.subplot(1,n,6)
151193
y_av = corepy.movingaverage(Attribute_corelog[(os.path.join(attribute_plotted[1] + '_median'))], Run_settings["moving_avg"])
152194
axs = sns.scatterplot(x=attribute_plotted[1] , y=Run_settings["Depth_model"], edgecolor='black',hue=Run_settings["RockClassification"], s=150,data = attributedata,palette=chemofacies_color)
153195
axs.legend([])
154-
axs=plt.plot(y_av,Attribute_corelog[Run_settings["Depth_model"]], color='blue',linewidth=1.0)
196+
#axs=plt.plot(y_av,Attribute_corelog[Run_settings["Depth_model"]], color='blue',linewidth=1.0)
155197

156198

157-
plt.xlim([0,30])
158-
plt.ylim((max(Attribute_corelog[Run_settings["Depth_model"]]),min(Attribute_corelog[Run_settings["Depth_model"]])))
159-
plt.yticks([])
199+
#plt.xlim([0,40])
200+
plt.ylim(Depth_figure_bottom,Depth_figure_top)
201+
#plt.yticks([])
160202
plt.xticks(fontsize=14)
161203
plt.xlabel(attribute_plotted[1], fontsize=18)
162-
plt.ylabel('')
204+
#plt.ylabel('')
163205

164206

165-
plt.subplot(1,n,7)
207+
plt.subplot(1,n,8)
166208
y_av = corepy.movingaverage(Attribute_corelog[(os.path.join(attribute_plotted[2] + '_median'))], Run_settings["moving_avg"])
167209

168-
axs=plt.plot(y_av,Attribute_corelog[Run_settings["Depth_model"]], color='blue',linewidth=1.0)
210+
#axs=plt.plot(y_av,Attribute_corelog[Run_settings["Depth_model"]], color='blue',linewidth=1.0)
169211
axs = sns.scatterplot(x=attribute_plotted[2] , y=Run_settings["Depth_model"],edgecolor='black', hue=Run_settings["RockClassification"],s=150, data = attributedata,palette=chemofacies_color)
170212
axs.legend([])
171213

172214
#plt.xlim([50,100])
173-
plt.ylim((max(Attribute_corelog[Run_settings["Depth_model"]]),min(Attribute_corelog[Run_settings["Depth_model"]])))
174-
plt.yticks([])
215+
plt.ylim(Depth_figure_bottom,Depth_figure_top)
216+
#plt.yticks([])
175217
plt.xticks(fontsize=14)
176218
plt.xlabel(attribute_plotted[2], fontsize=18)
177-
plt.ylabel('')
219+
#plt.ylabel('')
178220

179221

180-
plt.subplot(1,n,8)
222+
plt.subplot(1,n,7)
181223
y_av = corepy.movingaverage(Attribute_corelog[(os.path.join(attribute_plotted[3] + '_median'))], Run_settings["moving_avg"])
182224

183225
axs = sns.scatterplot(x=attribute_plotted[3] , y=Run_settings["Depth_model"],edgecolor='black', hue=Run_settings["RockClassification"],s=150, data = attributedata,palette=chemofacies_color)
184226
axs.legend([])
185-
axs=plt.plot(y_av,Attribute_corelog[Run_settings["Depth_model"]], color='blue',linewidth=1.0)
227+
#axs=plt.plot(y_av,Attribute_corelog[Run_settings["Depth_model"]], color='blue',linewidth=1.0)
186228

187229
#plt.xlim([0,3])
188-
plt.ylim((max(Attribute_corelog[Run_settings["Depth_model"]]),min(Attribute_corelog[Run_settings["Depth_model"]])))
189-
plt.yticks([])
230+
plt.ylim(Depth_figure_bottom,Depth_figure_top)
231+
#plt.yticks([])
190232
plt.xticks(fontsize=14)
191233
plt.xlabel(attribute_plotted[3], fontsize=18)
192-
plt.ylabel('')
234+
#plt.ylabel('')
193235

194236
plt.subplot(1,n,9)
195237
y_av = corepy.movingaverage(Attribute_corelog[(os.path.join(attribute_plotted[4] + '_median'))], Run_settings["moving_avg"])
196238

197239
axs = sns.scatterplot(x=attribute_plotted[4] , y=Run_settings["Depth_model"],edgecolor='black', hue=Run_settings["RockClassification"],s=150, data = attributedata,palette=chemofacies_color)
198240
axs.legend([])
199-
axs=plt.plot(y_av,Attribute_corelog[Run_settings["Depth_model"]], color='blue',linewidth=1.0)
241+
#axs=plt.plot(y_av,Attribute_corelog[Run_settings["Depth_model"]], color='blue',linewidth=1.0)
200242

201243
#plt.xlim([0,3])
202-
plt.ylim((max(Attribute_corelog[Run_settings["Depth_model"]]),min(Attribute_corelog[Run_settings["Depth_model"]])))
203-
plt.yticks([])
244+
plt.ylim(Depth_figure_bottom,Depth_figure_top)
245+
#plt.yticks([])
204246
plt.xticks(fontsize=14)
205247
plt.xlabel(attribute_plotted[4], fontsize=18)
206-
plt.ylabel('')
248+
#plt.ylabel('')
207249

208250
plt.savefig(os.path.join(dirName + '/' + Run_settings["Lease_Name"] + '_' + Formation_names + '_Attributelog' + '.png'),dpi = 300)
209-
plt.savefig(os.path.join(dirName + '/' + Run_settings["Lease_Name"] + '_' + Formation_names + '_Attributelog' + '.eps'),format='eps',dpi = 600)
251+
plt.savefig(os.path.join(dirName + '/' + Run_settings["Lease_Name"] + '_' + Formation_names + '_Attributelog' + '.eps'),format='eps',dpi = 600)

CorePycodes/Coreimage.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import math
88
import corepytools as corepy
99
import json
10+
import pandas as pd
1011

1112

1213
# Coreimage.py takes core image files that are depth registered LH_6732_6735.png, for example
@@ -40,6 +41,9 @@
4041
# Import datafiles
4142
# Coredata for XRF files and core tube photos. Directories were created by corepytools
4243
coredata = corepy.OutputXRF(Run_settings["Lease_Name"],Formation_names)
44+
45+
#coredata=pd.read_csv((os.path.join(Root_path + '/CoreData/CoreNeuralModel/' + Formation_names + '_TrainingDataset.csv')))
46+
4347
Tubes_dir = os.path.join(Root_path + str('/CoreData/CoreTubes') + '/' + Run_settings["Lease_Name"] + '_tubes_vis')
4448

4549
#makes a list of the file names and sorts them top to bottom so they are called correctly in the loop
@@ -48,7 +52,7 @@
4852

4953
# This section determines how many coretubes per row in the output image
5054
rows=math.ceil(len(file_names)/Corebeta['noOfCols'])
51-
chunksize=25 # number of files to be processed. might fail if folder doesnt have 100 files
55+
chunksize=60 # number of files to be processed. might fail if folder doesnt have 100 files
5256
number_chunks=math.ceil(len(file_names)/chunksize)
5357

5458
def chunks(l, n):
@@ -101,6 +105,6 @@ def chunks(l, n):
101105
axs[i,j].add_patch(rect) # Add the patch to the Axes
102106

103107
plt.savefig(os.path.join(dirName + '/' + Run_settings["Lease_Name"] + '_' + Formation_names + '_' + str(photo_top) + '.png'),dpi = 300)
104-
#plt.savefig(os.path.join(dirName + '/' + Run_settings["CoreOfStudy"] + '_' + Formation_names + '_' + str(photo_top) + '.eps'),format='eps',dpi = 600)
108+
plt.savefig(os.path.join(dirName + '/' + Run_settings["Lease_Name"] + '_' + Formation_names + '_' + str(photo_top) + '.eps'),format='eps',dpi = 600)
105109

106110
#plt.savefig(os.path.join(dirName + '/' + Run_settings["CoreOfStudy"] + '_' + Formation_names + '_' + str(photo_top) + '.png'),dpi = 300)

0 commit comments

Comments
 (0)