Skip to content

Commit 32f694b

Browse files
authored
Add methods Tr, Slb and Sti (#19)
* Add method tr, slb and sti. Update CHANGES.md Update packages Bump version to 0.0.3 * Add tests for Tr. Refactored some computed fields (moved to the super class). * Update test files. * Add more SRS test files. * Changed to use all uppercase method type names. * Update packages. Update lock file.
1 parent 3b1efcc commit 32f694b

28 files changed

Lines changed: 3539 additions & 729 deletions

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*.[Vv][Ii][Mm] binary
1010
*.[Ss][Tt][Dd] binary
1111
*.[Tt][Oo][Tt] binary
12+
*.[Tt][Rr][Tt] binary
1213

1314
# std, cpt, tot and dtr files are specified as eol=crlf
1415
*.[Cc][Pp][Tt] text eol=crlf

.github/workflows/branch.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
fail-fast: false
88
matrix:
99
python-version: ['3.11', '3.12', '3.13']
10-
poetry-version: ['1.8.3']
10+
poetry-version: ['2.1.1']
1111
os: [ubuntu-latest]
1212
runs-on: ${{ matrix.os }}
1313
steps:
@@ -30,7 +30,7 @@ jobs:
3030
fail-fast: false
3131
matrix:
3232
python-version: ['3.11', '3.12', '3.13']
33-
poetry-version: ['1.8.3']
33+
poetry-version: ['2.1.1']
3434
os: [ubuntu-latest]
3535
runs-on: ${{ matrix.os }}
3636
steps:

.github/workflows/release.yaml

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
name: Release
2-
on:
3-
release:
4-
types:
5-
- created
6-
7-
jobs:
8-
publish:
9-
strategy:
10-
fail-fast: false
11-
matrix:
12-
python-version: ['3.12']
13-
poetry-version: ['1.8.3']
14-
os: [ubuntu-latest]
15-
runs-on: ${{ matrix.os }}
16-
steps:
17-
- uses: actions/checkout@v4
18-
- uses: actions/setup-python@v5
19-
with:
20-
python-version: ${{ matrix.python-version }}
21-
- name: Run image
22-
uses: abatilo/actions-poetry@v2
23-
with:
24-
poetry-version: ${{ matrix.poetry-version }}
25-
- name: Publish
26-
env:
27-
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
28-
run: |
29-
poetry config pypi-token.pypi $PYPI_TOKEN
30-
poetry publish --build
1+
name: Release
2+
on:
3+
release:
4+
types:
5+
- created
6+
7+
jobs:
8+
publish:
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
python-version: ['3.12']
13+
poetry-version: ['2.1.1']
14+
os: [ubuntu-latest]
15+
runs-on: ${{ matrix.os }}
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-python@v5
19+
with:
20+
python-version: ${{ matrix.python-version }}
21+
- name: Run image
22+
uses: abatilo/actions-poetry@v2
23+
with:
24+
poetry-version: ${{ matrix.poetry-version }}
25+
- name: Publish
26+
env:
27+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
28+
run: |
29+
poetry config pypi-token.pypi $PYPI_TOKEN
30+
poetry publish --build

CHANGES.md

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

3+
_2025-02-17_
4+
5+
Version 0.0.3
6+
7+
Add support for the methods Pressure Sounding (Tr), Impact sounding (Slb) and Light sounding (Sti).
8+
39
_2024-10-15_
410

511
Version 0.0.2

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ len(method.method_data)
5151
1. Software dependencies
5252

5353
- Python 3.11 or higher
54-
- Poetry
54+
- Poetry 2
5555
- ruff code formatter
5656

5757
2. Clone this repository

poetry.lock

Lines changed: 659 additions & 551 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 & 6 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.2"
18+
version = "0.0.3"
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>"]
@@ -24,9 +24,9 @@ readme = "README.md"
2424
homepage = "https://github.com/norwegian-geotechnical-institute/sgf-parser"
2525
repository = "https://github.com/norwegian-geotechnical-institute/sgf-parser"
2626
classifiers = [
27-
# "Development Status :: 5 - Production/Stable",
27+
"Development Status :: 5 - Production/Stable",
2828
# "Development Status :: 4 - Beta",
29-
"Development Status :: 3 - Alpha",
29+
# "Development Status :: 3 - Alpha",
3030
"Operating System :: OS Independent",
3131
"Programming Language :: Python :: 3",
3232
"Topic :: Scientific/Engineering :: GIS",
@@ -58,7 +58,7 @@ no_implicit_reexport = false
5858

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

@@ -71,8 +71,6 @@ 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"}
7674

7775
[build-system]
7876
requires = ["poetry-core>=1.0.0"]

src/sgf_parser/models/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@
99
from sgf_parser.models.method_srs import MethodSRS, MethodSRSData
1010
from sgf_parser.models.method_svt import MethodSVT, MethodSVTData
1111
from sgf_parser.models.method_tot import MethodTOT, MethodTOTData
12+
from sgf_parser.models.method_tr import MethodTR, MethodTRData
13+
from sgf_parser.models.method_slb import MethodSLB, MethodSLBData
14+
from sgf_parser.models.method_sti import MethodSTI, MethodSTIData
1215
from sgf_parser.models.method_wst import MethodWST, MethodWSTData

src/sgf_parser/models/method.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from decimal import Decimal
55
from typing import Any
66

7-
from pydantic import BaseModel, Field, AliasChoices, model_validator
7+
from pydantic import BaseModel, Field, AliasChoices, model_validator, computed_field
88

99
from sgf_parser.datetime_parser import convert_str_to_datetime, convert_str_to_time
1010
from sgf_parser.models import MethodType
@@ -394,6 +394,27 @@ def guess_date_format(cls, data: Any) -> Any:
394394

395395
return data
396396

397+
@computed_field
398+
def depth_top(self) -> Decimal | None:
399+
if not self.method_data:
400+
return None
401+
402+
return min(method_data.depth for method_data in self.method_data)
403+
404+
@computed_field
405+
def depth_base(self) -> Decimal | None:
406+
if not self.method_data:
407+
return None
408+
409+
return max(method_data.depth for method_data in self.method_data)
410+
411+
@computed_field
412+
def stopcode(self) -> int | None:
413+
if not self.method_data:
414+
return None
415+
416+
return self.method_data[-1].comment_code
417+
397418
method_type: MethodType
398419
method_data_type: type[MethodData]
399420

src/sgf_parser/models/method_cpt.py

Lines changed: 1 addition & 22 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, AliasChoices, computed_field
4+
from pydantic import Field, AliasChoices
55

66
from sgf_parser.models import MethodType, MethodData, Method
77
from sgf_parser.models.types import ApplicationClass
@@ -251,27 +251,6 @@ def application_class(self) -> ApplicationClass:
251251
else:
252252
return ApplicationClass.UNKNOWN
253253

254-
@computed_field
255-
def depth_top(self) -> Decimal | None:
256-
if not self.method_data:
257-
return None
258-
259-
return min(method_data.depth for method_data in self.method_data)
260-
261-
@computed_field
262-
def depth_base(self) -> Decimal | None:
263-
if not self.method_data:
264-
return None
265-
266-
return max(method_data.depth for method_data in self.method_data)
267-
268-
@computed_field
269-
def stopcode(self) -> int | None:
270-
if not self.method_data:
271-
return None
272-
273-
return self.method_data[-1].comment_code
274-
275254
# "MA": "cone_area_ratio", # same as header code IE
276255
# "IE": "cone_area_ratio", # same as header code MA
277256
# "MB": "sleeve_area_ratio", # same as header code IF

0 commit comments

Comments
 (0)