xboa
|
Find the tune using the fast fourier transform technique. More...
Inherits object.
Public Member Functions | |
def | __init__ |
Initialise the tune finder. More... | |
def | get_tune |
Find the fractional tune for a given tracking object. More... | |
def | run_tracking |
Set position data from tracking output. More... | |
def | plot_signal |
Plot the FFT frequency spectrum. More... | |
def | plot_fft |
Plot the FFT frequency spectrum. More... | |
def | plot_fft_fit |
Draw the FFT spectrum and fit within a window. More... | |
Public Attributes | |
u | |
use_hanning_filter | |
fractional_tune | |
peak_x_list | |
peak_y_list | |
k_mag_x | |
k_mag_y | |
Private Member Functions | |
def | _get_max_peak |
Find the maximum peak in self.peak_index_list. More... | |
def | _sft_find_peaks |
Perform a slow Fourier Transform and find any peaks. More... | |
def | _fft_find_peaks |
Perform the Fast Fourier Transform and find any peaks. More... | |
def | _find_peaks |
Run the peak finder. More... | |
def | _recursive_refine_peak |
Use slow fourier transforms in the region of a peak to recursively improve the peak estimate to some tolerance. More... | |
def | _sft |
Calculate "Slow" Fourier Transform at k_x. More... | |
Private Attributes | |
_peak_finder | |
Find the tune using the fast fourier transform technique.
Apply a small displacement to the reference trajectory and track through a lattice; use the displaced trajectory
Definition at line 38 of file _fft_tune.py.
def __init__ | ( | self, | |
u_data = None , |
|||
peak_finder = None , |
|||
use_hanning_filter = False |
|||
) |
Initialise the tune finder.
Definition at line 51 of file _fft_tune.py.
def get_tune | ( | self, | |
tune_tolerance = None |
|||
) |
Find the fractional tune for a given tracking object.
Displaces the reference hit by an amount delta, tracks this hit using the tracking object and runs a one dimensional FFT against the axis variable. Number of samples used in the FFT is determined by the tracking object (and hence accuracy of the tune calculation).
Note that u_data must be of odd length for this algorithm; FFTTuneFinder will discard the last element if this is not the case.
Returns the principle Fourier frequency that is not 0.
Definition at line 81 of file _fft_tune.py.
References FFTTuneFinder._fft_find_peaks(), FFTTuneFinder._get_max_peak(), FFTTuneFinder._recursive_refine_peak(), FFTTuneFinder._sft_find_peaks(), FFTTuneFinder.fractional_tune, FFTTuneFinder.k_mag_x, FFTTuneFinder.k_mag_y, FFTTuneFinder.peak_x_list, FFTTuneFinder.peak_y_list, and FFTTuneFinder.u.
Referenced by FFTTuneFinder.plot_fft().
def run_tracking | ( | self, | |
axis, | |||
delta, | |||
reference_hit, | |||
tracking, | |||
use_hits = None |
|||
) |
Set position data from tracking output.
Definition at line 118 of file _fft_tune.py.
References FFTTuneFinder.u.
def plot_signal | ( | self, | |
title | |||
) |
Plot the FFT frequency spectrum.
Definition at line 133 of file _fft_tune.py.
References FFTTuneFinder.u.
def plot_fft | ( | self, | |
title, | |||
ymin = None , |
|||
ymax = None |
|||
) |
Plot the FFT frequency spectrum.
Definition at line 150 of file _fft_tune.py.
References FFTTuneFinder.get_tune(), FFTTuneFinder.k_mag_x, FFTTuneFinder.k_mag_y, and FFTTuneFinder.plot_fft_fit().
Referenced by FFTTuneFinder.plot_fft_fit().
def plot_fft_fit | ( | self, | |
title, | |||
peak_k_index, | |||
fit_lower_index, | |||
fit_upper_index, | |||
fit = None |
|||
) |
Draw the FFT spectrum and fit within a window.
Uses the ROOT library to do the fit; this means drawing the data onto a ROOT Canvas using self.plot_fft. Fits with a Gaussian; in the presence of noisy/low statistics data, this can improve the estimate of tune.
Returns a tuple of TCanvas, TH2, TGraph, TF1. Hint:- to get the fractional tune, use TF1::GetParameter(0); to get the estimated error, use TF1::GetParError(0).
Definition at line 190 of file _fft_tune.py.
References FFTTuneFinder.k_mag_x, FFTTuneFinder.k_mag_y, and FFTTuneFinder.plot_fft().
Referenced by FFTTuneFinder.plot_fft().
|
private |
Find the maximum peak in self.peak_index_list.
Definition at line 213 of file _fft_tune.py.
References FFTTuneFinder.fractional_tune, FFTTuneFinder.k_mag_x, FFTTuneFinder.k_mag_y, and FFTTuneFinder.peak_x_list.
Referenced by FFTTuneFinder.get_tune().
|
private |
Perform a slow Fourier Transform and find any peaks.
Definition at line 227 of file _fft_tune.py.
References FFTTuneFinder._find_peaks(), FFTTuneFinder._sft(), FFTTuneFinder.k_mag_x, and FFTTuneFinder.k_mag_y.
Referenced by FFTTuneFinder.get_tune().
|
private |
Perform the Fast Fourier Transform and find any peaks.
Definition at line 237 of file _fft_tune.py.
References FFTTuneFinder._find_peaks(), FFTTuneFinder.k_mag_x, FFTTuneFinder.k_mag_y, and FFTTuneFinder.u.
Referenced by FFTTuneFinder.get_tune().
|
private |
Run the peak finder.
Definition at line 248 of file _fft_tune.py.
References FFTTuneFinder.k_mag_x, FFTTuneFinder.k_mag_y, FFTTuneFinder.peak_x_list, and FFTTuneFinder.peak_y_list.
Referenced by FFTTuneFinder._fft_find_peaks(), and FFTTuneFinder._sft_find_peaks().
|
private |
Use slow fourier transforms in the region of a peak to recursively improve the peak estimate to some tolerance.
On each iteration, the new k_mag values are appended to k_mag_x/y.
Stop recursing if the new value is < the neighbouring value; we assume this is numerical precision noise and the recursion has converged (implicit that the seed peak was closer than any troughs).
Returns the new peak_index
Definition at line 270 of file _fft_tune.py.
References FFTTuneFinder._recursive_refine_peak(), FFTTuneFinder._sft(), FFTTuneFinder.k_mag_x, and FFTTuneFinder.k_mag_y.
Referenced by FFTTuneFinder._recursive_refine_peak(), and FFTTuneFinder.get_tune().
|
private |
Calculate "Slow" Fourier Transform at k_x.
"Slow" Fourier transform means using Sum(A_i cos(...) + A_i sin(...)) to get the FT at a given k value
Definition at line 321 of file _fft_tune.py.
References FFTTuneFinder.u, and FFTTuneFinder.use_hanning_filter.
Referenced by FFTTuneFinder._recursive_refine_peak(), and FFTTuneFinder._sft_find_peaks().
|
private |
Definition at line 52 of file _fft_tune.py.
u |
Definition at line 55 of file _fft_tune.py.
Referenced by FFTTuneFinder._fft_find_peaks(), FFTTuneFinder._sft(), FFTTuneFinder.get_tune(), FFTTuneFinder.plot_signal(), and FFTTuneFinder.run_tracking().
use_hanning_filter |
Definition at line 56 of file _fft_tune.py.
Referenced by FFTTuneFinder._sft().
fractional_tune |
Definition at line 57 of file _fft_tune.py.
Referenced by FFTTuneFinder._get_max_peak(), and FFTTuneFinder.get_tune().
peak_x_list |
Definition at line 58 of file _fft_tune.py.
Referenced by FFTTuneFinder._find_peaks(), FFTTuneFinder._get_max_peak(), and FFTTuneFinder.get_tune().
peak_y_list |
Definition at line 59 of file _fft_tune.py.
Referenced by FFTTuneFinder._find_peaks(), and FFTTuneFinder.get_tune().
k_mag_x |
Definition at line 60 of file _fft_tune.py.
Referenced by FFTTuneFinder._fft_find_peaks(), FFTTuneFinder._find_peaks(), FFTTuneFinder._get_max_peak(), FFTTuneFinder._recursive_refine_peak(), FFTTuneFinder._sft_find_peaks(), FFTTuneFinder.get_tune(), FFTTuneFinder.plot_fft(), and FFTTuneFinder.plot_fft_fit().
k_mag_y |
Definition at line 61 of file _fft_tune.py.
Referenced by FFTTuneFinder._fft_find_peaks(), FFTTuneFinder._find_peaks(), FFTTuneFinder._get_max_peak(), FFTTuneFinder._recursive_refine_peak(), FFTTuneFinder._sft_find_peaks(), FFTTuneFinder.get_tune(), FFTTuneFinder.plot_fft(), and FFTTuneFinder.plot_fft_fit().