xboa
Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
FFTTuneFinder Class Reference

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
 

Detailed Description

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.

Constructor & Destructor Documentation

def __init__ (   self,
  u_data = None,
  peak_finder = None,
  use_hanning_filter = False 
)

Initialise the tune finder.

  • u_data: position data, for use in Fourier Transform calculation
  • peak_finder: peak finder object, object used to find peaks in the tune diagram. If peak_finder is None, uses a WindowPeakFinder with a window size 10
  • use_hanning_filer: experimental hanning filter (probably doesnt work)

Definition at line 51 of file _fft_tune.py.

Member Function Documentation

def get_tune (   self,
  tune_tolerance = None 
)

Find the fractional tune for a given tracking object.

  • tune_tolerance: tolerance with which the tune finder will attempt to calculate the tune. If set to None, FTTuneFinder will use 1/len(u)/100

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.

  • reference_hit: Hit on the closed orbit (for a ring).
  • axis: string, variable from Hit.get_variables() over which the tune will be found.
  • delta: float, displacement from the reference_hit.
  • tracking: xboa.tracking.TrackingBase, tracking object to propagate particles through the lattice.
  • use_hits: list of integers, only consider hits returned by tracking with an index in use_hits. If set to None, consider all hits.

Definition at line 118 of file _fft_tune.py.

References FFTTuneFinder.u.

def plot_signal (   self,
  title 
)

Plot the FFT frequency spectrum.

  • title, string used as a title in FFT plots Returns tuple of TCanvas, TH2, TGraph

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.

  • title, string used as a title in FFT plots Returns tuple of TCanvas, TH2, TGraph

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.

  • title, string title for the plot
  • peak_k_index, integer corresponding to element from self.k_mag which makes the seed for the position of the hit
  • fit_lower_bound, integer corresponding to the element from self.k_mag which makes the lower edge of the fit window
  • fit_lower_bound, integer corresponding to the element from self.k_mag which makes the upper edge of the fit window
  • fit, ROOT.TF1 used for fitting. If set to None, a Gaussian will be used with reasonable parameters. Note that user has responsibility to set the fit window in fit

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().

def _get_max_peak (   self)
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().

def _sft_find_peaks (   self,
  interval 
)
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().

def _fft_find_peaks (   self)
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().

def _find_peaks (   self)
private
def _recursive_refine_peak (   self,
  k_x,
  x_tolerance 
)
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().

def _sft (   self,
  k_x 
)
private

Calculate "Slow" Fourier Transform at k_x.

  • k_x, float, position at which the sft is found
  • hanning filter, bool, set to True to apply a hanning filter

"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().

Member Data Documentation

_peak_finder
private

Definition at line 52 of file _fft_tune.py.

u
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
peak_y_list

Definition at line 59 of file _fft_tune.py.

Referenced by FFTTuneFinder._find_peaks(), and FFTTuneFinder.get_tune().

k_mag_x
k_mag_y

The documentation for this class was generated from the following file: