Problem
Many spectrum analysis graphs show "Data Unavailable" for older Betaflight logs (4.0.x, 4.3.x) that contain valid flight data.
Root Cause
The filter delay analysis in src/data_analysis/filter_delay.rs requires BOTH gyroADC (filtered) AND gyroUnfilt (unfiltered) data:
if let (Some(filtered), Some(unfiltered)) = (row.gyro[axis], row.gyro_unfilt[axis]) {
filtered_data.push(filtered as f32);
unfiltered_data.push(unfiltered as f32);
}
Note: The renderer already has fallback logic to use debug[0-2] as unfiltered gyro when gyroUnfilt[0-2] is not available (implemented in src/data_input/log_parser.rs). This works for many logs where pilots configured debug mode.
Problem occurs when BOTH sources are missing:
gyroUnfilt[0-2] - not available in older firmware ✗
debug[0-2] - pilot did not configure debug mode for this particular flight ✗
Historical Context
Older Betaflight (< 4.5): Unfiltered gyro logging depended on configuration:
- Default: Only
gyroADC[0-2] (filtered) was logged
- Debug mode configured: Unfiltered gyro logged to
debug[0-2] channels
- Common debug modes:
GYRO_SCALED, GYRO, GYRO_RAW
- Many pilots configured this when tuning PIDs or filters
- Some pilots left it off for normal flights (battery/performance/storage reasons)
- Renderer already handles debug fallback - this works for many logs
Modern Betaflight (≥ 4.5): Unfiltered gyro is logged automatically to gyroUnfilt[0-2] fields by default, so this is not an issue for recent logs.
When Does The Problem Occur?
- Tuning flights: Usually have debug mode → Works fine (fallback to debug)
- Normal flights with debug disabled: No unfiltered data → Fails (this issue)
- Storage-constrained flights: Debug disabled to save space → Fails (this issue)
Evidence
Log: 4.0.2_BTFL_AIKON_BLACKBOX_LOG_20190817_222106.06.csv
- CSV fields: Only has
gyroADC[0-2]
- Frames: 128,289 (legitimate flight)
- Debug mode: Not configured for this flight
- Renderer fallback: No
debug[0-2] to fall back to
- Renderer diagnostic:
Roll axis: gyro=282354, unfilt=0, both=0, longest_continuous=0
Axis 0 (Roll) extracted: 0 samples
- Result: "Data Unavailable" for gyro spectrum plots
Current Fallback Logic
The renderer already implements debug channel fallback in src/data_input/log_parser.rs:
// Apply Fallback Logic for gyro_unfilt (debug[0-2] --> gyroUnfilt[0-2])
for axis in 0..crate::axis_names::AXIS_NAMES.len() {
current_row_data.gyro_unfilt[axis] = match parsed_gyro_unfilt[axis] {
Some(val) => Some(val),
None => parsed_debug[axis], // ← Fallback to debug
};
}
This works well when debug mode was configured. The problem is spectrum analysis still requires unfiltered data even when neither source is available.
Impact
When both gyroUnfilt and debug[0-2] are missing:
- Gyro spectrum analysis graphs fail → "Data Unavailable"
- Gyro PSD (Power Spectral Density) plots fail
- Gyro vs Unfiltered comparison plots fail
- Filter delay analysis skipped
These are valid flight logs with usable gyroADC data, but certain analysis types cannot be performed.
Proposed Solutions
Option 1: Fallback to Filtered-Only Analysis (Recommended)
When both gyroUnfilt and debug[0-2] are unavailable, perform spectrum analysis on gyroADC alone:
- Still useful for identifying resonance frequencies
- Can show motor noise patterns
- Can identify problematic frequency bands
- Just can't show filtering effectiveness or calculate filter delay
- Label plots clearly: "Filtered Gyro Only - Unfiltered data not available"
Option 2: User-Friendly Status Messages
Improve console output to distinguish between cases:
- ✅ "Using debug channels as unfiltered gyro" (fallback working)
- ✅ "Unfiltered gyro available from gyroUnfilt fields" (modern logs)
- ⚠️ "Note: Neither gyroUnfilt nor debug channels available. Spectrum analysis shows filtered data only." (this issue)
Option 3: Configuration Flag
Add command-line flag: --allow-filtered-only-spectrums
- Default: OFF (current behavior - skip plots when unfiltered missing)
- When enabled: Generate filtered-only spectrum plots with clear labeling
- Gives users control over completeness vs. information trade-off
Recommendation
Implement Option 1 (filtered-only analysis with clear labeling) + Option 2 (better status messages):
- Keep existing debug fallback (already works well)
- When both sources unavailable: Generate spectrum plots from filtered gyro only
- Add clear labels:
- On plots: "[Filtered Gyro Only]" or "[No Unfiltered Reference]"
- In legend: "(gyroADC - no unfiltered data available)"
- Improve console messages: Clearly state which data source is being used
- Skip comparison plots gracefully: Can't compare filtered vs unfiltered without unfiltered data
This approach:
- ✅ Respects existing debug fallback (used by many tuning logs)
- ✅ Maximizes value for logs without debug mode
- ✅ Provides transparency about data limitations
- ✅ Maintains current behavior for logs with debug configured
Files Affected
src/data_analysis/filter_delay.rs - Add filtered-only fallback mode
src/plot_functions/plot_gyro_spectrums.rs - Support filtered-only spectrum generation
src/plot_functions/plot_psd.rs - Support filtered-only PSD analysis
src/plot_functions/plot_gyro_vs_unfilt.rs - Skip gracefully with informative message
src/data_input/log_parser.rs - Add status reporting for data source detection
Test Cases
- Modern log (≥ 4.5):
gyroUnfilt[0-2] present → Works (use gyroUnfilt)
- Tuning log with debug:
debug[0-2] present → Works (existing fallback)
- Normal flight without debug: Only
gyroADC[0-2] → Needs fix (filtered-only mode)
- Example:
4.0.2_BTFL_AIKON_BLACKBOX_LOG_20190817_222106.06.csv (282K frames)
- Mixed log file: Some logs with debug, some without → Should handle each appropriately
Summary
The renderer already handles the common case (debug mode configured) via debug channel fallback. This issue addresses the remaining case where pilots chose not to use debug mode for normal flights, leaving valuable filtered gyro data underutilized.
Problem
Many spectrum analysis graphs show "Data Unavailable" for older Betaflight logs (4.0.x, 4.3.x) that contain valid flight data.
Root Cause
The filter delay analysis in
src/data_analysis/filter_delay.rsrequires BOTHgyroADC(filtered) ANDgyroUnfilt(unfiltered) data:Note: The renderer already has fallback logic to use
debug[0-2]as unfiltered gyro whengyroUnfilt[0-2]is not available (implemented insrc/data_input/log_parser.rs). This works for many logs where pilots configured debug mode.Problem occurs when BOTH sources are missing:
gyroUnfilt[0-2]- not available in older firmware ✗debug[0-2]- pilot did not configure debug mode for this particular flight ✗Historical Context
Older Betaflight (< 4.5): Unfiltered gyro logging depended on configuration:
gyroADC[0-2](filtered) was loggeddebug[0-2]channelsGYRO_SCALED,GYRO,GYRO_RAWModern Betaflight (≥ 4.5): Unfiltered gyro is logged automatically to
gyroUnfilt[0-2]fields by default, so this is not an issue for recent logs.When Does The Problem Occur?
Evidence
Log: 4.0.2_BTFL_AIKON_BLACKBOX_LOG_20190817_222106.06.csv
gyroADC[0-2]debug[0-2]to fall back toCurrent Fallback Logic
The renderer already implements debug channel fallback in
src/data_input/log_parser.rs:This works well when debug mode was configured. The problem is spectrum analysis still requires unfiltered data even when neither source is available.
Impact
When both
gyroUnfiltanddebug[0-2]are missing:These are valid flight logs with usable
gyroADCdata, but certain analysis types cannot be performed.Proposed Solutions
Option 1: Fallback to Filtered-Only Analysis (Recommended)
When both
gyroUnfiltanddebug[0-2]are unavailable, perform spectrum analysis ongyroADCalone:Option 2: User-Friendly Status Messages
Improve console output to distinguish between cases:
Option 3: Configuration Flag
Add command-line flag:
--allow-filtered-only-spectrumsRecommendation
Implement Option 1 (filtered-only analysis with clear labeling) + Option 2 (better status messages):
This approach:
Files Affected
src/data_analysis/filter_delay.rs- Add filtered-only fallback modesrc/plot_functions/plot_gyro_spectrums.rs- Support filtered-only spectrum generationsrc/plot_functions/plot_psd.rs- Support filtered-only PSD analysissrc/plot_functions/plot_gyro_vs_unfilt.rs- Skip gracefully with informative messagesrc/data_input/log_parser.rs- Add status reporting for data source detectionTest Cases
gyroUnfilt[0-2]present → Works (use gyroUnfilt)debug[0-2]present → Works (existing fallback)gyroADC[0-2]→ Needs fix (filtered-only mode)4.0.2_BTFL_AIKON_BLACKBOX_LOG_20190817_222106.06.csv(282K frames)Summary
The renderer already handles the common case (debug mode configured) via debug channel fallback. This issue addresses the remaining case where pilots chose not to use debug mode for normal flights, leaving valuable filtered gyro data underutilized.