2.2.3.20. pycsamt.api.view#
User-facing result views for pyCSAMT public APIs.
- class pycsamt.api.view.APIFrame(data=None, *, name=None, kind=None, source=None, units=None, meta=None, description=None, copy=False, **frame_kwargs)
Bases:
PyCSAMTObjectA pyCSAMT dataframe view that keeps pandas behavior intact.
APIFrameis a thin wrapper aroundpandas.DataFrame. The dataframe remains available asdf; pyCSAMT adds compact display, metadata, units, statistics, and convenient conversion helpers.- Parameters:
- classmethod from_records(records, *, columns=None, **kwargs)
Build an
APIFramefrom record dictionaries.
- property df: DataFrame
Return the underlying pandas dataframe.
- property data: ndarray
Return dataframe values as a NumPy array.
- property columns: Index
Return dataframe columns.
- property stats: FrameProfile
Return a compact dataframe profile.
- summary(*, max_columns=8)
Return a static display summary for printing.
- profile()
Return the same object as
stats.- Return type:
- missing()
Return missing value counts by column.
- Return type:
- numeric_stats(**kwargs)
Return pandas
describefor numeric columns.
- to_pandas(*, copy=False)
Return the underlying dataframe, optionally copied.
- to_numpy(*args, **kwargs)
Return dataframe values as a NumPy array.
- to_dict(*args, **kwargs)
Delegate to
DataFrame.to_dictby default.
- copy(*, deep=True)
Return a copied view preserving metadata.
- with_df(df, **overrides)
Return a new
APIFramewith another dataframe.
- update_meta(**kwargs)
Update metadata in-place and return
self.
- class pycsamt.api.view.APIResult(**items)
Bases:
PyCSAMTObjectContainer for named result parts, including one or more tables.
- Parameters:
items (Any)
- items()
Return
(name, value)pairs.
- class pycsamt.api.view.APISurvey(collection=None, *, name=None, source=None, parser=None, meta=None)
Bases:
PyCSAMTObjectFriendly public facade over an
EDICollection.- Parameters:
- property n_sites: int
Return number of loaded sites.
- property df: APIFrame
Return the default summary table.
- property data: Any
Return the underlying EDI collection.
- summary(*, fields=None)
Return an editable APIFrame summary of loaded EDI files.
- errors()
Return parser errors from the last read operation.
- Return type:
- get_site(site, default=None)
Return one site by station, stem, filename, or path.
- to_dataframe(*args, api=True, **kwargs)
Return collection dataframe output, wrapped by default.
- to_collection()
Return the underlying collection.
- Return type:
- update_meta(**kwargs)
Update metadata in-place and return
self.
- summary_text()
Return a compact survey display.
- Return type:
- class pycsamt.api.view.APIViewConfig
Bases:
objectPackage-wide policy for dataframe-like public API views.
The backend controls what
pycsamt.api.view.wrap_frame()returns:"pycsamt"/True: return the built-inAPIFrame."pandas"/False: return the original dataframe-like object.callable: call
wrapper(data, **metadata)and return its result.
- configure(**kw)
Configure the view policy.
- Parameters:
kw (Any)
- Return type:
None
- context(**kw)
Temporarily override API view settings.
- Parameters:
kw (Any)
- Return type:
Generator[APIViewConfig, None, None]
- reset()
Reset to defaults.
- Return type:
None
- wrap_frame(data, **metadata)
Apply the configured dataframe wrapper.
- enabled()
Return whether API view wrapping is enabled.
- Return type:
- summary()
Return a compact configuration summary.
- Return type:
- class pycsamt.api.view.FrameProfile(rows, columns, column_names, numeric_columns, missing_cells, missing_fraction, memory_bytes)
Bases:
objectSmall immutable profile describing a dataframe.
- Parameters:
- rows: int
- columns: int
- missing_cells: int
- missing_fraction: float
- memory_bytes: int
- classmethod from_frame(df)
- Parameters:
df (DataFrame)
- Return type:
- class pycsamt.api.view.ProgressAPIConfig
Bases:
objectPackage-wide policy for
ProgressBar.- Variables:
default_verbose – Verbosity used when a call site’s own
verboseargument isNone. Does not override an explicitverbose=True/Falsepassed by the caller — useforce_verbosefor that.force_verbose – When set (
0,1, or2), overrides every call site’sverboseargument, explicit or not.None(default) leaves callers in control.style – Bar glyph set —
"ascii"(default, safe on legacy Windows console code pages) or"unicode".min_interval – Minimum seconds between bar redraws.
log_every – Default line-throttle for log-mode (verbose level
2) progress.Noneauto-computes~10lines per run.
- configure(**kw)
Set one or more configuration attributes by keyword.
- Parameters:
kw (Any)
- Return type:
None
- context(**kw)
Temporarily override progress config, then restore it.
- Parameters:
kw (Any)
- Return type:
Generator[ProgressAPIConfig, None, None]
- reset()
Reset to package defaults.
- Return type:
None
- resolve(verbose=None)
Resolve a call site’s
verboseargument to0/1/2.
- summary()
Return a human-readable configuration summary.
- Return type:
- class pycsamt.api.view.ProgressConfig(enabled='auto', desc=None, leave=False, unit='it', total=None)
Bases:
objectConfiguration for terminal progress display.
- leave: bool = False
- unit: str = 'it'
- pycsamt.api.view.api_frame(_func=None, *, name=None, kind=None, source=None, units=None, meta=None, description=None, copy=False)
Decorate a function so dataframe-like returns become
APIFrame.
- pycsamt.api.view.configure_api_view(**kw)
Configure the global API view backend.
- Parameters:
kw (Any)
- Return type:
None
- pycsamt.api.view.configure_progress(**kw)
Configure
PYCSAMT_PROGRESSwith keyword arguments.- Parameters:
kw (Any)
- Return type:
None
- pycsamt.api.view.get_progress_bar(total=None, *, desc=None, unit='it', verbose=None, leave=False, log_every=None)
Build a
ProgressBarhonouringPYCSAMT_PROGRESS(style, throttle, forced verbosity).This is the recommended entry point for AI-inversion agents, dataset generation, and realization loops — it lets a user silence or reshape progress output package-wide via
configure_progress()without touching every function’sverbosedefault.
- pycsamt.api.view.iter_progress(iterable, *, enabled='auto', desc=None, leave=False, unit='it', total=None)
Yield items, optionally wrapped by a
ProgressBar.
- pycsamt.api.view.maybe_wrap_frame(data, *, api=None, name=None, kind=None, source=None, units=None, meta=None, description=None, copy=False, **frame_kwargs)
Conditionally wrap data as an
APIFrame.When api is
None(the default), the globalPYCSAMT_API_VIEWconfiguration decides. Passapi=Trueto force wrapping, orapi=Falseto always return the raw dataframe regardless of the global setting.
- pycsamt.api.view.progress_enabled(value='auto')
Return whether progress should be displayed.
- pycsamt.api.view.read_edi(path, *, verbose=0, **kwargs)
Read one EDI file and return an
EDIFile.
- pycsamt.api.view.read_edis(sources, *, recursive=True, strict=False, on_dup='replace', progress='auto', leave=False, verbose=0)
Read many EDI files and return a public survey view.
- pycsamt.api.view.read_sites(sources, **kwargs)
Alias for
read_edis().
- pycsamt.api.view.reset_api_view()
Reset the global API view backend.
- Return type:
None
- pycsamt.api.view.reset_progress()
Reset
PYCSAMT_PROGRESSto package defaults.- Return type:
None
- pycsamt.api.view.wrap_frame(data, *, name=None, kind=None, source=None, units=None, meta=None, description=None, copy=False, **frame_kwargs)
Wrap dataframe-like data using the configured API view backend.
- pycsamt.api.view.wrap_result(result, *, name='result', kind=None, meta=None, wrap_tables=True)
Wrap a mapping of result parts as an
APIResult.
- pycsamt.api.view.geology_dataframe(catalog=None, *, name='geology_catalog')
Return a public APIFrame for a geology catalog.
- pycsamt.api.view.geology_table(catalog=None)
Alias for
geology_dataframe().
- pycsamt.api.view.quality_dataframe(sites)
Return a public APIFrame wrapper around metadata quality rows.
- pycsamt.api.view.quality_table(sites)
Alias for
quality_dataframe().
- pycsamt.api.view.sites_summary(sites, *, fields=('station', 'n_freq', 'has_tipper', 'period_min', 'period_max', 'lat', 'lon'), recursive=True, on_dup='replace', strict=False, verbose=0)
Return a public APIFrame wrapper around
emtoolssite summary.