diff options
| author | Sam Scholten | 2025-10-28 12:29:41 +1000 |
|---|---|---|
| committer | Sam Scholten | 2025-10-28 12:29:41 +1000 |
| commit | 633b667aa7896a8d6042c7a577b8ffd90acf85b0 (patch) | |
| tree | aba0d067444d1d5cc6e13e40ca2f8bfe0d0ab9ea | |
| parent | 2933fd30b32ab0d85c93beef55646015642bda7d (diff) | |
| download | scopekit-633b667aa7896a8d6042c7a577b8ffd90acf85b0.tar.gz scopekit-633b667aa7896a8d6042c7a577b8ffd90acf85b0.zip | |
Reduce non-uniform sampling warning verbosityv1.0.1
- Change threshold from 1% to 10% CV coefficient of variation
- Remove detailed worst-point reporting
- Combine warnings into a single concise message
- Only warn on severe irregularities that might affect analysis
| -rw-r--r-- | src/scopekit/data_manager.py | 37 |
1 files changed, 6 insertions, 31 deletions
diff --git a/src/scopekit/data_manager.py b/src/scopekit/data_manager.py index 78a8ea3..2f13ce3 100644 --- a/src/scopekit/data_manager.py +++ b/src/scopekit/data_manager.py @@ -414,38 +414,13 @@ class TimeSeriesDataManager: # Calculate statistics dt_mean = np.mean(dt) dt_std = np.std(dt) - dt_cv = dt_std / dt_mean if dt_mean > 0 else 0 # Coefficient of variation + dt_cv = dt_std / dt_mean if dt_mean > 1e-15 else 0 # Coefficient of variation # Check for significant non-uniformity - # CV > 0.01 (1%) indicates potentially problematic non-uniformity - if dt_cv > 0.01: + # CV > 0.1 (10%) indicates potentially problematic non-uniformity + if dt_cv > 0.1: warnings.warn( - f"Non-uniform sampling detected in trace {trace_idx}: " - f"mean dt={dt_mean:.3e}s, std={dt_std:.3e}s, CV={dt_cv:.2%}", UserWarning + f"Severe non-uniform sampling detected in trace {trace_idx}: " + f"mean dt={dt_mean:.3e}s, std={dt_std:.3e}s, CV={dt_cv:.2%}. " + f"May affect analysis results.", UserWarning ) - - # More detailed warning for severe non-uniformity - if dt_cv > 0.05: # 5% variation - # Find the most extreme deviations - dt_median = np.median(dt) - rel_deviations = np.abs(dt - dt_median) / dt_median - worst_indices = np.argsort(rel_deviations)[-5:] # 5 worst points - - worst_deviations = [] - for idx in reversed(worst_indices): - if ( - rel_deviations[idx] > 0.1 - ): # Only report significant deviations (>10%) - worst_deviations.append( - f"at t={t[idx]:.3e}s: dt={dt[idx]:.3e}s ({rel_deviations[idx]:.1%} deviation)" - ) - - if worst_deviations: - warnings.warn( - f"Severe sampling irregularities detected in trace {trace_idx}. " - f"Worst points: {'; '.join(worst_deviations)}", UserWarning - ) - warnings.warn( - "Non-uniform sampling may affect analysis results, especially for " - "frequency-domain analysis or event detection.", UserWarning - ) |
