Python library#
The data/analysis core runs without a window, i.e., headless.
The library can load logs, compute FFTs, and run the node transforms from a Python script through the facade in ultrazohm_dataviewer.api, which is re-exported at the package top level.
Note
Importing the package does not import the imgui GUI stack.
import ultrazohm_dataviewer and from ultrazohm_dataviewer import Client use only the Python standard library.
Accessing the analysis API loads its numerical dependencies.
Reads, conversions, and analysis also avoid GUI imports.
GUI entry points must be imported explicitly from ultrazohm_dataviewer.app.
The core is therefore usable on a headless server and import stays fast.
Controlling an open DataViewer#
Use Client when a script should change the running application.
The DataViewer must already be open.
The default endpoint is 127.0.0.1:19741; override it with Client("127.0.0.1:19742") or UZ_DATAVIEWER_ENDPOINT.
Each DataViewer instance must have its own endpoint.
from ultrazohm_dataviewer import Client
with Client() as viewer:
recording = viewer.load("Log.csv")
viewer.set_grid(2, 1)
viewer.add_signal(1, recording, "ia")
viewer.save_session("analysis.json")
The script runs in its own Python process; the DataViewer owns the plot and session state. GUI interactions and Python requests share that state. Each client call waits for its result or raises an exception; several calls are not a transaction. After an unrelated session replacement, create a new client and obtain new recording/node/view handles. Do not reuse handles from the previous session. See Usage guide for the full client API and Python editor workflow.
The DataViewer authenticates each request with a random per-instance credential.
Clients discover it automatically from a private per-user directory under the OS temporary directory.
For explicit connection management, Client also accepts a token= keyword argument.
Create a new client after restarting the DataViewer; credentials are never automatically refreshed to retry mutations.
Headless analysis quick start#
import ultrazohm_dataviewer as uz
data = uz.read("Log.csv") # -> Dataset (shared time axis + named signals)
t, ia = data.time, data["ia"]
df = data.to_dataframe() # Polars: column 'time' + one per signal
spec = uz.fft(t, ia) # -> FftResult (.freqs, .mag, .info, .ok); full span
sdf = uz.fft_frame(t, ia) # -> Polars DataFrame [frequency, amplitude]
# Node transforms — the exact calculations the GUI's node graph uses.
print(uz.kinds()) # ('fft', 'math', 'filter', 'shift')
t2, y2, info = uz.node("filter", (t, ia), type="low", cutoff=40, taps=201)
A runnable version is in examples/headless_example.py.
API reference#
The facade adds no compute logic of its own. The facade reuses the loader, FFT and node transforms used by the GUI. Thus, the results of library usage match the results of the GUI.
- class ultrazohm_dataviewer.api.Dataset(parsed)#
Bases:
objectA loaded log: an independent axis (exposed as
time) and named signals.Thin read-friendly wrapper over
loader.ParsedRun. Index a signal by name (data["ia"]), test membership ("ia" in data), iterate names, or pull the whole thing into a DataFrame withto_dataframe().- property names: list[str]#
Ordered list of signal names in this dataset.
- to_dataframe()#
Return a Polars DataFrame of time plus one column per signal.
Use
.to_pandas()on the result for pandas (requires pandas and pyarrow).
- class ultrazohm_dataviewer.analysis.FftResult(freqs: ndarray | None, mag: ndarray | None, info: str)
Bases:
objectSingle-sided amplitude spectrum plus a human-readable status line.
- freqs
Frequency axis (Hz),
Noneon failure.
- mag
Amplitude (same units as input
y),Noneon failure.
- info
Human-readable description of the computation or the failure reason.
- ok
Truewhenfreqsandmagare populated.
- property ok: bool
Truewhen the computation succeeded andfreqs/magare populated.
- ultrazohm_dataviewer.api.read(path, *, axis_column=None, axis_domain=None) Dataset#
Load a
.csv/.parquetlog and return its data as aDataset.
- ultrazohm_dataviewer.api.fft(time, y, *, remove_dc: bool = True, window: bool = True, x_min: float | None = None, x_max: float | None = None, timestamp_resolution: float = 0.0) FftResult#
Single-sided amplitude spectrum of
y.With no
x_min/x_maxthe whole record is transformed. Returns aultrazohm_dataviewer.analysis.FftResult(.freqs,.mag,.info,.ok). Passtimestamp_resolution=data.timestamp_resolutionfor a loaded Dataset to account for known logger quantization; plain arrays default to unspecified.
- ultrazohm_dataviewer.api.fft_frame(time, y, **kwargs)#
Like
fft()but returns a Polars DataFrame [frequency, amplitude].Raises
ValueError(with the reason) if the transform could not be computed.
- ultrazohm_dataviewer.api.node(kind: str, *signals, timestamp_resolution=0.0, **params)#
Run a node transform headlessly.
signalsare(time, y)tuples (one for unary kinds, two for binary math);paramsoverride the kind’s defaults. Returns(out_time, out_y, info)– e.g. anfftnode returns(freqs, mag, info).kindis one ofkinds()(fft/math/filter/shiftplus any plugins).
- ultrazohm_dataviewer.api.filter(time, y, **params)#
Validated
node('filter', ...)convenience wrapper (FIR low/high/band-pass).Returns
(time, filtered_y, info).
- ultrazohm_dataviewer.api.math(*signals, **params)#
Validated
node('math', ...)convenience wrapper (scale/offset/derivative/ integral/reciprocal and binary add/sub/mul/div).signalsare(time, y)tuples. Returns(time, y_out, info).
- ultrazohm_dataviewer.api.kinds() tuple[str, ...]#
The available node-transform kinds (builtins + any loaded plugins).
- ultrazohm_dataviewer.api.load_plugins(dirs: list[str] | None = None, console=None) tuple[str, ...]#
Import every
*.pyin the plugin directories and return the newly registered kinds. Missing directories are skipped; a failing file is logged (ifconsoleis given) and skipped. Never raises.