Scripts

BetaBeat.src Output Converter

Script to convert most important output files produced by BetaBeat.src / GetLLM into the standard format used in omc3 to allow straight forward comparison of the two.

Good to know: in BetaBeat.src the _free files correspond to AC dipole (or ADT-AC dipole) compensation by analytic equation while _free2 corresponds to compensation via effective model. It is written in GetLLM (at least once) here: https://github.com/pylhc/Beta-Beat.src/blob/63c5e39f63b03c00d18289cc9813a912fa6b933f/GetLLM/GetLLM.py#L606

omc3.scripts.betabeatsrc_output_converter.convert_old_beta_from_amplitude(inputdir: Path | str, outputdir: Path | str, suffix: str, plane: str, old_file_name: str = 'ampbeta', new_file_name: str = 'beta_amplitude_') None[source]

Looks in the provided directory for expected beta from amplitude file from BetaBeat.src for a given plane, converts it to the output format used by omc3 and write them to the new location.

The file naming should be getampbeta(x,y).out, with the following expected columns: NAME, S, COUNT, BETX, BETXSTD, BETXMDL, MUXMDL, BETXRES, BETXSTDRES.

Parameters:
  • inputdir (Union[Path, str]) -- Location of the directory with BetaBeat.src output files.

  • outputdir (Union[Path, str]) -- Location of the output directory for converted files.

  • suffix (str) -- Compensation suffix used in the provided BetaBeat.src output files.

  • plane (str) -- the transverse plane for which to look for the output file.

  • old_file_name (str) -- the standard naming for the old output file.

  • new_file_name (str) -- the standard naming for the new converted file.

omc3.scripts.betabeatsrc_output_converter.convert_old_beta_from_phase(inputdir: Path | str, outputdir: Path | str, suffix: str, plane: str, old_file_name: str = 'beta', new_file_name: str = 'beta_phase_') None[source]

Looks in the provided directory for expected beta from phase file from BetaBeat.src for a given plane, converts it to the output format used by omc3 and write them to the new location.

The file naming should be getbeta(x,y).out, with the following expected columns: NAME, S, COUNT, BETX, SYSBETX, STATBETX, ERRBETX, CORR_ALFABETA, ALFX, SYSALFX, STATALFX, ERRALFX, BETXMDL, ALFXMDL, MUXMDL, NCOMBINATIONS.

Parameters:
  • inputdir (Union[Path, str]) -- Location of the directory with BetaBeat.src output files.

  • outputdir (Union[Path, str]) -- Location of the output directory for converted files.

  • suffix (str) -- Compensation suffix used in the provided BetaBeat.src output files.

  • plane (str) -- the transverse plane for which to look for the output file.

  • old_file_name (str) -- the standard naming for the old output file.

  • new_file_name (str) -- the standard naming for the new converted file.

omc3.scripts.betabeatsrc_output_converter.convert_old_closed_orbit(inputdir: Path | str, outputdir: Path | str, plane: str, old_file_name: str = 'CO', new_file_name: str = 'orbit_') None[source]

Looks in the provided directory for expected closed orbit file from BetaBeat.src for a given plane, converts it to the output format used by omc3 and write them to the new location.

The file naming should be getCO(x,y).out, with the following expected columns: NAME, S, COUNT, X, STDX, XMDL, MUXMDL.

Parameters:
  • inputdir (Union[Path, str]) -- Location of the directory with BetaBeat.src output files.

  • outputdir (Union[Path, str]) -- Location of the output directory for converted files.

  • plane (str) -- the transverse plane for which to look for the output file.

  • old_file_name (str) -- the standard naming for the old output file.

  • new_file_name (str) -- the standard naming for the new converted file.

omc3.scripts.betabeatsrc_output_converter.convert_old_coupling(inputdir: Path | str, outputdir: Path | str, suffix: str, old_file_name: str = 'couple', new_file_name: str = 'f') None[source]

Looks in the provided directory for expected coupling file from BetaBeat.src, converts it to the output format used by omc3 and write them to the new location.

The file naming should be getcouple(x,y).out, with the following expected columns: NAME, S, COUNT, F1001W, FWSTD1, F1001R, F1001I, F1010W, FWSTD2, F1010R, F1010I, Q1001, Q1001STD, Q1010, Q1010STD, MDLF1001R, MDLF1001I, MDLF1010R, MDLF1010I.

Parameters:
  • inputdir (Union[Path, str]) -- Location of the directory with BetaBeat.src output files.

  • outputdir (Union[Path, str]) -- Location of the output directory for converted files.

  • suffix (str) -- Compensation suffix used in the provided BetaBeat.src output files.

  • old_file_name (str) -- the standard naming for the old output file.

  • new_file_name (str) -- the standard naming for the new converted file.

omc3.scripts.betabeatsrc_output_converter.convert_old_directory_to_new(opt: DotDict) None[source]

Looks in the provided directory for expected BetaBeat.src output files, converts it to the output format used by omc3 and write them to the new location.

Parameters:

opt (DotDict) -- The entrypoint parameters parsed from the command line.

omc3.scripts.betabeatsrc_output_converter.convert_old_dispersion(inputdir: Path | str, outputdir: Path | str, plane: str, old_file_name: str = 'D', new_file_name: str = 'dispersion_') None[source]

Looks in the provided directory for expected dispersion file from BetaBeat.src for a given plane, converts it to the output format used by omc3 and write them to the new location.

The file naming should be getD(x,y).out, with the following expected columns: NAME, S, COUNT, DX, STDDX, DPX, DXMDL, DPXMDL, MUXMDL.

Parameters:
  • inputdir (Union[Path, str]) -- Location of the directory with BetaBeat.src output files.

  • outputdir (Union[Path, str]) -- Location of the output directory for converted files.

  • plane (str) -- the transverse plane for which to look for the output file.

  • old_file_name (str) -- the standard naming for the old output file.

  • new_file_name (str) -- the standard naming for the new converted file.

omc3.scripts.betabeatsrc_output_converter.convert_old_normalised_dispersion(inputdir: Path | str, outputdir: Path | str, plane: str, old_file_name: str = 'ND', new_file_name: str = 'normalised_dispersion_') None[source]

Looks in the provided directory for expected normalized dispersion file from BetaBeat.src for a given plane, converts it to the output format used by omc3 and write them to the new location.

The file naming should be getND(x,y).out, with the following expected columns: NAME, S, COUNT, NDX, STDNDX, DX, DPX, NDXMDL, DXMDL, DPXMDL, MUXMDL.

Parameters:
  • inputdir (Union[Path, str]) -- Location of the directory with BetaBeat.src output files.

  • outputdir (Union[Path, str]) -- Location of the output directory for converted files.

  • plane (str) -- the transverse plane for which to look for the output file.

  • old_file_name (str) -- the standard naming for the old output file.

  • new_file_name (str) -- the standard naming for the new converted file.

omc3.scripts.betabeatsrc_output_converter.convert_old_phase(inputdir: Path | str, outputdir: Path | str, suffix: str, plane: str, old_file_name: str = 'phase', new_file_name: str = 'phase_') None[source]

Looks in the provided directory for expected phase file from BetaBeat.src for a given plane, converts it to the output format used by omc3 and write them to the new location.

The file naming should be getphase(x,y).out, with the following expected columns: NAME, NAME2, S, S1, COUNT, PHASEX, STDPHX, PHXMDL, MUXMDL.

Parameters:
  • inputdir (Union[Path, str]) -- Location of the directory with BetaBeat.src output files.

  • outputdir (Union[Path, str]) -- Location of the output directory for converted files.

  • suffix (str) -- Compensation suffix used in the provided BetaBeat.src output files.

  • plane (str) -- the transverse plane for which to look for the output file.

  • old_file_name (str) -- the standard naming for the old output file.

  • new_file_name (str) -- the standard naming for the new converted file.

omc3.scripts.betabeatsrc_output_converter.convert_old_total_phase(inputdir: Path | str, outputdir: Path | str, suffix: str, plane: str, old_file_name: str = 'phasetot', new_file_name: str = 'total_phase_') None[source]

Looks in the provided directory for expected total phase file from BetaBeat.src for a given plane, converts it to the output format used by omc3 and write them to the new location.

The file naming should be getphasetot(x,y).out, with the following expected columns: NAME, NAME2, S, S1, COUNT, PHASEX, STDPHX, PHXMDL, MUXMDL.

Parameters:
  • inputdir (Union[Path, str]) -- Location of the directory with BetaBeat.src output files.

  • outputdir (Union[Path, str]) -- Location of the output directory for converted files.

  • suffix (str) -- Compensation suffix used in the provided BetaBeat.src output files.

  • plane (str) -- the transverse plane for which to look for the output file.

  • old_file_name (str) -- the standard naming for the old output file.

  • new_file_name (str) -- the standard naming for the new converted file.

omc3.scripts.betabeatsrc_output_converter.converter_entrypoint(opt: DotDict) None[source]

Looks for expected BetaBeat.src output files in the provided input directory, converts them to the format used in omc3 and writes the converted files in the provided output directory.

--Required--

  • inputdir (str):

    Directory with BetaBeat.src output files.

  • outputdir (str):

    Output directory for converted files.

--Optional--

  • suffix (str):

    AC dipole compensation suffix used in the provided BetaBeat.src output (‘_free’ for compensation by equation, ‘_free2’ by model).

    choices: ('', '_free', '_free2')

    default: _free

Import K-Modulation Results

Imports K-Mod data and writes them into a file containing beta data, in the same format as beta-from-phase or beta-from-amplitude. This data can then be easily used for the same purposes, e.g. global correction.

Arguments:

--Required--

  • meas_files (PathOrStr):

    Paths to the Kmod results files to import. Can be either the TFS-files directly or a path to a folder containing them.

  • model (PathOrStr):

    Path to the model twiss file, or a folder containing ‘twiss_elemtents.dat’. The model determines which elements to keep.

  • beam (int):

    Beam for which to import.

--Optional--

  • output_dir (PathOrStr):

    Path to the directory where to write the output files.

omc3.scripts.kmod_import.convert_betastar_results(betastar_results_list: Sequence[tfs.TfsDataFrame], df_model: tfs.TfsDataFrame, beam: int) dict[str, tfs.TfsDataFrame][source]

Convert K-Modulation BetaStar results to kmod-DataFrames that can be placed in the optics-measurement directory.

Parameters:
  • betastar_results_list (Sequence[tfs.TfsDataFrame]) -- List of BetaStar results.

  • df_model (tfs.TfsDataFrame) -- Model data.

  • beam (int) -- Beam to import.

Returns:

Dictionary of kmod-DataFrames by planes and with BETASTAR ID as key.

Return type:

dict[str, tfs.TfsDataFrame]

omc3.scripts.kmod_import.convert_bpm_results(bpm_results_list: Sequence[tfs.TfsDataFrame], df_model: tfs.TfsDataFrame) dict[str, tfs.TfsDataFrame][source]

Convert K-Modulation BPM results to kmod-DataFrames that can be placed in the optics-measurement directory.

Parameters:
  • bpm_results_list (Sequence[tfs.TfsDataFrame]) -- List of BPM results.

  • df_model (tfs.TfsDataFrame) -- Model data.

Returns:

Dictionary of kmod-DataFrames by planes and with BPM ID as key.

Return type:

dict[str, tfs.TfsDataFrame]

omc3.scripts.kmod_import.import_kmod_data(opt: DotDict) dict[str, tfs.TfsDataFrame][source]

Reads model and measurement files to calculate differences in beta functions and writes the results to output files.

Parameters:
  • measurements (Sequence[Path|str]) -- A sequence of k-modulation results files to import. This can include either single measurements (e.g., ‘lsa_results.tfs’), averaged results (e.g., ‘averaged_bpm_beam1_ip1_beta0.22m.tfs’) or a path to the folder containing multiple of such files.

  • model (Path|str) -- Path to the model twiss file, or a folder containing ‘twiss_elements.dat’. Determines which elements to keep, i.e. twiss.dat keeps only the BPMs, twiss_elements.dat keeps BPMs and IPs.

  • output_dir (Path|str) -- Path to the output directory, i.e. the optics-measurement directory into which to import these K-Modulation results.

Returns:

Dictionary of kmod-DataFrames by planes and IDs (BPM, BETASTAR).

omc3.scripts.kmod_import.read_model_df(model_path: Path | str | TfsDataFrame) TfsDataFrame[source]

Read model twiss file, either directly or twiss_elements.dat from a folder.

K-Mod Luminosity Imbalance

Calculate the luminosity imbalance from the averaged K-modulation results, based on the effective betas for two IPs, i.e. assuming that apart from the beta-function all other parameters are identical for the two IPs.

This script needs the data in the format of the average script kmod_average.py, as the imbalance is calculated over both beams and this data is only available at that point. The dataframes therefore need to have the columns BEAM, BETSTAR and ERRBETSTAR, and data for both beams needs to be available.

Warning

You need to provide the data for exactly two of the four IP’s.

Arguments:

--Optional--

  • ip1 (PathOrStrOrDataFrame):

    Path or DataFrame of the averaged beta-star results of IP1.

  • ip2 (PathOrStrOrDataFrame):

    Path or DataFrame of the averaged beta-star results of IP2.

  • ip5 (PathOrStrOrDataFrame):

    Path or DataFrame of the averaged beta-star results of IP5.

  • ip8 (PathOrStrOrDataFrame):

    Path or DataFrame of the averaged beta-star results of IP8.

  • betastar (float):

    Model beta-star values (x, y) of measurements. Only used for filename.

  • output_dir (PathOrStr):

    Path to the directory where to write the output files.

omc3.scripts.kmod_lumi_imbalance.calculate_lumi_imbalance(opt: DotDict) tfs.TfsDataFrame[source]

Perform the luminosity imbalance calculation.

omc3.scripts.kmod_lumi_imbalance.get_effective_beta_star_w_err(df_ip: TfsDataFrame) tuple[float][source]

Calculates the effective beta*, i.e. the denominator of the luminosity as given in e.g. Eq(17): https://cds.cern.ch/record/941318/files/p361.pdf , without any constants as we assume here that these are equal for both IPs, and we only care about the ratio.

omc3.scripts.kmod_lumi_imbalance.get_imbalance_w_err(ipA_beta: float, ipA_beta_err: float, ipB_beta: float, ipB_beta_err: float) tuple[float, float][source]

Calculate the luminosity imbalance IP_A / IP_B and its error, based on the effective betas for IP_A and IP_B. This implies, that all the other beam parameters (see e.g. Eq(17): https://cds.cern.ch/record/941318/files/p361.pdf) are the same for both IPs.

omc3.scripts.kmod_lumi_imbalance.get_lumi_imbalance_df(**kwargs) TfsDataFrame[source]

Calculate the effective beta stars and the luminosity imbalance from the input dataframes.

Parameters:
  • ipA (tfs.TfsDataFrame) -- a TfsDataFrame with the averaged results from a kmod analysis, for IP_A.

  • ipB (tfs.TfsDataFrame) -- a TfsDataFrame with the averaged results from a kmod analysis, for IP_B.

  • (Actually

  • fine.) (any name that ends with an integer is)

Returns:

tfs.TfsDataFrame with effective beta stars per IP and the luminosity imbalance added to the header.

Update Natural Tune in Lin-Files

Script to update the natural tune in lin files, based on the spectrum data (amps and freqs) and a given frequency interval.

Arguments:

--Required--

  • files: List of paths to the spectrum files. The files need to be given without their ‘.lin’/’.amps[xy]’,’.freqs[xy]’ endings. (So usually the path of the TbT-Data file.)

  • interval (float): Frequency interval in which the highest peak should be found.

--Optional--

  • bpms: List of BPMs which need to be updated. If not given it will be all of them.

  • not_found_action (str): Defines what to do, if no line was found in given interval. ‘error’: throws a ValueError; ‘remove’: removes the bpm; ‘ignore’: keeps the old values.

    Choices: ['error', 'remove', 'ignore'] Default: error

  • planes (str): Which planes.

    Choices: ('X', 'Y') Default: ['X', 'Y']

  • rename_suffix (str): Additional suffix for output lin-file. Will be inserted between filename and extension. If empty, the original file is overwritten - unless they are old files, then the omc3 filename convention will be used.

    Default: None

Write MAD-X Macros

Write out madx scripts for the tracking macros.

Arguments:

--Required--

  • outputdir:

    Directory where the observation_points.def will be put.

  • twissfile:

    Path to twissfile with observationspoint in the NAME column.

Fake Measurement from Model

Script to generate a pseudo-measurement from a twiss-model.

The model the then generated measurement is compared to can be different from the twiss given, e.g. if the twiss incorporates errors.

Arguments:

--Required--

  • twiss (PathOrStrOrDataFrame):

    Twiss dataframe or path to twiss-file.

--Optional--

  • model (PathOrStrOrDataFrame):

    Alternative Model (Dataframe or Path) to use. If not given, twiss will be used.

  • outputdir (PathOrStr):

    Path to the output directory for the fake measurement.

  • parameters (str):

    Optics parameters to use

    choices: ('PHASEX', 'PHASEY', 'BETX', 'BETY', 'DX', 'DY', 'NDX', 'F1010', 'F1001')

    default: ['PHASEX', 'PHASEY', 'BETX', 'BETY', 'DX', 'DY', 'NDX', 'F1010', 'F1001']

  • randomize (str):

    Randomize values and/or errors from gaussian distributions. If not randomized, measurement values will be equal to the model values and the errors will be equal to the relative error * measurement.

    choices: ['values', 'errors']

    default: []

  • relative_errors (float):

    Relative errors. Either single value for all paramters orlist of values in order of parameters.

    default: [0.0]

  • seed (int):

    Set random seed.

omc3.scripts.fake_measurement_from_model.append_model(df: DataFrame, df_model: DataFrame, parameter: str, planes: str = '', beat: bool = False) DataFrame[source]

Add the values to the measurement.

omc3.scripts.fake_measurement_from_model.create_beta(df_twiss: DataFrame, df_model: DataFrame, parameter: str, relative_error: float, randomize: Sequence[str], headers: Dict)[source]

Create both beta_amp and beta_phase measurements.

omc3.scripts.fake_measurement_from_model.create_coupling(df_twiss: DataFrame, df_model: DataFrame, parameter: str, relative_error: float, randomize: Sequence[str], headers: Dict)[source]

Creates coupling measurements for either the difference or sum RDT.

omc3.scripts.fake_measurement_from_model.create_dispersion(df_twiss: DataFrame, df_model: DataFrame, parameter: str, relative_error: float, randomize: Sequence[str], headers: Dict)[source]

Creates dispersion measurement.

omc3.scripts.fake_measurement_from_model.create_measurement(df_twiss: DataFrame, parameter: str, relative_error: float, randomize: Sequence[str]) TfsDataFrame[source]

Create a new measurement Dataframe from df_twiss from parameter.

omc3.scripts.fake_measurement_from_model.create_normalized_dispersion(df_disp: DataFrame, df_beta: DataFrame, df_model: DataFrame, parameter: str, headers: Dict)[source]

Creates normalized dispersion from pre-created dispersion and beta dataframes.

omc3.scripts.fake_measurement_from_model.create_phase(df_twiss: DataFrame, df_model: DataFrame, parameter: str, relative_error: float, randomize: Sequence[str], headers: Dict)[source]

Creates both phase advance and total phase measurements.

omc3.scripts.fake_measurement_from_model.create_phase_advance(df_twiss: DataFrame, df_model: DataFrame, parameter: str, relative_error: float, randomize: Sequence[str], headers: Dict)[source]

Creates phase advance measurements.

omc3.scripts.fake_measurement_from_model.create_total_phase(df_twiss: DataFrame, df_model: DataFrame, parameter: str, relative_error: float, randomize: Sequence[str], headers: Dict)[source]

Creates total phase measurements.

omc3.scripts.fake_measurement_from_model.generate(opt) Dict[str, TfsDataFrame][source]

Takes a twiss file and writes the parameters in optics_parameters to Output_dir in the format global_correction_entrypoint uses (same format you would get from hole_in_one).

Linfile Cleaning

Performs an automated cleaning of different columns in the lin-file as a standalone script to allow for manual refinement after harpy is done.

The type of cleaning is determined by the number of values in the limit parameter. When no limit is given or a single number is given, auto-cleaning is performed:

All data is assumed to be gaussian distributed around a “true” value, and outliers are cleaned by calculating average and standard deviation of the given data.

The cleaning is done by removing all data-points that are outside of the 1-0.5/n estimated percentile of the data. Where n is the number of (remaining) data-points in each loop, and the process is repeated until n stays constant (or 2 or less data-points remain).

Datapoints with a standard deviation smaller than the given limit are not cleaned. The limit is given in whatever units the data itself is in and is an absolute value.

If two values are given for the limit parameter, all data-points in between these limits are kept and all data-points outside of these limits are cleaned.

Cleaning is done per given file independently i.e. removed BPMs from one file can be present in the next. The columns are iterated on the same file, i.e. the cleaning is done consecutively on the already cleaned data from the last column, yet the moments of the distribution themselves are evaluated per column.

In the end, the lin-files are overwritten with the cleaned ones. If the backup option is activated, a backup of the original file is created, which can be restored via the restore option. In case the restore-flag is given, only the filenames are required. No cleaning is performed with this option.

Arguments:

--Required--

  • files (PathOrStr):

    List of paths to the lin-files, including suffix.

--Optional--

  • backup:

    Create a backup of the files before overwriting. The backups are numbered, with the highest number being the latest backup.

    action: store_true

  • columns (str):

    Columns to clean on.

  • keep (str):

    Do not clean BPMs with given names.

  • limit (float):

    Two values: Do not clean data-points in between these values. Single value (auto-clean): Do not clean data-points deviating less than this limit from the average.

    default: 0.0

  • restore:

    Restore the latest backup of the files. If this parameter is given, no cleaning is performed.

    action: store_true

TODO: also use isolation forest, BUT this probably needs some modification there as well, as it only cleans on TUNE, not on NATTUNE. And it requires an accelerator instance.

omc3.scripts.linfile_clean.clean_columns(files: Sequence[Path | str], columns: Sequence[str], limit: float = None, keep: Sequence[str] = None, backup: bool = True)[source]

Clean the columns in the given files.

omc3.scripts.linfile_clean.main(opt)[source]

Main function, to parse commandline input and separate restoration from cleaning.

omc3.scripts.linfile_clean.restore_files(files: Sequence[Path | str])[source]

Restore backupped files.

Bad BPMs Summary

Scans all measurements in a list of given GUI output folders and compiles a list of bad BPMs with their given number of appearances after ‘harpy’ and ‘isolation forest’.

Usage

Get bad BPMs for LHC-Beam 1 from September 2024 and 2024-10-03

python -m omc3.scripts.bad_bpms_summary --dates 2024-09-* 2024-10-03 --accel_glob LHCB1 --outfile bad_bpms_sep_2024.txt  --print_percentage 50

--Required--

  • dates (str):

    Dates to include in analysis. This should be either subfolders in root or glob-patterns for those.

--Optional--

  • accel_glob (str):

    Accelerator name (glob for the sub-directories).

    default: LHCB*

  • outfile (PathOrStr):

    Path to the file to write out.

  • print_percentage (float):

    Print out BPMs that appear in more than this percentage of measurements.

  • root (PathOrStr):

    Path to the root directory, containing the dates.

    default: /user/slops/data/LHC_DATA/OP_DATA/Betabeat

omc3.scripts.bad_bpms_summary.collect_bad_bpm_files_in_dir(directory: Path) TfsDataFrame | None[source]

Collect bad-bpms for a single measurement directory.

Parameters:

directory (Path) -- Path to the directory possibly containing bad-bpm files of type file_types.

Returns:

TfsDataFrame with all bad-bpms from the given directory.

Return type:

tfs.TfsDataFrame

omc3.scripts.bad_bpms_summary.collect_bad_bpms(root: Path, dates: Sequence[Path | str], accel_glob: str) tfs.TfsDataFrame[source]

Create a TfsDataFrame with all bad-bpms within selected dates.

Parameters:
  • root (Path) -- Root path to the GUI output folder.

  • dates (Sequence[Path | str]) -- List of dates or glob patterns to collect bad-bpms from.

  • accel_glob (str) -- Accelerator name (glob for the sub-directories).

Returns:

TfsDataFrame with all bad-bpms within selected dates.

Return type:

tfs.TfsDataFrame

omc3.scripts.bad_bpms_summary.collect_date(date_dir: Path, accel_glob: str) TfsDataFrame | None[source]

Collect bad-bpms for a single date, by checking the sub-directories which conform to the accel_glob pattern.

In each accel directory, check for sub-directories named Measurements and Results, which in turn contain which in turn have entries containing the bad-bpms files.

Parameters:
  • date_dir (Path) -- Path to the date directory.

  • accel_glob (str) -- Accelerator name (glob for the sub-directories).

Returns:

TfsDataFrame with all bad-bpms for the date.

Return type:

tfs.TfsDataFrame

omc3.scripts.bad_bpms_summary.evaluate(df: TfsDataFrame) TfsDataFrame[source]

Evaluates the gathered bad-bpms and returns a TfsDataFrame with the results.

The evaluation is based on the following criteria: - Count how often a BPM is bad - Count the total number of (unique) files for each combination of accelerator, source and plane

From this information the percentage of how often a BPM is deemed bad is calculated.

Parameters:

df (tfs.TfsDataFrame) -- TfsDataFrame with all bad-bpms.

Returns:

TfsDataFrame with the evaluated results.

Return type:

tfs.TfsDataFrame

omc3.scripts.bad_bpms_summary.get_empty_df() TfsDataFrame[source]

Create an empty TfsDataFrame with the correct column names.

omc3.scripts.bad_bpms_summary.print_results(df_counted: TfsDataFrame, print_percentage: float)[source]

Log the results to console (INFO level if logger is setup, print otherwise).

Parameters:
  • df_counted (tfs.TfsDataFrame) -- TfsDataFrame with the evaluated results.

  • print_percentage (float) -- Print out BPMs that appear in more than this percentage of measurements.

omc3.scripts.bad_bpms_summary.read_harpy_bad_bpms_file(svd_file: Path) TfsDataFrame[source]

Reads a harpy bad-bpm file and returns a TfsDataFrame with all unique bad-bpms.

Parameters:

svd_file (Path) -- Path to the bad-bpm file.

Returns:

TfsDataFrame with all unique bad-bpms.

Return type:

tfs.TfsDataFrame

omc3.scripts.bad_bpms_summary.read_iforest_bad_bpms_file(iforest_file: Path) TfsDataFrame[source]

Reads an iforest bad-bpm file and returns a TfsDataFrame with all unique bad-bpms.

Parameters:

iforest_file (Path) -- Path to the bad-bpm file.

Returns:

TfsDataFrame with all unique bad-bpms.

Return type:

tfs.TfsDataFrame