From ae1add8777828b879301aa59d3a9680dcbfab502 Mon Sep 17 00:00:00 2001 From: Ken Kehoe Date: Thu, 21 Dec 2023 10:51:17 -0700 Subject: [PATCH] Catching divide by 0 error before it errors. (#780) --- act/qc/radiometer_tests.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/act/qc/radiometer_tests.py b/act/qc/radiometer_tests.py index bc34d7b0b2..34ba7687c2 100644 --- a/act/qc/radiometer_tests.py +++ b/act/qc/radiometer_tests.py @@ -262,7 +262,11 @@ def fft_shading_test_process( # Calculates to the left/right of each peak peak_l = max(fftv[range(sind, index[0])]) peak_r = max(fftv[range(index[-1], eind)]) - ratio.append(peak / np.mean([peak_l, peak_r])) + mean_value = np.mean([peak_l, peak_r]) + if mean_value == 0.0: + ratio.append(np.nan) + else: + ratio.append(peak / mean_value) # Checks ratios against thresholds for each freq range shading = 0