Skip to content

Commit

Permalink
Merge pull request #109 from arwoll/edd-spring2024
Browse files Browse the repository at this point in the history
Revert to performing detector-specific E recalibration Ceria Peaks
  • Loading branch information
rolfverberg authored Mar 4, 2024
2 parents 600f3ab + 2da07d8 commit c8cab60
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions CHAP/edd/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,10 +854,13 @@ def calibrate(self,
# Fit line to expected / computed peak locations from the last
# unconstrained fit.
fit = Fit.fit_data(
_fit_E0, 'linear', x=unconstrained_fit_centers,
unconstrained_fit_centers, 'linear', x=_fit_E0,
nan_policy='omit')
slope = fit.best_values['slope']
intercept = fit.best_values['intercept']
slope_correction = fit.best_values['slope']
intercept_correction = fit.best_values['intercept']
# In the fit above, x' = E0 = mx+b, and y' = m'x'+b' = m'm x + m'b + b'; hence the correction below
slope_final = fit.best_values['slope'] * detector.slope_initial_guess
intercept_final = fit.best_values['slope'] * detector.intercept_initial_guess + fit.best_values['intercept']

if interactive or save_figures:
# Third party modules
Expand Down Expand Up @@ -918,7 +921,7 @@ def calibrate(self,
marker='o', label='Single Strain')
axs[1,1].plot(fit_E0, unconstrained_fit_centers,
linestyle='', marker='o', label='Unconstrained')
axs[1,1].plot(slope * unconstrained_fit_centers + intercept,
axs[1,1].plot(slope_correction * unconstrained_fit_centers + intercept_correction,
unconstrained_fit_centers,
color='C1', label='Unconstrained: Linear Fit')
axs[1,1].legend()
Expand All @@ -927,8 +930,8 @@ def calibrate(self,
txt = 'Calibrated Values:\n\n' \
+ f'Takeoff Angle:\n {tth:.5f}$^\circ$'
if True or recalibrate_energy:
txt += f'\n\nSlope:\n {slope:.5f}\n\n' \
f'Intercept:\n {intercept:.5f}'
txt += f'\n\nSlope:\n {slope_final:.5f}\n\n' \
f'Intercept:\n {intercept_final:.5f}'
axs[1,1].text(
0.98, 0.02, txt,
ha='right', va='bottom', ma='left',
Expand All @@ -953,8 +956,8 @@ def calibrate(self,
# Slope and intercept should be very close to 1.0 and 0.0,
# which should be verified by the user in the figure.
return (
float(tth), float(detector.slope_initial_guess),
float(detector.intercept_initial_guess))
float(tth), float(slope_final),
float(intercept_final))


class MCAEnergyCalibrationProcessor(Processor):
Expand Down

0 comments on commit c8cab60

Please sign in to comment.