@@ -545,6 +545,27 @@ def gpu_convolve(signal, filter_coeffs, kernel, mode='symmetric'):
545545 # Zero-crossings indicate oscillation frequency
546546 zero_crossings = np .sum (np .diff (np .sign (current_detail_interp )) != 0 )
547547
548+ # Find local minima and maxima for period calculation
549+ from scipy .signal import find_peaks
550+
551+ # Use original detail data (before interpolation) for accurate period calculation
552+ minima_indices , _ = find_peaks (- current_detail )
553+ maxima_indices , _ = find_peaks (current_detail )
554+
555+ # Calculate average periods (in hours, accounting for downsampling)
556+ downsample_factor = 2 ** (i + 1 )
557+ if len (minima_indices ) > 1 :
558+ min_periods = np .diff (minima_indices )
559+ avg_min_period_hours = min_periods .mean () * downsample_factor
560+ else :
561+ avg_min_period_hours = 0
562+
563+ if len (maxima_indices ) > 1 :
564+ max_periods = np .diff (maxima_indices )
565+ avg_max_period_hours = max_periods .mean () * downsample_factor
566+ else :
567+ avg_max_period_hours = 0
568+
548569 # Title with comprehensive info
549570 ax_detail .set_title (f'Band { i + 1 } : { freq_bands [i ][0 ]} - { freq_bands [i ][2 ]} ' ,
550571 fontsize = 12 , fontweight = 'bold' , pad = 10 )
@@ -554,7 +575,7 @@ def gpu_convolve(signal, filter_coeffs, kernel, mode='symmetric'):
554575
555576 # Enhanced stats box showing frequency characteristics
556577 ax_detail .text (0.02 , 0.97 ,
557- f'σ: ${ detail_std :.1f} \n Mean|Δ|: ${ detail_mean_abs :.1f} \n Range: ${ detail_range :.1f} \n Zero-crossings: { zero_crossings } \n { freq_bands [i ][1 ]} ' ,
578+ f'σ: ${ detail_std :.1f} \n Mean|Δ|: ${ detail_mean_abs :.1f} \n Range: ${ detail_range :.1f} \n Zero-crossings: { zero_crossings } \n Min→Min: { avg_min_period_hours :.1f } h \n Max→Max: { avg_max_period_hours :.1f } h \ n{ freq_bands [i ][1 ]} ' ,
558579 transform = ax_detail .transAxes , fontsize = 8 , verticalalignment = 'top' ,
559580 bbox = dict (boxstyle = 'round' , facecolor = 'lightblue' , alpha = 0.7 ))
560581
0 commit comments