Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rescale error only if present #444

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions omc3/optics_measurements/data_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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):
Expand Down