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 stats: FrameProfile#
Return a compact dataframe profile.
- summary(*, max_columns=8)#
Return a static display summary for printing.
- 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:
- 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.
- update_meta(**kwargs)#
Update metadata in-place and return
self.
- 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.
- 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.
- 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:
- class pycsamt.api.view.ProgressConfig(enabled='auto', desc=None, leave=False, unit='it', total=None)#
Bases:
objectConfiguration for terminal progress display.
- 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.iter_progress(iterable, *, enabled='auto', desc=None, leave=False, unit='it', total=None)#
Yield items, optionally wrapped by
tqdm.
- 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.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.