From e7be22fb525d41f6641aae2d99ba6f384fe995f7 Mon Sep 17 00:00:00 2001 From: mgrover1 Date: Thu, 9 Nov 2023 08:41:02 -0600 Subject: [PATCH] FIX: Fix the testing suite to avoid nans --- tests/retrieve/test_qpe.py | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/tests/retrieve/test_qpe.py b/tests/retrieve/test_qpe.py index a4741dca7f..98b39503e9 100644 --- a/tests/retrieve/test_qpe.py +++ b/tests/retrieve/test_qpe.py @@ -1,6 +1,5 @@ """ Unit tests for rainfall rate estimation module. """ -import numpy as np from numpy.testing import assert_allclose import pyart @@ -163,19 +162,10 @@ def test_precip_rate(): # check that field is in grid object assert "NWS_primary_prate" in grid.fields.keys() - # check calculations are within 10^-4 orders of magnitude - assert ( - np.floor( - np.log10( - grid.fields["NWS_primary_prate"]["data"][0, 10, 10] - - ( - ( - (10 ** (grid.fields["reflectivity"]["data"][0, 10, 10] / 10)) - / 300 - ) - ** (1 / 1.4) - ) - ) - ) - < -4 - ) + # Calculate the estimated value + correct = ( + (10 ** (grid.fields["reflectivity"]["data"][0, 10, 10] / 10.0)) / 300.0 + ) ** (1 / 1.4) + + # Check for correctness + assert_allclose(grid.fields["NWS_primary_prate"]["data"][0, 10, 10], correct)