Visual & Display
On this page
Quick Reference โจ
set_visual_mode(ctx, mode)/get_visual_mode(ctx)โ switch the primary visualization preset.set_visual_auto_scale(ctx, bool)/set_visual_scale(ctx, scale)โ control display amplitude scaling.set_visual_enable_field(ctx, field, bool)โ show or hide individual fields in the renderer.set_phase_mode(ctx, mode)/get_phase_mode(ctx)โ select the phase-portrait rendering style (requiresphase_portraitvisual mode).set_phase_coherence_*โ global phase coherence configuration used by the statistics system.
Visual Modes ๐จ
Mode Palette
| Mode string | Description |
|---|---|
phase_portrait |
Scatter plot of real vs. imaginary components โ exposes attractors and limit cycles. |
waveform |
Time-domain waveform โ useful for scalar fields and debugging. |
phase |
Phase-only rendering โ highlights angular structure. |
energy |
Energy-density view โ quick stability checks. |
frequency |
Spectral magnitude โ inspect dispersion, filtering, and energy distribution. |
polar |
Polar plot of magnitude/phase pairs. |
fft |
Raw FFT magnitude display. |
singularities |
Highlight detected singular structures and related diagnostics. |
phase_magnitude |
Combined phase + magnitude view. |
spectrum |
Fourier-spectrum view. |
phase_magnitude also accepts the aliases phase_mag and phase+magnitude.
spectrum also accepts the aliases spectral and fourier_spectrum.
Note
Older error text still mentions
flux_lensas a visual-mode string, but the current Lua binding does not accept"flux_lens"inset_visual_mode. Use the Flux Lens diagnostic APIs on the dedicated Flux Lens page.
set_visual_mode(ctx, mode)
Set the active visualization preset. Accepts any mode string from the table above, or an integer mode code.
ooc.set_visual_mode(ctx, "phase_portrait")
ooc.set_visual_mode(ctx, "phase_magnitude")
ooc.set_visual_mode(ctx, "spectrum")
get_visual_mode(ctx)
Returns mode_code, mode_name โ both the integer code and the canonical string name.
local code, name = ooc.get_visual_mode(ctx)
ooc.log("visual mode: %d โ %s", code, name)
Display Scale ๐ญ
set_visual_auto_scale(ctx, enabled)
Enable or disable automatic amplitude scaling. When true, the renderer adjusts the display range to fit the fieldโs current value range. Returns true on success.
ooc.set_visual_auto_scale(ctx, true) -- auto-scale to field range
ooc.set_visual_auto_scale(ctx, false) -- use fixed scale
set_visual_scale(ctx, scale)
Set a fixed display scale factor (used when auto-scale is disabled). Returns true on success.
ooc.set_visual_scale(ctx, 2.5) -- amplify display by 2.5ร
Field Visibility ๐
set_visual_enable_field(ctx, field, enabled)
Show or hide an individual field in the renderer. field may be a field handle or a 0-based integer index. Returns true on success.
local f0 = ooc.get_field(ctx, 0)
ooc.set_visual_enable_field(ctx, f0, false) -- hide field 0
ooc.set_visual_enable_field(ctx, 1, true) -- show field 1
Phase Portrait Sub-modes ๐
When visual_mode is phase_portrait, you can select a rendering style with set_phase_mode. Calling set_phase_mode while a different visual mode is active raises a Lua error.
Phase Mode Palette
| Mode string | Description |
|---|---|
trace |
Continuous trace of the complex trajectory over time. |
scatter |
Scatter of (Re, Im) sample points without connecting lines. |
rosette |
Rosette / Lissajous-style closed-orbit rendering. |
rose_hist |
Histogram-weighted rose pattern โ highlights density of visited states. |
set_phase_mode(ctx, mode)
Set the phase-portrait rendering style. Must be called after set_visual_mode(ctx, "phase_portrait").
ooc.set_visual_mode(ctx, "phase_portrait")
ooc.set_phase_mode(ctx, "rosette")
get_phase_mode(ctx)
Returns mode_code, mode_name. Returns nil if no phase mode is set.
local code, name = ooc.get_phase_mode(ctx)
ooc.log("phase mode: %d โ %s", code, name)
Phase Coherence Configuration ๐ก
These five functions configure the global phase coherence system used by field_stats and the statistics pipeline. They accept a ctx argument but operate on process-wide state โ settings apply to all contexts in the process.
Note
These functions are convenience wrappers. The same settings can also be set atomically through
field_stats_set_phase_config(see the Field Methods page).
set_phase_coherence_thresholds(ctx, abs_threshold, rel_threshold)
Set the amplitude thresholds for phase sample inclusion:
abs_thresholdโ minimum absolute amplitude for a sample to count.rel_thresholdโ minimum amplitude relative to the current fieldmax_abs.
ooc.set_phase_coherence_thresholds(ctx, 0.01, 0.05)
set_phase_coherence_weighted(ctx, weighted)
When true, weight each phase sample by its amplitude when computing coherence. Amplitude-weighted coherence is more robust for fields with large dynamic range.
ooc.set_phase_coherence_weighted(ctx, true)
set_phase_coherence_lock_thresholds(ctx, on_threshold, off_threshold)
Set the hysteresis thresholds for the phase-lock state machine:
on_thresholdโ coherence level required to enter the locked state.off_thresholdโ coherence level at which the lock is released (must be โคon_threshold).
ooc.set_phase_coherence_lock_thresholds(ctx, 0.85, 0.70)
set_phase_coherence_smoothing(ctx, smoothing_seconds)
Set the EMA smoothing time constant for phase_coherence_ema. Larger values produce slower, more stable estimates.
ooc.set_phase_coherence_smoothing(ctx, 0.5) -- 0.5-second EMA window
set_phase_coherence_deramp(ctx, enabled)
Enable or disable phase-ramp detrending before computing coherence. Useful when the field has a dominant linear phase drift that would otherwise suppress the coherence estimate.
ooc.set_phase_coherence_deramp(ctx, true)
Examples ๐
Switching modes during a run
ooc.set_visual_mode(ctx, "waveform")
for i = 1, 100 do ooc.step(ctx) end
ooc.set_visual_mode(ctx, "frequency")
for i = 1, 100 do ooc.step(ctx) end
ooc.set_visual_mode(ctx, "spectrum")
Phase portrait with rosette rendering
ooc.set_visual_mode(ctx, "phase_portrait")
ooc.set_phase_mode(ctx, "rosette")
local code, name = ooc.get_phase_mode(ctx)
ooc.log("rendering as: %s", name) -- "rosette"
Fixed scale with selective field display
ooc.set_visual_auto_scale(ctx, false)
ooc.set_visual_scale(ctx, 4.0)
-- Two fields; only show field 0
ooc.set_visual_enable_field(ctx, 0, true)
ooc.set_visual_enable_field(ctx, 1, false)
Full phase coherence setup before a run
-- Amplitude thresholds: ignore samples below 1% of max
ooc.set_phase_coherence_thresholds(ctx, 0.0, 0.01)
-- Weight by amplitude for dynamic-range robustness
ooc.set_phase_coherence_weighted(ctx, true)
-- Hysteresis: lock at 85%, release at 70%
ooc.set_phase_coherence_lock_thresholds(ctx, 0.85, 0.70)
-- Smooth over ~1 second of simulation time
ooc.set_phase_coherence_smoothing(ctx, 1.0)
-- Detrend linear phase ramps
ooc.set_phase_coherence_deramp(ctx, true)
for i = 1, 1000 do ooc.step(ctx) end