sgf-parser 0.0.1a1__py3-none-any.whl
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/__init__.py +1 -0
- sgf_parser/datetime_parser.py +44 -0
- sgf_parser/models/__init__.py +9 -0
- sgf_parser/models/method.py +386 -0
- sgf_parser/models/method_cpt.py +277 -0
- sgf_parser/models/method_rp.py +75 -0
- sgf_parser/models/method_srs.py +196 -0
- sgf_parser/models/method_svt.py +57 -0
- sgf_parser/models/method_tot.py +195 -0
- sgf_parser/models/method_type.py +14 -0
- sgf_parser/models/method_wst.py +0 -0
- sgf_parser/models/types.py +127 -0
- sgf_parser/parser.py +129 -0
- sgf_parser/units.py +5 -0
- sgf_parser-0.0.1a1.dist-info/LICENSE +21 -0
- sgf_parser-0.0.1a1.dist-info/METADATA +111 -0
- sgf_parser-0.0.1a1.dist-info/RECORD +18 -0
- sgf_parser-0.0.1a1.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
from decimal import Decimal
|
|
2
|
+
from typing import Literal
|
|
3
|
+
|
|
4
|
+
from pydantic import Field, AliasChoices, computed_field
|
|
5
|
+
|
|
6
|
+
from sgf_parser.models import MethodType, MethodData, Method
|
|
7
|
+
from sgf_parser.models.types import ApplicationClass
|
|
8
|
+
from sgf_parser.units import unit
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class MethodCPTData(MethodData):
|
|
12
|
+
"""
|
|
13
|
+
Method CPT data
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
def __init__(self, **kwargs):
|
|
17
|
+
super().__init__(**kwargs)
|
|
18
|
+
|
|
19
|
+
penetration_force: Decimal | None = Field(None, alias="A", description="Penetration force (kN)")
|
|
20
|
+
penetration_rate: Decimal | None = Field(None, alias="B", description="Penetration rate (mm/s)")
|
|
21
|
+
depth: Decimal = Field(..., alias="D", description="Depth (m)")
|
|
22
|
+
|
|
23
|
+
# "F": Envi format (non-standard)
|
|
24
|
+
# "FS": SGF Standard and Geotech format
|
|
25
|
+
fs: Decimal | None = Field(None, description="Friction (kPa)", validation_alias=AliasChoices("FS", "F"))
|
|
26
|
+
|
|
27
|
+
# "M": "conductivity", # "conductivity",
|
|
28
|
+
conductivity: Decimal | None = Field(None, alias="M", description="Conductivity (S/m)")
|
|
29
|
+
|
|
30
|
+
zero_value_resistance: Decimal | None = Field(
|
|
31
|
+
None, description="Zero value resistance (MPa)", validation_alias=AliasChoices("NA", "NA2", "NA3")
|
|
32
|
+
)
|
|
33
|
+
zero_value_friction: Decimal | None = Field(
|
|
34
|
+
None, description="Zero value friction (kPa)", validation_alias=AliasChoices("NB", "NB2", "NB3")
|
|
35
|
+
)
|
|
36
|
+
zero_value_pressure: Decimal | None = Field(
|
|
37
|
+
None, description="Zero value pressure (kPa)", validation_alias=AliasChoices("NC", "NC2", "NC3")
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
temperature: Decimal | None = Field(None, alias="O", description="Temperature (degree C)")
|
|
41
|
+
qc: Decimal | None = Field(None, description="Resistance (MPa)", validation_alias=AliasChoices("QC", "Q"))
|
|
42
|
+
tilt: Decimal | None = Field(None, alias="TA", description="Inclination (degree)")
|
|
43
|
+
|
|
44
|
+
u2: Decimal | None = Field(None, alias="U", description="Shoulder pressure (kPa)")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class MethodCPT(Method):
|
|
48
|
+
"""
|
|
49
|
+
Method CPT
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
def __init__(self, **kwargs):
|
|
53
|
+
super().__init__(**kwargs)
|
|
54
|
+
|
|
55
|
+
name: str = "CPT"
|
|
56
|
+
method_type: Literal[MethodType.CPT] = MethodType.CPT
|
|
57
|
+
method_data_type: type[MethodCPTData] = MethodCPTData
|
|
58
|
+
|
|
59
|
+
method_data: list[MethodCPTData] = []
|
|
60
|
+
|
|
61
|
+
application_class_depth: ApplicationClass = ApplicationClass.UNKNOWN
|
|
62
|
+
application_class_resistance: ApplicationClass = ApplicationClass.UNKNOWN
|
|
63
|
+
application_class_friction: ApplicationClass = ApplicationClass.UNKNOWN
|
|
64
|
+
application_class_pressure: ApplicationClass = ApplicationClass.UNKNOWN
|
|
65
|
+
|
|
66
|
+
def _patch_zero_values_from_header_text(self: "MethodCPT"):
|
|
67
|
+
"""
|
|
68
|
+
Patch zero values on first data row, if present in the header field HT (remarks)
|
|
69
|
+
"""
|
|
70
|
+
if not self.remarks:
|
|
71
|
+
return
|
|
72
|
+
|
|
73
|
+
remarks = self.remarks.split(" ")
|
|
74
|
+
if len(remarks) != 6:
|
|
75
|
+
return
|
|
76
|
+
|
|
77
|
+
# NB: The values in the header are all in kPa, but we store NA in MPa.
|
|
78
|
+
# The diff at the end are OK (NA MPa, NB kPa, NC kPa).
|
|
79
|
+
# It is correct that the order is not A, B, C, ...:
|
|
80
|
+
NC_str, NA_str, NB_str, _, _, _ = remarks
|
|
81
|
+
|
|
82
|
+
try:
|
|
83
|
+
NA: Decimal = Decimal(NA_str)
|
|
84
|
+
NB: Decimal = Decimal(NB_str)
|
|
85
|
+
NC: Decimal = Decimal(NC_str)
|
|
86
|
+
except ValueError:
|
|
87
|
+
return
|
|
88
|
+
|
|
89
|
+
if self.method_data[0].zero_value_resistance:
|
|
90
|
+
return
|
|
91
|
+
|
|
92
|
+
if self.method_data[0].zero_value_friction:
|
|
93
|
+
return
|
|
94
|
+
|
|
95
|
+
if self.method_data[0].zero_value_pressure:
|
|
96
|
+
return
|
|
97
|
+
|
|
98
|
+
self.method_data[0].zero_value_resistance = (NA * unit.kPa).to(unit.MPa).magnitude
|
|
99
|
+
self.method_data[0].zero_value_friction = NB
|
|
100
|
+
self.method_data[0].zero_value_pressure = NC
|
|
101
|
+
|
|
102
|
+
def _get_data_field_max_value(self, field: str) -> Decimal:
|
|
103
|
+
"""
|
|
104
|
+
Return the max value for specified method data row field
|
|
105
|
+
"""
|
|
106
|
+
return max([getattr(row, field) if getattr(row, field) else Decimal("0") for row in self.method_data])
|
|
107
|
+
|
|
108
|
+
def _get_depth_delta(self) -> Decimal | None:
|
|
109
|
+
"""
|
|
110
|
+
Return the delta dept between the two first method data rows.
|
|
111
|
+
If no data rows, then return None
|
|
112
|
+
"""
|
|
113
|
+
if not self.method_data or len(self.method_data) < 2:
|
|
114
|
+
return None
|
|
115
|
+
|
|
116
|
+
return self.method_data[1].depth - self.method_data[0].depth
|
|
117
|
+
|
|
118
|
+
def _get_depth_class(self) -> ApplicationClass:
|
|
119
|
+
"""
|
|
120
|
+
Return the method's application class depending on the delta depth (not looking at any other factors)
|
|
121
|
+
|
|
122
|
+
Artificial Application Class 5 for returning error
|
|
123
|
+
|
|
124
|
+
+---------------------------|-- Class 1 ---|- Class 2 -----|-- Class 3 ----|-- Class 4 ----+
|
|
125
|
+
| delta Depth (delta D) <= | 20 mm | 20 mm | 50mm | 50mm |
|
|
126
|
+
|
|
127
|
+
"""
|
|
128
|
+
delta_depth = self._get_depth_delta()
|
|
129
|
+
if not delta_depth:
|
|
130
|
+
return ApplicationClass.UNKNOWN
|
|
131
|
+
|
|
132
|
+
if delta_depth <= 0.02:
|
|
133
|
+
return ApplicationClass.ONE
|
|
134
|
+
elif delta_depth <= 0.05:
|
|
135
|
+
return ApplicationClass.THREE
|
|
136
|
+
|
|
137
|
+
return ApplicationClass.OUT_OF_BOUNDS
|
|
138
|
+
|
|
139
|
+
def _get_zero_value_class(
|
|
140
|
+
self, field: str, pressure_class_map: list[tuple[Decimal, ApplicationClass]]
|
|
141
|
+
) -> ApplicationClass:
|
|
142
|
+
"""
|
|
143
|
+
Return the application class based on the absolute zero value from the last row of data form the pressure_class_map.
|
|
144
|
+
|
|
145
|
+
If value out of range, then return OUT_OF_BOUNDS (5) as a marker for error/not defined state
|
|
146
|
+
"""
|
|
147
|
+
if not self.method_data or len(self.method_data) < 2:
|
|
148
|
+
return ApplicationClass.UNKNOWN
|
|
149
|
+
|
|
150
|
+
value_last = getattr(self.method_data[-1], field)
|
|
151
|
+
|
|
152
|
+
if value_last is None:
|
|
153
|
+
return ApplicationClass.UNKNOWN
|
|
154
|
+
|
|
155
|
+
diff = abs(value_last)
|
|
156
|
+
|
|
157
|
+
for pressure, class_number in pressure_class_map:
|
|
158
|
+
if diff <= pressure:
|
|
159
|
+
return class_number
|
|
160
|
+
|
|
161
|
+
return ApplicationClass.OUT_OF_BOUNDS
|
|
162
|
+
|
|
163
|
+
def _calculate_application_class(
|
|
164
|
+
self,
|
|
165
|
+
) -> tuple[ApplicationClass, ApplicationClass, ApplicationClass, ApplicationClass]:
|
|
166
|
+
"""
|
|
167
|
+
Calculates the method's application class (also called quality class)
|
|
168
|
+
|
|
169
|
+
+-----------------------------------------------|-- Class 1 ---|- Class 2 -----|-- Class 3 ----|-- Class 4 ----+
|
|
170
|
+
| delta Depth (delta D) <= | 20 mm | 20 mm | 50mm | 50mm |
|
|
171
|
+
| NA = delta QC [MPa] - Zero value resistance<= | 35 kPa or 5% | 100 kPa or 5% | 200 kPa or 5% | 500 kPa or 5% |
|
|
172
|
+
| NB = delta fs [kPa] - Zero value friction <= | 5 kPa or 10% | 15 kPa or 15% | 25 kPa or 15% | 50 kPa or 20% |
|
|
173
|
+
| NC = delta u2 [kPa] - Zero value pressure <= | 10 kPa or 2% | 25 kPa or 3% | 50 kPa or 5% | |
|
|
174
|
+
+--------------------------------------------------------------------------------------------------------------+
|
|
175
|
+
"""
|
|
176
|
+
depth_class: ApplicationClass = self._get_depth_class()
|
|
177
|
+
|
|
178
|
+
qc_max_data_value = self._get_data_field_max_value(field="qc") # MPa
|
|
179
|
+
# convert to kPa
|
|
180
|
+
qc_max_data_value = (qc_max_data_value * unit.MPa).to(unit.kPa).magnitude
|
|
181
|
+
|
|
182
|
+
NA_class = self._get_zero_value_class(
|
|
183
|
+
field="zero_value_resistance",
|
|
184
|
+
pressure_class_map=[
|
|
185
|
+
(max(Decimal("35"), qc_max_data_value * Decimal("0.05")) / Decimal("1000"), ApplicationClass.ONE),
|
|
186
|
+
(max(Decimal("100"), qc_max_data_value * Decimal("0.05")) / Decimal("1000"), ApplicationClass.TWO),
|
|
187
|
+
(max(Decimal("200"), qc_max_data_value * Decimal("0.05")) / Decimal("1000"), ApplicationClass.THREE),
|
|
188
|
+
(max(Decimal("500"), qc_max_data_value * Decimal("0.05")) / Decimal("1000"), ApplicationClass.FOUR),
|
|
189
|
+
],
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
fs_max_data_value = self._get_data_field_max_value(field="fs") # kPa
|
|
193
|
+
NB_class = self._get_zero_value_class(
|
|
194
|
+
field="zero_value_friction",
|
|
195
|
+
pressure_class_map=[
|
|
196
|
+
(max(Decimal("5"), fs_max_data_value * Decimal("0.1")), ApplicationClass.ONE),
|
|
197
|
+
(max(Decimal("15"), fs_max_data_value * Decimal("0.15")), ApplicationClass.TWO),
|
|
198
|
+
(max(Decimal("25"), fs_max_data_value * Decimal("0.15")), ApplicationClass.THREE),
|
|
199
|
+
(max(Decimal("50"), fs_max_data_value * Decimal("0.2")), ApplicationClass.FOUR),
|
|
200
|
+
],
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
u2_max_data_value = self._get_data_field_max_value(field="u2") # kPa
|
|
204
|
+
NC_class = self._get_zero_value_class(
|
|
205
|
+
field="zero_value_pressure",
|
|
206
|
+
pressure_class_map=[
|
|
207
|
+
(max(Decimal("10"), u2_max_data_value * Decimal("0.02")), ApplicationClass.ONE),
|
|
208
|
+
(max(Decimal("25"), u2_max_data_value * Decimal("0.03")), ApplicationClass.TWO),
|
|
209
|
+
(max(Decimal("50"), u2_max_data_value * Decimal("0.05")), ApplicationClass.THREE),
|
|
210
|
+
],
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
return depth_class, NA_class, NB_class, NC_class
|
|
214
|
+
|
|
215
|
+
def post_processing(self):
|
|
216
|
+
"""
|
|
217
|
+
Post-processing
|
|
218
|
+
|
|
219
|
+
"""
|
|
220
|
+
|
|
221
|
+
if not self.method_data:
|
|
222
|
+
return
|
|
223
|
+
|
|
224
|
+
self._patch_zero_values_from_header_text()
|
|
225
|
+
|
|
226
|
+
(
|
|
227
|
+
self.application_class_depth,
|
|
228
|
+
self.application_class_resistance,
|
|
229
|
+
self.application_class_friction,
|
|
230
|
+
self.application_class_pressure,
|
|
231
|
+
) = self._calculate_application_class()
|
|
232
|
+
|
|
233
|
+
@property
|
|
234
|
+
def application_class(self) -> ApplicationClass:
|
|
235
|
+
"""
|
|
236
|
+
Return the application class based on the method's application class
|
|
237
|
+
"""
|
|
238
|
+
if (
|
|
239
|
+
self.application_class_depth
|
|
240
|
+
and self.application_class_resistance
|
|
241
|
+
and self.application_class_friction
|
|
242
|
+
and self.application_class_pressure
|
|
243
|
+
):
|
|
244
|
+
return max(
|
|
245
|
+
self.application_class_depth,
|
|
246
|
+
self.application_class_resistance,
|
|
247
|
+
self.application_class_friction,
|
|
248
|
+
self.application_class_pressure,
|
|
249
|
+
)
|
|
250
|
+
else:
|
|
251
|
+
return ApplicationClass.UNKNOWN
|
|
252
|
+
|
|
253
|
+
@computed_field
|
|
254
|
+
def depth_top(self) -> Decimal | None:
|
|
255
|
+
if not self.method_data:
|
|
256
|
+
return None
|
|
257
|
+
|
|
258
|
+
return min(method_data.depth for method_data in self.method_data)
|
|
259
|
+
|
|
260
|
+
@computed_field
|
|
261
|
+
def depth_base(self) -> Decimal | None:
|
|
262
|
+
if not self.method_data:
|
|
263
|
+
return None
|
|
264
|
+
|
|
265
|
+
return max(method_data.depth for method_data in self.method_data)
|
|
266
|
+
|
|
267
|
+
@computed_field
|
|
268
|
+
def stopcode(self) -> int | None:
|
|
269
|
+
if not self.method_data:
|
|
270
|
+
return None
|
|
271
|
+
|
|
272
|
+
return self.method_data[-1].comment_code
|
|
273
|
+
|
|
274
|
+
# "MA": "cone_area_ratio", # same as header code IE
|
|
275
|
+
# "IE": "cone_area_ratio", # same as header code MA
|
|
276
|
+
# "MB": "sleeve_area_ratio", # same as header code IF
|
|
277
|
+
# "IF": "sleeve_area_ratio", # same as header code MB
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
from decimal import Decimal
|
|
2
|
+
from typing import Literal
|
|
3
|
+
|
|
4
|
+
from pydantic import Field, computed_field
|
|
5
|
+
|
|
6
|
+
from sgf_parser.models import MethodType, MethodData, Method
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class MethodRPData(MethodData):
|
|
10
|
+
"""
|
|
11
|
+
Method RP data
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def __init__(self, **kwargs):
|
|
15
|
+
super().__init__(**kwargs)
|
|
16
|
+
|
|
17
|
+
depth: Decimal = Field(..., alias="D", description="Depth (m)")
|
|
18
|
+
penetration_force: Decimal | None = Field(None, alias="A", description="Penetration force (kN)")
|
|
19
|
+
penetration_rate: Decimal | None = Field(None, alias="B", description="Penetration rate (mm/s)")
|
|
20
|
+
|
|
21
|
+
flushing: bool | None = Field(None, alias="AR")
|
|
22
|
+
flushing_pressure: Decimal | None = Field(None, alias="I", description="Flushing pressure (MPa)")
|
|
23
|
+
flushing_flow: Decimal | None = Field(None, alias="J", description="Flushing flow (l/min)")
|
|
24
|
+
rotation_rate: Decimal | None = Field(None, alias="R", description="Rotation rate (rpm)")
|
|
25
|
+
increased_rotation_rate: bool | None = Field(None, alias="AQ")
|
|
26
|
+
torque: Decimal | None = Field(None, alias="V", description="Torque (kNm)")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class MethodRP(Method):
|
|
30
|
+
"""
|
|
31
|
+
Method RP
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
def __init__(self, **kwargs):
|
|
35
|
+
super().__init__(**kwargs)
|
|
36
|
+
|
|
37
|
+
name: str = "RP"
|
|
38
|
+
method_type: Literal[MethodType.RP] = MethodType.RP
|
|
39
|
+
method_data_type: type[MethodRPData] = MethodRPData
|
|
40
|
+
|
|
41
|
+
method_data: list[MethodRPData] = []
|
|
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
|
+
@computed_field
|
|
58
|
+
def stopcode(self) -> int | None:
|
|
59
|
+
if not self.method_data:
|
|
60
|
+
return None
|
|
61
|
+
|
|
62
|
+
return self.method_data[-1].comment_code
|
|
63
|
+
|
|
64
|
+
def post_processing(self):
|
|
65
|
+
"""
|
|
66
|
+
Post-processing
|
|
67
|
+
|
|
68
|
+
"""
|
|
69
|
+
|
|
70
|
+
if not self.method_data:
|
|
71
|
+
return
|
|
72
|
+
|
|
73
|
+
# Update flushing and increased rotation
|
|
74
|
+
self.flushing_update()
|
|
75
|
+
self.rotation_update()
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
from decimal import Decimal
|
|
2
|
+
from typing import Literal, Any
|
|
3
|
+
|
|
4
|
+
from pydantic import computed_field, Field, model_validator
|
|
5
|
+
|
|
6
|
+
from sgf_parser.models import MethodType, Method, MethodData
|
|
7
|
+
from sgf_parser.models.types import SoundingClass, StopCode, CommentCode
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class MethodSRSData(MethodData):
|
|
11
|
+
"""
|
|
12
|
+
Soil-Rock-Sounding (Swedish Jord-bergsondering)
|
|
13
|
+
|
|
14
|
+
Sounding classes:
|
|
15
|
+
|
|
16
|
+
12 (Jb-1)
|
|
17
|
+
41 (Jb-2)
|
|
18
|
+
42 (Jb-3)
|
|
19
|
+
73 (Jb-tot)
|
|
20
|
+
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
def __init__(self, **kwargs):
|
|
24
|
+
super().__init__(**kwargs)
|
|
25
|
+
|
|
26
|
+
depth: Decimal = Field(..., alias="D", description="Depth (m)")
|
|
27
|
+
|
|
28
|
+
penetration_force: Decimal | None = Field(None, alias="A", description="Penetration force (kN)")
|
|
29
|
+
penetration_rate: Decimal | None = Field(None, alias="B", description="Penetration rate (mm/s)")
|
|
30
|
+
engine_pressure: Decimal | None = Field(None, alias="P", description="Engine pressure (MPa)")
|
|
31
|
+
hammering_pressure: Decimal | None = Field(None, alias="AZ", description="Hammering pressure (MPa)")
|
|
32
|
+
rotation_rate: Decimal | None = Field(None, alias="R", description="Rotation rate (rpm)")
|
|
33
|
+
flushing_pressure: Decimal | None = Field(None, alias="I", description="Flushing pressure (MPa)")
|
|
34
|
+
flushing_flow: Decimal | None = Field(None, alias="J", description="Flushing flow (l/min)")
|
|
35
|
+
flushing: bool | None = Field(None, alias="AR")
|
|
36
|
+
hammering: bool | None = Field(None, alias="AP")
|
|
37
|
+
increased_rotation_rate: bool | None = Field(None, alias="AQ")
|
|
38
|
+
torque: Decimal | None = Field(None, alias="V", description="Torque (kNm)")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class MethodSRS(Method):
|
|
42
|
+
"""
|
|
43
|
+
Method SRS
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
def __init__(self, **kwargs):
|
|
47
|
+
super().__init__(**kwargs)
|
|
48
|
+
|
|
49
|
+
name: str = "SRS"
|
|
50
|
+
method_type: Literal[MethodType.SRS] = MethodType.SRS
|
|
51
|
+
method_data_type: type[MethodSRSData] = MethodSRSData
|
|
52
|
+
|
|
53
|
+
method_data: list[MethodSRSData] = []
|
|
54
|
+
|
|
55
|
+
sounding_class: SoundingClass = SoundingClass.JBTOT
|
|
56
|
+
|
|
57
|
+
@computed_field
|
|
58
|
+
def depth_top(self) -> Decimal | None:
|
|
59
|
+
if not self.method_data:
|
|
60
|
+
return None
|
|
61
|
+
|
|
62
|
+
return min(method_data.depth for method_data in self.method_data)
|
|
63
|
+
|
|
64
|
+
@computed_field
|
|
65
|
+
def depth_base(self) -> Decimal | None:
|
|
66
|
+
if not self.method_data:
|
|
67
|
+
return None
|
|
68
|
+
|
|
69
|
+
return max(method_data.depth for method_data in self.method_data)
|
|
70
|
+
|
|
71
|
+
@computed_field
|
|
72
|
+
def stopcode(self) -> int | None:
|
|
73
|
+
if not self.method_data:
|
|
74
|
+
return None
|
|
75
|
+
|
|
76
|
+
return self.method_data[-1].comment_code
|
|
77
|
+
|
|
78
|
+
@model_validator(mode="before")
|
|
79
|
+
@classmethod
|
|
80
|
+
def set_sounding_class(cls, data: Any) -> Any:
|
|
81
|
+
if isinstance(data, dict):
|
|
82
|
+
if "HM" in data and data["HM"] is not None:
|
|
83
|
+
data["sounding_class"] = {
|
|
84
|
+
"12": SoundingClass.JB1,
|
|
85
|
+
"41": SoundingClass.JB2,
|
|
86
|
+
"42": SoundingClass.JB3,
|
|
87
|
+
"73": SoundingClass.JBTOT,
|
|
88
|
+
}[data["HM"]]
|
|
89
|
+
|
|
90
|
+
return data
|
|
91
|
+
|
|
92
|
+
def post_processing(self):
|
|
93
|
+
"""
|
|
94
|
+
Post-processing
|
|
95
|
+
|
|
96
|
+
"""
|
|
97
|
+
|
|
98
|
+
if not self.method_data:
|
|
99
|
+
return
|
|
100
|
+
|
|
101
|
+
# Update flushing, hammering and increased rotation
|
|
102
|
+
self.flushing_update()
|
|
103
|
+
self.hammering_update()
|
|
104
|
+
self.rotation_update()
|
|
105
|
+
|
|
106
|
+
@computed_field
|
|
107
|
+
def depth_in_rock(self) -> Decimal | None:
|
|
108
|
+
_rock_top_depth = None
|
|
109
|
+
_rock_base_depth = None
|
|
110
|
+
|
|
111
|
+
if not self.method_data:
|
|
112
|
+
return None
|
|
113
|
+
|
|
114
|
+
if self.stopcode not in (
|
|
115
|
+
StopCode.STOP_AGAINST_STONE_BLOCK_OR_ROCK_93,
|
|
116
|
+
StopCode.STOP_AGAINST_PRESUMED_ROCK_94,
|
|
117
|
+
StopCode.SOUNDING_INTERRUPTED_95,
|
|
118
|
+
):
|
|
119
|
+
return None
|
|
120
|
+
|
|
121
|
+
for sample in self.method_data[::-1]:
|
|
122
|
+
if sample.comment_code == CommentCode.ROCK_END_42:
|
|
123
|
+
# 42 false positive
|
|
124
|
+
break
|
|
125
|
+
elif sample.comment_code in (
|
|
126
|
+
CommentCode.ROCK_OR_BEDROCK_41,
|
|
127
|
+
CommentCode.BEDROCK_43,
|
|
128
|
+
CommentCode.ROCK_LEVEL_80,
|
|
129
|
+
StopCode.STOP_AGAINST_PRESUMED_ROCK_94,
|
|
130
|
+
):
|
|
131
|
+
_rock_top_depth = sample.depth
|
|
132
|
+
if _rock_base_depth is None:
|
|
133
|
+
_rock_base_depth = sample.depth
|
|
134
|
+
break
|
|
135
|
+
elif _rock_base_depth is None:
|
|
136
|
+
_rock_base_depth = sample.depth
|
|
137
|
+
|
|
138
|
+
if _rock_top_depth is None or _rock_base_depth is None:
|
|
139
|
+
depth_in_rock = None
|
|
140
|
+
else:
|
|
141
|
+
depth_in_rock = _rock_base_depth - _rock_top_depth
|
|
142
|
+
|
|
143
|
+
return depth_in_rock
|
|
144
|
+
|
|
145
|
+
@computed_field
|
|
146
|
+
def depth_in_soil(self) -> Decimal | None:
|
|
147
|
+
if not self.method_data:
|
|
148
|
+
return None
|
|
149
|
+
|
|
150
|
+
if self.stopcode in (StopCode.INTERRUPTED_WITHOUT_STOP_90, StopCode.CANNOT_DRIVE_FURTHER_91):
|
|
151
|
+
return self.method_data[-1].depth
|
|
152
|
+
|
|
153
|
+
_depth_in_soil: Decimal | None = None
|
|
154
|
+
|
|
155
|
+
for sample in self.method_data[::-1]:
|
|
156
|
+
if sample.comment_code == CommentCode.ROCK_END_42:
|
|
157
|
+
# 42 false positive
|
|
158
|
+
if _depth_in_soil is None:
|
|
159
|
+
_depth_in_soil = sample.depth
|
|
160
|
+
break
|
|
161
|
+
elif sample.comment_code in (
|
|
162
|
+
CommentCode.ROCK_OR_BEDROCK_41,
|
|
163
|
+
CommentCode.BEDROCK_43,
|
|
164
|
+
StopCode.STOP_AGAINST_PRESUMED_ROCK_94,
|
|
165
|
+
CommentCode.ROCK_LEVEL_80,
|
|
166
|
+
):
|
|
167
|
+
_depth_in_soil = sample.depth
|
|
168
|
+
break
|
|
169
|
+
elif _depth_in_soil is None:
|
|
170
|
+
_depth_in_soil = sample.depth
|
|
171
|
+
|
|
172
|
+
return _depth_in_soil
|
|
173
|
+
|
|
174
|
+
@computed_field
|
|
175
|
+
def bedrock_elevation(self) -> Decimal | None:
|
|
176
|
+
# TODO: Unclear how to calculate bedrock elevation.
|
|
177
|
+
# Is it calculated in the same way as the norwegian total soundings?
|
|
178
|
+
# Does stop code 95 mean that the sounding was interrupted before reaching bedrock?
|
|
179
|
+
# Does stop code 80 mean that the sounding reached bedrock?
|
|
180
|
+
|
|
181
|
+
if self.point_z is None:
|
|
182
|
+
return None
|
|
183
|
+
|
|
184
|
+
_depth_in_soil: Decimal | None = self.depth_in_soil
|
|
185
|
+
|
|
186
|
+
if _depth_in_soil is None:
|
|
187
|
+
return None
|
|
188
|
+
|
|
189
|
+
if self.stopcode in (
|
|
190
|
+
StopCode.STOP_AGAINST_STONE_BLOCK_OR_ROCK_93,
|
|
191
|
+
StopCode.STOP_AGAINST_PRESUMED_ROCK_94,
|
|
192
|
+
StopCode.SOUNDING_INTERRUPTED_95, # TODO: Verify this ???
|
|
193
|
+
):
|
|
194
|
+
return Decimal(self.point_z) - _depth_in_soil
|
|
195
|
+
|
|
196
|
+
return None
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# # "VS": "vane_size", # Vingstorlek mm/mm Diameter/höjd
|
|
2
|
+
# "IV": "vane_diameter", # Not in speck, but seen in example files
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
from decimal import Decimal
|
|
5
|
+
from typing import Literal
|
|
6
|
+
|
|
7
|
+
from pydantic import computed_field, Field
|
|
8
|
+
|
|
9
|
+
from sgf_parser.models import MethodData, MethodType, Method
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class MethodSVTData(MethodData):
|
|
13
|
+
def __init__(self, **kwargs):
|
|
14
|
+
super().__init__(**kwargs)
|
|
15
|
+
|
|
16
|
+
depth: Decimal = Field(..., alias="D", description="Depth (m)")
|
|
17
|
+
|
|
18
|
+
maximum_measurement_torque: Decimal | None = Field(None, alias="AB", description="Maximum measurement torque (Nm)")
|
|
19
|
+
maximum_measurement_torque_remoulded: Decimal | None = Field(
|
|
20
|
+
None, alias="AB2", description="Maximum measurement torque (Nm)"
|
|
21
|
+
)
|
|
22
|
+
shear_strength: Decimal | None = Field(None, alias="AS", description="Shear strength (kPa)")
|
|
23
|
+
shear_strength_remoulded: Decimal | None = Field(None, description="Shear strength (kPa)")
|
|
24
|
+
sensitivity: Decimal | None = Field(None, alias="SV", description="Sensitivity (unitless)")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class MethodSVT(Method):
|
|
28
|
+
"""
|
|
29
|
+
Method SVT
|
|
30
|
+
"""
|
|
31
|
+
|
|
32
|
+
def __init__(self, **kwargs):
|
|
33
|
+
super().__init__(**kwargs)
|
|
34
|
+
|
|
35
|
+
name: str = "SVT"
|
|
36
|
+
method_type: Literal[MethodType.SVT] = MethodType.SVT
|
|
37
|
+
method_data_type: type[MethodSVTData] = MethodSVTData
|
|
38
|
+
|
|
39
|
+
method_data: list[MethodSVTData] = []
|
|
40
|
+
|
|
41
|
+
@computed_field
|
|
42
|
+
def depth_top(self) -> Decimal | None:
|
|
43
|
+
if not self.method_data:
|
|
44
|
+
return None
|
|
45
|
+
|
|
46
|
+
return min(method_data.depth for method_data in self.method_data)
|
|
47
|
+
|
|
48
|
+
@computed_field
|
|
49
|
+
def depth_base(self) -> Decimal | None:
|
|
50
|
+
if not self.method_data:
|
|
51
|
+
return None
|
|
52
|
+
|
|
53
|
+
return max(method_data.depth for method_data in self.method_data)
|
|
54
|
+
|
|
55
|
+
vane_height: Decimal | None = Field(None, description="Height of the vane used (mm).")
|
|
56
|
+
serial_number: str | None = Field(None, alias="HN", description="Serial number of the vane used.")
|
|
57
|
+
calibration_date: datetime | None = Field(None, description="Date of calibration of the vane used.")
|