diff --git a/omc3/optics_measurements/data_models.py b/omc3/optics_measurements/data_models.py index 1a19cb86..a433531f 100644 --- a/omc3/optics_measurements/data_models.py +++ b/omc3/optics_measurements/data_models.py @@ -126,7 +126,7 @@ def bpms(self, plane=None, dpp_value=None): def calibrate(self, calibs: Dict[str, pd.DataFrame]): """ - Use calibration data to rescale amplitude and amplitude error. + Use calibration data to rescale amplitude and amplitude error (if present). Args: calibs (Dict): Plane-Dictionary with DataFrames of calibration data. @@ -145,13 +145,14 @@ def calibrate(self, calibs: Dict[str, pd.DataFrame]): value={CALIBRATION: 1.}) # ERR_CALIBRATION is relative, NaN filled with absolute value below # Scale amplitude with the calibration - self[plane][i][f"AMP{plane}"] = self[plane][i].loc[:, f"AMP{plane}"] * data.loc[:, CALIBRATION] - - # Sum Amplitude Error (absolute) and Calibration Error (relative) - self[plane][i][f"{ERR}{AMPLITUDE}{plane}"] = np.sqrt( - self[plane][i][f"{ERR}{AMPLITUDE}{plane}"]**2 + - ((self[plane][i][f"{AMPLITUDE}{plane}"] * data.loc[:, ERR_CALIBRATION]).fillna(bpm_resolution))**2 - ) + self[plane][i][f"{AMPLITUDE}{plane}"] = self[plane][i].loc[:, f"{AMPLITUDE}{plane}"] * data.loc[:, CALIBRATION] + + if f"{ERR}{AMPLITUDE}{plane}" in self[plane][i].columns: + # Sum Amplitude Error (absolute) and Calibration Error (relative) + self[plane][i][f"{ERR}{AMPLITUDE}{plane}"] = np.sqrt( + self[plane][i][f"{ERR}{AMPLITUDE}{plane}"]**2 + + ((self[plane][i][f"{AMPLITUDE}{plane}"] * data.loc[:, ERR_CALIBRATION]).fillna(bpm_resolution))**2 + ) @ staticmethod def get_columns(frame, column):