pycsamt.map.view#

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")

Classes

MapView(data, *[, theme, backend])

A code-first session bound to one (multi-line) survey.

class pycsamt.map.view.MapView(data, *, theme='light', backend='plotly')[source]#

Bases: object

A code-first session bound to one (multi-line) survey.

Parameters:
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.

Parameters:
Return type:

MapView

classmethod from_lines(lines, *, theme='light', backend='plotly', **load_kwargs)[source]#

Build a view from an explicit {line: source} mapping.

Parameters:
Return type:

MapView

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(). Pass known_stations=existing_view.data.stations to geo-reference and group ModEM stations using a previously-loaded EDI survey. Pass fetch_elevation=False to skip the best-effort online elevation lookup (e.g. offline use, or large surveys where the extra round-trip isn’t wanted).

Parameters:
Return type:

MapView

property lines: tuple[str, ...][source]#

Return the profile/line names in this survey.

property stations: tuple[str, ...][source]#

Return the station IDs in this survey.

property n_stations: int[source]#

Return the number of stations across all lines.

property has_geo: bool[source]#

Whether stations carry finite map coordinates.

table()[source]#

Return survey stations as a pandas.DataFrame.

with_elevations(elev_map)[source]#

Return a copy with station elevations overridden by elev_map.

Parameters:

elev_map (dict[str, float])

Return type:

MapView

fetch_elevations(*, api_name='open_meteo')[source]#

Fetch station elevations online (see pycsamt.map.fetch_elevations()).

Parameters:

api_name (str)

Return type:

dict[str, float]

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()).

Parameters:
station(*, options=None, **overrides)[source]#

Build a 2-D station map figure.

Parameters:
Return type:

Any

profile(*, options=None, **overrides)[source]#

Build a profile-view figure.

Parameters:
Return type:

Any

pseudosection(*, options=None, **overrides)[source]#

Build a resistivity/phase pseudosection figure.

Parameters:
Return type:

Any

map3d(*, mode='fence', options=None, **overrides)[source]#

Build a 3-D fence/block/depth/surface figure.

Parameters:
Return type:

Any

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:

Any

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, .json and Plotly static images are supported (see pycsamt.map.export_figure()).

Parameters:
Return type:

Path

export_all(directory, *, fmt='html', views=('station', 'pseudosection', 'map3d'), **overrides)[source]#

Export several views into directory, keyed by view name.

Parameters:
Return type:

dict[str, Path]

launch(**kwargs)[source]#

Open this survey in the map-view platform.

Requires the optional Dash GUI extra (pycsamt.app.mapview).

Parameters:

kwargs (Any)

Return type:

None

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. None starts 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().

  • theme (str) – Used when building a MapView.

  • backend (str) – Used when building a MapView.

  • detect (str) – Used for path/folder inputs.

  • recursive (bool) – Used for path/folder inputs.

  • **load_kwargs (Any) – Extra options forwarded to MapView.from_folder or load_lines().

Return type:

None

pycsamt.map.view.launch_mapview(source=None, **kwargs)#

Alias for launch_app().

Parameters:
Return type:

None

pycsamt.map.view.open_app(source=None, **kwargs)#

Backward-compatible alias for launch_app().

Parameters:
Return type:

None