Index
subsurfaceio.logplot
Publication-quality graphical logs (boring / CPT / test-pit).
Compose a template and data payload, then write PDF or HTML:
from subsurfaceio.logplot import LogPlot
LogPlot().load_template('GintBorehole').load_data('B-1').write_pdf('log.pdf')
Modules:
| Name | Description |
|---|---|
render |
SVG logplot rendering. |
Classes:
| Name | Description |
|---|---|
AxisColumn |
Depth or elevation tick axis column. |
CPTLogData |
SI CPT row plus log-only |
Column |
One template column: header title, width share, and typed model. |
ColumnHeaderStyle |
Style for the column-header band above the log body. |
ColumnTitle |
Label drawn in the column-header band. |
Figure |
Page geometry and paging for a log plot. |
FigureMargins |
Figure margins as fractions of page width/height. |
GraphicColumn |
Hatch/fill graphic column (lithology, sampler, well, etc.). |
Header |
Metadata header grid below the figure title. |
LogPlot |
Publication-quality graphical log (SVG → PDF/HTML). |
LogPlotData |
Payload rendered by a log plot template. |
LogPlotMetadata |
Well-known scalars for the log title, header, and elevation axes. |
LogPlotTemplate |
Column layout and page settings for a log plot. |
PageState |
Current page depth window (meters). |
PlotColumn |
Continuous parameter plot column (matplotlib → SVG). |
PlotGrid |
Grid visibility for plot columns. |
PlotParameters |
Matplotlib line/marker style for a plot series. |
PlotSeries |
One data series drawn inside a plot column. |
SPTLogData |
SPT drive row for logplot (depths in m). |
SamplesData |
Sample interval row for sampler graphic/text columns. |
SpecimensData |
Lab specimen scalars plotted or labeled on the log. |
TextColumn |
Interval or point text column. |
TextParameters |
Typography for text columns. |
WellData |
Well-construction interval for graphic/text columns. |
XAxisLimits |
Optional fixed x-axis limits for a plot column. |
Attributes:
| Name | Type | Description |
|---|---|---|
Color |
TypeAlias
|
CSS/Plotly color string used in plot-column styling. |
ColumnModel |
TypeAlias
|
Discriminated axis, text, graphic, or plot column model. |
ColumnType |
TypeAlias
|
Discriminated template column kind. |
DEFAULT_LOGPLOT_HEADER_FIELDS |
tuple[str, ...]
|
|
FontWeight |
TypeAlias
|
Column-header font weight. |
HorizontalAlignment |
TypeAlias
|
Horizontal text alignment in a text column. |
TitleRotation |
TypeAlias
|
Column-header title rotation. |
WellPointer |
TypeAlias
|
gINT well-construction leader attach point (annulus, center, edge). |
Color
module-attribute
CSS/Plotly color string used in plot-column styling.
ColumnModel
module-attribute
ColumnModel: TypeAlias = Annotated[
AxisColumn | TextColumn | GraphicColumn | PlotColumn,
Field(discriminator="column_type"),
]
Discriminated axis, text, graphic, or plot column model.
ColumnType
module-attribute
Discriminated template column kind.
DEFAULT_LOGPLOT_HEADER_FIELDS
module-attribute
DEFAULT_LOGPLOT_HEADER_FIELDS: tuple[str, ...] = (
"project_name",
"client",
"location",
"{easting} / {northing}",
"test_id",
"{date_start} / {date_end}",
"engineer",
"surface_elevation",
"water_table",
"final_depth",
"method",
"contractor",
"crew",
"remarks",
)
FontWeight
module-attribute
Column-header font weight.
HorizontalAlignment
module-attribute
Horizontal text alignment in a text column.
TitleRotation
module-attribute
Column-header title rotation.
WellPointer
module-attribute
gINT well-construction leader attach point (annulus, center, edge).
AxisColumn
pydantic-model
Bases: BaseModel
Depth or elevation tick axis column.
Elevation mode uses LogPlotMetadata.surface_elevation.
Attributes:
| Name | Type | Description |
|---|---|---|
column_type |
Literal['axis']
|
Union tag; must be |
as_elevation |
bool
|
If True, ticks show elevation instead of depth. |
Fields:
-
column_type(Literal['axis']) -
as_elevation(bool)
CPTLogData
pydantic-model
Column
pydantic-model
Bases: BaseModel
One template column: header title, width share, and typed model.
Attributes:
| Name | Type | Description |
|---|---|---|
title |
ColumnTitle
|
Label in the column-header band. |
width_ratio |
float
|
Share of content width (normalized on the template). |
model |
ColumnModel
|
Discriminated column model. |
Fields:
-
title(ColumnTitle) -
width_ratio(float) -
model(ColumnModel)
ColumnHeaderStyle
pydantic-model
Bases: BaseModel
Style for the column-header band above the log body.
Attributes:
| Name | Type | Description |
|---|---|---|
size |
str
|
Header band height as a percent string (for example |
weight |
FontWeight
|
Font weight for column titles. |
Fields:
-
size(str) -
weight(FontWeight)
ColumnTitle
pydantic-model
Bases: BaseModel
Label drawn in the column-header band.
Attributes:
| Name | Type | Description |
|---|---|---|
title |
str
|
Header text. |
rotation |
TitleRotation
|
Title rotation. |
Fields:
-
title(str) -
rotation(TitleRotation)
Figure
pydantic-model
Bases: BaseModel
Page geometry and paging for a log plot.
Attributes:
| Name | Type | Description |
|---|---|---|
title |
str | None
|
Figure title; may interpolate |
width |
float
|
Page width in inches. |
height |
float
|
Page height in inches. |
watermark |
str | None
|
Footer watermark, or |
y_values_per_page |
int
|
Depth span (m) covered by one page. |
y_top |
float
|
Depth (m) at the top of the first page. |
Fields:
FigureMargins
pydantic-model
Bases: BaseModel
Figure margins as fractions of page width/height.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
float
|
Left margin as a fraction of page width. |
right |
float
|
Right content edge as a fraction of page width. |
top |
float
|
Top content edge as a fraction of page height. |
bottom |
float
|
Bottom margin as a fraction of page height. |
Fields:
GraphicColumn
pydantic-model
Bases: BaseModel
Hatch/fill graphic column (lithology, sampler, well, etc.).
Attributes:
| Name | Type | Description |
|---|---|---|
column_type |
Literal['graphic']
|
Union tag; must be |
data_source |
str
|
|
y_top_field |
str
|
Top-of-interval field on each row. |
y_bottom_field |
str
|
Bottom-of-interval field on each row. |
color_field |
str | None
|
Optional fill-color field. |
hatch_field |
str | None
|
Optional hatch-key field. |
text_field |
str | None
|
Optional label field or format template. |
pointer_field |
str | None
|
Optional well-pointer field ( |
width_factor |
float
|
Hatch strip width as a fraction of the column. |
horizontal_borders |
bool
|
If True, draw interval boundary lines. |
Fields:
-
column_type(Literal['graphic']) -
data_source(str) -
y_top_field(str) -
y_bottom_field(str) -
color_field(str | None) -
hatch_field(str | None) -
text_field(str | None) -
pointer_field(str | None) -
width_factor(float) -
horizontal_borders(bool)
Header
pydantic-model
Bases: BaseModel
Metadata header grid below the figure title.
fields chooses LogPlotMetadata
attributes or {field} templates, in column-major order. Missing values
render as - so the grid stays aligned across holes.
Attributes:
| Name | Type | Description |
|---|---|---|
height |
float
|
Header band height as a fraction of page height. |
nrows |
int
|
Number of header rows. |
ncols |
int
|
Number of header columns. |
logo |
str | None
|
Logo URL or path, or |
fields |
list[str]
|
Metadata names or |
Fields:
Validators:
LogPlot
pydantic-model
Bases: Model
Publication-quality graphical log (SVG → PDF/HTML).
Create with a LogPlotTemplate and
LogPlotData, then call
write_pdf or
write_html.
Attributes:
| Name | Type | Description |
|---|---|---|
template |
LogPlotTemplate
|
Column layout and page settings. |
data |
LogPlotData
|
Rows and metadata rendered by the template. |
Fields:
rendered_pages
property
Cached multipage SVG strings (computed on first access).
resolved_title
property
Figure title with metadata placeholders interpolated when possible.
svg_definitions
property
Shared SVG <defs> bag for the current page render.
generate_current_page_svg
Render the current page_state as an SVG document string.
Returns:
| Type | Description |
|---|---|
str
|
Complete SVG document for one page. |
generate_pages_svg
Render all pages covering the inferred depth range.
Returns:
| Type | Description |
|---|---|
list[str]
|
One SVG string per page. If no depth data is present (or the
inferred range yields no pages), returns a single page at
|
infer_data_ylim
Infer depth limits from template column data sources.
Returns:
| Type | Description |
|---|---|
Self
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If a column references an unknown |
load_data
Replace data from a bundled dataset and clear page cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_id
|
Literal[*available_datasets(),]
|
Name under |
required |
Returns:
| Type | Description |
|---|---|
Self
|
|
load_template
Replace template from a bundled dataset and clear page cache.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_id
|
Literal[*available_datasets(),]
|
Name under |
required |
Returns:
| Type | Description |
|---|---|
Self
|
|
set_page_state
Set the current page depth window from y_top.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
y_top
|
float
|
Depth (m) at the top of the page. |
required |
write_html
Write an HTML report with inline SVG pages.
The document title is resolved_title,
or Log plot when that is empty.
Opening the HTML in Chrome and using Print → PDF can show uneven
letter-spacing on SVG text (Chromium print/hinting). Prefer
write_pdf (CairoSVG) for publication PDFs. See TODO.md (logplot).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Output HTML path. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The written path. |
LogPlotData
pydantic-model
Bases: Model
Payload rendered by a log plot template.
Header and title values live on LogPlotMetadata.
LogPlotTemplate header.fields
chooses which appear and in what order.
Attributes:
| Name | Type | Description |
|---|---|---|
metadata |
LogPlotMetadata
|
Header and title scalars. |
strata |
list[StrataData]
|
Lithology intervals. |
samples |
list[SamplesData]
|
Sampler intervals. |
specimens |
list[SpecimensData]
|
Lab specimen rows. |
spt |
list[SPTLogData]
|
SPT drive rows. |
cpt |
list[CPTLogData]
|
CPT rows. |
well |
list[WellData]
|
Well-construction intervals. |
Fields:
-
metadata(LogPlotMetadata) -
strata(list[StrataData]) -
samples(list[SamplesData]) -
specimens(list[SpecimensData]) -
spt(list[SPTLogData]) -
cpt(list[CPTLogData]) -
well(list[WellData])
LogPlotMetadata
pydantic-model
Bases: BaseModel
Well-known scalars for the log title, header, and elevation axes.
Config:
extra:forbid
Fields:
-
test_id(str | None) -
project_id(str | None) -
project_name(str | None) -
client(str | None) -
contractor(str | None) -
engineer(str | None) -
location(str | None) -
crew(str | None) -
method(str | None) -
rig_model(str | None) -
remarks(str | None) -
easting(NullableFloat) -
northing(NullableFloat) -
surface_elevation(NullableFloat) -
water_table(NullableFloat) -
final_depth(NullableFloat) -
date_start(date | None) -
date_end(date | None)
LogPlotTemplate
pydantic-model
Bases: Model
Column layout and page settings for a log plot.
Attributes:
| Name | Type | Description |
|---|---|---|
figure |
Figure
|
Page geometry and paging. |
header |
Header
|
Metadata header grid. |
column_headers |
ColumnHeaderStyle
|
Style for the column-title band. |
margins |
FigureMargins
|
Figure margins as fractions of page size. |
columns |
list[Column]
|
Ordered template columns. |
Fields:
-
figure(Figure) -
header(Header) -
column_headers(ColumnHeaderStyle) -
margins(FigureMargins) -
columns(list[Column])
Validators:
PageState
pydantic-model
PlotColumn
pydantic-model
Bases: BaseModel
Continuous parameter plot column (matplotlib → SVG).
Attributes:
| Name | Type | Description |
|---|---|---|
column_type |
Literal['plot']
|
Union tag; must be |
show_legend |
bool
|
If True, draw a legend when multiple series exist. |
grid |
PlotGrid
|
Grid visibility. |
x_axis_limits |
XAxisLimits
|
Optional fixed x-axis limits. |
series |
list[PlotSeries]
|
Data series drawn in this column. |
Fields:
-
column_type(Literal['plot']) -
show_legend(bool) -
grid(PlotGrid) -
x_axis_limits(XAxisLimits) -
series(list[PlotSeries])
PlotGrid
pydantic-model
PlotParameters
pydantic-model
Bases: BaseModel
Matplotlib line/marker style for a plot series.
Attributes:
| Name | Type | Description |
|---|---|---|
marker |
str | None
|
Matplotlib marker, or |
color |
Color | None
|
Line/marker color. |
linewidth |
float
|
Line width in points. |
fillstyle |
Literal['full', 'left', 'right', 'bottom', 'top', 'none']
|
Matplotlib marker fill style. |
linestyle |
Literal['-', '--', '-.', ':', '', 'none']
|
Matplotlib line style. |
drawstyle |
Literal['default', 'steps', 'steps-pre', 'steps-mid', 'steps-post']
|
Matplotlib draw style (including steps). |
Fields:
-
marker(str | None) -
color(Color | None) -
linewidth(float) -
fillstyle(Literal['full', 'left', 'right', 'bottom', 'top', 'none']) -
linestyle(Literal['-', '--', '-.', ':', '', 'none']) -
drawstyle(Literal['default', 'steps', 'steps-pre', 'steps-mid', 'steps-post'])
drawstyle
pydantic-field
fillstyle
pydantic-field
PlotSeries
pydantic-model
Bases: BaseModel
One data series drawn inside a plot column.
Attributes:
| Name | Type | Description |
|---|---|---|
data_source |
str
|
|
x_field |
str
|
Horizontal data field. |
y_field |
str
|
Vertical field; typically |
parameters |
PlotParameters
|
Matplotlib style for this series. |
Fields:
-
data_source(str) -
x_field(str) -
y_field(str) -
parameters(PlotParameters)
SPTLogData
pydantic-model
Bases: DepthInterval
SPT drive row for logplot (depths in m).
Fields:
-
depth_top(NullableFloat) -
depth(NullableFloat) -
seating_blow_count(NullableFloat) -
main_blow_count_1(NullableFloat) -
main_blow_count_2(NullableFloat) -
main_blow_count_3(NullableFloat) -
blow_count(NullableFloat) -
seating_penetration(NullableFloat) -
main_penetration_1(NullableFloat) -
main_penetration_2(NullableFloat) -
main_penetration_3(NullableFloat) -
drive_length(NullableFloat) -
reported_blow_count(str | None)
Validators:
SamplesData
pydantic-model
Bases: DepthInterval
Sample interval row for sampler graphic/text columns.
Fields:
-
depth_top(NullableFloat) -
depth(NullableFloat) -
sample(str | None) -
sampler_type(SamplerGraphics | None) -
recovery(float | str | None) -
rock_quality_designation(NullableFloat) -
fracture_intensity(NullableFloat) -
return_flow(NullableFloat) -
drilling_rate_index(NullableFloat)
SpecimensData
pydantic-model
Bases: DepthInterval
Lab specimen scalars plotted or labeled on the log.
Fields:
-
depth_top(NullableFloat) -
depth(NullableFloat) -
dry_density(NullableFloat) -
bulk_density(NullableFloat) -
unit_weight(NullableFloat) -
water_content(NullableFloat) -
liquid_limit(float | str | None) -
plastic_limit(float | str | None) -
plasticity_index(float | str | None) -
fines_content(NullableFloat) -
environmental_data(str | None) -
undrained_shear_strength_torvane(NullableFloat) -
unconfined_compressive_strength(NullableFloat) -
unconfined_compressive_strength_pocket_penetrometer(NullableFloat) -
percent_passing_no4(NullableFloat) -
percent_passing_no10(NullableFloat)
unconfined_compressive_strength
pydantic-field
unconfined_compressive_strength_pocket_penetrometer
pydantic-field
undrained_shear_strength_torvane
pydantic-field
TextColumn
pydantic-model
Bases: BaseModel
Interval or point text column.
Attributes:
| Name | Type | Description |
|---|---|---|
column_type |
Literal['text']
|
Union tag; must be |
data_source |
str
|
|
text_field |
str
|
Attribute name or |
y_top_field |
str
|
Top-of-interval field on each row. |
y_bottom_field |
str
|
Bottom-of-interval field on each row. |
round_precision |
int | None
|
Optional numeric rounding before display. |
parameters |
TextParameters
|
Typography for this column. |
Fields:
-
column_type(Literal['text']) -
data_source(str) -
text_field(str) -
y_top_field(str) -
y_bottom_field(str) -
round_precision(int | None) -
parameters(TextParameters)
TextParameters
pydantic-model
Bases: BaseModel
Typography for text columns.
Attributes:
| Name | Type | Description |
|---|---|---|
font_size |
float
|
Font size in points. |
horizontal_alignment |
HorizontalAlignment
|
Horizontal text alignment. |
Fields:
-
font_size(float) -
horizontal_alignment(HorizontalAlignment)
WellData
pydantic-model
Bases: DepthInterval
Well-construction interval for graphic/text columns.
Fields:
-
depth_top(NullableFloat) -
depth(NullableFloat) -
hatch(WellGraphics | None) -
text(str | None) -
pointer(WellPointer | None)
XAxisLimits
pydantic-model
Bases: BaseModel
Optional fixed x-axis limits for a plot column.
Attributes:
| Name | Type | Description |
|---|---|---|
left |
NullableFloat
|
Lower x-limit, or |
right |
NullableFloat
|
Upper x-limit, or |
Fields: