From c1bbb9103e0b621a0e2928a5f3ba5543f8099bce Mon Sep 17 00:00:00 2001 From: Steven Zeltmann Date: Wed, 1 Nov 2023 15:15:12 -0400 Subject: [PATCH 1/2] add robustness back to fit_origin --- py4DSTEM/braggvectors/braggvector_methods.py | 21 ++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/py4DSTEM/braggvectors/braggvector_methods.py b/py4DSTEM/braggvectors/braggvector_methods.py index 267f81e5f..932056608 100644 --- a/py4DSTEM/braggvectors/braggvector_methods.py +++ b/py4DSTEM/braggvectors/braggvector_methods.py @@ -552,14 +552,19 @@ def fit_origin( from py4DSTEM.process.calibration import fit_origin if mask_check_data is True: - # TODO - replace this bad hack for the mask for the origin fit - mask = np.logical_not(q_meas[0] == 0) - qx0_fit, qy0_fit, qx0_residuals, qy0_residuals = fit_origin( - tuple(q_meas), - mask=mask, - ) - else: - qx0_fit, qy0_fit, qx0_residuals, qy0_residuals = fit_origin(tuple(q_meas)) + data_mask = np.logical_not(q_meas[0] == 0) + if mask is None: + mask = data_mask + else: + mask = np.logical_and(mask, data_mask) + + qx0_fit, qy0_fit, qx0_residuals, qy0_residuals = fit_origin( + tuple(q_meas), + mask=mask, + robust=robust, + robust_steps=robust_steps, + robust_thresh=robust_thresh, + ) # try to add to calibration try: From fac36a7f99378713e9af691bb9f2991aa1c0db09 Mon Sep 17 00:00:00 2001 From: Steven Zeltmann Date: Wed, 1 Nov 2023 15:19:24 -0400 Subject: [PATCH 2/2] add fit function option back --- py4DSTEM/braggvectors/braggvector_methods.py | 1 + 1 file changed, 1 insertion(+) diff --git a/py4DSTEM/braggvectors/braggvector_methods.py b/py4DSTEM/braggvectors/braggvector_methods.py index 932056608..a47a242c5 100644 --- a/py4DSTEM/braggvectors/braggvector_methods.py +++ b/py4DSTEM/braggvectors/braggvector_methods.py @@ -561,6 +561,7 @@ def fit_origin( qx0_fit, qy0_fit, qx0_residuals, qy0_residuals = fit_origin( tuple(q_meas), mask=mask, + fitfunction=fitfunction, robust=robust, robust_steps=robust_steps, robust_thresh=robust_thresh,