<jupyter_start><jupyter_text>UTAH FORGE PROJECT'S MISSIONEnable cutting-edge research and drilling and technology testing, as well as to allow scientists to identify a replicable, commercial pathway to EGS. In addition to the site itself, the FORGE effort will include a robust instrumentation, data collection, and data dissemination component to capture and share data and activities occurring at FORGE in real time. The innovative research, coupled with an equally-innovative collaboration and management platform, is truly a first of its kind endeavor. More details here https://utahforge.com/ The data used in this repository comes from the public data provided by Utah FORGE https://gdr.openei.org/submissions/1111 Some functions adapted from https://sainosmichelle.github.io/elements.html <NAME> (https://github.com/mariabravosegnini) and <NAME> (https://github.com/dianaceroallard)  have edited this notebook to be adapted for a python demonstration in Transform21 - Software Undergound.<jupyter_code>import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import lasio
import seaborn as sns
import warnings
warnings.filterwarnings('ignore')
%matplotlib inline<jupyter_output><empty_output><jupyter_text>Read 58-32 well logs in feet<jupyter_code>main = lasio.read('../alldata/58-32_main.las')<jupyter_output><empty_output><jupyter_text>Using Pandas to crete a DataFramethe DataFrames are two-dimensional tables with row and columns that can be easily edited and manipulated. i.e change size, call elements from within the table, perform operations, among other usages.<jupyter_code>#Create DataFrame line command from what it was read with Lasio
df_data = main.df()

#Printing the first 5 rows of the data frame with the header of the columns (if any) 
df_data.head(5)<jupyter_output><empty_output><jupyter_text>Other operations within the DataFrame<jupyter_code>#Delete columns - as many or as few as you need
df_data_small = df_data.drop(['AF10', 'AF20','AF30','AF60','AF90','AO20','AO30','AO60','AO90','SPAR',
                              'AT10','AT20','AT30','AT60','AT90','AORT','AORX','CDF','CFTC','CNTC','CTEM',
                              'DNPH','DPHZ','DSOZ','ECGR','ED','GDEV','GR','GR_EDTC','GTEM','HCAL',
                              'HDRA','HDRB','HGR','HMIN','HMNO','HNPO','HPRA','HTNP','ND','NPHI','NPOR',
                              'PEFZ','PXND_HILT','RHOZ','RSOZ','RWA_HILT','RXO8','RXOZ',
                              'STIT','TENS','TNPH','HTNP_SAN','ATCO10','ATCO20','ATCO30','ATCO60',
                              'ATCO90'],axis=1)
df_data_small.head(5)
#calling 1 column using index label to make a closer inspection
df_data['SP']
#change order of columns using pandas
df_data_columns=df_data_small[['SP','AO10','DCAL']]
df_data_columns
#change name of Columns
df_data_name=df_data_small.rename(columns={'SP':'Curve1','AO10':'Curve2'})
df_data_name
#lets look at the index, on this data frame we are using the first column "DEPT"
print(dfmain.index)
#to visually see how complete is the data and see if there are parameters with 
#missing data we can use this method

fig, ax = plt.subplots(figsize=(25,8))
sns.heatmap(dfmain.isnull(), ax=ax, cmap="magma")
plt.grid()
plt.show()<jupyter_output><empty_output><jupyter_text>Calculate Volume of shale (Vsh) from GR formula Vsh=(GR-GRmin)/(GRmax-GRmin)<jupyter_code>#Make operations with selected columns

dfmain['Vsh'] = dfmain['GR'] - min(dfmain['GR'])/(max(dfmain['GR'])- min(dfmain['GR']))
dfmain['Vsh'].describe()<jupyter_output><empty_output><jupyter_text>Read Thermal conductivity and mineralogy data measured in drill cuttings. CAUTION: Depths are in meters, need to be converted to feet Full report https://ugspub.nr.utah.gov/publications/misc_pubs/mp-169/mp-169-l.pdf<jupyter_code>#We can use Pandas to read a .csv file Thermal Conductivity lab data

TC_coredata = pd.read_csv ('../alldata/58-32_thermal_conductivity_data.csv') 

#we can use the operations to make units conversions and 
#substitute the columns with the new converted units.
#for example changing from ft to meters in the core data.

TC_coredata['Depth'] = (3.28084*TC_coredata['Lower Depth Interval (m)'])
TC_coredata['Matrix_TC']=TC_coredata['matrix thermal conductivity (W/m deg C)']
TC_coredata.set_index('Depth', inplace=True)

#XRD mineralogy lab data
XRD_coredata = pd.read_csv ('../alldata/58-32_xray_diffraction_data.csv') 
XRD_coredata = XRD_coredata.replace('tr',0)
XRD_coredata['Depth'] = (3.28084*XRD_coredata['Lower Depth Range (m)'])
XRD_coredata.set_index('Depth', inplace=True)

TC_coredata.tail(8)<jupyter_output><empty_output><jupyter_text>Create a function that would create a layout with basic logs and core data<jupyter_code>#basic plot to inspect data 
def make_layout_tc (log_df, XRD, TC):
    
    import numpy as np
    import pandas as pd
    import matplotlib
    import matplotlib.pyplot as plt
  
    fig, axs = plt.subplots(nrows=1, ncols=5, sharey=True, squeeze=True, figsize=(15, 15), gridspec_kw={'wspace': 0.25})
    fig.subplots_adjust(left=0.05, bottom=0.05, right=0.975, top=0.7, wspace=0.2, hspace=0.2)
    axs[0].set_ylabel('Depth (ft)')
    axs[0].invert_yaxis()
    axs[0].get_xaxis().set_visible(False)
    
    # First track GR/SP logs to display
    ax1 = axs[0].twiny()  
    ax1.plot(log_df.GR, log_df.index, '-', color='#2ea869', linewidth=0.5)
    ax1.set_xlim(0,450) 
    ax1.set_xlabel('GR (API)', color='#2ea869')
    ax1.minorticks_on()
    ax1.spines['top'].set_position(('axes', 1.075)) 
    
    ax2 = axs[0].twiny() 
    ax2.plot(log_df.SP, log_df.index, '-', color='#0a0a0a', linewidth=0.7)
    ax2.set_xlim(-200,200) 
    ax2.set_xlabel('SP(mV)', color='#0a0a0a')
    ax2.minorticks_on()
    ax2.spines['top'].set_position(('axes', 1.0))    
    ax2.grid(True)
    axs[0].get_xaxis().set_visible(False)
    
    # Second track RHOZ/NPHI logs to display
    ax1 = axs[1].twiny()  
    ax1.plot(log_df.RHOZ, log_df.index, '-', color='#ea0606', linewidth=0.5)
    ax1.set_xlim(1.5,3.0) 
    ax1.set_xlabel('RHOZ (g/cm3)', color='#ea0606')
    ax1.minorticks_on()
    ax1.spines['top'].set_position(('axes', 1.075))

    ax2 = axs[1].twiny()  
    ax2.plot(log_df.NPHI, log_df.index, '-', color='#1577e0', linewidth=0.5)
    ax2.set_xlim(1,0) 
    ax2.set_xlabel('NPHI (v/v)', color='#1577e0')
    ax2.minorticks_on()
    ax2.spines['top'].set_position(('axes', 1.0))
    ax2.grid(True)
    axs[1].get_xaxis().set_visible(False)
    
    # Third track Resistivities
    ax1 = axs[2].twiny()  
    ax1.plot(log_df.AT10, log_df.index, '-', color='#6e787c', linewidth=0.5)
    ax1.set_xlim(0.1,100000)  
    ax1.set_xlabel('AT10 (ohm.m)', color='#6e787c')
    ax1.set_xscale('log')
    ax1.minorticks_on()
    ax1.spines['top'].set_position(('axes', 1.075))
    
    ax2 = axs[2].twiny()  
    ax2.plot(log_df.AT90, log_df.index, '-', color='#ea0606', linewidth=0.5)
    ax2.set_xlim(0.1,100000)  
    ax2.set_xlabel('AT90 (ohm.m)', color='#ea0606')
    ax2.set_xscale('log')
    ax2.minorticks_on()
    ax2.spines['top'].set_position(('axes', 1.0))
    ax2.grid(True)
    axs[2].get_xaxis().set_visible(False)


  # Fourth track XRD to display
    ax1 = axs[3].twiny()  
    ax1.plot(XRD.Quartz, XRD.index, 'o', color='#eac406')
    ax1.set_xlim(0,50) 
    ax1.set_xlabel('Quartz %', color='#eac406')
    ax1.minorticks_on()
    ax1.spines['top'].set_position(('axes', 1.075))
    
    ax2 = axs[3].twiny()  
    ax2.plot(XRD['Illite'], XRD.index, 'o', color='#94898c')
    ax2.set_xlim(0,50) 
    ax2.set_xlabel('Illite %', color='#94898c')
    ax2.minorticks_on()
    ax2.spines['top'].set_position(('axes', 1.0))
    ax2.grid(True)
    axs[3].get_xaxis().set_visible(False)


    # Fifth track Temp/TC to display
    ax1 = axs[4].twiny()  
    ax1.plot(TC.Matrix_TC, TC.index, 'o', color='#6e787c')
    ax1.set_xlim(0,5) 
    ax1.set_xlabel('Matrix TC Measured W/mC', color='#6e787c')
    ax1.minorticks_on()
    ax1.spines['top'].set_position(('axes', 1.075))

    ax2 = axs[4].twiny()  
    ax2.plot(log_df.CTEM, log_df.index, '-', color='#ed8712')
    ax2.set_xlim(0,300) 
    ax2.set_xlabel('Temp degF', color='#ed8712')
    ax2.minorticks_on()
    ax2.spines['top'].set_position(('axes', 1.0))
    ax2.grid(True)
    axs[4].get_xaxis().set_visible(False)
         
    fig.suptitle('Well Data for UTAH FORGE 58-32',weight='bold', fontsize=20, y=0.85);
    plt.show()

make_layout_tc (dfmain, XRD_coredata, TC_coredata)<jupyter_output><empty_output><jupyter_text>Using Seaborn we will visualized the distribution and some statistict of basic logs<jupyter_code>#below we are building a data frame with selected columns from the file we have read
X=dfmain[['GR','SP', 'RHOZ','NPHI','AT10', 'AT90', 'CTEM']]
#plottign the statistic using Seaborn
color = ['#2ea869', '#0a0a0a', '#ea0606','#1577e0', '#6e787c','#ea0606', 
         '#ed8712']
sns.set(font_scale=1)
cols = X.columns
n_row = len(cols)
n_col = 2
n_sub = 1
fig = plt.figure(figsize=(10,20))
for i in range(len(cols)):
    plt.subplots_adjust(left=-0.3, right=1.3, bottom=-0.3, top=1.3)
    plt.subplot(n_row, n_col, n_sub)
    sns.distplot(X[cols[i]],norm_hist=False,kde=False, color=color[i],
                 label=['mean '+str('{:.2f}'.format(X.iloc[:,i].mean()))
                        +'\n''std '+str('{:.2f}'.format(X.iloc[:,i].std()))
                        +'\n''min '+str('{:.2f}'.format(X.iloc[:,i].min()))
                        +'\n''max '+str('{:.2f}'.format(X.iloc[:,i].max()))])                                                        
    n_sub+=1
    plt.legend()
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1603577371048253, 'fraction_numerical': 0.04586106489184692, 'mean_word_length': 4.1018567639257295, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '638879', 'license': 'CC0-1.0', 'n_tokens_mistral': 3888, 'n_tokens_neox': 3658, 'n_words': 735, 'path': 'notebooks/.ipynb_checkpoints/Tutorial_pyhton_transform21_UtahForge_58-32_well-Copy1-checkpoint.ipynb', 'repo_name': 'mariabravosegnini/Tutorial_Transform_2021', 'size': '9641'}