From 756930d91f754d18cb79ccc99c7ed189c065f9bf Mon Sep 17 00:00:00 2001 From: arwoll Date: Sat, 2 Mar 2024 15:40:48 -0500 Subject: [PATCH 1/2] Modified processory to perform detector-specific E recalibration from Bragg Peaks --- CHAP/edd/processor.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/CHAP/edd/processor.py b/CHAP/edd/processor.py index ffc6106..9a6af53 100755 --- a/CHAP/edd/processor.py +++ b/CHAP/edd/processor.py @@ -856,8 +856,11 @@ def calibrate(self, fit = Fit.fit_data( _fit_E0, 'linear', x=unconstrained_fit_centers, 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 @@ -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() @@ -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', @@ -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): From 2da07d816dc736d18be9a0363bf3684c7a6736d2 Mon Sep 17 00:00:00 2001 From: arwoll Date: Sun, 3 Mar 2024 22:01:25 -0500 Subject: [PATCH 2/2] Flip x & y axes during Ecal re-fit in Ceria Calib --- CHAP/edd/processor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHAP/edd/processor.py b/CHAP/edd/processor.py index 9a6af53..d2ddf30 100755 --- a/CHAP/edd/processor.py +++ b/CHAP/edd/processor.py @@ -854,7 +854,7 @@ 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_correction = fit.best_values['slope'] intercept_correction = fit.best_values['intercept']