From 0fc24204d983f7ec14e21d97fe15ecf400d4df8d Mon Sep 17 00:00:00 2001 From: William Xu Date: Tue, 6 Oct 2026 11:36:01 -0600 Subject: [PATCH] Mask NaNs/Infs in xycompare --- mom6_tools/m6plot.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mom6_tools/m6plot.py b/mom6_tools/m6plot.py index 3ca8fda..9363fb4 100644 --- a/mom6_tools/m6plot.py +++ b/mom6_tools/m6plot.py @@ -704,6 +704,9 @@ def xycompare(field1, field2, x=None, y=None, area=None, if (field1.shape)!=(field2.shape): raise Exception('field1 and field2 must be the same shape') + # Mask NaNs/Infs so they don't propagate into the statistics + field1 = numpy.ma.masked_invalid(field1); field2 = numpy.ma.masked_invalid(field2) + # Create coordinates if not provided xlabel, xunits, ylabel, yunits = createXYlabels(x, y, xlabel, xunits, ylabel, yunits) if debug: print('x,y label/units=',xlabel,xunits,ylabel,yunits)