pycsamt.api.section#

Global section-view controls for pyCSAMT figures.

This module centralizes layout choices used by 2-D section-like plots: pseudo-sections, inversion sections, model slices, and compact dashboard panels. It complements pycsamt.api.style, pycsamt.api.station, pycsamt.api.control, and pycsamt.api.plot.

Examples

Apply a publication section preset temporarily:

from pycsamt.api.section import PYCSAMT_SECTION
from pycsamt.tdem import plot_temavg_section

with PYCSAMT_SECTION.context("publication"):
    ax = plot_temavg_section(avg, section="publication")

Use the data-aware dynamic layout for many stations:

ax = plot_temavg_section(avg, section="dynamic")

Customize one preset globally:

from pycsamt.api import configure_section
configure_section(
    dynamic__figure__max_width=16.0,
    dynamic__colorbar__max_ticks=5,
)

Functions

configure_section(**kw)

Configure PYCSAMT_SECTION.

reset_section()

Reset PYCSAMT_SECTION to package defaults.

Classes

PyCSAMTSection()

Package-wide section-view control container.

SectionAxisStyle([xlabel, ylabel, ...])

Axis behavior for section-like plots.

SectionColorbarStyle([show, side, size, ...])

Colorbar geometry and tick-density controls.

SectionFigureStyle([figsize, tight, ...])

Figure geometry for section-like plots.

SectionStyle([figure, axis, colorbar, ...])

Complete visual-control bundle for one section preset.

class pycsamt.api.section.PyCSAMTSection[source]#

Bases: object

Package-wide section-view control container.

style_for(preset='pseudosection')[source]#

Return the section style associated with preset.

Parameters:

preset (str)

Return type:

SectionStyle

configure(**kw)[source]#

Configure section styles using section__attribute paths.

Parameters:

kw (Any)

Return type:

None

context(preset=None, **kw)[source]#

Temporarily override section styles, then restore them.

Parameters:
  • preset (str | None)

  • kw (Any)

Return type:

Generator[PyCSAMTSection, None, None]

use_preset(preset)[source]#

Copy one preset into the pseudosection slot.

Parameters:

preset (str)

Return type:

None

reset()[source]#

Reset section controls to package defaults.

Return type:

None

summary()[source]#

Return a human-readable summary.

Return type:

str

class pycsamt.api.section.SectionAxisStyle(xlabel='Station', ylabel=None, y_direction='down', aspect='auto', grid=False, station_side='top', title=True, xlabel_pad=None, ylabel_pad=None, y_type='depth')[source]#

Bases: object

Axis behavior for section-like plots.

Parameters:
xlabel: str = 'Station'#
ylabel: str | None = None#
y_direction: str = 'down'#
aspect: str | float = 'auto'#
grid: bool = False#
station_side: str = 'top'#
title: bool = True#
xlabel_pad: float | None = None#
ylabel_pad: float | None = None#
y_type: str = 'depth'#
apply(ax, *, xlabel=None, ylabel=None, title=None)[source]#

Apply axis labels, direction, aspect, and grid state.

Parameters:
  • ax (Any)

  • xlabel (str | None)

  • ylabel (str | None)

  • title (str | None)

Return type:

None

class pycsamt.api.section.SectionColorbarStyle(show=True, side='right', size='3.5%', pad=0.04, max_ticks=6, tick_format=None)[source]#

Bases: object

Colorbar geometry and tick-density controls.

Parameters:
show: bool = True#
side: str = 'right'#
size: str = '3.5%'#
pad: float = 0.04#
max_ticks: int | None = 6#
tick_format: str | None = None#
add(mappable, ax, *, label=None, **kw)[source]#

Attach a section colorbar to ax.

Parameters:
Return type:

Any | None

class pycsamt.api.section.SectionFigureStyle(figsize=(9.5, 4.4), tight=True, constrained=False, title=True, min_width=7.0, max_width=14.0, min_height=3.2, max_height=7.5, station_width=0.16, y_sample_height=0.03, label_width=0.055, colorbar_width=0.55)[source]#

Bases: object

Figure geometry for section-like plots.

Parameters:
figsize: tuple[float, float] | str = (9.5, 4.4)#
tight: bool = True#
constrained: bool = False#
title: bool = True#
min_width: float = 7.0#
max_width: float = 14.0#
min_height: float = 3.2#
max_height: float = 7.5#
station_width: float = 0.16#
y_sample_height: float = 0.03#
label_width: float = 0.055#
colorbar_width: float = 0.55#
resolve(*, n_stations=None, n_y=None, max_label_len=None, colorbar=True)[source]#

Return a concrete figure size in inches.

Parameters:
  • n_stations (int | None)

  • n_y (int | None)

  • max_label_len (int | None)

  • colorbar (bool)

Return type:

tuple[float, float]

class pycsamt.api.section.SectionStyle(figure=<factory>, axis=<factory>, colorbar=<factory>, station_preset='pseudosection')[source]#

Bases: object

Complete visual-control bundle for one section preset.

Parameters:
figure: SectionFigureStyle#
axis: SectionAxisStyle#
colorbar: SectionColorbarStyle#
station_preset: str = 'pseudosection'#
topo_active()[source]#

Return True when the global topo config applies to this section.

Checks PYCSAMT_TOPO against self.axis.y_type. Period / frequency sections return False even when topo is globally enabled, because they carry no real elevation information.

Return type:

bool

copy(**kw)[source]#

Return a modified deep copy of this section style.

Parameters:

kw (Any)

Return type:

SectionStyle

figsize_for(*, n_stations=None, n_y=None, labels=None, colorbar=True)[source]#

Return a concrete figure size for this section.

Parameters:
Return type:

tuple[float, float]

apply_axis(ax, **kw)[source]#

Apply this style’s axis policy to ax.

Parameters:
Return type:

None

add_colorbar(mappable, ax, *, label=None, **kw)[source]#

Attach a colorbar using this style’s colorbar policy.

Parameters:
Return type:

Any | None

apply_stations(ax, positions, labels=None, *, station_style=None, xlim=None)[source]#

Apply station rendering for this section style.

Parameters:
Return type:

Any

pycsamt.api.section.configure_section(**kw)[source]#

Configure PYCSAMT_SECTION.

Parameters:

kw (Any)

Return type:

None

pycsamt.api.section.reset_section()[source]#

Reset PYCSAMT_SECTION to package defaults.

Return type:

None