From 9a037082a2a188a3f923740b14ea4bed8169c267 Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 20 Nov 2023 14:17:48 -0800 Subject: [PATCH] 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