2.29.3.3. pycsamt.topo.extract#

Extract elevation and chainage arrays from Sites / EDI collections.

These utilities are the bridge between pycsamt’s data model and the topography rendering pipeline. They operate on any object that contains EDI-like items with HEAD lat/lon/elev attributes — including Sites, plain lists of EDIFile, and EDIBatch objects.

Examples

>>> from pycsamt.topo.extract import extract_elevation, extract_chainage
>>> elev = extract_elevation(sites)  # (n_stations,)  m a.s.l.
>>> chain = extract_chainage(sites)  # (n_stations,)  km

Functions

extract_chainage(sites, *[, order])

Compute along-profile cumulative distance (km) for each station.

extract_elevation(sites, *[, warn])

Extract per-station elevation (m a.s.l.) from a Sites or EDI collection.

extract_station_names(sites)

Return station name / ID strings in collection order.

has_elevation(sites)

Return True if any station carries a meaningful non-zero elevation.

pycsamt.topo.extract.extract_elevation(sites, *, warn=True)[source]

Extract per-station elevation (m a.s.l.) from a Sites or EDI collection.

Reads the .elev (or .elevation / .alt) field from each station’s HEAD coordinate block. Returns a zero array and emits a UserWarning when no valid non-zero elevation is found.

Parameters:
  • sites (Sites, EDICollection, list[EDIFile], or single EDIFile) – Any object that contains station data with HEAD lat/lon/elev.

  • warn (bool) – Emit the “no non-zero elevation” warning. Applications that report a flat survey themselves (the desktop Topography view) pass False.

Returns:

Elevation in metres above sea level, one value per station in the order they appear in the collection.

Return type:

numpy.ndarray, shape (n_stations,)

pycsamt.topo.extract.extract_chainage(sites, *, order='given')[source]

Compute along-profile cumulative distance (km) for each station.

Uses a flat-Earth approximation: cumulative Euclidean distance in lat/lon space scaled to metres, converted to km.

Parameters:
  • sites (Sites, EDICollection, list[EDIFile])

  • order ({"given", "auto"}, default "given") – "given" accumulates distance in the container order, which must be the profile order (correct for crooked lines). "auto" first sorts the stations by their projection on the profile’s principal axis (first principal component of the positions, pointing east for mostly E-W lines and north for mostly N-S lines; chainage 0 is at that axis’ start), so the result does not depend on how the container is sorted. Use it for a Sites loaded from a folder, which is in file-name order (L1-0, L1-1020, L1-1110, L1-150, ...): there "given" zig-zags and returns chainages far too large. On strongly bent lines "auto" can swap close neighbours.

Returns:

Chainage in km of each station, in the order of *sites*, measured from the profile’s first station (0).

Return type:

numpy.ndarray, shape (n_stations,)

Raises:

ValueError – If order is not "auto" or "given".

Examples

With order="auto" the chainage of each station is the same whatever the order of the input (here two stations given in reverse, 0.1 deg of latitude apart):

>>> extract_chainage(sites_reversed, order="auto")
...
array([11.1,  0. ])
pycsamt.topo.extract.has_elevation(sites)[source]

Return True if any station carries a meaningful non-zero elevation.

Parameters:

sites (any station container)

Return type:

bool

pycsamt.topo.extract.extract_station_names(sites)[source]

Return station name / ID strings in collection order.

Parameters:

sites (any station container)

Return type:

list[str]