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
|
Compute along-profile cumulative distance (km) for each station. |
|
Extract per-station elevation (m a.s.l.) from a Sites or EDI collection. |
|
Return station name / ID strings in collection order. |
|
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 aUserWarningwhen no valid non-zero elevation is found.- Parameters:
- Returns:
Elevation in metres above sea level, one value per station in the order they appear in the collection.
- Return type:
- 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:
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 aSitesloaded 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:
- 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: