From ea4a8d0ce8a5ee91b6fdbed9f23350bd9baabf71 Mon Sep 17 00:00:00 2001 From: Ken Kehoe Date: Thu, 21 Dec 2023 15:59:03 +0000 Subject: [PATCH] Catching divide by 0 error before it errors. --- 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