Skip to content

Commit

Permalink
Reading for release v0.12.0
Browse files Browse the repository at this point in the history
  • Loading branch information
snakesonabrain committed Mar 30, 2024
1 parent 00be5d8 commit 059e15d
Show file tree
Hide file tree
Showing 9 changed files with 402 additions and 72 deletions.
19 changes: 18 additions & 1 deletion groundhog/general/parameter_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,24 @@
'API relative density description': 'api_relativedensity',
'Limiting unit skin friction [kPa]': 'fs_lim',
'Limiting unit end bearing [kPa]': 'qb_lim',
'Tension modifier [-]': 'tension_modifier'
'Tension modifier [-]': 'tension_modifier',
'Borehole diameter [mm]': 'borehole_diameter',
'Rod length [m]': 'rod_length',
'Country': 'country',
'Hammer type': 'hammertype',
'Hammer release': 'hammerrelease',
'Sampler type': 'samplertype',
'Vertical total stress [kPa]': 'sigma_vo',
'Vertical effective stress [kPa]': 'sigma_vo_eff',
'N [-]': 'N',
'N1_60 [-]': 'N1_60',
'eta H [%]': 'eta_H',
'eta B [-]': 'eta_B',
'eta S [-]': 'eta_S',
'eta R [-]': 'eta_R',
'd50 [mm]': 'd_50',
'N60 [-]': 'N_60',
'Granular': 'granular'
}

def map_depth_properties(target_df, layering_df, target_z_key=None,
Expand Down
2 changes: 0 additions & 2 deletions groundhog/siteinvestigation/insitutests/pcpt_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1702,8 +1702,6 @@ def apply_correlation(self, name, outputs, apply_for_soiltypes='all', **kwargs):
:return: Adds a column with key `outkey` to the dataframe with PCPT data
"""



for resultkey in outputs:
header = outputs[resultkey]
if header in self.data.columns:
Expand Down
342 changes: 307 additions & 35 deletions groundhog/siteinvestigation/insitutests/spt_correlations.py

Large diffs are not rendered by default.

43 changes: 29 additions & 14 deletions groundhog/siteinvestigation/insitutests/spt_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# Project imports
from groundhog.general.plotting import plot_with_log, GROUNDHOG_PLOTTING_CONFIG
from groundhog.general.parameter_mapping import map_depth_properties, merge_two_dicts, reverse_dict
from groundhog.general.parameter_mapping import SOIL_PARAMETER_MAPPING, merge_two_dicts, reverse_dict
from groundhog.siteinvestigation.insitutests.spt_correlations import *
from groundhog.siteinvestigation.insitutests.pcpt_processing import InsituTestProcessing
from groundhog.general.soilprofile import SoilProfile, plot_fence_diagram
Expand All @@ -29,7 +29,7 @@
'Hammer type': ['Safety', ],
'Hammer release': ['Rope and pulley',],
'Sampler type': ['Standard sampler', ],
'eta H [-]': [np.nan,],
'eta H [%]': [np.nan,],
'eta B [-]': [np.nan,],
'eta S [-]': [np.nan,],
'eta R [-]': [np.nan,]
Expand Down Expand Up @@ -226,38 +226,53 @@ def map_properties(self, layer_profile, spt_profile=DEFAULT_SPT_PROPERTIES,

# region Correlations

def apply_correlation(self, name, outkey, resultkey, apply_for_soiltypes='all', **kwargs):
def apply_correlation(self, name, outputs, apply_for_soiltypes='all', **kwargs):
"""
Applies a correlation to the given SPT data. The name of the correlation needs to be chosen from the following available correlations.
Each correlation corresponds to a function in the `spt_correlations` module.
By default, the correlation is applied to the entire depth range. However, a restriction on the soil
types to which the correlation can be applied can be specified with the `apply_for_soiltypes` keyword argument.
A list with the soil types for which the correlation needs to be applied can be provided.
- Overburden correction Liao and Whitman (1986) (`overburdencorrection_spt_liaowhitman`) - Calculation of overburden correction according to Liao & Whitman (1986)
- N60 correction (`spt_N60_correction`) - Correction of measured SPT N number to an equivalent N60 at energy ratio of 60%
- Overburden correction Liao and Whitman (1986): `overburdencorrection_spt_liaowhitman`,
- Overburden correction ISO 22476-3: `overburdencorrection_spt_ISO`
- N60 correction: `spt_N60_correction`
- Relative density Kulhawy and Mayne (1990): `relativedensity_spt_kulhawymayne`
- Relative density class Terzaghi and Peck (1967): `relativedensityclass_spt_terzaghipeck`
- Undrained shear strength class Terzaghi and Peck (1967): `undrainedshearstrengthclass_spt_terzaghipeck`
- Undrained shear strength Salgado (2008): `undrainedshearstrength_spt_salgado`
- Friction angle Kulhawy and Mayne (1990): `frictionangle_spt_kulhawymayne`
- Friction angle PHT (1974): `frictionangle_spt_PHT`
Note that certain correlations require either the application of preceding correlations
:param name: Name of the correlation according to the list defined above
:param outkey: Key used to the output column
:param resultkey: Key of the output dictionary of the correlation to be used
:param outputs: a dict of keys and values where keys are the same as the keys in the correlation, values are the table headers you want
:param apply_for_soiltypes: List with soil types to which the correlation needs the be applied.
:param kwargs: Optional keyword arguments for the correlation.
:return: Adds a column with key `outkey` to the dataframe with SPT data
"""

if outkey in self.data.columns:
self.data.drop(outkey, axis=1, inplace=True)
for resultkey in outputs:
header = outputs[resultkey]
if header in self.data.columns:
self.data.drop(header, axis=1, inplace=True)

self.data.rename(columns=SOIL_PARAMETER_MAPPING, inplace=True)

self.data.rename(columns=SPT_KEY_MAPPING, inplace=True)
for i, row in self.data.iterrows():
if apply_for_soiltypes == 'all' or row['Soil type'] in apply_for_soiltypes:
params = merge_two_dicts(kwargs, dict(row))
self.data.loc[i, outkey] = CORRELATIONS[name](**params)[resultkey]
results = CORRELATIONS[name](**params)
for resultkey in outputs:
header = outputs[resultkey]
self.data.loc[i, header] = results[resultkey]
else:
self.data.loc[i, outkey] = np.nan
self.data.rename(columns=reverse_dict(SPT_KEY_MAPPING), inplace=True)
for resultkey in outputs:
header = outputs[resultkey]
self.data.loc[i, header] = np.nan

self.data.rename(columns=reverse_dict(SOIL_PARAMETER_MAPPING), inplace=True)
# endregion

def plot_raw_spt(self, n_range=(0, 100), n_tick=10, z_range=None, z_tick=2,
Expand Down
6 changes: 3 additions & 3 deletions notebooks/Tutorial - SPT data processing with Groundhog.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@
"metadata": {
"hide_input": false,
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -449,7 +449,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
"version": "3.10.9"
},
"toc": {
"base_numbering": 1,
Expand All @@ -466,5 +466,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
Binary file modified tests/siteinvestigation/insitutests/data/output_pcpt.xlsx
Binary file not shown.
Binary file modified tests/siteinvestigation/insitutests/data/spt_example_layering.xlsx
Binary file not shown.
36 changes: 29 additions & 7 deletions tests/siteinvestigation/insitutests/test_spt_correlations.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_spt_N60_correction(self):
hammertype='Donut',
hammerrelease='Rope and pulley'
)
self.assertEqual(result['eta_H [pct]'], 45)
self.assertEqual(result['eta_H [%]'], 45)
self.assertEqual(result['eta_B [-]'], 1)
self.assertEqual(result['eta_S [-]'], 1)
self.assertEqual(result['eta_R [-]'], 0.85)
Expand All @@ -50,24 +50,24 @@ def test_spt_N60_correction(self):
eta_H=50,
fail_silently=False
)
self.assertEqual(result['eta_H [pct]'], 50)
self.assertEqual(result['eta_H [%]'], 50)
self.assertEqual(result['eta_B [-]'], 1)
self.assertEqual(result['eta_S [-]'], 1)
self.assertEqual(result['eta_R [-]'], 0.85)

def test_relativedensity_spt_kulhawymayne(self):
result = spt_correlations.relativedensity_spt_kulhawymayne(
N_1_60=30,
N1_60=30,
d_50=0.2
)
self.assertAlmostEqual(result['Dr [pct]'], 83.99, 2)
result = spt_correlations.relativedensity_spt_kulhawymayne(
N_1_60=6,
N1_60=6,
d_50=0.2
)
self.assertAlmostEqual(result['Dr [pct]'], 37.56, 2)
result = spt_correlations.relativedensity_spt_kulhawymayne(
N_1_60=30,
N1_60=30,
d_50=0.2,
ocr=10
)
Expand All @@ -76,13 +76,13 @@ def test_relativedensity_spt_kulhawymayne(self):
def test_undrainedshearstrength_spt_salgado(self):
result = spt_correlations.undrainedshearstrength_spt_salgado(
N_60=30,
plasticity_index=30,
pi=30,
fail_silently=False
)
self.assertAlmostEqual(result['Su [kPa]'], 135, 1)
result = spt_correlations.undrainedshearstrength_spt_salgado(
N_60=2,
plasticity_index=60,
pi=60,
fail_silently=False
)
self.assertAlmostEqual(result['Su [kPa]'], 8.6, 1)
Expand All @@ -100,3 +100,25 @@ def test_frictionangle_spt_kulhawymayne(self):
fail_silently=False
)
self.assertAlmostEqual(result['Phi [deg]'], 36.5, 1)

def test_relativedensityclass_spt_terzaghipeck(self):
result = spt_correlations.relativedensityclass_spt_terzaghipeck(N=25, fail_silently=False)
self.assertEqual(result['Dr class'], "Medium dense")

def test_overburdencorrection_spt_ISO(self):
result = spt_correlations.overburdencorrection_spt_ISO(N=25, sigma_vo_eff=98)
self.assertEqual(result['N1 [-]'], 25)

def test_frictionangle_spt_PHT(self):
result = spt_correlations.frictionangle_spt_PHT(N1_60=25)
self.assertAlmostEqual(result['Phi [deg]'], 34.3, 1)

def test_youngsmodulus_spt_AASHTO(self):
result = spt_correlations.youngsmodulus_spt_AASHTO(N1_60=25, soiltype='Coarse sands')
self.assertAlmostEqual(result['Es [MPa]'], 25, 1)

def test_undrainedshearstrengthclass_spt_terzaghipeck(self):
result = spt_correlations.undrainedshearstrengthclass_spt_terzaghipeck(N=5)
self.assertEqual(result['Consistency class'], 'Medium')
self.assertEqual(result['qu min [kPa]'], 50)
self.assertEqual(result['qu max [kPa]'], 100)
26 changes: 16 additions & 10 deletions tests/siteinvestigation/insitutests/test_spt_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,13 @@ def test_spt_overburdencorrection(self):
self.pandas_spt.map_properties(layer_profile=layers)
self.pandas_spt.apply_correlation(
name='Overburden correction Liao and Whitman (1986)',
outkey='N1 [-]',
resultkey='N1 [-]'
outputs={'N1 [-]': 'N1 [-]', 'CN [-]': 'CN [-]'}
)
self.assertAlmostEqual(self.pandas_spt.data['N1 [-]'].iloc[0], 20.5, 1)

self.assertAlmostEqual(self.pandas_spt.data['N1 [-]'].iloc[0], 7, 1)
self.assertAlmostEqual(self.pandas_spt.data['N1 [-]'].iloc[1], 12.6, 1)
self.assertAlmostEqual(self.pandas_spt.data['CN [-]'].iloc[0], 1, 1)


def test_spt_N60correction(self):
"""
Expand All @@ -99,8 +102,7 @@ def test_spt_N60correction(self):
self.pandas_spt.map_properties(layer_profile=layers)
self.pandas_spt.apply_correlation(
name='N60 correction',
outkey='N60 [-]',
resultkey='N60 [-]'
outputs={'N60 [-]': 'N60 [-]'}
)
self.assertAlmostEqual(self.pandas_spt.data['N60 [-]'].iloc[0], 7 * 60 * 1 * 1 * 0.75 / 60, 1)
self.assertAlmostEqual(self.pandas_spt.data['N60 [-]'].iloc[-1], 53 * 60 * 1 * 1 * 1 / 60, 1)
Expand All @@ -115,14 +117,19 @@ def test_spt_N60correction_custom(self):
self.test_pandas_spt_creation()

spt_custom_props = spt_processing.DEFAULT_SPT_PROPERTIES
spt_custom_props['eta H [-]'].iloc[0] = 50
spt_custom_props['eta H [%]'].iat[0] = 50

self.pandas_spt.map_properties(layer_profile=layers, spt_profile=spt_custom_props)

self.pandas_spt.apply_correlation(
name='N60 correction',
outkey='N60 [-]',
resultkey='N60 [-]'
outputs={'N60 [-]': 'N60 [-]',
'eta_H [-]': 'eta H [-]',
'eta_B [-]': 'eta B [-]',
'eta_S [-]': 'eta S [-]',
'eta_R [-]': 'eta R [-]'}
)

self.assertAlmostEqual(self.pandas_spt.data['N60 [-]'].iloc[0], 7 * 50 * 1 * 1 * 0.75 / 60, 1)
self.assertAlmostEqual(self.pandas_spt.data['N60 [-]'].iloc[-1], 53 * 50 * 1 * 1 * 1 / 60, 1)

Expand All @@ -139,8 +146,7 @@ def test_spt_N60correction_withNaNs(self):
self.pandas_spt.map_properties(layer_profile=layers)
self.pandas_spt.apply_correlation(
name='N60 correction',
outkey='N60 [-]',
resultkey='N60 [-]'
outputs={'N60 [-]': 'N60 [-]'}
)
self.assertTrue(np.math.isnan(self.pandas_spt.data['N60 [-]'].iloc[2]))

0 comments on commit 059e15d

Please sign in to comment.