From ce8807c7221638a98ef217800d8fa10570cf6481 Mon Sep 17 00:00:00 2001 From: pedromorgan Date: Fri, 31 May 2019 22:18:37 +0100 Subject: [PATCH] make it inportable --- .gitignore | 3 ++ README.md | 8 ++-- calcs.py | 116 ++++++++++++++++++++++++++++++------------------- raw_grapher.py | 1 + sbt_index.py | 5 +++ 5 files changed, 85 insertions(+), 48 deletions(-) diff --git a/.gitignore b/.gitignore index 894a44c..404ec8d 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,6 @@ venv.bak/ # mypy .mypy_cache/ + +# Editors +.idea/ diff --git a/README.md b/README.md index a24e76a..485278a 100644 --- a/README.md +++ b/README.md @@ -6,17 +6,17 @@ Reference Book on CPT techniques and analysis: T. Lunne , J.J.M Powell, P.K. Rob Three Python scripts have been created to perform the calculations and data visualisation based on the techniques provided by Lunne et al and according to Geotechnical industry practice (British Standard: BS EN ISO 22476-1:2012) -The Raw data is loaded into Python from *.xls files*, with four columns of data representing the required datasets. The first row of each of the columns saved within the excel files assumes a header with the standard [AGS4](https://www.ags.org.uk/) headers. +The Raw data is loaded into Python from `.xls` files, with four columns of data representing the required datasets. The first row of each of the columns saved within the excel files assumes a header with the standard [AGS4](https://www.ags.org.uk/) headers. 1) Test Depth (SCPT_DPTH). 2) Tip Resistance (SCPT_RES). 3) Cone Sleeve Friction (SCPT_FRES). 4) Measured Pore Pressure (U2 position, behind the tip) (SCPT_PWP2). Calculations: - This is performed within the *calcs.py* script. The user should satisfy themselves that the assumptions used for the calculations are repreentative of the ground conditions. + This is performed within the `calcs.py` script. The user should satisfy themselves that the assumptions used for the calculations are repreentative of the ground conditions. Graphing: -The *raw_grapher.py* script has been setup to import the requried parameters for producing the standard tip resistance, sleeve friction and pore pressure plots. The resuting plots will be saved as a *.png file* within the specified root folder. +The `raw_grapher.py` script has been setup to import the requried parameters for producing the standard tip resistance, sleeve friction and pore pressure plots. The resuting plots will be saved as a *.png file* within the specified root folder. Soil Behaviour Type Index: -The *sbt_index.py* script reads the calculated *Ic - Soil Behavior Type Index* arrays and plots the data with the representative descriptions based on the industry standard guidance and Lunne et al. Two plots are saved as a *.png file* within the specified root folder, illustrating the test trace as well as an _interpreted_ soil column. +The `sbt_index.py` script reads the calculated *Ic - Soil Behavior Type Index* arrays and plots the data with the representative descriptions based on the industry standard guidance and Lunne et al. Two plots are saved as a *.png file* within the specified root folder, illustrating the test trace as well as an _interpreted_ soil column. diff --git a/calcs.py b/calcs.py index a6b3f22..afe6087 100644 --- a/calcs.py +++ b/calcs.py @@ -1,45 +1,73 @@ -import pandas as pd +# -*- coding: utf-8 -*- + import numpy as np -from tkinter import Tk -from tkinter.filedialog import askopenfilename -########################################################################################################################################################################## -Tk().withdraw() -file = askopenfilename(filetypes=[('EXCEL Files','*.xls')]) -data_source = pd.read_excel(file,header=0,true_values=True) -#data_source -########################################################################################################################################################################## -#Data_Source -z = data_source['SCPT_DPTH'] #Depth -qc = data_source['SCPT_RES'] #Cone Resistance -fs = data_source['SCPT_FRES'] #Sleeve Friction -u2 = data_source['SCPT_PWP2'] #U2 pore pressure -########################################################################################################################################################################## -#Assumptions -title = 'CPT01' #CPT test number -gwl = 3.5 #ground water level -soil_den = 18 #soil density -max_depth = 30 #Maximum depth to display plots -########################################################################################################################################################################## -#Calculations -u0 = [0] #Hydrostatic water pressure -for i in np.arange(len(z)): - if z[i] < gwl: - u0.append(0) - elif z[i] > gwl: - u0.append((z[i] - gwl)*10) - -udl = (u2 - u0) #U_delta -sig_vo = z * soil_den #Total Vertical Stress -sig1_vo = sig_vo - u0 #Effective Vertical Stress -np.seterr(divide='ignore') #Ignore math errors -Rf = (fs/qc) * 100 #Friction Ratio -qt = (qc*1000) + (0.21+u2) #qt kPa -qn = qt - sig_vo #net qc -Bq = udl/(qn) #Pore pressure ratio -qtm = qt/1000 #qt MPa -Su_15 = qn / 15 #Su Nkt = 15 -Su_15 = qn / 20 #Su Nkt = 20 -qt_norm = qn / sig1_vo #normalised qc -fr_norm = ((fs * 1000) / qn) * 100 #normalised fs -ic = np.sqrt(np.power(((3.47-(np.log10(qc/0.1)))),2) + np.power(((np.log10(Rf)+1.22)),2)) #Soil Behaviour Type Index -########################################################################################################################################################################## \ No newline at end of file + +class CPTViz: + + def __init__(self, z=None, qc=None, fs=None, u2=None, + title='CPT01', # CPT test number + gwl = 3.5, # ground water level + soil_den = 18, # soil density + max_depth = 30 # Maximum depth to display plots + ): + + # Hydrostatic water pressure + u0 = [0] + for i in np.arange(len(z)): + if z[i] < gwl: + u0.append(0) + elif z[i] > gwl: + u0.append((z[i] - gwl)*10) + + # U_delta + self.udl = (u2 - u0) + + # Total Vertical Stress + sig_vo = z * soil_den + + # Effective Vertical Stress + sig1_vo = sig_vo - u0 + + np.seterr(divide='ignore') # Ignore math errors + + # Friction Ratio + Rf = (fs/qc) * 100 + + # qt kPa + qt = (qc * 1000) + (0.21 + u2) + + # net qc + qn = qt - sig_vo + + # Pore pressure ratio + self.Bq = self.udl / (qn) + + # qt MPa + qtm = qt / 1000 + + Su_15 = qn / 15 #Su Nkt = 15 + Su_15 = qn / 20 #Su Nkt = 20 + + # normalised qc + qt_norm = qn / sig1_vo + + # normalised fs + fr_norm = ((fs * 1000) / qn) * 100 + + # Soil Behaviour Type Index + self.ic = np.sqrt(np.power(((3.47-(np.log10(qc/0.1)))),2) + np.power(((np.log10(Rf)+1.22)),2)) + + @property + def pore_pressure_ratio(self): + return self.udl / (qn) + +# def read_data_source(): +# Tk().withdraw() +# file = askopenfilename(filetypes=[('EXCEL Files','*.xls')]) +# data_source = pd.read_excel(file,header=0,true_values=True) +# +# +# z = data_source['SCPT_DPTH'] #Depth +# qc = data_source['SCPT_RES'] #Cone Resistance +# fs = data_source['SCPT_FRES'] #Sleeve Friction +# u2 = data_source['SCPT_PWP2'] #U2 pore pressure \ No newline at end of file diff --git a/raw_grapher.py b/raw_grapher.py index 2cc7727..694b507 100644 --- a/raw_grapher.py +++ b/raw_grapher.py @@ -1,5 +1,6 @@ import matplotlib.pyplot as plt from calcs import max_depth, z, qc, fs, u2, u0, Rf, Bq + ########################################################################################################################################################################## #Initialise Figures fig = plt.figure(1,figsize=(20,20),dpi=300) diff --git a/sbt_index.py b/sbt_index.py index f41a068..029b299 100644 --- a/sbt_index.py +++ b/sbt_index.py @@ -1,7 +1,12 @@ +# -*- coding: utf-8 -*- + import numpy as np import matplotlib.pyplot as plt import matplotlib.patches as mpatches + from calcs import ic, max_depth, z + + ########################################################################################################################################################################## #Check Soil Behaviour Type sbt = []