跳转到主要内容

解析土壤测量数据。

项目描述

PYGEF

Code style: black PyPi Version GitHub stars Coverage Status

简单的*.gef文件解析器。这些是基于ASCII的文件,用于土壤特性测量。兼容Python 3.9。

最近添加了xml钻孔文件的解析,xml解析仍处于初步阶段,不是所有文件都受支持。如果您发现pygef无法处理的文件,请提交相关issue或PR :)

安装

最新稳定版本

$ pip install pygef

尖端版本(可能破坏)

$ pip install git+https://github.com/cemsbv/pygef.git

CPT文件

>> > from pygef import read_cpt
>> >  # read gef and xml files
>> > cpt_data = read_cpt("./my-cpt.xml")
>> > cpt_data
CPTData: {'bro_id': 'CPT000000099543',
          'cone_diameter': 44,
          'cone_surface_area': 1500,
          'cone_surface_quotient': 0.67,
          'cone_to_friction_sleeve_distance': 100,
          'cone_to_friction_sleeve_surface_area': 22530,
          'cone_to_friction_sleeve_surface_quotient': 1.0,
          ...
              'zlm_pore_pressure_u3_after': None,
'zlm_pore_pressure_u3_before': None}
>> >  # access the underlying polars DataFrame under the `data` attribute
>> > cpt_data.data.head()
shape: (5, 9)
┌────────────┬───────┬───────────┬────────────┬─────┬────────────┬────────────┬────────────┬────────────┐
 penetratio  depth  elapsedTi  coneResist  ...  inclinatio  inclinatio  localFrict  frictionRa 
 nLength     ---    me         ance             nNS         nResultant  ion         tio        
 ---         f64    ---        ---              ---         ---         ---         ---        
 f64                f64        f64              i64         i64         f64         f64        
╞════════════╪═══════╪═══════════╪════════════╪═════╪════════════╪════════════╪════════════╪════════════╡
 0.0         0.0    -9.99999
e  -9.99999e5  ...  -999999     -999999     -9.99999e5  -9.99999e5 
                    5                                                                          
├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
 0.02        0.02   11.0       2.708       ...  0           0           0.03        0.6        
├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
 0.04        0.039  13.0       4.29        ...  0           0           0.039       0.8        
├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
 0.06        0.059  15.0       5.124       ...  0           0           0.045       0.9        
├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┤
 0.08        0.079  17.0       5.45        ...  0           0           0.049       1.0        
└────────────┴───────┴───────────┴────────────┴─────┴────────────┴────────────┴────────────┴────────────┘

钻孔文件

>> > from pygef import read_bore
>> >  # read gef and xml files
>> > bore_data = read_bore("./my-bore.xml")
>> > bore_data
BoreData: {'bore_hole_completed': True,
           'bore_rock_reached': False,
           'data': (13, 8),
           'delivered_location': Location(srs_name='urn:ogc:def:crs:EPSG::28992', x=158322.139, y=444864.706),
           'delivered_vertical_position_datum': 'nap',
           'delivered_vertical_position_offset': 10.773,
           'delivered_vertical_position_reference_point': 'maaiveld',
           'description_procedure': 'ISO14688d1v2019c2020',
           'final_bore_depth': 12.0,
           'final_sample_depth': 12.0,
           'research_report_date': datetime.date(2021, 10, 19)}
>> >  # access the underlying polars DataFrame under the `data` attribute
>> > bore_data.data.head()
shape: (5, 8)
┌────────────┬────────────┬────────────┬──────────┬────────────┬────────────┬────────────┬─────────┐
 upper_boun  lower_boun  geotechnic  color     dispersed_  organic_ma  sand_media  soil_di 
 dary        dary        al_soil_na  ---       inhomogeni  tter_conte  n_class     st      
 ---         ---         me          str       ty          nt_class    ---         ---     
 f64         f64         ---                   ---         ---         str         list[f6 
                         str                   bool        str                     4]      
╞════════════╪════════════╪════════════╪══════════╪════════════╪════════════╪════════════╪═════════╡
 0.0         1.0         zwakGrindi  donkergr  false       nietOrgani  middelgrof  [0.2,   
                         gZand       ijs                   sch         420
tot630u  0.0,    
                                                                       m           ...     
                                                                                   0.0]    
├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
 1.0         1.1         zwakGrindi  donkergr  false       nietOrgani  middelgrof  [0.2,   
                         gZand       ijs                   sch         420
tot630u  0.0,    
                                                                       m           ...     
                                                                                   0.0]    
├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
 1.1         2.0         zwakZandig  standaar  false       nietOrgani  null        [0.0,   
                         eKleiMetGr  dBruin                sch                     0.1,    
                         ind                                                       ...     
                                                                                   0.0]    
├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
 2.0         3.0         zwakZandig  standaar  false       nietOrgani  null        [0.0,   
                         eKlei       dGrijs                sch                     0.0,    
                                                                                   ...     
                                                                                   0.0]    
├╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
 3.0         4.0         zwakZandig  donkergr  false       nietOrgani  null        [0.0,   
                         eKlei       ijs                   sch                     0.0,    
                                                                                   ...     
                                                                                   0.0]    
└────────────┴────────────┴────────────┴──────────┴────────────┴────────────┴────────────┴─────────┘

绘图

from pygef import read_cpt, read_bore
from pygef.plotting import plot_cpt, plot_bore

# plot cpt file
plot_cpt(read_cpt("myfile.xml"))

# plot a bore file
plot_bore(read_bore("myfile.xml"))

文档

构建文档

python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
pip install .

sphinx-build -b html docs public

格式

我们使用black和isort格式化代码。

black --config "pyproject.toml" .
isort --settings-path "pyproject.toml" .

代码审查

为了保持代码质量,我们使用GitHub超级代码审查工具。

在本地运行代码检查器,请从根目录运行以下bash脚本

docker run \
--env VALIDATE_ALL_CODEBASE=false \
--env RUN_LOCAL=true \
--env VALIDATE_JSCPD=false \
--env VALIDATE_CSS=false \
--env VALIDATE_BASH=false \
--env VALIDATE_YAML=false \
--env VALIDATE_PYTHON_PYLINT=false \
--env VALIDATE_NATURAL_LANGUAGE=false \
--env VALIDATE_MARKDOWN=false \
--env LINTER_RULES_PATH=/ \
--env PYTHON_BLACK_CONFIG_FILE=pyproject.toml \
--env PYTHON_ISORT_CONFIG_FILE=pyproject.toml \
--env PYTHON_MYPY_CONFIG_FILE=pyproject.toml \
--env PYTHON_FLAKE8_CONFIG_FILE=.flake8 \
-v $(pwd):/tmp/lint ghcr.io/super-linter/super-linter:v6

单元测试

使用覆盖率测试软件

python -m pip install --upgrade pip setuptools
pip install -r requirements.txt
pip install .

coverage run -m pytest

需求

需求由python 3.9的pip-compile自动生成

pip-compile --extra=test --extra=docs --extra=lint --extra=map --output-file=requirements.txt pyproject.toml

要更新定义范围内的需求,请运行

pip-compile --upgrade --extra=test --extra=docs --extra=lint --extra=map --output-file=requirements.txt pyproject.toml

自动升级Polars代码,使其与未来的版本兼容。

pip install -U polars-upgrade
polars-upgrade src/pygef tests --target-version=0.19.19

项目详情


下载文件

下载您平台上的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源代码分发

pygef-0.11.0.tar.gz (34.1 kB 查看哈希值)

上传时间 源代码

构建分发

pygef-0.11.0-py3-none-any.whl (36.0 kB 查看哈希值)

上传时间 Python 3

由以下组织支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面