Harmonic Analysis

IO Handlers

Input Handler

exception harmonic_analysis.io_handlers.input_handler.ArgumentError[source]

Output Handler

Main Functions

Clean

harmonic_analysis.clean.detect_bpms_with_exact_zeros(bpm_data)[source]

Detects BPMs with exact zeros due to OP workaround

harmonic_analysis.clean.detect_bpms_with_spikes(bpm_data, max_peak_cut)[source]

Detects BPMs with spikes > max_peak_cut

harmonic_analysis.clean.detect_flat_bpms(bpm_data, min_peak_to_peak)[source]

Detects BPMs with the same values for all turns

harmonic_analysis.clean.detect_known_bad_bpms(bpm_data, list_of_bad_bpms)[source]

Searches for known bad BPMs

harmonic_analysis.clean.fix_polarity(wrong_polarity_names, bpm_data)[source]

Fixes wrong polarity

harmonic_analysis.clean.resync_bpms(bpm_data, file_date)[source]

Resynchronizes BPMs between the injection point and start of the lattice if the acquisition date is after 2016-04-01.

Harpy

This module is the actual implementation of the resonance search for turn-by-turn data. It uses a combination of the laskar method with SVD decomposition to speed up the search of resonances.

harmonic_analysis.harpy.clean_by_tune(tunes, tune_clean_limit)[source]

This function looks for outliers in the tunes pandas Series and returns their indices.

Parameters:
  • tunes -- Pandas series with the tunes per BPM and the BPM names as index.
  • tune_clean_limit -- No BPM will find as oulier if its distance to the average is lower than this limit.
harmonic_analysis.harpy.harmonic_analysis(bpm_matrix=None, usv=None, mode='bpm', sequential=False)[source]

Performs the laskar method on every of the BPMs signals contained in each row of the bpm_matrix pandas DataFame.

Parameters:
  • bpm_matrix -- Pandas DataFrame containing the signals of each bpm in each row. In bpm mode this parameter is obligatory.
  • usv -- Truncated SVD decomposition of the bpm matrix. It must contain a tuple (U, S, V), where U must be a DataFrame with the bpm names as index.
  • mode -- one of ‘bpm’, ‘svd’, or ‘fast’. Check ‘harmonic_analysis_bpm’ documentation for ‘bpm’ mode and ‘harmonic_analysis_svd” for ‘svd’ and ‘fast’.
  • sequential -- If true, it will run all the computations in a single core.
Returns:

A numpy array with the frequencies found per BPM. bpm_coefficients: A numpy array containing the complex coefficients found per BPM.

Return type:

frequencies

harmonic_analysis.harpy.harmonic_analysis_bpm(bpm_matrix, sequential=False, num_harms=300)[source]

Performs the laskar method on every of the BPMs signals contained in each row of the bpm_matrix pandas DataFame. This method will run the full laskar analysis in each BPM in parallel (slow).

Parameters:
  • bpm_matrix -- Pandas DataFrame containing the signals of each bpm in each row. In bpm mode this parameter is obligatory.
  • sequential -- If true, it will run all the computations in a single core.
  • num_harms -- Number of harmonics to compute per BPM.
Returns:

A numpy array with the frequencies found per BPM. bpm_coefficients: A numpy array containing the complex coefficients found per BPM.

Return type:

frequencies

harmonic_analysis.harpy.harmonic_analysis_svd(usv, fast=False, sequential=False, num_harms=300)[source]

Performs the laskar method on every of the BPMs signals contained in each row of the bpm_matrix pandas DataFame. It takes advantage of the truncation of the V matrix in the SVD decomposition to speed up the calculations. Mode ‘svd’ is slower but more precise, ‘bpm’ mode is the fastest but makes more assumptions.

Parameters:
  • usv -- Truncated SVD decomposition of the bpm matrix. It must contain a tuple (U, S, V), where U must be a DataFrame with the bpm names as index.
  • fast -- If true, it will use the ‘fast’ calculation mode (‘svd’ otherwise)
  • sequential -- If true, it will run all the computations in a single core.
  • num_harms -- Number of harmonics to compute per BPM.
Returns:

A numpy array with the frequencies found per BPM. bpm_coefficients: A numpy array containing the complex coefficients found per BPM.

Return type:

frequencies

harmonic_analysis.harpy.harpy(harpy_input, bpm_matrix_x, usv_x, bpm_matrix_y, usv_y)[source]

Helpers

Chroma

Get Optics 3D

Created on 31/07/17

author:Lukas Malina

It computes horizontal normalised dispersion from 3D kicks, together with the phase advance it uses the model with AC-Dipole element in, i. e. there is no compensation for AC-Dipole.

Tune Clean