bode_metrics
Analyze AC simulation results to extract filter characteristics, magnitude slope, magnitude/phase at specific frequencies, or crossing frequencies from LTspice .raw files or completed jobs.
Instructions
AC / Bode-plot analysis in one tool, selected by mode. The response shape depends on the mode:
mode='filter' — filter type, cutoffs (at ref_db below passband), passband gain/ripple, stopband rejection, transition BW, pole-order.
mode='slope' — magnitude slope (dB/decade + dB/octave) between f_low and f_high; pick endpoints ≥1 decade past any knee.
mode='point' — magnitude (dB + linear) and phase at each of frequencies (log-axis interpolation; out-of-range clamps + warns).
mode='crossing' — every frequency where quantity crosses level (phase is UNWRAPPED first); the escape hatch for custom queries like unity-gain (0 dB) or phase-margin (-180°) frequencies.
Pass all_steps=true to compute the chosen mode for every step of a .step sweep in one call (returns a steps list instead of a single result) — e.g. the -3 dB cutoff at every value of a stepped component.
To analyze a run of a completed sweep/MC job, pass job_id + run_index instead of raw_file (combine with all_steps to also sweep the .step axis within that run).
For loop-gain stability margins use stability_metrics; for resonant peaks & Q use resonance.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| raw_file | No | Path to AC analysis .raw result file. Pass this OR ``job_id``, not both. | |
| job_id | No | Analyze a specific run of a completed sweep/MC (or single) job instead of a raw_file path; pair with ``run_index``. Combine with ``all_steps`` to sweep the .step axis WITHIN that run. | |
| run_index | No | 0-based run to analyze when ``job_id`` is given (default 0). | |
| signal | Yes | Signal name (e.g. 'V(out)') | |
| mode | Yes | Which view of the AC response to compute: 'filter' — LPF/HPF/BPF/BSF type, cutoffs, ripple, rejection (args: ref_db, flatness_db, passband_range, stopband_range) 'slope' — magnitude slope between two frequencies (args: f_low, f_high — both required) 'point' — magnitude (dB + linear) and phase at specific frequencies (args: frequencies — required; include_unwrapped_phase) 'crossing' — every frequency where magnitude/phase crosses a level (args: quantity + level — required; direction, f_start, f_end, max_results, min_separation_decades) | |
| step | No | Step index for .step sweeps | |
| all_steps | No | Compute the metric for EVERY step of a stepped (.step) sweep in one call, instead of the single `step`. Returns `steps`: a list of per-step results (each tagged with its `step` index). A step whose computation fails is returned with an `error` field rather than aborting the whole call. On a non-stepped raw this returns a single entry. Use this for 'give me the cutoff/slope/gain at every step'. | |
| quantity | No | crossing: 'magnitude_db' | 'magnitude_linear' | 'phase_deg'. | |
| level | No | crossing: level to cross, in the units of `quantity`. | |
| direction | No | crossing: edge direction. | any |
| f_start | No | crossing: lower frequency bound. | |
| f_end | No | crossing: upper frequency bound. | |
| max_results | No | crossing: cap on returned crossings. | |
| min_separation_decades | No | crossing: merge crossings within this many decades. | |
| frequencies | No | point: frequencies to query (SPICE notation). | |
| include_unwrapped_phase | No | point: also return cumulative unwrapped phase. | |
| ref_db | No | filter: cutoff reference below passband (dB). | |
| flatness_db | No | filter: passband flatness tolerance (dB). | |
| passband_range | No | filter: optional [f_lo, f_hi] passband override. | |
| stopband_range | No | filter: optional [f_lo, f_hi] stopband region. | |
| f_low | No | slope: low frequency bound (required). | |
| f_high | No | slope: high frequency bound (required). | |
| format | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filter_type | No | ||
| passband_gain_db | No | ||
| passband_low_hz | No | ||
| passband_high_hz | No | ||
| passband_ripple_db | No | ||
| cutoff_low_hz | No | ||
| cutoff_high_hz | No | ||
| ref_db | No | ||
| cutoff_level_db | No | ||
| stopband_rejection_db | No | ||
| transition_bandwidth_hz | No | ||
| rolloff_slope_db_per_decade | No | ||
| estimated_order | No | ||
| warnings | No | ||
| signal | No | ||
| f_low_hz | No | ||
| f_high_hz | No | ||
| gain_low_db | No | ||
| gain_high_db | No | ||
| delta_db | No | ||
| span_decades | No | ||
| slope_db_per_decade | No | ||
| slope_db_per_octave | No | ||
| nearest_pole_order_estimate | No | ||
| points | No | ||
| quantity | No | ||
| level | No | ||
| direction | No | ||
| crossings | No | ||
| mode | No | ||
| all_steps | No | ||
| step_count | No | ||
| steps | No |