From d823606db7d0f1b832e08896e0efceeebc12ba6f Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 20 Nov 2023 14:16:09 -0800 Subject: [PATCH 1/3] Removing the extra factor of 2/pi --- py4DSTEM/process/polar/polar_analysis.py | 1 - 1 file changed, 1 deletion(-) diff --git a/py4DSTEM/process/polar/polar_analysis.py b/py4DSTEM/process/polar/polar_analysis.py index 4f053dcfa..5050a7d46 100644 --- a/py4DSTEM/process/polar/polar_analysis.py +++ b/py4DSTEM/process/polar/polar_analysis.py @@ -411,7 +411,6 @@ def calculate_pair_dist_function( if density is not None: pdf = pdf_reduced.copy() pdf[1:] /= 4 * np.pi * density * r[1:] * (r[1] - r[0]) - pdf *= 2 / np.pi pdf += 1 # damp and clip values below zero From 9a037082a2a188a3f923740b14ea4bed8169c267 Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 20 Nov 2023 14:17:48 -0800 Subject: [PATCH 2/3] Making positivity optional --- py4DSTEM/process/polar/polar_analysis.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/py4DSTEM/process/polar/polar_analysis.py b/py4DSTEM/process/polar/polar_analysis.py index 5050a7d46..67c623ce5 100644 --- a/py4DSTEM/process/polar/polar_analysis.py +++ b/py4DSTEM/process/polar/polar_analysis.py @@ -218,6 +218,7 @@ def calculate_pair_dist_function( r_max=20.0, r_step=0.02, damp_origin_fluctuations=True, + enforce_positivity=True, density=None, plot_background_fits=False, plot_sf_estimate=False, @@ -281,6 +282,8 @@ def calculate_pair_dist_function( The value of the PDF approaching the origin should be zero, however numerical instability may result in non-physical finite values there. This flag toggles damping the value of the PDF to zero near the origin. + enforce_positivity: + Force all pdf values to be >0. density : number or None The density of the sample, if known. If this is not provided, only the reduced PDF is calculated. If this value is provided, the PDF is also @@ -416,7 +419,8 @@ def calculate_pair_dist_function( # damp and clip values below zero if damp_origin_fluctuations: pdf *= r_mask - pdf = np.maximum(pdf, 0.0) + if enforce_positivity: + pdf = np.maximum(pdf, 0.0) # store results self.pdf = pdf From 00fb124e2f5388c24407b6d854c99fe6735cc4c3 Mon Sep 17 00:00:00 2001 From: SE Zeltmann Date: Mon, 20 Nov 2023 18:29:01 -0500 Subject: [PATCH 3/3] format with black --- py4DSTEM/process/polar/polar_analysis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py4DSTEM/process/polar/polar_analysis.py b/py4DSTEM/process/polar/polar_analysis.py index 67c623ce5..7df00a235 100644 --- a/py4DSTEM/process/polar/polar_analysis.py +++ b/py4DSTEM/process/polar/polar_analysis.py @@ -282,7 +282,7 @@ def calculate_pair_dist_function( The value of the PDF approaching the origin should be zero, however numerical instability may result in non-physical finite values there. This flag toggles damping the value of the PDF to zero near the origin. - enforce_positivity: + enforce_positivity: Force all pdf values to be >0. density : number or None The density of the sample, if known. If this is not provided, only the