From ccbbec5456a7ecbbdbca425477a55c360718c0a1 Mon Sep 17 00:00:00 2001 From: Pierre-Francois Leget Date: Fri, 8 Nov 2024 08:22:16 -0800 Subject: [PATCH] filter nan --- .../pipe/tasks/computeExposureSummaryStats.py | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/python/lsst/pipe/tasks/computeExposureSummaryStats.py b/python/lsst/pipe/tasks/computeExposureSummaryStats.py index 4ef851bd4..e064ec974 100644 --- a/python/lsst/pipe/tasks/computeExposureSummaryStats.py +++ b/python/lsst/pipe/tasks/computeExposureSummaryStats.py @@ -506,16 +506,26 @@ def update_psf_stats( [summary.psfTE4E1, summary.psfTE4E2, summary.psfTE4Ex], ] - for config, texoutput in zip(TExTreecorrConfig, TExOutput): - - task = ComputeExPsfTask(config) - output = task.run( - e1Residuals, e2Residuals, ra, dec, units="degree" - ) - - texoutput[0] = output.metric_E1 - texoutput[1] = output.metric_E2 - texoutput[2] = output.metric_Ex + isNotNan = np.array([True] * len(ra)) + isNotNan &= np.isfinite(ra) + isNotNan &= np.isfinite(dec) + isNotNan &= np.isfinite(e1Residuals) + isNotNan &= np.isfinite(e2Residuals) + + if np.sum(isNotNan) > 1: + + for config, texoutput in zip(TExTreecorrConfig, TExOutput): + + task = ComputeExPsfTask(config) + output = task.run( + e1Residuals[isNotNan], e2Residuals[isNotNan], + ra[isNotNan], dec[isNotNan], + units="degree", + ) + + texoutput[0] = output.metric_E1 + texoutput[1] = output.metric_E2 + texoutput[2] = output.metric_Ex if image_mask is not None: maxDistToNearestPsf = maximum_nearest_psf_distance(