Skip to content

Context

subsurfaceio.cross_section.render.context

Render-time coordinate context for cross-section DXF export.

Classes:

Name Description
RenderContext

Meter-based layout state shared by all column renderers.

RenderContext dataclass

Meter-based layout state shared by all column renderers.

Methods:

Name Description
from_section

Build context bounds from section stations and optional overrides.

iter_major_ticks

Return major vertical axis tick values.

section_x_max

Right edge of the rendered section in meters.

test_y_bounds

Return the vertical frame for one test, including surface when needed.

y_for_test_row

Map one depth sample to section Y.

y_values_for_test

Return section Y coordinates for all rows in test.

Attributes:

Name Type Description
axis_x_left float
axis_x_right float
section CrossSection
site_tests dict[str, InSituTest]
y_max float
y_min float

axis_x_left instance-attribute

axis_x_left: float

axis_x_right instance-attribute

axis_x_right: float

section instance-attribute

section: CrossSection

site_tests instance-attribute

site_tests: dict[str, InSituTest]

y_max instance-attribute

y_max: float

y_min instance-attribute

y_min: float

from_section classmethod

from_section(
    section: CrossSection, site_tests: dict[str, InSituTest]
) -> RenderContext

Build context bounds from section stations and optional overrides.

Parameters:

Name Type Description Default
section CrossSection

Cross-section definition.

required
site_tests dict[str, InSituTest]

Tests keyed by test_id for the section stations.

required

Returns:

Type Description
RenderContext

Context with vertical bounds expanded to nice axis ticks.

iter_major_ticks

iter_major_ticks(
    y_min: float | None = None, y_max: float | None = None
) -> list[float]

Return major vertical axis tick values.

Parameters:

Name Type Description Default
y_min float | None

Lower bound; defaults to the context y_min.

None
y_max float | None

Upper bound; defaults to the context y_max.

None

Returns:

Type Description
list[float]

Evenly spaced major tick values covering the range.

section_x_max

section_x_max() -> float

Right edge of the rendered section in meters.

Returns:

Type Description
float

Maximum station right edge in section meters.

test_y_bounds

test_y_bounds(test: InSituTest) -> tuple[float, float]

Return the vertical frame for one test, including surface when needed.

Parameters:

Name Type Description Default
test InSituTest

In-situ test placed on the section.

required

Returns:

Type Description
tuple[float, float]

(y_bottom, y_top) in section coordinates.

y_for_test_row

y_for_test_row(
    test: InSituTest, depth: float | None
) -> float | None

Map one depth sample to section Y.

Parameters:

Name Type Description Default
test InSituTest

In-situ test providing surface elevation when needed.

required
depth float | None

Sample depth in meters, or None.

required

Returns:

Type Description
float | None

Section Y, or None when depth is None.

y_values_for_test

y_values_for_test(test: InSituTest) -> list[float]

Return section Y coordinates for all rows in test.

Parameters:

Name Type Description Default
test InSituTest

In-situ test whose data rows have depth.

required

Returns:

Type Description
list[float]

Section Y for each row with a non-null depth.