Map API Reference#
This page collects the main map modules. The full autogenerated API reference also includes ../api/map.
Core Data#
Core data extraction helpers for pycsamt.map.
- pycsamt.map._core.normalize_station_id(name)[source]#
Loosely-normalized station id for fuzzy matching.
Lowercases and strips everything but letters/digits, so minor formatting differences between sources —
23-18-001Avs23_18_001avs23 18 001A— still match. Used as a fallback tier (never the only lookup) wherever a station from one source (EDI, ModEM, an uploaded elevation file, …) needs to be matched against another.
- class pycsamt.map._core.StationRecord(id, latitude=None, longitude=None, elevation=None, line=None, index=0, source=None)[source]#
Bases:
objectA normalized station row used by map renderers.
- Parameters:
- class pycsamt.map._core.ProfileLine(name, stations=())[source]#
Bases:
objectA named sequence of stations in one profile.
- Parameters:
name (str)
stations (tuple[StationRecord, ...])
- stations: tuple[StationRecord, ...] = ()#
- class pycsamt.map._core.MapData(sites, stations=(), profiles=(), metadata=<factory>)[source]#
Bases:
objectNormalized survey data shared by map renderers.
- Parameters:
sites (Any)
stations (tuple[StationRecord, ...])
profiles (tuple[ProfileLine, ...])
- stations: tuple[StationRecord, ...] = ()#
- profiles: tuple[ProfileLine, ...] = ()#
- class pycsamt.map._core.ComponentSpec(name, indices=None, mode='tensor')[source]#
Bases:
objectParsed impedance component request.
- class pycsamt.map._core.FrequencySelection(requested, actual, index, delta, relative_delta, within_tolerance=True)[source]#
Bases:
objectNearest-frequency selection metadata.
- Parameters:
- class pycsamt.map._core.FrequencyValue(station, value, selection)[source]#
Bases:
objectStation value and selected-frequency metadata.
- Parameters:
station (str)
value (float)
selection (FrequencySelection)
- selection: FrequencySelection#
- pycsamt.map._core.ensure_map_data(data, *, recursive=True, line_map=None, verbose=0)[source]#
Return normalized map data.
- Parameters:
data (Any) – EDI path, directory, iterable, or
Sites.recursive (bool) – Passed to
pycsamt.emtools._core.ensure_sites().line_map (dict[str, Iterable[str]] | None) – Optional
line -> station namesmapping used when line metadata is not embedded in EDI objects.verbose (int) – Verbosity passed to
ensure_sites().
- Return type:
- pycsamt.map._core.station_records(data, **kwargs)[source]#
Return normalized station records for data.
- Parameters:
- Return type:
tuple[StationRecord, …]
- pycsamt.map._core.profile_lines(data, **kwargs)[source]#
Return normalized profile lines for data.
- Parameters:
- Return type:
tuple[ProfileLine, …]
- pycsamt.map._core.component_spec(component)[source]#
Return a parsed impedance component specification.
- Parameters:
component (str | None)
- Return type:
- pycsamt.map._core.component_index(component)[source]#
Return tensor indices for an impedance component.
- pycsamt.map._core.component_values(arr, component, *, quantity='rho')[source]#
Extract a 1-D value series for one component.
- pycsamt.map._core.select_frequency(frequencies, requested=None, *, tolerance=None)[source]#
Select the closest finite positive frequency.
- Parameters:
- Return type:
FrequencySelection | None
- pycsamt.map._core.value_at_frequency(data, *, frequency, quantity='rho', component='xy', tolerance=None)[source]#
Return station values at the closest frequency.
- pycsamt.map._core.value_at_frequency_details(data, *, frequency, quantity='rho', component='xy', tolerance=None)[source]#
Return values with selected-frequency metadata.
Loading And Sessions#
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.
- pycsamt.map.loader.load_lines(source, *, detect='folder', recursive=True, line_map=None, verbose=0)[source]#
Build one combined
MapDatafrom multiple lines.- Parameters:
source (Any) – Mapping, sequence, directory, or file (see module docstring). A
MapDatais returned unchanged.detect ({"folder", "auto", "flat"}, default "folder") –
Line-grouping rule applied only when source is a single directory:
folderOne line per immediate sub-folder holding EDI files (a flat folder becomes one line named after it).
autoGroup by the station-ID prefix, e.g.
22-001->L22.flatTreat 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 namesmapping forwarded toensure_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:
- 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 thegroupsstore used by the GUI loader, making the two paths share one grouping contract.
High-level MapView session façade for pyCSAMT maps.
MapView is the single object scripts, notebooks, and the map-view
platform share. It holds one combined MapData
(possibly spanning many lines) and renders every view through the
existing builders, so the GUI carries no plotting logic of its own.
Examples
>>> from pycsamt.map import MapView
>>> mv = MapView.from_folder("data/survey", detect="folder")
>>> mv.lines
('L18PLT', 'L22PLT')
>>> fig = mv.station(overlay="rho", frequency=1024)
>>> mv.export("out/station.html")
- class pycsamt.map.view.MapView(data, *, theme='light', backend='plotly')[source]#
Bases:
objectA code-first session bound to one (multi-line) survey.
- classmethod from_folder(path, *, detect='folder', recursive=True, theme='light', backend='plotly', **load_kwargs)[source]#
Build a view from a directory of one or more lines.
- classmethod from_lines(lines, *, theme='light', backend='plotly', **load_kwargs)[source]#
Build a view from an explicit
{line: source}mapping.
- classmethod from_inversion_results(folder, *, known_stations=None, fetch_elevation=True, theme='light', backend='plotly', verbose=0)[source]#
Build a view from a ModEM 3-D inversion result folder.
See
pycsamt.map.inversion.load_modem_lines(). Passknown_stations=existing_view.data.stationsto geo-reference and group ModEM stations using a previously-loaded EDI survey. Passfetch_elevation=Falseto skip the best-effort online elevation lookup (e.g. offline use, or large surveys where the extra round-trip isn’t wanted).
- table()[source]#
Return survey stations as a
pandas.DataFrame.
- fetch_elevations(*, api_name='open_meteo')[source]#
Fetch station elevations online (see
pycsamt.map.fetch_elevations()).
- export_topography(path, *, fmt=None)[source]#
Export this survey’s station id/elevation/coordinates.
Useful for an EDI-sourced view: a ModEM (or Occam2D/MARE2DEM) inversion result carries no real elevation of its own, so exporting it here produces a small, portable file that can be re-applied later — even in a session that never reloads these EDIs — via the “Upload file” elevation source (see
pycsamt.map.topo.export_elevations()).
- station(*, options=None, **overrides)[source]#
Build a 2-D station map figure.
- Parameters:
options (StationMapOptions | None)
overrides (Any)
- Return type:
- profile(*, options=None, **overrides)[source]#
Build a profile-view figure.
- Parameters:
options (ProfileMapOptions | None)
overrides (Any)
- Return type:
- pseudosection(*, options=None, **overrides)[source]#
Build a resistivity/phase pseudosection figure.
- Parameters:
options (ProfileMapOptions | None)
overrides (Any)
- Return type:
- map3d(*, mode='fence', options=None, **overrides)[source]#
Build a 3-D fence/block/depth/surface figure.
- Parameters:
mode (str)
options (VolumeMapOptions | None)
overrides (Any)
- Return type:
- figure(view='station', **overrides)[source]#
Build a figure for view by name.
- Parameters:
view ({"station", "profile", "pseudosection", "map3d"}) – Which renderer to call.
**overrides – Forwarded to the matching renderer.
- Return type:
- export(path, *, view='station', fmt=None, scale=2.0, width=None, height=None, **overrides)[source]#
Render view and write it to path.
The format is inferred from the suffix unless fmt is given;
.html,.png,.jsonand Plotly static images are supported (seepycsamt.map.export_figure()).
- pycsamt.map.view.launch_app(source=None, *, host='127.0.0.1', port=8770, debug=False, open_browser=True, theme='light', backend='plotly', detect='folder', recursive=True, **load_kwargs)#
Launch the interactive map-view app.
- Parameters:
source (Any) – Optional survey source.
Nonestarts the welcome screen. Otherwise accepts data, paths, sites, or mappings.host (str) – Forwarded to
pycsamt.app.mapview.launch().port (int) – Forwarded to
pycsamt.app.mapview.launch().debug (bool) – Forwarded to
pycsamt.app.mapview.launch().open_browser (bool) – Forwarded to
pycsamt.app.mapview.launch().detect (str) – Used for path/folder inputs.
recursive (bool) – Used for path/folder inputs.
**load_kwargs (Any) – Extra options forwarded to
MapView.from_folderorload_lines().
- Return type:
None
- pycsamt.map.view.launch_mapview(source=None, **kwargs)#
Alias for
launch_app().
- pycsamt.map.view.open_app(source=None, **kwargs)#
Backward-compatible alias for
launch_app().
Renderers#
2-D station-map API for pyCSAMT surveys.
- class pycsamt.map.station.StationMap(data, *, options=None, **ensure_kwargs)[source]#
Bases:
objectBuilder object for station-map figures.
- Parameters:
data (Any)
options (StationMapOptions | None)
ensure_kwargs (Any)
- with_overlay(overlay, **kwargs)[source]#
Return a copy with a different overlay.
- Parameters:
- Return type:
- pycsamt.map.station.plot_station_map(data, *, options=None, **kwargs)[source]#
Build a 2-D station map.
- Parameters:
data (Any)
options (StationMapOptions | None)
kwargs (Any)
- Return type:
- pycsamt.map.station.build_station_map(data, options=None)[source]#
Build a Plotly 2-D station map.
- Parameters:
data (MapData)
options (StationMapOptions | None)
- Return type:
Profile-view and pseudosection API for pyCSAMT surveys.
- class pycsamt.map.profile.ProfileMap(data, *, options=None, **ensure_kwargs)[source]#
Bases:
objectBuilder object for profile maps.
- Parameters:
data (Any)
options (ProfileMapOptions | None)
ensure_kwargs (Any)
- with_options(**kwargs)[source]#
Return a copy with updated options.
- Parameters:
kwargs (Any)
- Return type:
- with_quantity(quantity)[source]#
Return a copy using another mapped quantity.
- Parameters:
quantity (str)
- Return type:
- with_component(component)[source]#
Return a copy using one impedance component.
- Parameters:
component (str)
- Return type:
- pycsamt.map.profile.plot_profile_map(data, *, options=None, **kwargs)[source]#
Build a profile-view map.
- Parameters:
data (Any)
options (ProfileMapOptions | None)
kwargs (Any)
- Return type:
- pycsamt.map.profile.plot_pseudosection(data, *, options=None, **kwargs)[source]#
Build a resistivity or phase pseudosection.
- Parameters:
data (Any)
options (ProfileMapOptions | None)
kwargs (Any)
- Return type:
- pycsamt.map.profile.build_profile_map(data, options)[source]#
Build the concrete profile-view figure.
- Parameters:
data (MapData)
options (ProfileMapOptions)
- Return type:
- pycsamt.map.profile.build_pseudosection(data, options)[source]#
Build the concrete pseudosection figure.
- Parameters:
data (MapData)
options (ProfileMapOptions)
- Return type:
3-D map API for fence, block, and depth-slice views.
- class pycsamt.map.volume.Map3D(data, *, options=None, **ensure_kwargs)[source]#
Bases:
objectBuilder object for 3-D survey maps.
- Parameters:
data (Any)
options (VolumeMapOptions | None)
ensure_kwargs (Any)
- pycsamt.map.volume.plot_3d_map(data, *, options=None, **kwargs)[source]#
Build a 3-D map.
- Parameters:
data (Any)
options (VolumeMapOptions | None)
kwargs (Any)
- Return type:
- pycsamt.map.volume.plot_volume_map(data, *, options=None, **kwargs)[source]#
Build a 3-D volume map.
- Parameters:
data (Any)
options (VolumeMapOptions | None)
kwargs (Any)
- Return type:
- pycsamt.map.volume.build_3d_map(data, options)[source]#
Build the concrete 3-D figure.
- Parameters:
data (MapData)
options (VolumeMapOptions)
- Return type:
Options, Overlays, Export#
Configuration dataclasses for pycsamt.map.
- class pycsamt.map.config.StationMapOptions(overlay='index', frequency=None, frequency_tolerance=None, component='xy', theme='light', backend='plotly', selected_id=None, line_filter=None, marker_size=10, basemap=None, cmap='plasma', value_range=None, log_color=False, opacity=0.92, show_labels=True, show_profiles=True, show_contours=False, contour_image=False, contour_mode='filled+lines', contour_levels=12, contour_opacity=0.55, contour_interp='cubic', contour_smooth=1.0, contour_grid_res=150, bearing=0.0, title='')[source]#
Bases:
objectOptions for 2-D station maps.
- Parameters:
overlay (str)
frequency (float | None)
frequency_tolerance (float | None)
component (str)
theme (Literal['light', 'dark', 'publication'])
backend (Literal['plotly', 'matplotlib'])
selected_id (str | None)
marker_size (int)
basemap (str | None)
cmap (str)
log_color (bool)
opacity (float)
show_labels (bool)
show_profiles (bool)
show_contours (bool)
contour_image (bool)
contour_mode (str)
contour_levels (int)
contour_opacity (float)
contour_interp (str)
contour_smooth (float)
contour_grid_res (int)
bearing (float)
title (str)
- class pycsamt.map.config.ProfileMapOptions(quantity='rho', component='xy', components=('xy', 'yx'), theme='light', backend='plotly', period_range=None, phase_range=None, value_range=None, x_axis='station', log_rho=True, height_per_panel=260, show_errbar=False, cmap=None)[source]#
Bases:
objectOptions for pseudosection and profile-view maps.
- class pycsamt.map.config.VolumeMapOptions(mode='fence', quantity='resistivity', component='xy', theme='light', cmap='RdYlBu_r', depth_range=None, period_range=None, rho_range=None, iso_range=None, value_range=None, log_color=True, opacity=0.85, show_contours=False, show_labels=True, n_slices=5, surface_count=12, line_spacing=1.0, azimuth=0.0, topography=True, show_terrain=True, terrain_opacity=0.7, show_stations=False, station_symbol='diamond', station_size=4, station_color='#1f2937', station_labels=False, aspectmode='data', x_unit='m', depth_unit='m', smooth_sections=True, section_res=100, title='')[source]#
Bases:
objectOptions for 3-D fence, block, and depth-slice maps.
- Parameters:
mode (Literal['fence', 'block', 'depth', 'surface'])
quantity (str)
component (str)
theme (Literal['light', 'dark', 'publication'])
cmap (str)
log_color (bool)
opacity (float)
show_contours (bool)
show_labels (bool)
n_slices (int)
surface_count (int)
line_spacing (float)
azimuth (float)
topography (bool)
show_terrain (bool)
terrain_opacity (float)
show_stations (bool)
station_symbol (str)
station_size (int)
station_color (str)
station_labels (bool)
aspectmode (str)
x_unit (str)
depth_unit (str)
smooth_sections (bool)
section_res (int)
title (str)
- class pycsamt.map.config.ExportOptions(path, format=None, width=None, height=None, scale=2.0, include_plotlyjs='cdn')[source]#
Bases:
objectOptions used by figure export helpers.
- Parameters:
Overlay helpers for station, profile, and 3-D maps.
- class pycsamt.map.overlays.ContourOverlay(values, x, y, levels=12, cmap='viridis', opacity=0.65)[source]#
Bases:
objectDescription of an interpolated contour overlay.
- class pycsamt.map.overlays.TopographyOverlay(elevation, source='stations', opacity=0.7)[source]#
Bases:
objectTopography aligned to map coordinates.
- class pycsamt.map.overlays.CRSConfig(source, target=4326, always_xy=True)[source]#
Bases:
objectCoordinate transform settings.
- class pycsamt.map.overlays.BasemapConfig(style, center, zoom, bearing=0.0, layers=())[source]#
Bases:
objectPlotly geographic map layout settings.
- pycsamt.map.overlays.basemap_style_and_layers(style, *, dark=False)[source]#
Resolve a style name into a (base style, raster layers) pair.
ESRI styles are rendered as
white-bg+ a raster tile layer; native Plotly styles are returned as-is with no layers.
- pycsamt.map.overlays.resolve_crs_info(mode='geo', *, zone=50, hemisphere='N', epsg=4326)[source]#
Return a human-readable CRS description.
- pycsamt.map.overlays.transform_xy(x, y, *, crs)[source]#
Transform coordinates between two CRS definitions.
- pycsamt.map.overlays.reproject_xy_to_lonlat(x, y, *, epsg)[source]#
Reproject x, y from epsg to WGS84 lon/lat.
- pycsamt.map.overlays.build_contour_overlay(x, y, values, *, levels=12, cmap='Viridis', opacity=0.65, grid_size=80, mode='lines')[source]#
Build an interpolated map contour overlay.
Returns a Plotly
Contourtrace on a regular grid.
- pycsamt.map.overlays.build_geo_contour_image(lons, lats, values, *, cmap='jet', n_levels=12, opacity=0.6, mode='filled+lines', log_scale=False, grid_res=160, expand=0.06, interp='cubic', smooth_sigma=0.0)[source]#
Render a Surfer-style filled-contour PNG for a basemap image layer.
Interpolates sparse station values onto a regular lon/lat grid and rasterises filled (and/or line) contours to a transparent PNG. The result is meant to be added to a Plotly map as an
imagelayer.- Returns:
{"image": "data:image/png;base64,...", "coordinates": [...], "vmin": float, "vmax": float}(coordinates are the TL, TR, BR, BL[lon, lat]corners), orNonewhen it cannot be built.- Return type:
dict | None
- Parameters:
- pycsamt.map.overlays.interpolate_overlay_grid(x, y, values, *, grid_size=80, method='linear')[source]#
Interpolate scattered values to a regular grid.
- pycsamt.map.overlays.build_topography_overlay(x, y, elevation, *, opacity=0.7, colorscale='Earth')[source]#
Build a Plotly 3-D terrain mesh or surface.
- pycsamt.map.overlays.build_station_label_overlay(x, y, labels, *, geo=False, name='Station labels', color='#111827')[source]#
Build a reusable station-label overlay trace.
- pycsamt.map.overlays.build_profile_line_overlay(x, y, *, geo=False, name='Profile', color='#2563eb', width=2.0)[source]#
Build a reusable profile-line overlay trace.
- pycsamt.map.overlays.build_basemap_layout(lon, lat, *, dark=False, style=None, bearing=0.0)[source]#
Return layout settings for geographic station maps.
Figure export helpers for pycsamt.map.
- pycsamt.map.export.save_png(fig, path, **kwargs)[source]#
Save a Matplotlib-like or Plotly-like figure as PNG.
- pycsamt.map.export.export_figure(fig, options)[source]#
Export fig according to options.
- Parameters:
fig (Any)
options (ExportOptions)
- Return type: