Closed GeorgeGayno-NOAA closed 3 years ago
Of course it must be fixed. But as part of the fix we need a test that demonstrates the bug.
Four tests were added under #279 to test all 'if' branches of sst_guess
at c05b1e4
Here is the result of the SST default test. The SST returned for a point located at 65 degrees south latitude is below freezing (268.6845 Kelvin). That is clearly wrong:
Run tests to check default logic for SST.
CHECK DEFAULT LOGIC FOR FIELD NUMBER 11
AT LATITUDE 75.0000000000000
- TOTAL POINTS FOR VAR 11 REPLACED BY NEARBY VALUES: 0
- TOTAL POINTS FOR VAR 11 REPLACED BY DEFAULT VALUE: 1
OK
CHECK DEFAULT LOGIC FOR FIELD NUMBER 11
AT LATITUDE 45.0000000000000
- TOTAL POINTS FOR VAR 11 REPLACED BY NEARBY VALUES: 0
- TOTAL POINTS FOR VAR 11 REPLACED BY DEFAULT VALUE: 1
OK
CHECK DEFAULT LOGIC FOR FIELD NUMBER 11
AT LATITUDE 0.000000000000000E+000
- TOTAL POINTS FOR VAR 11 REPLACED BY NEARBY VALUES: 0
- TOTAL POINTS FOR VAR 11 REPLACED BY DEFAULT VALUE: 1
OK
CHECK DEFAULT LOGIC FOR FIELD NUMBER 11
AT LATITUDE -65.0000000000000
- TOTAL POINTS FOR VAR 11 REPLACED BY NEARBY VALUES: 0
- TOTAL POINTS FOR VAR 11 REPLACED BY DEFAULT VALUE: 1
TEST FAILED
SST SHOULD BE: 273.160000000000
SST FROM TEST: 268.684500000000
5
Good catch!
Bug was fixed with d69114e. The test is now working.
Excellent example of Test-Driven Development!
BTW does this change any of the output of our consistency checks?
If not, is it because they are all in the Northern hemisphere?
BTW does this change any of the output of our consistency checks?
If not, is it because they are all in the Northern hemisphere?
All the consistency tests (most are global) still pass. The default SST is only used when the search fails to find a neighboring valid SST value. Here "neighboring" is about 100 km. So for the default to be used, the lake must be isolated (away from larger water bodies). It must also be open water (i.e., not ice covered). And I doubt there are any isolated, open water lakes in Antarctica. (Our land masks are under ./fix/fix_fv3_gmted2010. The south pole is tile 6. I don't see any lakes.). So without the unit test, this bug would probably not have been found.
The
sst_guess
routine sets the SST values for small lakes that are far from other water bodies. The SST is based on latitude as follows:I suspect the first 'if' block should be
if (abs(latitude) >= 60)
. Otherwise, SST values south of minus 60 would be below freezing.I don't think this is causing problems because there are likely very few isolated open water lakes south of minus 60. But it should be fixed anyway.