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,195 @@
|
|
|
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, Method, MethodData, StopCode
|
|
7
|
+
from sgf_parser.models.types import CommentCode
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class MethodTOTData(MethodData):
|
|
11
|
+
"""
|
|
12
|
+
Method TOT data
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
def __init__(self, **kwargs):
|
|
16
|
+
super().__init__(**kwargs)
|
|
17
|
+
|
|
18
|
+
# "A": "penetration_force", # "feed_force",
|
|
19
|
+
penetration_force: Decimal | None = Field(None, alias="A", description="Penetration force (kN)")
|
|
20
|
+
|
|
21
|
+
# "AB": "maximum_measurement_torque",
|
|
22
|
+
# "AB2": "maximum_measurement_torque_remoulded",
|
|
23
|
+
# "AP": "hammering",
|
|
24
|
+
hammering: bool | None = Field(None, alias="AP")
|
|
25
|
+
|
|
26
|
+
# "AZ": "hammering_pressure",
|
|
27
|
+
hammering_pressure: Decimal | None = Field(None, alias="AZ", description="Hammering pressure (MPa)")
|
|
28
|
+
|
|
29
|
+
# "AQ": "increased_rotation_rate",
|
|
30
|
+
increased_rotation_rate: bool | None = Field(None, alias="AQ")
|
|
31
|
+
|
|
32
|
+
# "AR": "flushing", # flushing
|
|
33
|
+
flushing: bool | None = Field(None, alias="AR")
|
|
34
|
+
|
|
35
|
+
# "AS": "shear_strength",
|
|
36
|
+
# "B": "penetration_rate", # "penetration_rate",
|
|
37
|
+
penetration_rate: Decimal | None = Field(None, alias="B", description="Penetration rate (mm/s)")
|
|
38
|
+
|
|
39
|
+
# # "C": "penetration_resistance", # B = 200/C (unit: s/0.2m)
|
|
40
|
+
# penetration_resistance: Decimal | None = Field(None, alias="C")
|
|
41
|
+
|
|
42
|
+
# "D": "depth", # "depth",
|
|
43
|
+
depth: Decimal = Field(..., alias="D", description="Depth (m)")
|
|
44
|
+
|
|
45
|
+
# # "F": "fs", # "friction" Envi format
|
|
46
|
+
# # "FS": "fs", # "friction" Geotech format
|
|
47
|
+
# "I": "flushing_pressure",
|
|
48
|
+
flushing_pressure: Decimal | None = Field(None, alias="I", description="Flushing pressure (MPa)")
|
|
49
|
+
|
|
50
|
+
# "J": "flushing_flow",
|
|
51
|
+
flushing_flow: Decimal | None = Field(None, alias="J", description="Flushing flow (l/min)")
|
|
52
|
+
|
|
53
|
+
# "M": "conductivity", # "conductivity",
|
|
54
|
+
# "NA": "zero_value_resistance", # "zero_value_resistance",
|
|
55
|
+
# "NB": "zero_value_friction", # "zero_value_friction",
|
|
56
|
+
# "NC": "zero_value_pressure", # "zero_value_pressure",
|
|
57
|
+
# "O": "temperature", # "temperature",
|
|
58
|
+
|
|
59
|
+
# "P": "engine_pressure",
|
|
60
|
+
engine_pressure: Decimal | None = Field(None, alias="P", description="Engine pressure (MPa)")
|
|
61
|
+
|
|
62
|
+
# # "Q": "qc", # "resistance" Envi format
|
|
63
|
+
# # "QC": "qc", # "resistance" Geotech format
|
|
64
|
+
# "R": "rotation_rate",
|
|
65
|
+
rotation_rate: Decimal | None = Field(None, alias="R", description="Rotation rate (rpm)")
|
|
66
|
+
|
|
67
|
+
# "SV": "sensitivity",
|
|
68
|
+
|
|
69
|
+
# "TA": "tilt", # "tilt",
|
|
70
|
+
# "U": "u2", # "shoulder_pressure",
|
|
71
|
+
|
|
72
|
+
# "V": "torque", # Vridmoment
|
|
73
|
+
torque: Decimal | None = Field(None, alias="V", description="Torque (kNm)")
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class MethodTOT(Method):
|
|
77
|
+
"""
|
|
78
|
+
Method TOT
|
|
79
|
+
"""
|
|
80
|
+
|
|
81
|
+
def __init__(self, **kwargs):
|
|
82
|
+
super().__init__(**kwargs)
|
|
83
|
+
|
|
84
|
+
name: str = "TOT"
|
|
85
|
+
|
|
86
|
+
method_type: Literal[MethodType.TOT] = MethodType.TOT
|
|
87
|
+
method_data_type: type[MethodTOTData] = MethodTOTData
|
|
88
|
+
method_data: list[MethodTOTData] = []
|
|
89
|
+
|
|
90
|
+
@computed_field
|
|
91
|
+
def depth_top(self) -> Decimal | None:
|
|
92
|
+
if not self.method_data:
|
|
93
|
+
return None
|
|
94
|
+
|
|
95
|
+
return min(method_data.depth for method_data in self.method_data)
|
|
96
|
+
|
|
97
|
+
@computed_field
|
|
98
|
+
def depth_base(self) -> Decimal | None:
|
|
99
|
+
if not self.method_data:
|
|
100
|
+
return None
|
|
101
|
+
|
|
102
|
+
return max(method_data.depth for method_data in self.method_data)
|
|
103
|
+
|
|
104
|
+
@computed_field
|
|
105
|
+
def stopcode(self) -> int | None:
|
|
106
|
+
if not self.method_data:
|
|
107
|
+
return None
|
|
108
|
+
|
|
109
|
+
return self.method_data[-1].comment_code
|
|
110
|
+
|
|
111
|
+
@computed_field
|
|
112
|
+
def depth_in_rock(self) -> Decimal | None:
|
|
113
|
+
_rock_top_depth = None
|
|
114
|
+
_rock_base_depth = None
|
|
115
|
+
|
|
116
|
+
if not self.method_data:
|
|
117
|
+
return None
|
|
118
|
+
|
|
119
|
+
if self.stopcode not in (
|
|
120
|
+
StopCode.STOP_AGAINST_STONE_BLOCK_OR_ROCK_93,
|
|
121
|
+
StopCode.STOP_AGAINST_PRESUMED_ROCK_94,
|
|
122
|
+
):
|
|
123
|
+
return None
|
|
124
|
+
|
|
125
|
+
for sample in self.method_data[::-1]:
|
|
126
|
+
if sample.comment_code == CommentCode.ROCK_END_42:
|
|
127
|
+
# 42 false positive
|
|
128
|
+
break
|
|
129
|
+
elif sample.comment_code in (CommentCode.ROCK_OR_BEDROCK_41, CommentCode.BEDROCK_43):
|
|
130
|
+
_rock_top_depth = sample.depth
|
|
131
|
+
if _rock_base_depth is None:
|
|
132
|
+
_rock_base_depth = sample.depth
|
|
133
|
+
break
|
|
134
|
+
elif _rock_base_depth is None:
|
|
135
|
+
_rock_base_depth = sample.depth
|
|
136
|
+
|
|
137
|
+
if _rock_top_depth is None or _rock_base_depth is None:
|
|
138
|
+
depth_in_rock = None
|
|
139
|
+
else:
|
|
140
|
+
depth_in_rock = _rock_base_depth - _rock_top_depth
|
|
141
|
+
|
|
142
|
+
return depth_in_rock
|
|
143
|
+
|
|
144
|
+
@computed_field
|
|
145
|
+
def depth_in_soil(self) -> Decimal | None:
|
|
146
|
+
_depth_in_soil = None
|
|
147
|
+
|
|
148
|
+
if not self.method_data:
|
|
149
|
+
return None
|
|
150
|
+
|
|
151
|
+
if self.stopcode in (StopCode.INTERRUPTED_WITHOUT_STOP_90, StopCode.CANNOT_DRIVE_FURTHER_91):
|
|
152
|
+
return self.method_data[-1].depth
|
|
153
|
+
|
|
154
|
+
for sample in self.method_data[::-1]:
|
|
155
|
+
if sample.comment_code == CommentCode.ROCK_END_42:
|
|
156
|
+
# 42 false positive
|
|
157
|
+
if _depth_in_soil is None:
|
|
158
|
+
_depth_in_soil = sample.depth
|
|
159
|
+
break
|
|
160
|
+
elif sample.comment_code in (CommentCode.ROCK_OR_BEDROCK_41, CommentCode.BEDROCK_43):
|
|
161
|
+
_depth_in_soil = sample.depth
|
|
162
|
+
break
|
|
163
|
+
elif _depth_in_soil is None:
|
|
164
|
+
_depth_in_soil = sample.depth
|
|
165
|
+
|
|
166
|
+
return _depth_in_soil
|
|
167
|
+
|
|
168
|
+
@computed_field
|
|
169
|
+
def bedrock_elevation(self) -> Decimal | None:
|
|
170
|
+
if self.point_z is None:
|
|
171
|
+
return None
|
|
172
|
+
|
|
173
|
+
_depth_in_soil: Decimal | None = self.depth_in_soil
|
|
174
|
+
|
|
175
|
+
if _depth_in_soil is None:
|
|
176
|
+
return None
|
|
177
|
+
|
|
178
|
+
if self.stopcode in (StopCode.STOP_AGAINST_STONE_BLOCK_OR_ROCK_93, StopCode.STOP_AGAINST_PRESUMED_ROCK_94):
|
|
179
|
+
return Decimal(self.point_z) - _depth_in_soil
|
|
180
|
+
|
|
181
|
+
return None
|
|
182
|
+
|
|
183
|
+
def post_processing(self):
|
|
184
|
+
"""
|
|
185
|
+
Post-processing
|
|
186
|
+
|
|
187
|
+
"""
|
|
188
|
+
|
|
189
|
+
if not self.method_data:
|
|
190
|
+
return
|
|
191
|
+
|
|
192
|
+
# Update flushing, hammering and increased rotation
|
|
193
|
+
self.flushing_update()
|
|
194
|
+
self.hammering_update()
|
|
195
|
+
self.rotation_update()
|
|
File without changes
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ApplicationClass(enum.IntEnum):
|
|
5
|
+
"""
|
|
6
|
+
(
|
|
7
|
+
ONE=1,
|
|
8
|
+
TWO=2,
|
|
9
|
+
THREE=3,
|
|
10
|
+
FOUR=4,
|
|
11
|
+
OUT_OF_BOUNDS=10,
|
|
12
|
+
UNKNOWN=100,
|
|
13
|
+
)
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
ONE = 1
|
|
17
|
+
TWO = 2
|
|
18
|
+
THREE = 3
|
|
19
|
+
FOUR = 4
|
|
20
|
+
OUT_OF_BOUNDS = 10
|
|
21
|
+
UNKNOWN = 100
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class StopCode(enum.IntEnum):
|
|
25
|
+
"""
|
|
26
|
+
SGF stop codes
|
|
27
|
+
|
|
28
|
+
# Different descriptions found in different documents:
|
|
29
|
+
# 90: Sondering avsluttet uten å ha oppnådd stopp
|
|
30
|
+
# 90: Avbruten utan stopp
|
|
31
|
+
# 91: Fast grunn. Sondering kan ikke drives videre etter normal prosedyre
|
|
32
|
+
# 91: Kan ej neddrivas ytterligare
|
|
33
|
+
# 92 Antatt stein eller blokk
|
|
34
|
+
# 92: Stopp mot sten eller block
|
|
35
|
+
# 93: Antatt berg
|
|
36
|
+
# 93: Stopp mot sten, block eller berg
|
|
37
|
+
# 94: Avsluttet etter boret ønsket dybde i fjell
|
|
38
|
+
# 94: Stopp mot förmodat berg
|
|
39
|
+
# 95: Brudd i borestenger eller spiss
|
|
40
|
+
# 95: Jordbergsondering avbruten
|
|
41
|
+
# 96: Annen material eller maskinfeil
|
|
42
|
+
# 96: Förutbestämt djup (Ny stoppkod enl. Europeiska fältstandarden för CPT-sondering)
|
|
43
|
+
# 97: Boring avsluttet (årsak notert)
|
|
44
|
+
# 97: Max kapacitet (Ny stoppkod enl. Europeiska fältstandarden för CPT-sondering)
|
|
45
|
+
# 98: Max lutning (Ny stoppkod enl. Europeiska fältstandarden för CPT-sondering)
|
|
46
|
+
# 99: Utrustning skadad
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
INTERRUPTED_WITHOUT_STOP_90 = 90
|
|
50
|
+
CANNOT_DRIVE_FURTHER_91 = 91
|
|
51
|
+
STOP_AGAINST_STONE_OR_BLOCK_92 = 92
|
|
52
|
+
STOP_AGAINST_STONE_BLOCK_OR_ROCK_93 = 93
|
|
53
|
+
STOP_AGAINST_PRESUMED_ROCK_94 = 94
|
|
54
|
+
SOUNDING_INTERRUPTED_95 = 95
|
|
55
|
+
PREDETERMINED_DEPTH_96 = 96
|
|
56
|
+
MAX_CAPACITY_97 = 97
|
|
57
|
+
MAX_INCLINATION_98 = 98
|
|
58
|
+
EQUIPMENT_DAMAGED_99 = 99
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class CommentCode(enum.IntEnum):
|
|
62
|
+
"""
|
|
63
|
+
Selected SGF comment codes
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
SOIL_END_40 = 40
|
|
67
|
+
ROCK_OR_BEDROCK_41 = 41
|
|
68
|
+
ROCK_END_42 = 42
|
|
69
|
+
BEDROCK_43 = 43
|
|
70
|
+
ROCK_LEVEL_80 = 80
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class ParseState(enum.Enum):
|
|
74
|
+
"""
|
|
75
|
+
Parse state
|
|
76
|
+
"""
|
|
77
|
+
|
|
78
|
+
HEADER = 0
|
|
79
|
+
METHOD = 1
|
|
80
|
+
DATA = 2
|
|
81
|
+
QUIT = 3
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
class FlushingVariant(enum.StrEnum):
|
|
85
|
+
"""
|
|
86
|
+
Flushing variants
|
|
87
|
+
"""
|
|
88
|
+
|
|
89
|
+
CODE_K = "K"
|
|
90
|
+
CODE_AR = "AR"
|
|
91
|
+
CODE_I = "I"
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class HammeringVariant(enum.StrEnum):
|
|
95
|
+
"""
|
|
96
|
+
Hammering variants
|
|
97
|
+
"""
|
|
98
|
+
|
|
99
|
+
K = "K"
|
|
100
|
+
AP = "AP"
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class RotationVariant(enum.StrEnum):
|
|
104
|
+
"""
|
|
105
|
+
Rotation variants
|
|
106
|
+
"""
|
|
107
|
+
|
|
108
|
+
K = "K"
|
|
109
|
+
AQ = "AQ"
|
|
110
|
+
R = "R"
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class SoundingClass(enum.StrEnum):
|
|
114
|
+
"""
|
|
115
|
+
Soil-Rock-Sounding (Swedish Jord-bergsondering) classes
|
|
116
|
+
(
|
|
117
|
+
JB1 = Jb-1,
|
|
118
|
+
JB2 = Jb-2,
|
|
119
|
+
JB3 = Jb-3,
|
|
120
|
+
JBTOT = Jb-tot,
|
|
121
|
+
)
|
|
122
|
+
"""
|
|
123
|
+
|
|
124
|
+
JB1 = "Jb-1"
|
|
125
|
+
JB2 = "Jb-2"
|
|
126
|
+
JB3 = "Jb-3"
|
|
127
|
+
JBTOT = "Jb-tot"
|
sgf_parser/parser.py
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from typing import TextIO, Any
|
|
3
|
+
|
|
4
|
+
from sgf_parser.models.method import Method, MethodData
|
|
5
|
+
from sgf_parser import models
|
|
6
|
+
from sgf_parser.models import ParseState
|
|
7
|
+
|
|
8
|
+
# Fields are generally separated by "," and contain a single "="
|
|
9
|
+
# separating the key from the value. However, some fields have values
|
|
10
|
+
# containing ",", with no quoting. To handle this, we require the key
|
|
11
|
+
# to contain only a-z and A-Z. In addition, the Geotech AB extension,
|
|
12
|
+
# have date fields (key "%") with no "=" separating the key from the
|
|
13
|
+
# value...
|
|
14
|
+
_RE_FIELD_SEP = re.compile(r",(?:(?=[a-zA-Z])|(?=%))")
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Parser:
|
|
18
|
+
"""
|
|
19
|
+
A class to parse an SGF file
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
method_code_class_mapping = {
|
|
23
|
+
"7": models.MethodCPT,
|
|
24
|
+
"07": models.MethodCPT,
|
|
25
|
+
"107A": models.MethodCPT,
|
|
26
|
+
"107B": models.MethodCPT,
|
|
27
|
+
"23": models.MethodRP,
|
|
28
|
+
"24": models.MethodTOT,
|
|
29
|
+
"12": models.MethodSRS,
|
|
30
|
+
"41": models.MethodSRS,
|
|
31
|
+
"42": models.MethodSRS,
|
|
32
|
+
"73": models.MethodSRS,
|
|
33
|
+
"13": models.MethodSVT,
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
def parse(self, file: TextIO) -> list[Method]:
|
|
37
|
+
"""
|
|
38
|
+
Parse the SGF file
|
|
39
|
+
|
|
40
|
+
The file parameter must be an opened file in text mode (with correct character encoding), pointing at the start
|
|
41
|
+
of the file to parse. The file pointer may not point at the end of the file when this method returns.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
blocks = {
|
|
45
|
+
"£": ParseState.METHOD,
|
|
46
|
+
"$": ParseState.HEADER,
|
|
47
|
+
"#": ParseState.DATA,
|
|
48
|
+
"€": ParseState.METHOD,
|
|
49
|
+
"#$": ParseState.QUIT,
|
|
50
|
+
}
|
|
51
|
+
methods: list[Method] = []
|
|
52
|
+
method: Method | None = None
|
|
53
|
+
header: dict[str, Any] = {}
|
|
54
|
+
|
|
55
|
+
state = None
|
|
56
|
+
for row in file:
|
|
57
|
+
row = row.rstrip()
|
|
58
|
+
if not row:
|
|
59
|
+
continue
|
|
60
|
+
|
|
61
|
+
# Possible state changes
|
|
62
|
+
if row in blocks:
|
|
63
|
+
_new_state = blocks[row]
|
|
64
|
+
_old_state = state
|
|
65
|
+
if _new_state == ParseState.DATA and state in (ParseState.HEADER, ParseState.METHOD):
|
|
66
|
+
# Starting a new data block, so store the current collected header in a new method
|
|
67
|
+
method = self.parse_header(header)
|
|
68
|
+
header = {}
|
|
69
|
+
elif _new_state in (ParseState.HEADER, ParseState.METHOD) and _old_state == ParseState.DATA:
|
|
70
|
+
# Finished populating current method, since new method is starting
|
|
71
|
+
# Store the current method, and empty the current method
|
|
72
|
+
if method:
|
|
73
|
+
methods.append(method)
|
|
74
|
+
else:
|
|
75
|
+
raise Exception("Method is None, that is unexpected")
|
|
76
|
+
method = None
|
|
77
|
+
state = _new_state
|
|
78
|
+
continue
|
|
79
|
+
|
|
80
|
+
match state:
|
|
81
|
+
case ParseState.HEADER | ParseState.METHOD:
|
|
82
|
+
header |= self._convert_str_to_dict(row)
|
|
83
|
+
case ParseState.DATA:
|
|
84
|
+
if not method:
|
|
85
|
+
raise ValueError("No method to add data to")
|
|
86
|
+
method.method_data.append(self.parse_data(method, row))
|
|
87
|
+
case ParseState.QUIT:
|
|
88
|
+
break
|
|
89
|
+
case None:
|
|
90
|
+
raise ValueError("First block is not a main block")
|
|
91
|
+
|
|
92
|
+
if method:
|
|
93
|
+
method.post_processing()
|
|
94
|
+
methods.append(method)
|
|
95
|
+
|
|
96
|
+
return methods
|
|
97
|
+
|
|
98
|
+
@staticmethod
|
|
99
|
+
def _convert_str_to_dict(line: str) -> dict[str, Any]:
|
|
100
|
+
"""
|
|
101
|
+
Convert row to dict. If repeated keys, then append values with ", " (comma and a space) as a separator
|
|
102
|
+
"""
|
|
103
|
+
line = line.rstrip(",")
|
|
104
|
+
result: dict[str, Any] = {}
|
|
105
|
+
for k, v in (i.split("=", 1) if "=" in i else [i[0], i[1:]] for i in re.split(_RE_FIELD_SEP, line) if i):
|
|
106
|
+
if not v:
|
|
107
|
+
continue
|
|
108
|
+
if k in result:
|
|
109
|
+
result[k] += f", {v}"
|
|
110
|
+
else:
|
|
111
|
+
result[k] = v
|
|
112
|
+
return result
|
|
113
|
+
|
|
114
|
+
def parse_header(self, header: dict[str, Any]) -> Method:
|
|
115
|
+
"""
|
|
116
|
+
When finished collecting the header dict, then create the Method object
|
|
117
|
+
"""
|
|
118
|
+
if "HM" not in header:
|
|
119
|
+
raise ValueError("Header does not contain a HM field")
|
|
120
|
+
|
|
121
|
+
if header["HM"] not in self.method_code_class_mapping:
|
|
122
|
+
raise ValueError(f"Unsupported value in the HM field {header['HM']!r}")
|
|
123
|
+
|
|
124
|
+
return self.method_code_class_mapping[header["HM"]].model_validate(header)
|
|
125
|
+
|
|
126
|
+
def parse_data(self, method: Method, row: str) -> MethodData:
|
|
127
|
+
row_dict = self._convert_str_to_dict(row)
|
|
128
|
+
method_data = method.method_data_type.model_validate(row_dict)
|
|
129
|
+
return method_data
|
sgf_parser/units.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Norwegian Geotechnical Institute (NGI)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: sgf-parser
|
|
3
|
+
Version: 0.0.1a1
|
|
4
|
+
Summary: Parser for the Swedish Geotechnical Society / Svenska Geotekniska Föreningen (SGF) data format
|
|
5
|
+
Home-page: https://github.com/norwegian-geotechnical-institute/sgf-parser
|
|
6
|
+
License: MIT
|
|
7
|
+
Author: Jostein Leira
|
|
8
|
+
Author-email: jostein@leira.net
|
|
9
|
+
Maintainer: Jostein Leira
|
|
10
|
+
Maintainer-email: jostein@leira.net
|
|
11
|
+
Requires-Python: >=3.11,<4
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: GIS
|
|
19
|
+
Requires-Dist: pint (>=0.23,<0.24)
|
|
20
|
+
Requires-Dist: pydantic (>=2.6.3,<3.0.0)
|
|
21
|
+
Requires-Dist: python-dateutil (>=2.9.0.post0,<3.0.0)
|
|
22
|
+
Requires-Dist: types-python-dateutil (>=2.8.19.20240311,<3.0.0.0)
|
|
23
|
+
Project-URL: Repository, https://github.com/norwegian-geotechnical-institute/sgf-parser
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# sgf-parser
|
|
27
|
+
|
|
28
|
+
Parser for data from geotechnical field investigations in the data format
|
|
29
|
+
specified in Report 3:2012E from the Swedish Geotechnical Society /
|
|
30
|
+
[Svenska Geotekniska Föreningen](http://sgf.net/) (SGF).
|
|
31
|
+
|
|
32
|
+
This package is inspired by the [libsgfdata](https://github.com/emerald-geomodelling/libsgfdata)
|
|
33
|
+
package by [EMerald Geomodelling](https://www.emerald-geomodelling.com/).
|
|
34
|
+
|
|
35
|
+
Latest releases see [CHANGES.md](CHANGES.md)
|
|
36
|
+
|
|
37
|
+
# Installation (end user)
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install sgf-parser
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Basic usage
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from sgf_parser import Parser
|
|
47
|
+
|
|
48
|
+
with open("c:/dev/sgf-parser/tests/data/cpt-test-3.cpt", "rt") as file:
|
|
49
|
+
# The test file only contains one method
|
|
50
|
+
[method] = Parser().parse(file)
|
|
51
|
+
|
|
52
|
+
print(repr(method))
|
|
53
|
+
# <MethodCPT CPT method_data=[<MethodCPTData 1.000>, <MethodCPTData 1.020>, <MethodCPTData 1.040>,
|
|
54
|
+
# <MethodCPTData 1.060>, <MethodCPTData 1.080>, <MethodCPTData 1.100>, <MethodCPTData 1.120>, ...,
|
|
55
|
+
# <MethodCPTData 24.940>, <MethodCPTData 24.960>, <MethodCPTData 24.980>]>
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
method.model_dump(exclude={'method_data'}, exclude_defaults=True)
|
|
59
|
+
# {'location_name': 'Test', 'project_number': '1234', 'method_type_string': '107A',
|
|
60
|
+
# 'conducted_at': datetime.datetime(2019, 9, 5, 11, 5), 'predrilling_depth': Decimal('1.00'),
|
|
61
|
+
# 'cone_reference': '5349', 'cone_area_ratio': Decimal('0.844'), 'sleeve_area_ratio': Decimal('0'),
|
|
62
|
+
# 'application_class_depth': <ApplicationClass.ONE: 1>, 'application_class_resistance': <ApplicationClass.ONE: 1>,
|
|
63
|
+
# 'application_class_friction': <ApplicationClass.ONE: 1>, 'application_class_pressure': <ApplicationClass.ONE: 1>,
|
|
64
|
+
# 'depth_top': Decimal('1.000'), 'depth_base': Decimal('24.980'), 'stopcode': 90}
|
|
65
|
+
|
|
66
|
+
method.stopcode
|
|
67
|
+
# 90
|
|
68
|
+
|
|
69
|
+
len(method.method_data)
|
|
70
|
+
# 1200
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
# Getting Started developing
|
|
75
|
+
|
|
76
|
+
1. Software dependencies
|
|
77
|
+
|
|
78
|
+
- Python 3.11 or higher
|
|
79
|
+
- Poetry
|
|
80
|
+
- ruff code formatter
|
|
81
|
+
|
|
82
|
+
2. Clone this repository
|
|
83
|
+
|
|
84
|
+
3. Install
|
|
85
|
+
|
|
86
|
+
`poetry install`
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# Build and Test
|
|
90
|
+
|
|
91
|
+
Run in the project root folder:
|
|
92
|
+
|
|
93
|
+
poetry shell pytest
|
|
94
|
+
|
|
95
|
+
Build the package wheel:
|
|
96
|
+
|
|
97
|
+
poetry build
|
|
98
|
+
|
|
99
|
+
# Publish
|
|
100
|
+
|
|
101
|
+
# TODOs
|
|
102
|
+
|
|
103
|
+
- [ ] Implement everything
|
|
104
|
+
- [ ] Do the rest
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
# Contribute
|
|
108
|
+
|
|
109
|
+
Please start by adding an issue before submitting any pull requests.
|
|
110
|
+
|
|
111
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
sgf_parser/__init__.py,sha256=uJrN8Ri2HgEdkbw6CWeAooeoebA8tZfcAvsOkGF0m3M,36
|
|
2
|
+
sgf_parser/datetime_parser.py,sha256=VQyixN_gkhSVpoHQOA0tDHChIL89HTtv4XOfKIzUtRQ,1162
|
|
3
|
+
sgf_parser/models/__init__.py,sha256=f5TUFvp0_wbyPP32V4nBUbuF_xFbY1uQsnqAPih2KWM,494
|
|
4
|
+
sgf_parser/models/method.py,sha256=G_aeBw15SQBfCYrSmpoZ3x6zxV6x7Se7dvNVmRE47RQ,14654
|
|
5
|
+
sgf_parser/models/method_cpt.py,sha256=aK2_RkR_dMMvNw7_dLqeX6Dy1jo84StTM1aHAkjIGeI,10787
|
|
6
|
+
sgf_parser/models/method_rp.py,sha256=YDlkZYtBLjTgaC6qUZHco0Bdvxry_SpTJQLPhgg9Acg,2170
|
|
7
|
+
sgf_parser/models/method_srs.py,sha256=OfAYVVL63jF1Sp3LRXYNyoD0klE0NCHupZKekfY5H24,6388
|
|
8
|
+
sgf_parser/models/method_svt.py,sha256=BywWy8XIn5QSk_JBrkhfwwmZ9vcEXDepof7K3VFqm6w,2048
|
|
9
|
+
sgf_parser/models/method_tot.py,sha256=xz-5RXdkjIFuQpY7-6ZeG0KcFWEVm99G-gNR6aqhmVo,6198
|
|
10
|
+
sgf_parser/models/method_type.py,sha256=-IV7hJmt5I3NjUqPGwJLLqwRrdubGXsfDLc0_a_yhXw,173
|
|
11
|
+
sgf_parser/models/method_wst.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
+
sgf_parser/models/types.py,sha256=IgHUPi0hV9V5kkzRM3FWScrlBrF9RM5FtQonK7o0F-w,2556
|
|
13
|
+
sgf_parser/parser.py,sha256=3H0DCJfyY4jUBpO5J-pjUlA1kj-8rss8KkGRnl24Bok,4738
|
|
14
|
+
sgf_parser/units.py,sha256=55_zIkKi7wsoQkRKxMIPvGUAgH8AmWXh0Yobn05Dks4,102
|
|
15
|
+
sgf_parser-0.0.1a1.dist-info/LICENSE,sha256=0ooAuz7cztjSOr3NY_j81tJfBrl1ID8ZcSUMSVc76jk,1095
|
|
16
|
+
sgf_parser-0.0.1a1.dist-info/METADATA,sha256=PnT-0uQr-Tx3nXc32Ix2AN0EPZ1KnajBNKmFomx6mws,3243
|
|
17
|
+
sgf_parser-0.0.1a1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
18
|
+
sgf_parser-0.0.1a1.dist-info/RECORD,,
|