pycsamt.map.loader#

Multi-line EDI ingestion for pycsamt.map.

A map-view survey is usually made of several profile lines, each stored as its own EDI folder. The renderers in pycsamt.map already understand the per-station line attribute, but the normalizer pycsamt.map._core.ensure_map_data() only consumes a single source. This module lifts the multi-line grouping logic out of the GUI layer so scripts and notebooks can build one combined MapData from many lines.

Accepted source forms#

mapping

{line_name: dir | iterable_of_edis} — explicit line layout.

sequence of directories

[dir_a, dir_b, ...] — one line per directory (named after it).

sequence of EDI-like items / files

Treated as a single "line".

single directory

Grouped according to detect (see load_lines()).

single file

A one-station line named after the file stem.

Functions

load_lines(source, *[, detect, recursive, ...])

Build one combined MapData from multiple lines.

resolve_line_groups(source, *[, detect, ...])

Return a {line_name: source} mapping for source.

pycsamt.map.loader.load_lines(source, *, detect='folder', recursive=True, line_map=None, verbose=0)[source]#

Build one combined MapData from multiple lines.

Parameters:
  • source (Any) – Mapping, sequence, directory, or file (see module docstring). A MapData is returned unchanged.

  • detect ({"folder", "auto", "flat"}, default "folder") –

    Line-grouping rule applied only when source is a single directory:

    folder

    One line per immediate sub-folder holding EDI files (a flat folder becomes one line named after it).

    auto

    Group by the station-ID prefix, e.g. 22-001 -> L22.

    flat

    Treat the whole directory as a single line.

  • recursive (bool) – Recurse into sub-directories when discovering EDI files and when calling ensure_map_data().

  • line_map (dict[str, Iterable[str]] | None) – Optional line -> station names mapping forwarded to ensure_map_data() for sources without embedded line metadata.

  • verbose (int) – Verbosity forwarded to ensure_map_data().

Returns:

Stations from every line, re-indexed and tagged with their resolved line name; profiles are rebuilt per line.

Return type:

MapData

pycsamt.map.loader.resolve_line_groups(source, *, detect='folder', recursive=True)[source]#

Return a {line_name: source} mapping for source.

The values are passed straight to ensure_map_data(), so they may be directories, lists of file paths, or EDI-like iterables. This mirrors the groups store used by the GUI loader, making the two paths share one grouping contract.

Parameters:
Return type:

dict[str, Any]