ge.io — Data I/O¶
Read the file formats commonly used for geotechnical data exchange, without having to parse them by hand.
CSV reader¶
Auto-detects the header row (skipping metadata lines) and optionally reads a units row. Returns a dict of NumPy arrays plus a pandas DataFrame if pandas is installed.
res = ge.read_csv(
"borehole_log.csv",
sep=",", skiprows=None, # auto-detect
units_row=True,
encoding="utf-8",
)
res["data"]["depth"] # np.ndarray
res["df"] # pandas DataFrame (or None)
res["units"] # {'depth': 'm', 'qc': 'MPa', ...}
res["header_row"]
res["n_rows"]
AGS4 reader (UK / Australia / NZ)¶
The AGS4 format is the UK / Commonwealth ground-investigation data
standard. GeoEq parses every group and returns a dict keyed by group
name (LOCA, GEOL, SCPT, ISPT, …):
groups = ge.read_ags("investigation.ags")
groups["LOCA"]["headings"] # ['LOCA_ID', 'LOCA_NATE', 'LOCA_NATN', ...]
groups["LOCA"]["units"] # ['', 'm', 'm', ...]
groups["LOCA"]["data"] # [{'LOCA_ID': 'BH1', ...}, ...]
groups["GEOL"]["data"][0]["GEOL_DESC"] # 'Topsoil'
GEF-CPT reader (Netherlands)¶
The GEF (Geef Eenvoudige Formaat) format is the Dutch standard for
CPT data exchange. GeoEq parses the #KEY= value header (terminated
by #EOH=) and the subsequent columnar data, applying
#COLUMNVOID placeholders as NaN:
res = ge.read_gef("sounding.gef")
res["header"] # dict of #KEY metadata
res["columns"] # ['depth', 'qc', 'fs', ...]
res["units"] # ['m', 'MPa', 'MPa', ...]
res["data"]["qc"] # np.ndarray (COLUMNVOID -> NaN)
CPT container¶
A light wrapper around (depth, qc, fs, u2) arrays with classmethods
for loading directly from file. The container aliases differing
column names across formats (e.g. Dutch sondeerlengte → depth):
# Direct construction
c = ge.CPT(depth=z, qc=qc, fs=fs, u2=u2, title="BH1-CPT-1")
# From a file
c = ge.CPT.from_gef("sounding.gef")
c = ge.CPT.from_ags("investigation.ags")
print(c) # CPT('sounding', n=420, z=0.5..21.5 m)
# Feed into the functional API
Qt, Fr, Bq = ge.cpt_normalize(c.qc, c.fs, sigma_v, sigma_v_eff, c.u2)
zones = [ge.cpt_sbt(Qt[i], Fr[i]) for i in range(len(c))]
API reference¶
read_csv
¶
read_csv(path, sep: str = ',', skiprows: Optional[int] = None, encoding: str = 'utf-8', units_row: bool = False) -> dict
Read a geotech CSV file.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
File path.
TYPE:
|
sep
|
Field separator. Default ','.
TYPE:
|
skiprows
|
Number of header rows to skip. If None, auto-detected.
TYPE:
|
encoding
|
File encoding. Default 'utf-8'.
TYPE:
|
units_row
|
If True, treat the row after the header as a units row (returned in the 'units' dict) and skip it for numeric parsing.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict
|
|
Source code in geoeq/io/csv_reader.py
read_ags
¶
Parse an AGS4 file and return all groups as dicts.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
AGS file path.
TYPE:
|
encoding
|
File encoding (AGS4 specifies UTF-8). Default 'utf-8'.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict
|
|
Reference
AGS (2017) -- AGS4 data-transfer specification.
Source code in geoeq/io/ags_reader.py
read_gef
¶
Read a Dutch GEF-CPT file.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
Path to the .gef file.
TYPE:
|
encoding
|
File encoding (most GEF files are 'latin-1'). Default.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict
|
|
Reference
NEN -- GEF file specification (CPT-Report).
Source code in geoeq/io/gef_reader.py
| Python | |
|---|---|
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
CPT
¶
CPT(depth: Sequence[float], qc: Sequence[float], fs: Sequence[float] = None, u2: Sequence[float] = None, title: str = 'CPT')
Container for a single CPT sounding.
| ATTRIBUTE | DESCRIPTION |
|---|---|
depth |
Depth (m).
TYPE:
|
qc |
Cone tip resistance (MPa or kPa -- callers must be consistent).
TYPE:
|
fs |
Sleeve friction (kPa).
TYPE:
|
u2 |
Pore pressure behind cone (kPa). Default zeros.
TYPE:
|
title |
Sounding name.
TYPE:
|
Source code in geoeq/io/cpt_container.py
from_gef
classmethod
¶
Build a CPT from a GEF file.
Source code in geoeq/io/cpt_container.py
from_ags
classmethod
¶
Build a CPT from an AGS4 file (uses STCN / SCPT / CPTU groups).