sgf-parser 0.0.1b4__tar.gz → 0.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sgf_parser-0.0.1b4 → sgf_parser-0.0.2}/PKG-INFO +3 -3
- {sgf_parser-0.0.1b4 → sgf_parser-0.0.2}/pyproject.toml +3 -3
- {sgf_parser-0.0.1b4 → sgf_parser-0.0.2}/src/sgf_parser/models/__init__.py +1 -0
- {sgf_parser-0.0.1b4 → sgf_parser-0.0.2}/src/sgf_parser/models/method.py +50 -4
- sgf_parser-0.0.2/src/sgf_parser/models/method_dp.py +102 -0
- {sgf_parser-0.0.1b4 → sgf_parser-0.0.2}/src/sgf_parser/models/method_srs.py +4 -2
- {sgf_parser-0.0.1b4 → sgf_parser-0.0.2}/src/sgf_parser/models/method_type.py +2 -1
- {sgf_parser-0.0.1b4 → sgf_parser-0.0.2}/src/sgf_parser/models/types.py +13 -0
- {sgf_parser-0.0.1b4 → sgf_parser-0.0.2}/src/sgf_parser/parser.py +14 -5
- {sgf_parser-0.0.1b4 → sgf_parser-0.0.2}/LICENSE +0 -0
- {sgf_parser-0.0.1b4 → sgf_parser-0.0.2}/README.md +0 -0
- {sgf_parser-0.0.1b4 → sgf_parser-0.0.2}/src/sgf_parser/__init__.py +0 -0
- {sgf_parser-0.0.1b4 → sgf_parser-0.0.2}/src/sgf_parser/datetime_parser.py +0 -0
- {sgf_parser-0.0.1b4 → sgf_parser-0.0.2}/src/sgf_parser/models/method_cpt.py +0 -0
- {sgf_parser-0.0.1b4 → sgf_parser-0.0.2}/src/sgf_parser/models/method_dt.py +0 -0
- {sgf_parser-0.0.1b4 → sgf_parser-0.0.2}/src/sgf_parser/models/method_rp.py +0 -0
- {sgf_parser-0.0.1b4 → sgf_parser-0.0.2}/src/sgf_parser/models/method_svt.py +0 -0
- {sgf_parser-0.0.1b4 → sgf_parser-0.0.2}/src/sgf_parser/models/method_tot.py +0 -0
- {sgf_parser-0.0.1b4 → sgf_parser-0.0.2}/src/sgf_parser/models/method_wst.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sgf-parser
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.2
|
|
4
4
|
Summary: Parser for the Swedish Geotechnical Society / Svenska Geotekniska Föreningen (SGF) data format
|
|
5
5
|
Home-page: https://github.com/norwegian-geotechnical-institute/sgf-parser
|
|
6
6
|
License: MIT
|
|
@@ -16,9 +16,9 @@ Classifier: Programming Language :: Python :: 3
|
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
18
|
Classifier: Topic :: Scientific/Engineering :: GIS
|
|
19
|
-
Requires-Dist: pydantic (>=2.
|
|
19
|
+
Requires-Dist: pydantic (>=2.8.2,<3.0.0)
|
|
20
20
|
Requires-Dist: python-dateutil (>=2.9.0.post0,<3.0.0)
|
|
21
|
-
Requires-Dist: types-python-dateutil (>=2.
|
|
21
|
+
Requires-Dist: types-python-dateutil (>=2.9,<3.0)
|
|
22
22
|
Project-URL: Repository, https://github.com/norwegian-geotechnical-institute/sgf-parser
|
|
23
23
|
Description-Content-Type: text/markdown
|
|
24
24
|
|
|
@@ -15,7 +15,7 @@ exclude = '''
|
|
|
15
15
|
|
|
16
16
|
[tool.poetry]
|
|
17
17
|
name = "sgf-parser"
|
|
18
|
-
version = "0.0.
|
|
18
|
+
version = "0.0.2"
|
|
19
19
|
description = "Parser for the Swedish Geotechnical Society / Svenska Geotekniska Föreningen (SGF) data format"
|
|
20
20
|
license = "MIT"
|
|
21
21
|
authors = ["Jostein Leira <jostein@leira.net>"]
|
|
@@ -58,9 +58,9 @@ no_implicit_reexport = false
|
|
|
58
58
|
|
|
59
59
|
[tool.poetry.dependencies]
|
|
60
60
|
python = ">=3.11,<4"
|
|
61
|
-
pydantic = "^2.
|
|
61
|
+
pydantic = "^2.8.2"
|
|
62
62
|
python-dateutil = "^2.9.0.post0"
|
|
63
|
-
types-python-dateutil = "^2.
|
|
63
|
+
types-python-dateutil = "^2.9"
|
|
64
64
|
|
|
65
65
|
|
|
66
66
|
[tool.poetry.group.dev.dependencies]
|
|
@@ -3,6 +3,7 @@ from sgf_parser.models.method_type import MethodType
|
|
|
3
3
|
from sgf_parser.models.types import StopCode, ParseState
|
|
4
4
|
from sgf_parser.models.method import Method, MethodData
|
|
5
5
|
from sgf_parser.models.method_cpt import MethodCPT, MethodCPTData
|
|
6
|
+
from sgf_parser.models.method_dp import MethodDP, MethodDPData
|
|
6
7
|
from sgf_parser.models.method_dt import MethodDT, MethodDTData
|
|
7
8
|
from sgf_parser.models.method_rp import MethodRP, MethodRPData
|
|
8
9
|
from sgf_parser.models.method_srs import MethodSRS, MethodSRSData
|
|
@@ -14,6 +14,7 @@ from sgf_parser.models.types import FlushingVariant, HammeringVariant, RotationV
|
|
|
14
14
|
class MethodData(BaseModel, abc.ABC):
|
|
15
15
|
@classmethod
|
|
16
16
|
def _fix_malformed_data(cls, code: str) -> str | None:
|
|
17
|
+
"""Wrong K codes as "4,0" will be converted to "40"."""
|
|
17
18
|
return re.sub("[^0-9]", "", code)
|
|
18
19
|
|
|
19
20
|
@classmethod
|
|
@@ -53,20 +54,19 @@ class MethodData(BaseModel, abc.ABC):
|
|
|
53
54
|
"""
|
|
54
55
|
if isinstance(data, dict):
|
|
55
56
|
if "K" in data and data["K"] is not None:
|
|
56
|
-
|
|
57
57
|
# We want to interpret K as a stop code (with integer value)
|
|
58
58
|
# sometimes K is a string with e.g. "SAND", in that case we move it to T
|
|
59
59
|
K_is_digit = any(char.isdigit() for char in data["K"])
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
if not K_is_digit:
|
|
62
62
|
# move it to T (remarks column)
|
|
63
63
|
if "T" not in data:
|
|
64
64
|
data["T"] = data["K"]
|
|
65
65
|
else:
|
|
66
66
|
data["T"] = f"{data['K']}, {data['T']}"
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
del data["K"]
|
|
69
|
-
|
|
69
|
+
|
|
70
70
|
else:
|
|
71
71
|
# we identify the most important stop code, and move the rest to T
|
|
72
72
|
_code, _rest = cls._extract_comment_code(data)
|
|
@@ -83,6 +83,52 @@ class MethodData(BaseModel, abc.ABC):
|
|
|
83
83
|
comment_code: int | None = Field(None, alias="K")
|
|
84
84
|
remarks: str | None = Field(None, alias="T")
|
|
85
85
|
|
|
86
|
+
@model_validator(mode="before")
|
|
87
|
+
@classmethod
|
|
88
|
+
def penetration_rate_validator(cls, data: Any) -> Any:
|
|
89
|
+
"""
|
|
90
|
+
If the penetration rate (B mm/s) is not set, but C is (s/0.2m) then convert C to B and set B.
|
|
91
|
+
"""
|
|
92
|
+
if isinstance(data, dict):
|
|
93
|
+
if ("B" not in data or data["B"] is None) and "C" in data and data["C"] is not None:
|
|
94
|
+
# B is not set, but C is, convert C to B
|
|
95
|
+
try:
|
|
96
|
+
data["B"] = 200 / float(data["C"])
|
|
97
|
+
except (ZeroDivisionError, ValueError):
|
|
98
|
+
data["B"] = None
|
|
99
|
+
|
|
100
|
+
return data
|
|
101
|
+
|
|
102
|
+
@model_validator(mode="before")
|
|
103
|
+
@classmethod
|
|
104
|
+
def torque_validator(cls, data: Any) -> Any:
|
|
105
|
+
"""
|
|
106
|
+
If the torque V (kNm) is not set, but AB is (Nm) then convert AB to V and set V.
|
|
107
|
+
"""
|
|
108
|
+
if isinstance(data, dict):
|
|
109
|
+
if ("V" not in data or data["V"] is None) and "AB" in data and data["AB"] is not None:
|
|
110
|
+
try:
|
|
111
|
+
data["V"] = float(data["AB"]) / 1000
|
|
112
|
+
except ValueError:
|
|
113
|
+
data["V"] = None
|
|
114
|
+
|
|
115
|
+
return data
|
|
116
|
+
|
|
117
|
+
@model_validator(mode="before")
|
|
118
|
+
@classmethod
|
|
119
|
+
def ramming_validator(cls, data: Any) -> Any:
|
|
120
|
+
"""
|
|
121
|
+
If the ramming S (blows/0.2m) is not set, but SA is (blows/0.1m) then convert SA to S and set S.
|
|
122
|
+
"""
|
|
123
|
+
if isinstance(data, dict):
|
|
124
|
+
if ("S" not in data or data["S"] is None) and "SA" in data and data["SA"] is not None:
|
|
125
|
+
try:
|
|
126
|
+
data["S"] = float(data["SA"]) * 2
|
|
127
|
+
except ValueError:
|
|
128
|
+
data["S"] = None
|
|
129
|
+
|
|
130
|
+
return data
|
|
131
|
+
|
|
86
132
|
def __repr__(self):
|
|
87
133
|
return f"<{self.__class__.__name__} {self.depth}>"
|
|
88
134
|
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
from decimal import Decimal
|
|
2
|
+
from typing import Literal, Any
|
|
3
|
+
|
|
4
|
+
from pydantic import Field, model_validator, computed_field, AliasChoices
|
|
5
|
+
|
|
6
|
+
from sgf_parser.models import MethodData, Method, MethodType
|
|
7
|
+
from sgf_parser.models.types import DPType
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class MethodDPData(MethodData):
|
|
11
|
+
"""
|
|
12
|
+
Dynamic Probing Data
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
def __init__(self, **kwargs):
|
|
16
|
+
super().__init__(**kwargs)
|
|
17
|
+
|
|
18
|
+
depth: Decimal = Field(..., alias="D", description="Depth (m)")
|
|
19
|
+
|
|
20
|
+
penetration_force: Decimal | None = Field(None, alias="A", description="Penetration force (kN)")
|
|
21
|
+
penetration_rate: Decimal | None = Field(
|
|
22
|
+
None,
|
|
23
|
+
validation_alias=AliasChoices(
|
|
24
|
+
"B", # mm/s
|
|
25
|
+
"C", # s/0.2m
|
|
26
|
+
),
|
|
27
|
+
description="Penetration rate (mm/s)",
|
|
28
|
+
)
|
|
29
|
+
torque: Decimal | None = Field(
|
|
30
|
+
None,
|
|
31
|
+
validation_alias=AliasChoices(
|
|
32
|
+
"V", # kNm
|
|
33
|
+
"AB", # Nm
|
|
34
|
+
),
|
|
35
|
+
description="Torque (kNm)",
|
|
36
|
+
)
|
|
37
|
+
ramming: Decimal = Field(None, validation_alias=AliasChoices("S", "SA"), description="Ramming (Blow/0.2 m)")
|
|
38
|
+
rotation_rate: Decimal | None = Field(None, alias="R", description="Rotation rate (rpm)")
|
|
39
|
+
increased_rotation_rate: bool | None = Field(None, alias="AQ")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class MethodDP(Method):
|
|
43
|
+
"""
|
|
44
|
+
Dynamic Probing (Swedish Hejarsondering)
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
def __init__(self, **kwargs):
|
|
48
|
+
super().__init__(**kwargs)
|
|
49
|
+
|
|
50
|
+
name: str = "DP"
|
|
51
|
+
method_type: Literal[MethodType.DP] = MethodType.DP
|
|
52
|
+
method_data_type: type[MethodDPData] = MethodDPData
|
|
53
|
+
|
|
54
|
+
type: DPType
|
|
55
|
+
|
|
56
|
+
predrilling_depth: Decimal = Field(Decimal("0"), alias="HO")
|
|
57
|
+
|
|
58
|
+
cone_type: str | None = Field(
|
|
59
|
+
None, validation_alias=AliasChoices("KonTyp", "HN", "HC"), description="Type of cone used."
|
|
60
|
+
)
|
|
61
|
+
cushion_type: str | None = Field(None, alias="DynTyp", description="Type of impact cushion used.")
|
|
62
|
+
use_damper: bool | None = Field(None, alias="Gummi", description="Use of damper.")
|
|
63
|
+
|
|
64
|
+
method_data: list[MethodDPData] = []
|
|
65
|
+
|
|
66
|
+
@computed_field
|
|
67
|
+
def depth_top(self) -> Decimal | None:
|
|
68
|
+
if not self.method_data:
|
|
69
|
+
return None
|
|
70
|
+
|
|
71
|
+
return min(method_data.depth for method_data in self.method_data)
|
|
72
|
+
|
|
73
|
+
@computed_field
|
|
74
|
+
def depth_base(self) -> Decimal | None:
|
|
75
|
+
if not self.method_data:
|
|
76
|
+
return None
|
|
77
|
+
|
|
78
|
+
return max(method_data.depth for method_data in self.method_data)
|
|
79
|
+
|
|
80
|
+
@model_validator(mode="before")
|
|
81
|
+
@classmethod
|
|
82
|
+
def set_operation(cls, data: Any) -> Any:
|
|
83
|
+
if isinstance(data, dict):
|
|
84
|
+
if "HM" in data and data["HM"] is not None:
|
|
85
|
+
data["type"] = {
|
|
86
|
+
"8": DPType.DPSH_A,
|
|
87
|
+
"108A": DPType.DPSH_A,
|
|
88
|
+
"108B": DPType.DPL,
|
|
89
|
+
"108C": DPType.DPM,
|
|
90
|
+
"108D": DPType.DPH,
|
|
91
|
+
"9": DPType.DPSH_B,
|
|
92
|
+
"108E": DPType.DPSH_B,
|
|
93
|
+
}[data["HM"]]
|
|
94
|
+
|
|
95
|
+
return data
|
|
96
|
+
|
|
97
|
+
@computed_field
|
|
98
|
+
def stopcode(self) -> int | None:
|
|
99
|
+
if not self.method_data:
|
|
100
|
+
return None
|
|
101
|
+
|
|
102
|
+
return self.method_data[-1].comment_code
|
|
@@ -14,8 +14,8 @@ class MethodSRSData(MethodData):
|
|
|
14
14
|
Sounding classes:
|
|
15
15
|
|
|
16
16
|
12 (Jb-1)
|
|
17
|
-
41 (Jb-2)
|
|
18
|
-
42 (Jb-3)
|
|
17
|
+
41 71 (Jb-2)
|
|
18
|
+
42 72 (Jb-3)
|
|
19
19
|
73 (Jb-tot)
|
|
20
20
|
|
|
21
21
|
"""
|
|
@@ -83,7 +83,9 @@ class MethodSRS(Method):
|
|
|
83
83
|
data["sounding_class"] = {
|
|
84
84
|
"12": SoundingClass.JB1,
|
|
85
85
|
"41": SoundingClass.JB2,
|
|
86
|
+
"71": SoundingClass.JB2,
|
|
86
87
|
"42": SoundingClass.JB3,
|
|
88
|
+
"72": SoundingClass.JB3,
|
|
87
89
|
"73": SoundingClass.JBTOT,
|
|
88
90
|
}[data["HM"]]
|
|
89
91
|
|
|
@@ -134,3 +134,16 @@ class Operation(enum.StrEnum):
|
|
|
134
134
|
|
|
135
135
|
MANUAL = "MANUAL"
|
|
136
136
|
MECHANICAL = "MECHANICAL"
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
class DPType(enum.StrEnum):
|
|
140
|
+
"""
|
|
141
|
+
DP Type (Dynamic Probing)
|
|
142
|
+
|
|
143
|
+
"""
|
|
144
|
+
|
|
145
|
+
DPSH_A = "DPSH-A"
|
|
146
|
+
DPL = "DPL"
|
|
147
|
+
DPM = "DPM"
|
|
148
|
+
DPH = "DPH"
|
|
149
|
+
DPSH_B = "DPSH-B"
|
|
@@ -11,7 +11,7 @@ from sgf_parser.models import ParseState
|
|
|
11
11
|
# to contain only a-z and A-Z. In addition, the Geotech AB extension,
|
|
12
12
|
# have date fields (key "%") with no "=" separating the key from the
|
|
13
13
|
# value...
|
|
14
|
-
_RE_FIELD_SEP = re.compile(r",(
|
|
14
|
+
_RE_FIELD_SEP = re.compile(r",(?=[a-zA-Z%])")
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
class Parser:
|
|
@@ -20,20 +20,29 @@ class Parser:
|
|
|
20
20
|
"""
|
|
21
21
|
|
|
22
22
|
method_code_class_mapping = {
|
|
23
|
-
"7": models.MethodCPT,
|
|
24
23
|
"07": models.MethodCPT,
|
|
25
24
|
"101": models.MethodWST,
|
|
26
25
|
"102": models.MethodWST,
|
|
27
26
|
"107A": models.MethodCPT,
|
|
28
27
|
"107B": models.MethodCPT,
|
|
28
|
+
"108A": models.MethodDP,
|
|
29
|
+
"108B": models.MethodDP,
|
|
30
|
+
"108C": models.MethodDP,
|
|
31
|
+
"108D": models.MethodDP,
|
|
32
|
+
"108E": models.MethodDP,
|
|
33
|
+
"12": models.MethodSRS,
|
|
34
|
+
"13": models.MethodSVT,
|
|
29
35
|
"23": models.MethodRP,
|
|
30
36
|
"24": models.MethodTOT,
|
|
31
|
-
"
|
|
37
|
+
"35": models.MethodDT,
|
|
32
38
|
"41": models.MethodSRS,
|
|
33
39
|
"42": models.MethodSRS,
|
|
40
|
+
"7": models.MethodCPT,
|
|
41
|
+
"71": models.MethodSRS,
|
|
42
|
+
"72": models.MethodSRS,
|
|
34
43
|
"73": models.MethodSRS,
|
|
35
|
-
"
|
|
36
|
-
"
|
|
44
|
+
"8": models.MethodDP,
|
|
45
|
+
"9": models.MethodDP,
|
|
37
46
|
}
|
|
38
47
|
|
|
39
48
|
def parse(self, file: TextIO) -> list[Method]:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|