Skip to content

Commit 2254fd0

Browse files
josteinlCamelia Dominguez Quintans
andauthored
Add Weight Sounding Test (WST) (#11)
* Dissipation test HM = 35 addition * Dissipation test HM = 35 addition 2 * Dissipation test HM = 35 addition 3 * Dissipation test HM = 35 addition 4 * Work in progress. Checking in for backup. Start on WST * Add missing import Bump version to 0.0.1a3 * Extend MethodWST Ran ruff formatting Fix wrong default type for predrilling_depth (int -> Decimal) Add test * Update the lock file * Update the lock file. Add The Unlicense license to accepted ones. --------- Co-authored-by: Camelia Dominguez Quintans <camelia.dominguez.quintans@ngi.no>
1 parent e8b98b5 commit 2254fd0

14 files changed

Lines changed: 1157 additions & 311 deletions

File tree

.github/workflows/branch.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ jobs:
5151
- name: Run bandit
5252
run: poetry run bandit .
5353
- name: Run safety
54-
run: poetry run safety check -i 62044 -i 70612
54+
run: poetry run safety check -i 70612
5555
- name: Check for acceptable licenses
56-
run: poetry run pip-licenses --allow-only="MIT License;BSD License;Python Software Foundation License;Apache Software License;Mozilla Public License 2.0 (MPL 2.0);ISC License (ISCL)"
56+
run: poetry run pip-licenses --allow-only="MIT License;BSD License;Python Software Foundation License;Apache Software License;Mozilla Public License 2.0 (MPL 2.0);ISC License (ISCL);The Unlicense (Unlicense)"

CHANGES.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
# NGI Python SGF Parser Package
22

3+
_2024-07-29_
4+
5+
Version 0.0.1b2
6+
7+
Support Weight Sounding Test (WST) (Swedish Viktsondering)
8+
39
_2024-06-21_
410

511
Version 0.0.1b1
612

713
Update packages.
814

15+
916
_2024-05-22_
1017

1118
Version 0.0.1a2

poetry.lock

Lines changed: 331 additions & 303 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ exclude = '''
1515

1616
[tool.poetry]
1717
name = "sgf-parser"
18-
version = "0.0.1b1"
18+
version = "0.0.1b2"
1919
description = "Parser for the Swedish Geotechnical Society / Svenska Geotekniska Föreningen (SGF) data format"
2020
license = "MIT"
2121
authors = ["Jostein Leira <jostein@leira.net>"]
@@ -58,7 +58,7 @@ no_implicit_reexport = false
5858

5959
[tool.poetry.dependencies]
6060
python = ">=3.11,<4"
61-
pydantic = "^2.6.3"
61+
pydantic = "^2.7.1"
6262
python-dateutil = "^2.9.0.post0"
6363
types-python-dateutil = "^2.8.19.20240311"
6464

@@ -71,6 +71,8 @@ bandit = "*"
7171
safety = "*"
7272
pip-licenses = "*"
7373
ruff = "*"
74+
# Pinned due to problem with unpinned ruamel-yaml subdependency ruamel-yaml-clib not able to install on windows
75+
ruamel-yaml-clib={platform = "win32", version = "<0.2.6"}
7476

7577
[build-system]
7678
requires = ["poetry-core>=1.0.0"]

src/sgf_parser/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from sgf_parser.parser import Parser
1+
from sgf_parser.parser import Parser

src/sgf_parser/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
from sgf_parser.models.method_srs import MethodSRS, MethodSRSData
99
from sgf_parser.models.method_svt import MethodSVT, MethodSVTData
1010
from sgf_parser.models.method_tot import MethodTOT, MethodTOTData
11+
from sgf_parser.models.method_wst import MethodWST, MethodWSTData

src/sgf_parser/models/method.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ def guess_date_format(cls, data: Any) -> Any:
355355
serial_number: str | None = Field(None, alias="HC")
356356

357357
# "HO": "predrilling_depth",
358-
predrilling_depth: Decimal = Field(0, alias="HO")
358+
predrilling_depth: Decimal = Field(Decimal("0"), alias="HO")
359359

360360
# "HQ": "conducted_by",
361361
conducted_by: str | None = Field(None, alias="HQ")

src/sgf_parser/models/method_dt.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from decimal import Decimal
22
from typing import Literal
33

4-
from pydantic import Field
4+
from pydantic import Field, computed_field
55

66
from sgf_parser.models import MethodType, MethodData, Method
77

@@ -18,6 +18,7 @@ def __init__(self, **kwargs):
1818
u2: Decimal | None = Field(None, alias="AG", description="Shoulder pressure (kPa)")
1919
depth: Decimal | None = Field(None, alias="D", description="Depth (m)")
2020

21+
2122
class MethodDT(Method):
2223
"""
2324
Method Pore Pressure Dissipation Test (placeholder)
@@ -30,4 +31,20 @@ def __init__(self, **kwargs):
3031
method_type: Literal[MethodType.DT] = MethodType.DT
3132
method_data_type: type[MethodDTData] = MethodDTData
3233

33-
method_data: list[MethodDTData] = []
34+
method_data: list[MethodDTData] = []
35+
36+
@computed_field
37+
def stopcode(self) -> int | None:
38+
if not self.method_data:
39+
return None
40+
41+
return self.method_data[-1].comment_code
42+
43+
def post_processing(self):
44+
"""
45+
Post-processing
46+
47+
"""
48+
49+
if not self.method_data:
50+
return
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
from decimal import Decimal
2+
from typing import Literal, Any
3+
4+
from pydantic import Field, model_validator, computed_field
5+
6+
from sgf_parser.models import MethodData, Method, MethodType
7+
from sgf_parser.models.types import Operation
8+
9+
10+
class MethodWSTData(MethodData):
11+
"""
12+
Weight Sounding Test (Swedish Viktsondering) Data
13+
"""
14+
15+
def __init__(self, **kwargs):
16+
super().__init__(**kwargs)
17+
18+
depth: Decimal = Field(..., alias="D", description="Depth (m)")
19+
turning: Decimal = Field(..., alias="H", description="Turning (half revolution/0.2 m)")
20+
load: Decimal = Field(..., alias="W", description="Load (kN)")
21+
penetration_rate: Decimal | None = Field(None, alias="B", description="Penetration rate (mm/s)")
22+
23+
hammering: bool | None = Field(None, alias="AP")
24+
rotation_rate: Decimal | None = Field(None, alias="R", description="Rotation rate (rpm)")
25+
26+
27+
class MethodWST(Method):
28+
"""
29+
Weight Sounding Test (Swedish Viktsondering)
30+
"""
31+
32+
def __init__(self, **kwargs):
33+
super().__init__(**kwargs)
34+
35+
name: str = "WST"
36+
method_type: Literal[MethodType.WST] = MethodType.WST
37+
method_data_type: type[MethodWSTData] = MethodWSTData
38+
39+
operation: Operation = Operation.MECHANICAL
40+
41+
method_data: list[MethodWSTData] = []
42+
43+
@computed_field
44+
def depth_top(self) -> Decimal | None:
45+
if not self.method_data:
46+
return None
47+
48+
return min(method_data.depth for method_data in self.method_data)
49+
50+
@computed_field
51+
def depth_base(self) -> Decimal | None:
52+
if not self.method_data:
53+
return None
54+
55+
return max(method_data.depth for method_data in self.method_data)
56+
57+
@model_validator(mode="before")
58+
@classmethod
59+
def set_operation(cls, data: Any) -> Any:
60+
if isinstance(data, dict):
61+
if "HM" in data and data["HM"] is not None:
62+
data["operation"] = {
63+
"101": Operation.MANUAL,
64+
"102": Operation.MECHANICAL,
65+
}[data["HM"]]
66+
67+
return data

src/sgf_parser/models/types.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,12 @@ class SoundingClass(enum.StrEnum):
125125
JB2 = "Jb-2"
126126
JB3 = "Jb-3"
127127
JBTOT = "Jb-tot"
128+
129+
130+
class Operation(enum.StrEnum):
131+
"""
132+
Operation
133+
"""
134+
135+
MANUAL = "MANUAL"
136+
MECHANICAL = "MECHANICAL"

0 commit comments

Comments
 (0)