diff --git a/_modules/index.html b/_modules/index.html index 784ef67c..ac4321fd 100644 --- a/_modules/index.html +++ b/_modules/index.html @@ -11,11 +11,11 @@ - - - - - + + + + + diff --git a/_modules/omc3/amplitude_detuning_analysis.html b/_modules/omc3/amplitude_detuning_analysis.html index 60cbc206..9548304f 100644 --- a/_modules/omc3/amplitude_detuning_analysis.html +++ b/_modules/omc3/amplitude_detuning_analysis.html @@ -11,11 +11,11 @@ - - - - - + + + + + @@ -459,7 +459,9 @@

Source code for omc3.amplitude_detuning_analysis

# Main ------------------------------------------------------------------------- -
[docs]@entrypoint(_get_params(), strict=True) +
+[docs] +@entrypoint(_get_params(), strict=True) def analyse_with_bbq_corrections(opt: DotDict) -> Tuple[TfsDataFrame, TfsDataFrame]: """ Create amplitude detuning analysis with BBQ correction from timber data. @@ -488,7 +490,10 @@

Source code for omc3.amplitude_detuning_analysis

return kick_df, bbq_df
-
[docs]def get_kick_and_bbq_df(kick: Union[Path, str], bbq_in: Union[Path, str], + +
+[docs] +def get_kick_and_bbq_df(kick: Union[Path, str], bbq_in: Union[Path, str], beam: int = None, filter_opt: FilterOpts = None, ) -> Tuple[tfs.TfsDataFrame, tfs.TfsDataFrame]: @@ -528,7 +533,10 @@

Source code for omc3.amplitude_detuning_analysis

return kick_df, bbq_df
-
[docs]def single_action_analysis(kick_df: tfs.TfsDataFrame, kick_plane: str, detuning_order: int = 1, corrected: bool = False + +
+[docs] +def single_action_analysis(kick_df: tfs.TfsDataFrame, kick_plane: str, detuning_order: int = 1, corrected: bool = False ) -> tfs.TfsDataFrame: """Performs the fit one action and tune pane at a time.""" LOG.info(f"Performing amplitude detuning ODR for single-plane kicks in {kick_plane}.") @@ -560,7 +568,10 @@

Source code for omc3.amplitude_detuning_analysis

return kick_df
-
[docs]def double_action_analysis(kick_df: tfs.TfsDataFrame, detuning_order: int = 1, corrected: bool = False + +
+[docs] +def double_action_analysis(kick_df: tfs.TfsDataFrame, detuning_order: int = 1, corrected: bool = False ) -> tfs.TfsDataFrame: """Performs the full 2D/4D fitting of the data.""" if detuning_order > 1: @@ -601,7 +612,10 @@

Source code for omc3.amplitude_detuning_analysis

return kick_df
-
[docs]def get_approx_bbq_interval( + +
+[docs] +def get_approx_bbq_interval( bbq_df: TfsDataFrame, time_array: Sequence[CERNDatetime], window: int) -> Tuple[CERNDatetime, CERNDatetime]: """Get approximate start and end times for averaging, based on window length and kick interval.""" bbq_tmp = bbq_df.dropna() @@ -625,6 +639,7 @@

Source code for omc3.amplitude_detuning_analysis

return bbq_tmp.index[i_start], bbq_tmp.index[i_end]
+ # Private Functions ------------------------------------------------------------ diff --git a/_modules/omc3/check_corrections.html b/_modules/omc3/check_corrections.html index 700439f4..096b5750 100644 --- a/_modules/omc3/check_corrections.html +++ b/_modules/omc3/check_corrections.html @@ -11,11 +11,11 @@ - - - - - + + + + + @@ -523,7 +523,9 @@

Source code for omc3.check_corrections

     return params
 
 
-
[docs]@entrypoint(get_params()) +
+[docs] +@entrypoint(get_params()) def correction_test_entrypoint(opt: DotDict, accel_opt) -> None: """ Entrypoint function to test the given corrections. @@ -566,6 +568,7 @@

Source code for omc3.check_corrections

         _do_plots(corrections, opt)
+ # Input Parameters ------------------------------------------------------------- def _check_opt_add_dicts(opt: DotDict) -> DotDict: diff --git a/_modules/omc3/correction/filters.html b/_modules/omc3/correction/filters.html index 2fa77fb5..e231f7b2 100644 --- a/_modules/omc3/correction/filters.html +++ b/_modules/omc3/correction/filters.html @@ -11,11 +11,11 @@ - - - - - + + + + + @@ -241,7 +241,9 @@

Source code for omc3.correction.filters

 # Measurement Filter -----------------------------------------------------------
 
 
-
[docs]def filter_measurement( +
+[docs] +def filter_measurement( keys: Sequence[str], meas: Dict[str, pd.DataFrame], model: pd.DataFrame, opt: DotDict ) -> dict: """Filters measurements in `keys` based on the dict-entries (keys as in `keys`) @@ -255,6 +257,7 @@

Source code for omc3.correction.filters

     return new
+ def _get_measurement_filters() -> defaultdict: """Returns a dict with the respective `_get_*` filter-functions that defaults to `~_get_filtered_generic`. Some columns might need to have extra steps for @@ -370,7 +373,9 @@

Source code for omc3.correction.filters

 # Response Matrix Filter -------------------------------------------------------
 
 
-
[docs]def filter_response_index(response: Dict, measurement: Dict, keys: Sequence[str]): +
+[docs] +def filter_response_index(response: Dict, measurement: Dict, keys: Sequence[str]): """Filters the index of the response matrices `response` by the respective entries in `measurement`.""" # rename MU to PHASE as we create a PHASE-Response afterwards # easier to do here, than to check eveywhere below. (jdilly) @@ -390,6 +395,7 @@

Source code for omc3.correction.filters

     return new_response
+ def _get_response_filters() -> Dict[str, Callable]: """ Returns a dict with the respective `_get_*_response` functions that defaults diff --git a/_modules/omc3/correction/handler.html b/_modules/omc3/correction/handler.html index dfbb4508..89ac962e 100644 --- a/_modules/omc3/correction/handler.html +++ b/_modules/omc3/correction/handler.html @@ -11,11 +11,11 @@ - - - - - + + + + + @@ -241,7 +241,9 @@

Source code for omc3.correction.handler

 LOG = logging_tools.get_logger(__name__)
 
 
-
[docs]def correct(accel_inst: Accelerator, opt: DotDict) -> None: +
+[docs] +def correct(accel_inst: Accelerator, opt: DotDict) -> None: """ Perform global correction as described in :mod:`omc3.global_correction`. Args: @@ -314,6 +316,7 @@

Source code for omc3.correction.handler

     LOG.info("Finished Iterative Global Correction.")
+ # Input ------------------------------------------------------------------------ @@ -343,7 +346,9 @@

Source code for omc3.correction.handler

         return f"{beta_filename}{parameter[-1].lower()}{EXT}"
 
 
-
[docs]def get_measurement_data( +
+[docs] +def get_measurement_data( keys: Sequence[str], meas_dir: Path, beta_filename: str, @@ -377,6 +382,7 @@

Source code for omc3.correction.handler

     return filtered_keys, measurement
+ def _load_fullresponse(full_response_path: Path, variables: Sequence[str]) -> dict: """ Full response is dictionary of optics-parameter gradients upon diff --git a/_modules/omc3/correction/model_appenders.html b/_modules/omc3/correction/model_appenders.html index e59fe68e..8b7f7a16 100644 --- a/_modules/omc3/correction/model_appenders.html +++ b/_modules/omc3/correction/model_appenders.html @@ -11,11 +11,11 @@ - - - - - + + + + + @@ -231,7 +231,9 @@

Source code for omc3.correction.model_appenders

< LOG = logging_tools.get_logger(__name__) -
[docs]def add_differences_to_model_to_measurements( +
+[docs] +def add_differences_to_model_to_measurements( model: pd.DataFrame, measurement: Dict[str, pd.DataFrame], keys: Sequence[str] = None, @@ -260,6 +262,7 @@

Source code for omc3.correction.model_appenders

< return res_dict
+ def _get_model_appenders() -> Dict[str, Callable]: return defaultdict(lambda: _get_model_generic, { f"{PHASE}X": _get_model_phases, f"{PHASE}Y": _get_model_phases, @@ -309,7 +312,9 @@

Source code for omc3.correction.model_appenders

< # ---- -
[docs]def add_coupling_to_model(model: pd.DataFrame) -> pd.DataFrame: +
+[docs] +def add_coupling_to_model(model: pd.DataFrame) -> pd.DataFrame: """ Computes the coupling RDTs from the input model TfsDataFrame and returns a copy of said TfsDataFrame with columns for the real and imaginary parts of the computed coupling RDTs. @@ -331,6 +336,7 @@

Source code for omc3.correction.model_appenders

< result_tfs_df[f"{rdt}{suffix}"] = func(coupling_rdts_df[rdt]).astype(np.float64) return result_tfs_df
+
diff --git a/_modules/omc3/correction/model_diff.html b/_modules/omc3/correction/model_diff.html index f35d75c3..4920aca3 100644 --- a/_modules/omc3/correction/model_diff.html +++ b/_modules/omc3/correction/model_diff.html @@ -11,11 +11,11 @@ - - - - - + + + + + @@ -225,7 +225,9 @@

Source code for omc3.correction.model_diff

 from omc3.optics_measurements.toolbox import ang_diff
 
 
-
[docs]def diff_twiss_parameters(model_a: tfs.TfsDataFrame, +
+[docs] +def diff_twiss_parameters(model_a: tfs.TfsDataFrame, model_b: tfs.TfsDataFrame, parameters: Sequence[str] = None) -> tfs.TfsDataFrame: """Create a TfsDataFrame containing of the given parameters between @@ -255,6 +257,7 @@

Source code for omc3.correction.model_diff

     return diff_df
+ # Helper ----------------------------------------------------------------------- diff --git a/_modules/omc3/correction/response_io.html b/_modules/omc3/correction/response_io.html index 7b5f1fc9..0eb2da4f 100644 --- a/_modules/omc3/correction/response_io.html +++ b/_modules/omc3/correction/response_io.html @@ -11,11 +11,11 @@ - - - - - + + + + + @@ -229,7 +229,9 @@

Source code for omc3.correction.response_io

 # Fullresponse -----------------------------------------------------------------
 
 
-
[docs]def read_fullresponse(path: Path, optics_parameters: Sequence[str] = None) -> Dict[str, pd.DataFrame]: +
+[docs] +def read_fullresponse(path: Path, optics_parameters: Sequence[str] = None) -> Dict[str, pd.DataFrame]: """Load the response matrices from disk. Beware: As empty DataFrames are skipped on write, default for not found entries are empty DataFrames. @@ -249,7 +251,10 @@

Source code for omc3.correction.response_io

     return fullresponse
-
[docs]def write_fullresponse(path: Path, fullresponse: Dict[str, pd.DataFrame]): + +
+[docs] +def write_fullresponse(path: Path, fullresponse: Dict[str, pd.DataFrame]): """Write the full response matrices to disk. Beware: Empty Dataframes are skipped! (HDF creates gigantic files otherwise) """ @@ -261,10 +266,13 @@

Source code for omc3.correction.response_io

             store.put(value=response_df, key=param, format="table")
+ # Varmap ----------------------------------------------------------------------- -
[docs]def read_varmap(path: Path, k_values: Sequence[str] = None) -> Dict[str, Dict[str, pd.Series]]: +
+[docs] +def read_varmap(path: Path, k_values: Sequence[str] = None) -> Dict[str, Dict[str, pd.Series]]: """Load the variable mapping file from disk. Beware: As empty DataFrames are skipped on write, default for not found entries are empty Series. @@ -285,7 +293,10 @@

Source code for omc3.correction.response_io

     return varmap
-
[docs]def write_varmap(path: Path, varmap: Dict[str, Dict[str, pd.Series]]): + +
+[docs] +def write_varmap(path: Path, varmap: Dict[str, Dict[str, pd.Series]]): """Write the variable mapping file to disk. Beware: Empty Dataframes are skipped! (HDF creates gigantic files otherwise) """ @@ -296,6 +307,7 @@

Source code for omc3.correction.response_io

                 store.put(value=varmap_series, key=f"{param}/{subparam}", format="table")
+ # Helper ----------------------------------------------------------------------- diff --git a/_modules/omc3/correction/response_madx.html b/_modules/omc3/correction/response_madx.html index f2aa2334..e8a6e39d 100644 --- a/_modules/omc3/correction/response_madx.html +++ b/_modules/omc3/correction/response_madx.html @@ -11,11 +11,11 @@ - - - - - + + + + + @@ -244,7 +244,9 @@

Source code for omc3.correction.response_madx

# Full Response Mad-X ########################################################## -
[docs]def create_fullresponse( +
+[docs] +def create_fullresponse( accel_inst: Accelerator, variable_categories: Sequence[str], delta_k: float = 2e-5, @@ -283,6 +285,7 @@

Source code for omc3.correction.response_madx

return fullresponse
+ def _generate_madx_jobs( accel_inst: Accelerator, variables: Sequence[str], diff --git a/_modules/omc3/correction/response_twiss.html b/_modules/omc3/correction/response_twiss.html index 6b580ad7..d6a13cc0 100644 --- a/_modules/omc3/correction/response_twiss.html +++ b/_modules/omc3/correction/response_twiss.html @@ -11,11 +11,11 @@ - - - - - + + + + + @@ -347,7 +347,9 @@

Source code for omc3.correction.response_twiss

# Twiss Response Class ######################################################## -

[docs]class TwissResponse: +
+[docs] +class TwissResponse: """Provides Response Matrices calculated from sequence, model and given variables. Args: @@ -846,7 +848,9 @@

Source code for omc3.correction.response_twiss

# Getters ################################ -

[docs] def get_beta_beat(self, mapped=True): +
+[docs] + def get_beta_beat(self, mapped=True): """ Returns Response Matrix for Beta Beating """ if not self._beta: self._beta = self._calc_beta_response() @@ -857,7 +861,10 @@

Source code for omc3.correction.response_twiss

self._beta_beat_mapped = self._map_to_variables(self._beta_beat, self._var_to_el["K1L"]) return self._beta_beat_mapped if mapped else self._beta_beat

-
[docs] def get_dispersion(self, mapped=True): + +
+[docs] + def get_dispersion(self, mapped=True): """ Returns Response Matrix for Dispersion """ if not self._dispersion: self._dispersion = self._calc_dispersion_response() @@ -867,7 +874,10 @@

Source code for omc3.correction.response_twiss

return self._dispersion_mapped if mapped else self._dispersion

-
[docs] def get_norm_dispersion(self, mapped=True): + +
+[docs] + def get_norm_dispersion(self, mapped=True): """ Returns Response Matrix for Normalized Dispersion """ if not self._norm_dispersion: self._norm_dispersion = self._calc_norm_dispersion_response() @@ -876,7 +886,10 @@

Source code for omc3.correction.response_twiss

self._norm_dispersion_mapped = self._map_dispersion_response(self._norm_dispersion) return self._norm_dispersion_mapped if mapped else self._norm_dispersion

-
[docs] def get_phase(self, mapped=True): + +
+[docs] + def get_phase(self, mapped=True): """ Returns Response Matrix for Total Phase """ if not self._phase: self._phase = self._calc_phase_response() @@ -889,7 +902,10 @@

Source code for omc3.correction.response_twiss

else: return self._phase

-
[docs] def get_phase_adv(self, mapped=True): + +
+[docs] + def get_phase_adv(self, mapped=True): """ Returns Response Matrix for Phase Advance """ if not self._phase_adv: self._phase_adv = self._calc_phase_advance_response() @@ -902,7 +918,10 @@

Source code for omc3.correction.response_twiss

else: return self._phase_adv

-
[docs] def get_tune(self, mapped=True): + +
+[docs] + def get_tune(self, mapped=True): """ Returns Response Matrix for the Tunes """ if not self._tune: self._tune = self._calc_tune_response() @@ -915,7 +934,10 @@

Source code for omc3.correction.response_twiss

else: return self._tune

-
[docs] def get_coupling(self, mapped=True): + +
+[docs] + def get_coupling(self, mapped=True): """ Returns Response Matrix for the coupling """ if not self._coupling: self._coupling = self._calc_coupling_response() @@ -928,6 +950,7 @@

Source code for omc3.correction.response_twiss

else: return self._coupling

+ def get_variable_names(self): return self._variables @@ -937,7 +960,9 @@

Source code for omc3.correction.response_twiss

else: return self._var_to_el[order] -

[docs] def get_response_for(self, observables=None) -> dict: # Dict[str, ???] +
+[docs] + def get_response_for(self, observables=None) -> dict: # Dict[str, ???] """ Calculates and returns only desired response matrices """ # calling functions for the getters to call functions only if needed def caller(func, plane): @@ -990,13 +1015,17 @@

Source code for omc3.correction.response_twiss

# response[key] = obs_map[key][0](*obs_map[key][1:3]) # I still don't know why there is a sign-change between B1 and B2 (jdilly, 2021) response[key] = self._beam_sign * obs_map[key][0](*obs_map[key][1:3]) - return response

+ return response
+
+ # Associated Functions ######################################################### -
[docs]def response_add(*args) -> pd.DataFrame: +
+[docs] +def response_add(*args) -> pd.DataFrame: """ Merges two or more Response Matrix DataFrames """ base_df = args[0] for df in args[1:]: @@ -1004,12 +1033,18 @@

Source code for omc3.correction.response_twiss

return base_df

-
[docs]def upper(list_of_strings: Sequence[str]) -> Sequence[str]: + +
+[docs] +def upper(list_of_strings: Sequence[str]) -> Sequence[str]: """ Set all items of list to uppercase """ return [item.upper() for item in list_of_strings]
-
[docs]def get_phase_advances(twiss_df: pd.DataFrame) -> Dict[str, pd.DataFrame]: + +
+[docs] +def get_phase_advances(twiss_df: pd.DataFrame) -> Dict[str, pd.DataFrame]: """ Calculate phase advances between all elements @@ -1032,20 +1067,29 @@

Source code for omc3.correction.response_twiss

return phase_advance_dict

-
[docs]def dphi(data, q): + +
+[docs] +def dphi(data, q): """Return dphi from phase advances in data, see Eq. 7 in [#DillyUpdatedGlobalOpticsCorrection2018]_""" return data + np.where(data <= 0, q, 0) # '<=' seems to be what MAD-X does
-
[docs]def tau(data, q): + +
+[docs] +def tau(data, q): """Return tau from phase advances in data, see Eq. 8 in [#DillyUpdatedGlobalOpticsCorrection2018]_""" return data + np.where(data <= 0, q / 2, -q / 2) # '<=' seems to be what MAD-X does
+ # Wrapper ################################################################## -
[docs]def create_response( +
+[docs] +def create_response( accel_inst: Accelerator, vars_categories: Sequence[str], optics_params: List[str], @@ -1062,6 +1106,7 @@

Source code for omc3.correction.response_twiss

raise ValueError("Responses are all empty. " f"Are variables {tr.get_variable_names()} correct for '{optics_params}'?") return response

+
diff --git a/_modules/omc3/correction/sequence_evaluation.html b/_modules/omc3/correction/sequence_evaluation.html index 592b6958..a45cc88c 100644 --- a/_modules/omc3/correction/sequence_evaluation.html +++ b/_modules/omc3/correction/sequence_evaluation.html @@ -11,11 +11,11 @@ - - - - - + + + + + @@ -239,7 +239,9 @@

Source code for omc3.correction.sequence_evaluation

# Read Sequence ############################################################## -
[docs]def evaluate_for_variables( +
+[docs] +def evaluate_for_variables( accel_inst: Accelerator, variable_categories, order: int = 4, @@ -280,6 +282,7 @@

Source code for omc3.correction.sequence_evaluation

return mapping
+ def _generate_madx_jobs( accel_inst: Accelerator, variables: Sequence[str], @@ -494,7 +497,9 @@

Source code for omc3.correction.sequence_evaluation

# Wrapper ################################################################## -
[docs]def check_varmap_file(accel_inst: Accelerator, vars_categories): +
+[docs] +def check_varmap_file(accel_inst: Accelerator, vars_categories): """ Checks on varmap file and creates it if not in model folder. """ if accel_inst.modifiers is None: @@ -509,6 +514,7 @@

Source code for omc3.correction.sequence_evaluation

write_varmap(varmap_path, mapping) return varmap_path
+
diff --git a/_modules/omc3/definitions/formats.html b/_modules/omc3/definitions/formats.html index edac782d..7a5c55c5 100644 --- a/_modules/omc3/definitions/formats.html +++ b/_modules/omc3/definitions/formats.html @@ -11,11 +11,11 @@ - - - - - + + + + + @@ -220,13 +220,16 @@

Source code for omc3.definitions.formats

 BACKUP_FILENAME = "{basefile}_backup{counter}"
 
 
-
[docs]def get_config_filename(script): +
+[docs] +def get_config_filename(script): """Default Filename for config-files. Call from script with ``__file__``.""" return CONFIG_FILENAME.format( script=Path(script).name.split('.')[0], time=datetime.utcnow().strftime(TIME) )
+
diff --git a/_modules/omc3/global_correction.html b/_modules/omc3/global_correction.html index bdbeb2ac..718ac64e 100644 --- a/_modules/omc3/global_correction.html +++ b/_modules/omc3/global_correction.html @@ -11,11 +11,11 @@ - - - - - + + + + + @@ -483,7 +483,9 @@

Source code for omc3.global_correction

     return params
 
 
-
[docs]@entrypoint(correction_params()) +
+[docs] +@entrypoint(correction_params()) def global_correction_entrypoint(opt: DotDict, accel_opt) -> None: """Do the global correction. Iteratively.""" LOG.info("Starting Iterative Global Correction.") @@ -496,6 +498,7 @@

Source code for omc3.global_correction

     handler.correct(accel_inst, opt)
+ def _check_opt_add_dicts(opt: dict) -> dict: # acts inplace... """ Check on options and put in missing values """ def_dict = _get_default_values() diff --git a/_modules/omc3/harpy/clean.html b/_modules/omc3/harpy/clean.html index 87c70a9f..41c3a63f 100644 --- a/_modules/omc3/harpy/clean.html +++ b/_modules/omc3/harpy/clean.html @@ -11,11 +11,11 @@ - - - - - + + + + + @@ -222,7 +222,9 @@

Source code for omc3.harpy.clean

 NTS_LIMIT = 8.  # Noise to signal limit
 
 
-
[docs]def clean(harpy_input, bpm_data, model): +
+[docs] +def clean(harpy_input, bpm_data, model): """ Cleans BPM TbT matrix: removes BPMs not present in the model and based on specified cuts. Also cleans the noise using singular value decomposition. @@ -248,6 +250,7 @@

Source code for omc3.harpy.clean

     return bpm_data, usv, all_bad_bpms, bpm_res
+ def _get_only_model_bpms(bpm_data, model): if model is None: return bpm_data, [] @@ -381,7 +384,9 @@

Source code for omc3.harpy.clean

     return bpm_data.iloc[:, :-1]
 
 
-
[docs]def svd_decomposition(matrix, num_singular_values, dominance_limit=None, num_iter=None): +
+[docs] +def svd_decomposition(matrix, num_singular_values, dominance_limit=None, num_iter=None): """ Computes reduced (K largest values) singular value decomposition of a matrix. Requiring K singular values from MxN matrix results in matrices sized: @@ -413,6 +418,7 @@

Source code for omc3.harpy.clean

             u_mat_mask[:, :int(np.max(indices))+1])
+ def _remove_dominant_elements(u_mat, s_mat, dominance_limit, num_iter=3): u_mat_mask = np.ones(u_mat.shape, dtype=bool) if dominance_limit is None: diff --git a/_modules/omc3/harpy/frequency.html b/_modules/omc3/harpy/frequency.html index fda899e4..cb21966f 100644 --- a/_modules/omc3/harpy/frequency.html +++ b/_modules/omc3/harpy/frequency.html @@ -11,11 +11,11 @@ - - - - - + + + + + @@ -251,7 +251,9 @@

Source code for omc3.harpy.frequency

 Z_TOLERANCE = 0.0003
 
 
-
[docs]def estimate_tunes(harpy_input, usvs): +
+[docs] +def estimate_tunes(harpy_input, usvs): """ Estimates the tunes from the `FFT` of decomposed data. @@ -270,6 +272,7 @@

Source code for omc3.harpy.frequency

     return [tunex, tuney, tunez]
+ def _estimate_tune(sv_mat, window, q_s=False): upper_power = int(np.power(2, np.ceil(np.log2(sv_mat.shape[1])))) synchro_limit = int(upper_power / 16) # 0.03125: synchrotron tunes are lower, betatron higher @@ -280,7 +283,9 @@

Source code for omc3.harpy.frequency

     return np.fft.rfftfreq(2 * upper_power)[synchro_limit + np.argmax(coefs[synchro_limit:])]
 
 
-
[docs]def harpy_per_plane(harpy_input, bpm_matrix, usv, tunes, plane): +
+[docs] +def harpy_per_plane(harpy_input, bpm_matrix, usv, tunes, plane): """ Calculates the spectra of TbT data, finds the main lines and cleans the BPMs for which the main line hasn't been found or is too far from its average over BPMs. @@ -327,7 +332,10 @@

Source code for omc3.harpy.frequency

     return df, spectra, bad_bpms_summaries
-
[docs]def find_resonances(tunes, nturns, plane, spectra, order_resonances): + +
+[docs] +def find_resonances(tunes, nturns, plane, spectra, order_resonances): """ Finds higher order lines in the spectra. @@ -360,6 +368,7 @@

Source code for omc3.harpy.frequency

     return df
+ def _get_main_resonances(tunes, spectra, plane, tolerance, df): freq = sum(r * t for r, t in zip(tunes, MAIN_LINES[plane])) % 1 max_coefs, max_freqs = _search_highest_coefs(freq, tolerance, spectra["FREQS"], spectra["COEFFS"]) @@ -393,7 +402,9 @@

Source code for omc3.harpy.frequency

     return np.where(np.abs(mid_phase) > 0.5, mid_phase - np.sign(mid_phase), mid_phase)
 
 
-
[docs]def clean_by_tune(tunes: pd.Series, tune_clean_limit: Number) -> pd.Series: +
+[docs] +def clean_by_tune(tunes: pd.Series, tune_clean_limit: Number) -> pd.Series: """ Looks for outliers in the tunes pandas Series and returns their indices. @@ -407,6 +418,7 @@

Source code for omc3.harpy.frequency

     return bad_bpms_names
+ def _get_bad_bpms_summary(not_tune_bpms, cleaned_by_tune_bpms): return ([f"{bpm_name} The main resonance has not been found" for bpm_name in not_tune_bpms] + [f"{bpm_name} tune is too far from average" for bpm_name in cleaned_by_tune_bpms]) @@ -464,7 +476,9 @@

Source code for omc3.harpy.frequency

     return (abs(x) + abs(y) + bool(z) * (abs(z) - 1)) * max(1e-4, 1 / n_turns)
 
 
-
[docs]def windowed_padded_rfft(harpy_input, matrix, tunes, svd=None): +
+[docs] +def windowed_padded_rfft(harpy_input, matrix, tunes, svd=None): """ Calculates the spectra using specified windowing function and zero-padding. @@ -502,7 +516,10 @@

Source code for omc3.harpy.frequency

     return frequencies, coefficients
-
[docs]def windowing(length, window='hamming'): + +
+[docs] +def windowing(length, window='hamming'): """ Provides specified windowing function of given length. @@ -532,7 +549,10 @@

Source code for omc3.harpy.frequency

     return windows[window] / np.sum(windows[window])
-
[docs]def get_freq_mask(harpy_input, tunes, auto_tol): + +
+[docs] +def get_freq_mask(harpy_input, tunes, auto_tol): """ Computes mask to get intervals around resonances in frequency domain. @@ -563,6 +583,7 @@

Source code for omc3.harpy.frequency

     return _get_partial_freq_mask(harpy_input, mask, freqs, tol)
+ def _get_natural_tunes(harpy_input, tunes): if harpy_input.natdeltas is not None: return [r + t if t != 0 else 0 for r, t in zip(tunes, harpy_input.natdeltas)] diff --git a/_modules/omc3/harpy/handler.html b/_modules/omc3/harpy/handler.html index cf4ad89d..f8ef5121 100644 --- a/_modules/omc3/harpy/handler.html +++ b/_modules/omc3/harpy/handler.html @@ -11,11 +11,11 @@ - - - - - + + + + + @@ -235,7 +235,9 @@

Source code for omc3.harpy.handler

 PLANE_TO_NUM = {**P2N, "Z": 3}
 
 
-
[docs]def run_per_bunch(tbt_data, harpy_input): +
+[docs] +def run_per_bunch(tbt_data, harpy_input): """ Cleans data, analyses frequencies and searches for resonances. @@ -290,6 +292,7 @@

Source code for omc3.harpy.handler

     return lins
+ def _get_cut_tbt_matrix(tbt_data, turn_indices, plane): start = max(0, min(turn_indices)) end = min(max(turn_indices), tbt_data.matrices[0][plane].shape[1]) diff --git a/_modules/omc3/harpy/kicker.html b/_modules/omc3/harpy/kicker.html index df180bae..2ea55aad 100644 --- a/_modules/omc3/harpy/kicker.html +++ b/_modules/omc3/harpy/kicker.html @@ -11,11 +11,11 @@ - - - - - + + + + + @@ -223,7 +223,9 @@

Source code for omc3.harpy.kicker

 LOGGER = logging_tools.getLogger(__name__)
 
 
-
[docs]def phase_correction(bpm_data_orig, lin_frame, plane): +
+[docs] +def phase_correction(bpm_data_orig, lin_frame, plane): """ Corrects phase of main spectral line assuming exponentially decaying oscillations. @@ -254,6 +256,7 @@

Source code for omc3.harpy.kicker

     return lin_frame
+ def _get_damping(bpm_data): coefs = np.polyfit(np.arange(bpm_data.shape[1]), np.maximum.accumulate(np.log(np.abs(bpm_data[::-1]))).T, 1) diff --git a/_modules/omc3/hole_in_one.html b/_modules/omc3/hole_in_one.html index 5f3214e3..cbeadd2e 100644 --- a/_modules/omc3/hole_in_one.html +++ b/_modules/omc3/hole_in_one.html @@ -11,11 +11,11 @@ - - - - - + + + + + @@ -268,7 +268,9 @@

Source code for omc3.hole_in_one

     return params
 
 
-
[docs]@entrypoint(hole_in_one_params(), strict=False) +
+[docs] +@entrypoint(hole_in_one_params(), strict=False) def hole_in_one_entrypoint(opt, rest): """ Runs frequency analysis and measures lattice optics. @@ -522,6 +524,7 @@

Source code for omc3.hole_in_one

         _measure_optics(lins, optics_opt)
+ def _get_suboptions(opt, rest): if opt.harpy: harpy_opt, rest = _harpy_entrypoint(rest) diff --git a/_modules/omc3/kmod/analysis.html b/_modules/omc3/kmod/analysis.html index 97032726..7bf1c6c8 100644 --- a/_modules/omc3/kmod/analysis.html +++ b/_modules/omc3/kmod/analysis.html @@ -11,11 +11,11 @@ - - - - - + + + + + @@ -232,7 +232,9 @@

Source code for omc3.kmod.analysis

 LOG = logging_tools.get_logger(__name__)
 
 
-
[docs]def return_sign_for_err(n): +
+[docs] +def return_sign_for_err(n): """ Creates an array for error calculation, of form: [[ 0. 0. 0.] @@ -251,6 +253,7 @@

Source code for omc3.kmod.analysis

     return sign
+ def propagate_beta_in_drift(beta_waist, drift): beta = beta_waist + drift**2/beta_waist return beta @@ -365,7 +368,9 @@

Source code for omc3.kmod.analysis

 np.vectorize(fit_approx)
 
 
-
[docs]def average_beta_from_Tune(Q, TdQ, l, Dk): +
+[docs] +def average_beta_from_Tune(Q, TdQ, l, Dk): """Calculates average beta function in quadrupole from tune change ``TdQ`` and ``delta K``.""" beta_av = 2 * (1 / np.tan(2 * np.pi * Q) * @@ -373,6 +378,7 @@

Source code for omc3.kmod.analysis

     return abs(beta_av)
+ def average_beta_focussing_quadrupole(b, w, L, K, Lstar): beta0 = b + ((Lstar - w) ** 2 / b) @@ -499,7 +505,9 @@

Source code for omc3.kmod.analysis

     return np.abs(twiss_df.loc[BPMR, 'S'] - twiss_df.loc[BPML, 'S']) / 2
 
 
-
[docs]def get_phase_from_model(kmod_input_params, plane): +
+[docs] +def get_phase_from_model(kmod_input_params, plane): """Get the phase from twiss model.""" twiss_df = tfs.read(kmod_input_params.model_dir / TWISS_DAT, index='NAME') BPML, BPMR = get_BPM(kmod_input_params)[0], get_BPM(kmod_input_params)[1] @@ -509,6 +517,7 @@

Source code for omc3.kmod.analysis

     return phase_adv_model, phase_adv_err
+ def get_phase_from_measurement(kmod_input_params, plane): phase_df = tfs.read( kmod_input_params.measurement_dir / f'{PHASE_NAME}{plane.lower()}{EXT}', index='NAME' diff --git a/_modules/omc3/knob_extractor.html b/_modules/omc3/knob_extractor.html index 97212887..dc980021 100644 --- a/_modules/omc3/knob_extractor.html +++ b/_modules/omc3/knob_extractor.html @@ -11,11 +11,11 @@ - - - - - + + + + + @@ -307,7 +307,9 @@

Source code for omc3.knob_extractor

 }
 
 
-
[docs]class Col: +
+[docs] +class Col: """ DataFrame Columns used in this script. """ madx: str = "madx" lsa: str = "lsa" @@ -315,11 +317,15 @@

Source code for omc3.knob_extractor

     value: str = "value"
-