[Bug]: Silent bug in adjust_prs_val_units()
conditional where if prs_val0:
will be False
if prs_val0
is 0
#797
Labels
bug
Bug fix (will increment patch version)
What happened?
Overview
There is a conditional in
adjust_prs_val_units()
that checksif prs_val0:
to perform unit adjustment on the prs axis. This is a silent bug in this conditional where unit adjustment is not being performed whenprs_val0 == 0
because0 == False
in boolean form.Related code:
e3sm_diags/e3sm_diags/derivations/acme.py
Lines 433 to 446 in 43f5f74
Example Case
There are several derived variables that define
prs_low0=0
. For example, notice howCLDLOW_TAU_1.3_9.4_MISR
has aprs_low0=0
below. For the dataset I was working with, this value is never used due to the silent bug. No prs axis adjustments occur and the prs low value from the dataset (-0.001) is used which results in incorrect results.e3sm_diags/e3sm_diags/derivations/acme.py
Lines 1378 to 1393 in 43f5f74
What did you expect to happen? Are there are possible answers you came across?
The conditional should be updated to
if prs_val0 is not None:
sinceprs_val0
is optional. This logic is implemented correctly on the dev branch,cdat-migration-fy24
.Minimal Complete Verifiable Example (MVCE)
No response
Relevant log output
No response
Anything else we need to know?
How I found it
In PR #794, I found the following variables had large diffs. I stepped through the code on
main
and the dev branch and found thatmain
doesn't perform prs unit adjustment while the dev branch does.Affects the following derived variables:
e3sm_diags/e3sm_diags/derivations/acme.py
Lines 1362 to 1409 in 43f5f74
Environment
main
and all versions ofe3sm_diags
that hascosp_bin_sum()
The text was updated successfully, but these errors were encountered: